我不太明白第二题为啥这么写不对。思路就是分奇偶位统计出各自的最大值,然后分奇偶位看一下加到这个最大值需要多少。如果奇偶位的最大值相同,那么有一半需要再全部+1```c++#include <bits/stdc++.h>using namespace std;int main() {int n;long long num;vector<long long> nums;long long oddMax=-1, evenMax = -1;while (cin >> n) {int res = 0;nums = vector<long long>(n, 0);for (int i = 0; i < n; ++i) {cin >> num;nums[i] = num;if (i%2 == 0) evenMax = evenMax > num ? evenMax : num;else oddMax = oddMax > num ? oddMax : num;}for (int i = 0; i < n; ++i) {if (i%2 == 0) {res += (evenMax-nums[i]);}else {res += (oddMax - nums[i]);}}if (evenMax == oddMax) res += (n/2);cout << res << endl;}}```