72012024-01-03 12:59:22MagyarKendeSZLGBányász RPG (40 pont)cpp17Wrong answer 15/4028ms4500 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), [](point a, point b){ return a[1] < b[1]; });

    // initially I was using a priority queue with but that got a time fail,
    // I got the hint that you can use two pointers :O
    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];
            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;
}
SubtaskSumTestVerdictTimeMemory
base15/40
1Wrong answer0/03ms1828 KiB
2Wrong answer0/08ms2708 KiB
3Accepted2/23ms2376 KiB
4Accepted2/23ms2468 KiB
5Accepted2/26ms2664 KiB
6Accepted2/212ms2996 KiB
7Accepted2/23ms2984 KiB
8Accepted2/24ms2952 KiB
9Accepted3/33ms2916 KiB
10Wrong answer0/33ms2976 KiB
11Wrong answer0/33ms3064 KiB
12Wrong answer0/33ms3076 KiB
13Wrong answer0/43ms3080 KiB
14Wrong answer0/43ms3216 KiB
15Wrong answer0/217ms3976 KiB
16Wrong answer0/223ms4104 KiB
17Wrong answer0/218ms3980 KiB
18Wrong answer0/228ms4500 KiB