第一题(多条件排序):2084. enjoy cp!!!

📅 2026/7/19 22:27:40
第一题(多条件排序):2084. enjoy cp!!!
一、题目2084 - enjoy cp!!! - acm.bjtu二、答案#includebits/stdc.h using namespace std; struct Student{ int id; int num; int time; }; bool cmp(Student a,Student b){ if(a.num ! b.num) return a.num b.num; if(a.time ! b.time) return a.time b.time; return a.id b.id; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin n; vectorStudent stu(n); for(int i0;in;i) cin stu[i].id stu[i].num stu[i].time; sort(stu.begin(),stu.end(),cmp); for(auto a:stu) couta.id a.num a.time endl; return 0; }三、收获首先好久不打了第一道题回忆了一下板子#includebits/stdc.h using namespace std; int main() { ios::sync_with_stdio(false); // 关闭C/C输入输出同步 cin.tie(nullptr); // 解除cin和cout绑定 return 0; }其次自定义cmp时注意比大的就是大于号比小的就是小于号多个条件时按照优先级依次写就好。