Submission #1071888

#TimeUsernameProblemLanguageResultExecution timeMemory
1071888edogawa_somethingTricks of the Trade (CEOI23_trade)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vii; typedef pair<ll,ll> pii; #define F first #define S second #define all(v) v.begin(),v.end() #define pb push_back const ll M=6e3+10; const ll inf=2e18; ll n,k,a[M],b[M],pre[M],suf[M],pm[M],sm[M]; int main() { ios_base::sync_with_stdio(0),cin.tie(0); cin>>n>>k; for(int i=0;i<n;i++) cin>>a[i]; for(int i=0;i<n;i++) cin>>b[i]; pre[0]=b[0]; for(int i=1;i<n;i++) { pre[i]=pre[i-1]-b[i-1]+a[i-1]+b[i]; } suf[0]=b[0]-a[0]; for(int i=1;i<n;i++) { suf[i]=suf[i-1]-b[i-1]-a[i]+b[i]; } pm[0]=pre[0]; for(int i=1;i<n;i++) pm[i]=max(pre[i],pm[i-1]); sm[n-1]=suf[n-1]; for(int i=n-2;i>=0;i--) sm[i]=max(suf[i],sm[i+1]); ll ans=0; for(int i=0;i<n-1;i++) { ans=max(ans,pre[i]+sm[i+1]); } cout<<ans<<'\n'; for(int i=0;i<n;i++) { cout<<0; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...