3096. 得到更多分数的最少关卡数目
class Solution {
public:
int minimumLevels(vector<int>& possible) {
int bob = 0, alice = 0;
for (auto i : possible) {
bob += get_value(i);
}
for (int i = 0;i < possible.size() - 1;i++) {
alice += get_value(possible[i]);
bob -= get_value(possible[i]);
if (alice > bob) {
return i+1;
}
}
return -1;
}
int get_value(int x) {
if (x == 1) {
return 1;
} else if (x == 0) {
return -1;
}
return 0;
}
};