You are viewing a single comment's thread. Return to all comments →
C++ solution :
int luckBalance(int k, vector<vector<int>> contests) { vector<int> imp; int luck=0; for (int i=0;i<contests.size();i++) { if (contests[i][1]) { imp.push_back(contests[i][0]); luck-=contests[i][0]; } else luck+=contests[i][0]; } sort(imp.begin(), imp.end(), greater<int>()); for (int i=0;i<min(k, (int)imp.size());i++) luck+=2*imp[i]; return luck; }
Seems like cookies are disabled on this browser, please enable them to open this website
Luck Balance
You are viewing a single comment's thread. Return to all comments →
C++ solution :