#include <bits/stdc++.h>
using namespace std;
int n, tot = 0, ans = 0;;
int main() {
cin >> n;
vector<int> a(n + 1);
for (int i = 1; i <= n; i++) {
cin >> a[i];
tot += a[i];
}
bool flag ;
while (tot > 0) {
flag = 0;
for (int i = 1; i <= n; i++) {
if (flag) {
if (a[i] > 0) {
a[i]--;
tot--;
}
else if (a[i] == 0) {
flag = 0;
}
} else {
if (a[i] > 0) {
flag = 1;
ans++;
a[i]--;
tot--;
} else
continue;
}
}
}
cout << ans;
return 0;
}
全部回复 共 0 条
还没有人回复。往下写第一条。
发表回复
登录后即可回复本帖,与出题人和同学一起讨论。
登录