Submission #881504

#TimeUsernameProblemLanguageResultExecution timeMemory
881504Yang8onSjeckanje (COCI21_sjeckanje)C++14
15 / 110
2023 ms2648 KiB
#include <bits/stdc++.h> #define Yang8on Nguyen_Dinh_Son #define sonphamay Nguyen_Dinh_Son #define aothtday "Sjeckanje" #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 endl '\n' #define pii pair<int, ll> #define pb push_back #define all(v) v.begin(), v.end() #define f first #define s second #define maxn 200005 #define maxm #define maxx #define mod 1000000007 #define base 311 #define ModHas 1000000003ll #define gb(i, j) ((i >> j) & 1) #define int long long using namespace std; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll GetRandom(ll l, ll r) { return uniform_int_distribution<ll> (l, r)(rng); } int n, q; ll a[maxn], dp[maxn]; void solve() { cin >> n >> q; fi(i, 1, n) cin >> a[i]; fi(_, 1, q) { int l, r; ll val; cin >> l >> r >> val; fi(i, l, r) a[i] += val; fi(i, 1, n) fi(j, 1, i) dp[i] = max(dp[i], abs(a[i] - a[j]) + dp[j - 1]); cout << dp[n] << '\n'; fi(i, 1, n) dp[i] = 0; } } signed main() { if(fopen(aothtday".inp", "r")) { freopen(aothtday".inp","r",stdin); freopen(aothtday".out","w",stdout); } ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); int nTest = 1; // cin >> nTest; while(nTest --) { solve(); } return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:61:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |         freopen(aothtday".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:62:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   62 |         freopen(aothtday".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...