# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
869121 | Alora | Sjeckanje (COCI21_sjeckanje) | C++17 | 1 ms | 2396 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.
#include <bits/stdc++.h>
#define Alora "cownav"
#define fi(i,a,b) for(int i = a; i <= b; i++)
#define fid(i,a,b) for(int i = a; i >= b; i--)
#define ll long long
#define f first
#define se second
#define pii pair<int, int>
#define getbit(i, j) ((i >> j) & 1)
#define all(v) v.begin(), v.end()
#define pb push_back
#define maxn 200005
const int M = 1e9 + 7;
using namespace std;
int m, n;
ll a[maxn], dp[3][maxn];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(NULL);
if(fopen(Alora".inp","r")){
freopen(Alora".inp","r",stdin);
freopen(Alora".out","w",stdout);}
cin >> n >> m;
fi(i, 1, n) cin >> a[i];
while(m--){
int l, r, x;
cin >> l >> r >> x;
fi(i, l, r) a[i] += x;
dp[0][1] = dp[1][1] = 0;
fi(i, 2, n){
dp[0][i] = max(dp[0][i - 1], dp[1][i - 1]);
dp[1][i] = dp[0][i - 1] + abs(a[i] - a[i - 1]);
}
cout << max(dp[0][n], dp[1][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... |