Advertisement
Graf_Rav

Untitled

Dec 31st, 2017
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6.     int n;
  7.     cin>>n;
  8.     int a[16];
  9.     for(int i=0;i<16;i++){
  10.         a[i]=0;
  11.     }
  12.     for(int i=0;i<n;i++){
  13.         int b;
  14.         cin>>b;
  15.        
  16.         a[b-1]++;
  17.     }
  18.    
  19.     for(int i=0;i<16;i++){
  20.         int maxi=0;
  21.         int ans;
  22.         for(int j=0;j<16;j++){
  23.             if(a[j]>maxi){
  24.                 ans=j+1;
  25.                 maxi=a[j];
  26.                 a[j]=0;
  27.             }
  28.         }
  29.        
  30.         if(maxi==0){
  31.             break;
  32.         }
  33.         else{
  34.             cout<<ans<<' '<<maxi<<'\n';
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement