Submission #513860

#TimeUsernameProblemLanguageResultExecution timeMemory
513860blueSjeckanje (COCI21_sjeckanje)C++17
15 / 110
2082 ms420 KiB
#include <iostream> using namespace std; using ll = long long; ll* a; bool cmp(int i, int j) { if(a[i] != a[j]) return a[i] < a[j]; else return i < j; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, q; cin >> n >> q; a = new ll[1+n+1]; for(int i = 1; i <= n; i++) cin >> a[i]; a[0] = a[n+1] = 0; for(int j = 1; j <= q; j++) { ll l, r, x; cin >> l >> r >> x; for(int i = l; i <= r; i++) a[i] += x; ll dp[1+n]; dp[0] = 0; for(int i = 1; i <= n; i++) { dp[i] = 0; for(int j = 1; j <= i; j++) dp[i] = max(dp[i], dp[j-1] + abs(a[i] - a[j])); } cout << dp[n] << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...