提交时间:2024-01-25 09:23:45
运行 ID: 127526
#include<bits/stdc++.h> using namespace std; int n,t; struct hole{ int people; int num; }h[1000010]; bool cmp(hole x,hole y){ if(x.people!=y.people) return x.people>y.people; return x.num<y.num; } int main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>t; h[t].people++; h[t].num=t; } sort(h+1,h+1+n,cmp); int cnt=1; while(h[cnt].people!=0) cnt++; cnt--; for(int i=1;i<cnt;i++) cout<<h[i].num<<"->"; cout<<h[cnt].num; return 0; }