提交时间:2024-01-25 09:47:36
运行 ID: 127654
#include<bits/stdc++.h> using namespace std; int n,t,maxn; 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(){ memset(h,0,sizeof(h)); cin>>n; for(int i=1;i<=n;i++){ cin>>t; h[t].people++; h[t].num=t; maxn=max(maxn,t); } sort(h+1,h+1+maxn,cmp); int cnt=1; while(1){ cout<<h[cnt].num; if(h[cnt+1].people==0) return 0; cout<<"->"; cnt++; } return 0; }