Submission #1278856

#TimeUsernameProblemLanguageResultExecution timeMemory
1278856Robert_juniorSjeckanje (COCI21_sjeckanje)C++20
0 / 110
0 ms332 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back  
#define all(x) x.begin(), x.end()
#define ins insert
#define F first
#define S second
#define ld long double
const int N = 1e5 + 7, mod = 1e9 + 7;
void solve(){
    int n, q;
    cin>>n>>q;
    int a[n + 1];
    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;
        }
        int ans = 0;
        for(int i = 1; i < n; i++){
            ans += abs(a[i] - a[i + 1]);
        }
        cout<<ans<<'\n';
    }
}
signed main(){
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
    //freopen("area.in", "r", stdin);
    //freopen("area.out", "w", stdout);
    int t = 1;
    //cin>>t;
    while(t--){
        solve();
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...