Submission #1053020

#TimeUsernameProblemLanguageResultExecution timeMemory
1053020LudisseyBikeparking (EGOI24_bikeparking)C++17
44 / 100
37 ms8612 KiB
#include <bits/stdc++.h> #define int long long #define sz(a) (int)a.size() #define all(a) a.begin(), a.end() using namespace std; int N,M,Q; signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> N; vector<int> x(N),y(N); vector<int> kp(N); for (int i = 0; i < N; i++) cin >> x[i]; for (int i = 0; i < N; i++) cin >> y[i]; int j=0; int sm=0; for (int i = 0; i < N; i++) { while(j<N&&j<i&&y[i]>0 ) { if(y[j]>0) { j++; continue; } int df=min(x[j],y[i]); x[j]-=df; y[i]-=df; sm+=df; if(x[j]==0) j++; } } j=0; for (int i = 0; i < N; i++) { while(j<i&&y[i]>0 ) { int df=min(x[j],y[i]); x[j]-=df; y[i]-=df; sm+=df; if(x[j]==0) j++; } kp[i]+=y[i]; } for (int i = 0; i < N; i++){ int df=min(x[i],kp[i]); x[i]-=df; kp[i]-=df; sm-=kp[i]; } cout << sm << "\n"; 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...