提交时间:2023-09-12 13:07:53

运行 ID: 101997

#include<bits/stdc++.h> #define int long long using namespace std; namespace Fast{ inline int fr(){ register int x = 0,f = 1; static char c = getchar(); while (c < '0' || c > '9'){ if (c == '-'){ f = -1; } c = getchar(); } while (c >= '0' && c <= '9'){ x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); } return x * f; } inline void CCF(int opt){ ios::sync_with_stdio(false); if (opt == 0){ cout.tie(0); return ; } if (opt >= 1){ cin.tie(0); } if (opt >= 2){ cout.tie(0); } } } using namespace Fast; struct H{ int id,sum; }s[114514]; bool cmp(H a,H b){ if (a.sum == b.sum){ return a.id < b.id; } return a.sum > b.sum; } signed main(){ //freopen(".in","r",stdin); //freopen(".out","w",stdout); CCF(2); int n = fr(); for (int i = 1;i <= 1000;i++){ s[i].id = i; } for (int i = 1;i <= n;i++){ int x = fr(); s[x].sum++; } sort(s + 1,s + 1001,cmp); cout<<s[1].id; for (int i = 2;i <= 1000;i++){ if (s[i].sum == 0){ break; } cout<<"->"<<s[i].id; } return 0; }