东北大学oj NEU-OJ 1044简易版最长序列

/* Name: NEU-OJ 1044简易版最长序列 Author: Unimen Date: 31/05/2011 16:29 Description: 简单题目 */ #include <iostream> #include <cstdlib> using namespace std; int nCase; int n; unsigned array[100001]; int cmp(const void *elem1, const void *elem2) { return *(int *)elem1 - *(int *)elem2; } int main() { while(cin>>nCase) { while(nCase--) { cin>>n; for(int i=0; i<n; ++i) cin>>array[i]; qsort(array, n, sizeof(unsigned), cmp); int len = 0; int index1 = 0; int index2 = 1; while(index2 <= n) { if(array[index1] == array[index2]) { index2++; } else { if(len < index2 - index1 ) len = index2 - index1; index1 = index2; index2++; } } if(len == 0) cout<<n<<endl; else cout<<len<<endl; } } return 0; }

你可能感兴趣的:(东北大学oj NEU-OJ 1044简易版最长序列)