240142026-02-03 17:53:52algoproBányász RPG (40 pont)cpp17Wrong answer 0/40400ms1076 KiB
// UUID: 473ef5dd-9b78-4686-8d65-4b06e4c17b9d
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
	ios::sync_with_stdio(false);
    cin.tie(0);

    int n; cin >>n;

    vector<pair<int, int>>anyag(n);

    for (int i = 0; i < n; i++){
        cin >>anyag[i].first;
    }
    for (int i = 0; i < n; i++){
        cin >>anyag[i].second;
    }

    sort(anyag.begin(), anyag.end());

    int tp = 0;
    ll ido = 0;

    int count = 0;

    int b = 0, j = n-1; 
    while (b <= j){
        if (tp >= anyag[b].first){
            ido+=anyag[b].second;
            tp+=anyag[b].second;
            anyag[b].second = 0;
            b++;
        }
        else{
            anyag[j].second--;
            ido += 2;
            tp++;
            if (anyag[j].second == 0) j--;
        }
        count ++;
    }

    cout << count << "\n";
    cout << ido;
}
SubtaskSumTestVerdictTimeMemory
base0/40
1Wrong answer0/01ms512 KiB
2Wrong answer0/06ms316 KiB
3Wrong answer0/21ms316 KiB
4Wrong answer0/21ms316 KiB
5Wrong answer0/24ms516 KiB
6Wrong answer0/29ms564 KiB
7Wrong answer0/22ms316 KiB
8Wrong answer0/22ms316 KiB
9Wrong answer0/31ms316 KiB
10Wrong answer0/31ms316 KiB
11Wrong answer0/31ms316 KiB
12Wrong answer0/31ms368 KiB
13Wrong answer0/42ms316 KiB
14Wrong answer0/41ms316 KiB
15Time limit exceeded0/2400ms820 KiB
16Wrong answer0/221ms820 KiB
17Time limit exceeded0/2400ms820 KiB
18Wrong answer0/228ms1076 KiB