fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int t, n, b, index, arr[10005], max, temp;
  7. cin>>t;
  8. while(t--) {
  9. cin>>n; b=n;
  10. for(int i=0; i<10005; i++) arr[i]=0; max=0;
  11. while(b--) {
  12. cin>>index; arr[index]++;
  13. }
  14. for(int i=0; i<10005; i++) {
  15. if(arr[i]>max) {
  16. max=arr[i]; temp=i;
  17. }
  18. }
  19. cout<<temp<<" "<<max<<endl;
  20. }
  21. return 0;
  22. }
Success #stdin #stdout 0s 3300KB
stdin
2
5
1 2 3 2 5
6
1 2 2 1 1 2
stdout
2 2
1 3