Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main(){
- int n;
- cin>>n;
- int a[16];
- for(int i=0;i<16;i++){
- a[i]=0;
- }
- for(int i=0;i<n;i++){
- int b;
- cin>>b;
- a[b-1]++;
- }
- for(int i=0;i<16;i++){
- int maxi=0;
- int ans;
- for(int j=0;j<16;j++){
- if(a[j]>maxi){
- ans=j+1;
- maxi=a[j];
- a[j]=0;
- }
- }
- if(maxi==0){
- break;
- }
- else{
- cout<<ans<<' '<<maxi<<'\n';
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement