2 solutions

  • 1
    @ 2026-5-16 15:18:22
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    	int n;
    	cin>>n;
    	map<int,int> h;
    	for(int i=1;i<=n;i++)
    	{
    		int x;
    		cin>>x;
    		h[x]++;
    	}
    	for(auto it=h.rbegin();it!=h.rend();it++) 
    	{
    		cout<<it->second<<endl;
    	}
    	for(int i=1;i<=n-h.size();i++)
    	{
    		cout<<"0"<<endl;
    	}
    	return 0;	
    }
    • 0
      @ 2025-10-12 11:56:59
      #include<bits/stdc++.h>
      using namespace std;
      int main()
      {
      	int n;
      	cin>>n;
      	map<int,int> h;
      	for(int i=1;i<=n;i++){
      		int x;
      		cin>>x;
      		h[x]++;
      	}
      	stack<int> tk;
      	for(auto i:h){
      		tk.push(i.second);
      	}
      	int q=0;
      	for(auto i:h){
      		cout<<tk.top()<<endl;
      		tk.pop();
      		q++;
      	}
      	for(int i=1;i<=n-q;i++){
      		cout<<0<<endl;
      	}
      	return 0;
      }
      
      • 1

      Information

      ID
      2623
      Time
      1000ms
      Memory
      256MiB
      Difficulty
      3
      Tags
      # Submissions
      7
      Accepted
      7
      Uploaded By