原题题目
代码实现(首刷自解)
class Solution {
public:int stoneGameVI(vector<int>& aliceValues, vector<int>& bobValues) {
vector<pair<int,int>> scores;int alice = 0,bob = 0;for(int i=0;i<bobValues.size();++i) scores.push_back({
abs(aliceValues[i]+bobValues[i]),i});sort(scores.begin(),scores.end(),greater<pair<int,int>>());for(int i=0;i<scores.size();++i){
if(!(i%2)) alice += aliceValues[scores[i].second];else bob += bobValues[scores[i].second]; }if(alice > bob) return 1;else if(alice == bob) return 0;else return -1;}
};