提交时间:2024-01-26 15:56:45

运行 ID: 129046

#include<bits/stdc++.h> using namespace std; long long a[100005]; struct s{ long long gs,zhi; }b[10000005]; bool cmp(s x,s y){ if(x.gs!=y.gs){ return x.gs>y.gs; } else{ return x.zhi<y.zhi; } } int main(){ long long n; cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; b[a[i]].zhi=a[i]; b[a[i]].gs++; } sort(b+1,b+n+1,cmp); cout<<b[1].zhi; for(int i=2;;i++){ if(b[i].gs==0){ break; } else{ cout<<"->"<<b[i].zhi; } } return 0; }