Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
127439 | 谢思涵 | 救援顺序 | C++ | 解答错误 | 40 | 19 MS | 1588 KB | 518 | 2024-01-25 09:06:01 |
#include <iostream> #include <algorithm> using namespace std; struct cave { int pcnt, id; }cnt[1000100]; int a[20000]; 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; cin >> n; for(int i = 1; i <= n; i++) {cin >> a[i]; cnt[a[i]].pcnt++; cnt[a[i]].id = a[i];} sort(cnt + 1, cnt + n + 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; }