Submission #870126

#TimeUsernameProblemLanguageResultExecution timeMemory
870126LTTrungCHLSjeckanje (COCI21_sjeckanje)C++17
0 / 110
1 ms4440 KiB
///***LTT***/// /// ->NHAT QUOC GIA<- /// #include<bits/stdc++.h> //#pragma GCC optimize ("O3") //#pragma GCC optimize ("unroll-loops") //#pragma GCC target("popcnt") //#define int long long #define endl "\n" #define F first #define S second #define pb push_back using namespace std; const long long oo = 1e9+7; const int N = 2 * 1e5 + 10; int n, q; long long a[N], d[N], dp[N]; int l, r, x; void inp(){ cin >> n >> q; for (int i = 1;i <= n;i++){ cin >> a[i]; } return; } void solve(){ for (int i = 1;i <= q;i++){ cin >> l >> r >> x; for (int j = l;j <= r;j++){ a[j] += x; } for (int j = 1;j < n;j++){ d[j] = abs(a[j] - a[j + 1]); } long long ans = 0; for (int j = 1;j < n;j++){ dp[j] = d[j] + dp[j - 2]; ans = max(ans, dp[j]); } cout << ans <<"\n"; } return; } int main(){ ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL); if (fopen("file.inp", "r")){ freopen("file.inp", "r", stdin); freopen("file.out", "w", stdout); } //int t; //cin >> t; //while(t--){ inp(); solve(); //} }

Compilation message (stderr)

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