第二题,仅供参考 #include <bits/stdc++.h> using namespace std; int N; struct num{ int time; int sorce; friend bool operator < (num a,num b) { if(a.sorce==b.sorce) { return a.time < b.time; } return a.sorce > b.sorce; } }; int main() { scanf("%d",&;N); if(N==0) { return 0; } vector<num> arr; for(int i=0;i<N;i++) { int t=0,s=0; scanf("%d%d",&;t,&;s); num n; n.time=t; n.sorce=s; arr.push_back(n); } sort(arr.begin(),arr.end()); int ans = arr[0].sorce; int cur_time = 2; for(int i=1;i<N;i++) { if(arr[i].time >= cur_time) { ans+= arr[i].sorce; cur_time++; } } printf("%d",ans); return 0; }

相关推荐

03-23 15:00
已编辑
厦门大学 Java
xiaowl:你这个简历的问题是对于技术点、项目的描述,都是描述action的,对于面试官而言,仅能知道你干了什么,无法判断你为什么这么干,干的好不好。
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务