提交时间:2024-01-26 15:57:42
运行 ID: 129047
#include<bits/stdc++.h> using namespace std; struct node{ int id, x; }; const int N=1010; node a[N]; bool cmp(node x,node y){ if(x.x == y.x) return x.id < y.id; return x.x > y.x; } int main(){ int n, s; cin >> n; for(int i = 1; i < N; i++) a[i].id = i; for(int i = 1; i <= n; i++){ cin >> s; a[s].x++; } sort(a + 1, a + 1001, cmp); cout << a[1].id; for(int i = 2; i < N; i++){ if(a[i].x==0) break; else cout << "->" << a[i].id; } return 0; }