?
# | Author | Problem | Lang | Verdict | Time | Memory | Sent | Judged | |
---|---|---|---|---|---|---|---|---|---|
81845299 |
Practice: sanchit_1999 |
1359D - 47 | C++14 (GCC 6-32) | Accepted | 62 ms | 496 KB | 2020-05-29 07:09:24 | 2020-05-29 08:08:30 |
#include <algorithm> #include <iostream> using namespace std; #define N 123456 #define i0toN(i, n) for(int i = 0; i < int(n); i++) #define i1toN(i, n) for(int i = 1; i <= int(n); i++) #define nl "\n" void sktg() { ios::sync_with_stdio(0); cin.tie(0); } int n, a[N], ans; int main() { sktg(); ans = 0; cin >> n; i0toN(i, n)cin >> a[i]; i0toN(i, 31) { int res = 0, mx = 0, cur = 0; i0toN(j, n) { if (a[j] > i) {cur = 0; continue;} mx = max(mx, a[j]); cur += a[j]; res = max(res, cur - mx); if (cur < 0)cur = 0; } ans = max(ans, res); } cout << ans << nl; return 0; }
?
?
?
?