Given N points on a number axis, each point has a color. k colors are used in total to find a shortest interval, including all k colors.
After a while, 0.0 first thought about the second answer, and later found that the data range was too large to write 0.0. Later, I went to the question to find out that Nima was really clever.
Maintain a heap and add the first beads of each color to the heap. Then, remove the leftmost beads, add the next beads of this color, and update ans.
Sure enough, we still need to use a small data structure such as a heap constant for such a big data range, 0.0.
I wrote the heap but opened the STL queue 0.0. Don't say I'm sick. I'm just not used to the STL heap.
#include<queue>#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>using namespace std;typedef pair<int,int> abcd;int n,m,k,top,ans=0x7fffffff,maxnum=0;abcd heap[70];queue<int>q[70];void Insert(abcd x){heap[++top]=x;int t=top;while( t>1 && heap[t]
Bzoj 1293 scoi2009 birthday gift heap