제출 #869122

#제출 시각아이디문제언어결과실행 시간메모리
869122AloraSjeckanje (COCI21_sjeckanje)C++17
0 / 110
1 ms2396 KiB
#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; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...