72022024-01-03 13:02:50MagyarKendeSZLGBányász RPG (40 pont)cpp17Elfogadva 40/4035ms5460 KiB
#include <bits/stdc++.h>

#define speed cin.tie(0); ios::sync_with_stdio(0)
#define cinv(v) for (auto& e : v) cin >> e;
#define all(v) v.begin(), v.end()
#define has(s, e) s.count(e)

using namespace std;
using ll = long long;
using point = array<int, 2>;

int main() {
    speed;

    int N;
    cin >> N;
    vector<point> v(N);

    for (int i = 0; i < N; i++) cin >> v[i][0];
    for (int i = 0; i < N; i++) cin >> v[i][1];

    sort(all(v));

    ll t = 0, xp = 0;
    int l = 0, r = N - 1;
    while (l <= r) {
        if (v[l][0] <= xp) {
            // finish the remaining in one sitting (yum)
            t += v[l][1];
            xp += v[l][1];
            v[l] = {0, 0};
            l++;
        } else {
            // if had to finish the inefficient way, this is done (mining be boring aa hell)
            if (--v[r][1] == 0) r--;
            t += 2; // go one by one here, time and xp gain is constant
            xp++;
        }
    }

    cout << t;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base40/40
1Elfogadva0/03ms1828 KiB
2Elfogadva0/08ms2268 KiB
3Elfogadva2/23ms2232 KiB
4Elfogadva2/23ms2456 KiB
5Elfogadva2/28ms2884 KiB
6Elfogadva2/214ms3312 KiB
7Elfogadva2/24ms3172 KiB
8Elfogadva2/24ms3256 KiB
9Elfogadva3/33ms3408 KiB
10Elfogadva3/33ms3508 KiB
11Elfogadva3/33ms3988 KiB
12Elfogadva3/33ms3960 KiB
13Elfogadva4/43ms3976 KiB
14Elfogadva4/43ms4124 KiB
15Elfogadva2/221ms5028 KiB
16Elfogadva2/228ms5116 KiB
17Elfogadva2/223ms4940 KiB
18Elfogadva2/235ms5460 KiB