Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
102145 | 王为治 | 救援顺序 | C++ | 编译错误 | 0 | 0 MS | 0 KB | 520 | 2023-09-12 13:38:36 |
#include<bits/stdc++.h> #define int long long using namespace std; int n; struct node { int x; int pos; } node a[100001]; map<int,int> mp; bool cmp(node x,node y) { if(mp[x.x] == mp[y.x])return x.x<y.x; return mp[x.x] > mp[y.x]; } signed main() { cin >> n; for(int i = 1 ;i <= n ;i++) { cin >> a[i].x; mp[a[i].x]++; } sort(a+1 ,a+n+1 ,cmp); for(int i = 1;i <= n;i++) { if(i != 1 && a[i].x != a[i-1].x)cout << "->"; if(a[i].x != a[i-1].x)cout << a[i].x; } return 0; }