Submission #673778

#TimeUsernameProblemLanguageResultExecution timeMemory
673778TrentSjeckanje (COCI21_sjeckanje)C++17
15 / 110
10 ms444 KiB
#include "bits/stdc++.h" #include <cstring> #include <fstream> using namespace std; #define ll long long #define forR(i, x) for(int i = 0; i < x; ++i) #define REP(i, a, b) for(int i = (a); i < (b); ++i) #define open(s) freopen(((string) s + ".in").c_str(), "r", stdin); freopen(((string) s + ".out").c_str(), "w", stdout) #define all(i) i.begin(), i.end() #define boost() cin.sync_with_stdio(0); cin.tie() #define int ll const int MN = 210; int arr[MN], dp[MN]; signed main() { int n, q; cin >> n >> q; REP(i, 1, n + 1) cin >> arr[i]; forR(g, q){ int l, r, x; cin >> l >> r >> x; REP(i, l, r + 1) arr[i] += x; REP(i, 1, n + 1){ dp[i] = 0; int ma=arr[i], mi=arr[i]; for(int j = i; j >= 1; --j){ ma=max(ma, arr[j]); mi = min(mi, arr[j]); dp[i] = max(dp[i], ma - mi + dp[j - 1]); } } cout << dp[n] << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...