Submission #1011983

#TimeUsernameProblemLanguageResultExecution timeMemory
1011983vantamSjeckanje (COCI21_sjeckanje)C++17
15 / 110
2077 ms2556 KiB
#pragma GCC optimize("O3") #pragma GCC target("avx,avx2,fma") #include<bits/stdc++.h> using namespace std; const int N=1005 ; long long i,j,n,q,type,l,r,x,ma,mi,lt,rt; long long a[200005],dp[200005] ; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); #define NAME "test" if(fopen(NAME".inp", "r")){ freopen(NAME".inp", "r", stdin); freopen(NAME".out", "w", stdout); } cin >> n >> q; for(i=1;i<=n;i++) cin >> a[i] ; while(q--){ cin >> l >> r >> x ; for(i=l;i<=r;i++) a[i]+=x ; dp[0]=0 ; for(i=1;i<=n;i++){ ma=a[i]; mi=a[i]; dp[i]=-1e18; for(j=i;j>=1;j--){ ma=max(ma,a[j]) ; mi=min(mi,a[j]) ; dp[i]=max(dp[i], dp[j-1]+ma-mi) ; } } cout << dp[n] << '\n' ; } return 0; }

Compilation message (stderr)

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