Submission #376283

#TimeUsernameProblemLanguageResultExecution timeMemory
376283dantoh000Sjeckanje (COCI21_sjeckanje)C++14
0 / 110
1 ms364 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n,q; ll a[2005]; ll dp[2005]; int main(){ scanf("%d%d",&n,&q); for (int i = 1; i <= n; i++){ scanf("%lld",&a[i]); } for (int Q = 0; Q < q; Q++){ int l,r; ll x; scanf("%d%d%lld",&l,&r,&x); for (int i = l ;i <= r; i++){ a[i] += x; } ll A = -1000000000000000000; ll B = -1000000000000000000; for (int i = 1; i <= n; i++){ dp[i] = max(A+a[i], B-a[i]); A = max(A, dp[i-1]-a[i]); B = max(B, dp[i-1]+a[i]); //printf("%lld ",dp[i]); } printf("%lld\n",dp[n]); } }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    8 |     scanf("%d%d",&n,&q);
      |     ~~~~~^~~~~~~~~~~~~~
Main.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 |         scanf("%lld",&a[i]);
      |         ~~~~~^~~~~~~~~~~~~~
Main.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   15 |         scanf("%d%d%lld",&l,&r,&x);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...