# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
870126 | LTTrungCHL | Sjeckanje (COCI21_sjeckanje) | C++17 | 1 ms | 4440 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.
///***LTT***///
/// ->NHAT QUOC GIA<- ///
#include<bits/stdc++.h>
//#pragma GCC optimize ("O3")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("popcnt")
//#define int long long
#define endl "\n"
#define F first
#define S second
#define pb push_back
using namespace std;
const long long oo = 1e9+7;
const int N = 2 * 1e5 + 10;
int n, q;
long long a[N], d[N], dp[N];
int l, r, x;
void inp(){
cin >> n >> q;
for (int i = 1;i <= n;i++){
cin >> a[i];
}
return;
}
void solve(){
for (int i = 1;i <= q;i++){
cin >> l >> r >> x;
for (int j = l;j <= r;j++){
a[j] += x;
}
for (int j = 1;j < n;j++){
d[j] = abs(a[j] - a[j + 1]);
}
long long ans = 0;
for (int j = 1;j < n;j++){
dp[j] = d[j] + dp[j - 2];
ans = max(ans, dp[j]);
}
cout << ans <<"\n";
}
return;
}
int main(){
ios_base::sync_with_stdio(NULL);
cin.tie(NULL);
cout.tie(NULL);
if (fopen("file.inp", "r")){
freopen("file.inp", "r", stdin);
freopen("file.out", "w", stdout);
}
//int t;
//cin >> t;
//while(t--){
inp();
solve();
//}
}
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... |