Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
127675 | baim. | 救援顺序 | C++ | 解答错误 | 30 | 13 MS | 660 KB | 531 | 2024-01-25 09:51:39 |
#include <bits/stdc++.h> 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; else return x.id < y.id; } int main() { int h, maxn = -1; cin >> h; for(int i = 1; i <= h; 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 <= 400; i++){ if(cnt[i].pcnt) cout << "->" << cnt[i].id; } cout<<endl; }