Submission #1083909

# Submission time Handle Problem Language Result Execution time Memory
1083909 2024-09-04T13:56:32 Z duytuandao21 Sjeckanje (COCI21_sjeckanje) C++17
0 / 110
6 ms 344 KB
#include<bits/stdc++.h>
using namespace std;

const int N = 2e6 + 7;
const int inf = 1e9 + 7;
const long long infll = 1e18 + 7;
typedef pair< float, int > ii;

int n, q;
int a[N];

long long GetResult() {
    vector<long long> dp(n + 1, 0);
    long long res = -infll;
    for (int i = 1; i <= n; i++) {
        int maxValue = -inf;
        int minValue = inf;
        for (int j = i; j > 0; j--) {
            maxValue = max(maxValue, a[j]);
            minValue = min(minValue, a[j]);
            dp[i] = max(dp[i], dp[j - 1] + maxValue - minValue);
            res = max(res, dp[i]);
        }
        // cout << dp[i] << ' ';
    }   
    return res;
} 
int main() 
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> q;
    for (int i = 1; i <= n; i++) cin >> a[i];
    while (q--) {
        int l, r, v; cin >> l >> r >> v;
        for (int i = l; i <= r; i++) a[i] += v;
        cout << GetResult();
        if (q > 0) cout << '\n';
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -