Submission #490592

#TimeUsernameProblemLanguageResultExecution timeMemory
490592inksamuraiSjeckanje (COCI21_sjeckanje)C++17
0 / 110
2 ms340 KiB
#include <bits/stdc++.h> #define fi first #define se second #define pb push_back #define sz(a) (int)a.size() #define all(a) a.begin(),a.end() #define rep(i,n) for(int i=0;i<n;i++) #define crep(i,x,n) for(int i=x;i<n;i++) #define drep(i,n) for(int i=n-1;i>=0;i--) #define vec(...) vector<__VA_ARGS__> #define _31av4qi ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0) using namespace std; typedef long long ll; typedef long double ld; using pii=pair<int,int>; using vi=vector<int>; int sgn(int x){ return x>=0?1:-1; } int main(){ _31av4qi; int n,q; cin>>n>>q; vi a(n); rep(i,n){ cin>>a[i]; } vi _d(n); rep(cs,q){ int l,r,x; cin>>l>>r>>x; l--,r--; crep(i,l,r+1) a[i]+=x; crep(i,1,n) _d[i-1]=a[i]-a[i-1]; ll ans=0; vec(vec(ll)) dp(n,vec(ll)(2,0)); rep(i,n-1){ dp[i][0]=max(dp[i][0],(i==0?0:dp[i-1][0])+(ll)_d[i]); dp[i][1]=max(dp[i][1],(i==0?0:dp[i-1][1])-(ll)_d[i]); dp[i][1]=max(dp[i][1],(i==0?0:dp[i-1][0])); dp[i][0]=max(dp[i][0],(i==0?0:dp[i-1][1])); // cout<<_d[i]<<" "; } cout<<max(dp[n-2][1],dp[n-2][0])<<"\n"; } // return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:37:6: warning: unused variable 'ans' [-Wunused-variable]
   37 |   ll ans=0;
      |      ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...