제출 #1229906

#제출 시각아이디문제언어결과실행 시간메모리
1229906gry3125Bikeparking (EGOI24_bikeparking)C++20
19 / 100
244 ms33288 KiB
#include <bits/stdc++.h>
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define ll long long int
using namespace std;

int main() {
    ll n; cin >> n; ll r = 0;
    set<ll> x; map<ll,ll> cnt; 
    for (int i = 0; i < n; i++) {
        ll xi; cin >> xi; 
        if (xi == 0) continue;
        x.insert(i); cnt[i] = xi;
    }
    deque<ll> y;
    for (int i = 0; i < n; i++) {
        ll yi; cin >> yi;
        while (yi--) {
            if (x.lower_bound(i) == x.begin()) {
                y.push_front(i); continue;
            }
            r++; cnt[*prev(x.lower_bound(i))]--;
            if (cnt[*prev(x.lower_bound(i))] == 0) {
            	x.erase(prev(x.lower_bound(i))); 
            }
        }
    }
    deque<ll> nx;
    for (auto w : x) nx.pb(w);
    for (int i = 0; i < y.size(); i++) {
        if (y[i] < nx[i]) r--;
        if (y[i] > nx[i]) r++;
    }
    cout << r;
    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...