Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
127502 谢思涵 救援顺序 C++ 通过 100 14 MS 660 KB 574 2024-01-25 09:18:33

Tests(10/10):


#include <iostream> #include <algorithm> using namespace std; struct cave { int pcnt, id; }cnt[100100]; int a[2001000]; bool cmp(cave x, cave y) { if(x.pcnt != y.pcnt) return x.pcnt > y.pcnt; return x.id < y.id; } int main() { int n, maxn = -1; cin >> n; for(int i = 1; i <= n; i++) { cin >> a[i]; maxn = max(maxn, a[i]); cnt[a[i]].pcnt++; cnt[a[i]].id = a[i]; } sort(cnt + 1, cnt + maxn + 1, cmp); cout << cnt[1].id; for(int i = 2; i <= 1500; i++) if(cnt[i].pcnt) cout << "->" << cnt[i].id; cout << endl; return 0; }


测评信息: