Monday, December 23, 2013

codechef MAXCOUNT - "count of maximum" solution

codechef MAXCOUNT - "count of maximum": http://www.codechef.com/problems/MAXCOUNT

my c++ solution to codechef MAXCOUNT - "count of maximum": http://ideone.com/IZ573R
#include <iostream>
using namespace std;

int main() {
// your code goes here
int t, n, b, index, arr[10005], max, temp;
cin>>t;
while(t--) {
cin>>n; b=n;
for(int i=0; i<10005; i++) arr[i]=0; max=0;
while(b--) {
cin>>index; arr[index]++;
}
for(int i=0; i<10005; i++) {
if(arr[i]>max) {
max=arr[i]; temp=i;
}
}
cout<<temp<<" "<<max<<endl;
}
return 0;
}

No comments:

Post a Comment