Submission #1121406

#TimeUsernameProblemLanguageResultExecution timeMemory
1121406ezzzayBikeparking (EGOI24_bikeparking)C++14
100 / 100
113 ms8024 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define ff first #define ss second #define pb push_back const int N=3e5+5; int x[N],y[N]; int dp[N]; signed main(){ int n; cin>>n; for(int i=1;i<=n;i++){ cin>>x[i]; } for(int i=1;i<=n;i++){ cin>>y[i]; } int h=0,w=0,s=0; for(int i=n;i>=1;i--){ int x1=min(w,x[i]); x[i]-=x1; w-=x1; int x2=min(s,x[i]); x[i]-=x2; s-=x2; h+=x1+x2; s+=min(x[i],y[i]); w+=y[i]-min(x[i],y[i]); } cout<<h-w; }
#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...