fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <map>
  5. #include <algorithm>
  6. using namespace std;
  7.  
  8. int main(int argc, char const *argv[]){
  9. int n,t;
  10. cin>>n;
  11. int hash[1005] = {0};
  12. for(int i = 0; i<n ; i++){
  13. cin>>t;
  14. hash[t-1]++;
  15. }
  16. sort(hash,hash+1005);
  17. for(int i = 0 ;i < 1005 ; i++){
  18. if(hash[i]!=0){
  19. cout<<i<<"\t"<<hash[i]<<endl;
  20. }
  21. }
  22. int answer = hash[1004] + hash[1003] + 2;
  23. cout<<answer<<endl;
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0s 3468KB
stdin
5
2 3 4 1 1
stdout
1001	1
1002	1
1003	1
1004	2
5