Submission #522834

# Submission time Handle Problem Language Result Execution time Memory
522834 2022-02-06T01:25:06 Z julian33 Sjeckanje (COCI21_sjeckanje) C++14
0 / 110
1 ms 332 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int mxN=2e5+5;

ll a[mxN],dp[mxN];

int main(){
    cin.sync_with_stdio(0); cin.tie(0);

    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

    int n,q; cin>>n>>q;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    while(q--){
        int l,r,x; cin>>l>>r>>x;
        for(int i=l;i<=r;i++)
            a[i]+=x;
        for(int i=1;i<=n;i++){
            dp[i]=dp[i-1];
            if(i>1) dp[i]=max(dp[i],dp[i-2]+abs(a[i]-a[i-1]));
            if(i>2) dp[i]=max(dp[i],dp[i-3]+max(abs(a[i]-a[i-1]),max(abs(a[i]-a[i-2]),abs(a[i-1]-a[i-2]))));
        }
        cout<<dp[n]<<"\n";
    }
}   
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -