全部评论
华为这个笔试是只招测试吗
#include<bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int ans = 0; vector<pair<int, int>> tmp; for(int i = 0; i < n; ++i){ int a, b; cin >> a >> b; tmp.push_back(make_pair(a, b)); } sort(tmp.begin(), tmp.end(), [](pair<int, int>&; a, pair<int, int>&; b){ return a.first == b.first ? a.second > b.second : a.first < b.first; }); int start = 0; for(int i = 1; i <= 7 * 105 &;&; start < n; ++i){ for(int j = start; j < n; ++j){ if(tmp[j].first >= i){ ans += tmp[j].second; start = j + 1; break; } } } cout << ans; return 0; } 第二题25%,不知道哪里有问题,求大佬帮忙看看
相关推荐
05-29 18:15
山东科技大学 运营 点赞 评论 收藏
分享
点赞 评论 收藏
分享