제출 #1364191

#제출 시각아이디문제언어결과실행 시간메모리
1364191avahwBikeparking (EGOI24_bikeparking)C++20
25 / 100
19 ms4932 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll n;
    cin >> n;
    vector<ll> slots(n);
    vector<ll> ppl(n);
    for(ll i = 0; i < n; i++) cin >> slots[i];
    for(ll i = 0; i < n; i++) cin >> ppl[i];
    // do upgrades
    ll score = 0;
    ll curr_ppl = n - 1;
    for(ll i = n - 2; i >= 0; i--){
        // if we've run out of ppl beneath us to upgrade, continue
        if(ppl[curr_ppl] == 0) curr_ppl--;
        if(curr_ppl <= i) continue;
        // assign these slots
        ll remove = min(slots[i], ppl[curr_ppl]);
        slots[i] -= remove;
        ppl[curr_ppl] -= remove;
        score += remove;

    }
    // do samegrades
    for(ll i = 0; i < n; i++){
        ll remove = min(slots[i], ppl[i]);
        slots[i] -= remove;
        ppl[i] -= remove;
    }
    // do downgrades
    for(ll i = 0; i < n; i++) score -= ppl[i];
    cout << score << "\n";

}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…