이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
int main(){
    ll n;
    cin >> n;
    vector<ll> slots(n);
    vector<ll> users(n);
    for(ll i = 0; i < n; i++){
        cin >> slots[i];
    }
    for(ll i = 0; i < n; i++){
        cin >> users[i];
    }
    ll j = 1;
    ll happy = 0;
    ll stage = 0;
    for(ll i = 0; i < n; i++){
        while(j<=i){
            j++;
        }
        while(slots[i]!=0){
            if(j>=n) {stage = 1; break;}
            ll x = min(slots[i], users[j]);
            slots[i]-=x;
            users[j]-=x;
            happy+=x;
            if(users[j]==0){
                j++;
            }
        }
        if(stage == 1) {
            ll x = min(slots[i], users[i]);
            slots[i]-=x;
            users[i]-=x;
            break;
        }
    }
    happy -= accumulate(users.begin(), users.end(), ll(0));
    cout << happy;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |