# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1011983 | vantam | Sjeckanje (COCI21_sjeckanje) | C++17 | 2077 ms | 2556 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
const int N=1005 ;
long long i,j,n,q,type,l,r,x,ma,mi,lt,rt;
long long a[200005],dp[200005] ;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);
#define NAME "test"
if(fopen(NAME".inp", "r")){
freopen(NAME".inp", "r", stdin);
freopen(NAME".out", "w", stdout);
}
cin >> n >> q;
for(i=1;i<=n;i++) cin >> a[i] ;
while(q--){
cin >> l >> r >> x ;
for(i=l;i<=r;i++) a[i]+=x ;
dp[0]=0 ;
for(i=1;i<=n;i++){
ma=a[i];
mi=a[i];
dp[i]=-1e18;
for(j=i;j>=1;j--){
ma=max(ma,a[j]) ;
mi=min(mi,a[j]) ;
dp[i]=max(dp[i], dp[j-1]+ma-mi) ;
}
}
cout << dp[n] << '\n' ;
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |