Submission #1341217

#TimeUsernameProblemLanguageResultExecution timeMemory
1341217sallyBikeparking (EGOI24_bikeparking)C++20
25 / 100
105 ms5104 KiB
#include<iostream>
#include<vector>
using namespace std;
#define int long long
signed main() {
    int N;
    cin>>N;
    vector<int> slot(N+1), person(N+1);
    for(int i=0; i<N; i++) cin>>slot[i];
    for(int i=0; i<N; i++) cin>>person[i];
    int ptr = 0, ans = 0;
    for(int i=0; i<N; i++) {
        int need = person[i];
        for(int t = ptr; t<i && need; t++) {
            int take = min(need, slot[t]);
            slot[t] -= take;
            need -= take;
            ans += take;
        }
        while(slot[ptr] == 0 && ptr<N) ptr++;
        person[i] = need;
    }
    int cnt = 0;
    for(int i=0; i<N; i++) {
        int take =  min(slot[i], person[i]);
        slot[i] -= take;
        person[i] -= take;
    }
    for(int i=0; i<N; i++) {
        ans -= person[i];
    }
    cout<<ans;
}
#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...