제출 #366694

#제출 시각아이디문제언어결과실행 시간메모리
366694faustaadpSjeckanje (COCI21_sjeckanje)C++17
0 / 110
3 ms364 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define pb push_back #define mp make_pair #define fi first #define se second const int NN = 1e6 + 5; const int mo = 1e9 + 7; const ld eps = 1e-9; ll n, q, a[NN]; ll ST[4 * NN][3][3]; void init(ll aa, ll bb, ll ee) { if(aa == bb) { for(ll i = 0; i < 3; i++) for(ll j = 0; j < 3; j++) { if(i != 2 && j != 2) ST[ee][i][j] = -1e18; else { ll cst = 0; if(i == 0)cst -= a[aa]; if(j == 0)cst -= a[aa]; if(i == 1)cst += a[aa]; if(j == 1)cst += a[aa]; ST[ee][i][j] = cst; } } } else { ll ce = (aa + bb) / 2; init(aa, ce, ee * 2); init(ce + 1, bb, ee * 2 + 1); for(ll i = 0; i < 3; i++) for(ll j = 0; j < 3; j++) { ST[ee][i][j] = ST[ee * 2][i][0] + ST[ee * 2 + 1][1][j]; ST[ee][i][j] = max(ST[ee][i][j], ST[ee * 2][i][1] + ST[ee * 2 + 1][0][j]); ST[ee][i][j] = max(ST[ee][i][j], ST[ee * 2][i][2] + ST[ee * 2 + 1][2][j]); } } } int main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin >> n >> q ; for(ll i = 1; i <= n; i++) cin >> a[i]; init(1, n, 1); for(ll i = 1; i <= q; i++) { ll L, R, tam; cin >> L >> R >> tam; for(ll i = L; i <= R; i++) a[i] += tam; init(1, n, 1); cout << ST[1][2][2] << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...