Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int luckBalance(int k, vector<vector<int>> contests) {
- int max_luck {0};
- multiset<int> important_contests;
- for (auto e : contests){
- if (e[1] == 0){
- max_luck += e[0];
- } else {
- important_contests.insert(e[0]);
- }
- }
- int i{0};
- int t;
- if (important_contests.size() > k)
- t = important_contests.size() - k;
- else t = 0;
- for (auto e : important_contests){
- if (i < t){
- max_luck -= e;
- ++i;
- } else {
- max_luck += e;
- }
- }
- return max_luck;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement