int fu() {
int ans = 0;
for (int i = 1; i <= n; i++) {
int t = s[n] - s[i] - c[i];
ans = max(t, ans);
}
return ans;
}
int zheng() {
int ans = 0;
for (int i = 2; i <= n ; i++) {
int t = -s[i - 1] + s[n - i] + c[i];
ans = max(t, ans);
}
return ans;
}
int zero() {
int ans = 0;
int t = 0;
int xx = 0, yy = 0;
for (int i = 1; i <= n; i++)
if (c[i] < 0) {
xx = i;
break;
}
xx--;
for (int i = n; i >= 1; i--)if (c[i] > 0) {
yy = i;
break;
}
yy++;
t = 0;
if (xx > 0)
for (int i = 1; i <= xx; i++) {
t = max(t, s[xx] - s[i] - c[i]);
}
ans += t;
// t = 0;
if (xx + 1 <= yy - 1)
for (int i = xx + 1; i <= yy - 1; i ++) {
ans += abs(c[i]);
}
//
t = 0;
if (yy <= n)
for (int i = yy + 1; i <= n; i ++) {
t = max(t, s[yy - 1] - s[i - 1] + c[i]);
}
ans += t;
return ans;
}
时间复杂度是多少?(估计大概的就行),谢谢!