标签:style blog color io os for sp div log
#include <iostream> #include <set> #include <map> using namespace std; unsigned int P; set<unsigned int> ideaSet; unsigned int idea[1000001]; int numOfIdea; int main() { scanf("%ud", &P); for(int i = 0; i < P; ++i) { scanf("%ud", &idea[i]); ideaSet.insert(idea[i]); } numOfIdea = ideaSet.size(); int num = 0; map<unsigned int, unsigned int> mp; int s = 0; int t = 0; int res = P; for(;;) { while(num < numOfIdea && t < P) { if(mp[idea[t++]]++ == 0) { num++; } } if(num < numOfIdea) break; res = min(res, t - s); if(--mp[idea[s++]] == 0) --num; } printf("%d\n", res); return 0; }
标签:style blog color io os for sp div log
原文地址:http://www.cnblogs.com/shuanghong/p/4044409.html