Submission #870129

# Submission time Handle Problem Language Result Execution time Memory
870129 2023-11-07T02:25:39 Z LTTrungCHL Sjeckanje (COCI21_sjeckanje) C++17
0 / 110
1 ms 4444 KB
///***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];
long long 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();
    //}
}



# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -