Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
101621 罗恩祥 救援顺序 C++ 通过 100 17 MS 1808 KB 662 2023-09-09 11:24:15

Tests(10/10):


#include <iostream> #include <algorithm> using namespace std; struct cave { long long num; long long people = 0; }; bool CMP(cave c1,cave c2) { if(c1.people == c2.people) return c1.num < c2.num; else return c1.people>c2.people; } int main() { cave lst[100005]; long long num; cin >> num; for(int i = 1;i <= num;i++) { int index; cin >> index; lst[index].people++; lst[index].num = index; } sort(lst,lst+100005,CMP); long long index = 0; while(true) { if(lst[index+1].people != 0) { cout << lst[index].num << "->"; } else { cout << lst[index].num; break; } index++; } }


测评信息: