185562025-10-26 18:17:08zsombBányász RPG (40 pont)cpp17Wrong answer 24/4068ms1076 KiB
#include <bits/stdc++.h>
using namespace std;



int main(){
    int n;
    cin >> n;
    vector<pair<int,int>> a(n);

    for(auto& i : a)
        cin >> i.first;

    for(auto& i : a)
        cin >> i.second;

    sort(a.begin(), a.end());
    int t = 0;
    int ido = 0;
    for(int i = 0; i< n; i++){
        if(t >= a[i].first)
            ido += a[i].second;
        else if (a[i].second + t < a[i].first)
            ido += a[i].second*2;
        else {
            ido += 2*(a[i].first - t) + a[i].second - a[i].first;
        }
        t += a[i].second;
        
    }
    cout << ido;
    
}
SubtaskSumTestVerdictTimeMemory
base24/40
1Accepted0/01ms316 KiB
2Accepted0/013ms316 KiB
3Accepted2/21ms316 KiB
4Accepted2/21ms316 KiB
5Wrong answer0/210ms608 KiB
6Wrong answer0/221ms572 KiB
7Wrong answer0/23ms328 KiB
8Wrong answer0/24ms316 KiB
9Accepted3/31ms316 KiB
10Accepted3/31ms316 KiB
11Accepted3/31ms316 KiB
12Accepted3/31ms316 KiB
13Accepted4/41ms316 KiB
14Accepted4/41ms328 KiB
15Wrong answer0/239ms740 KiB
16Wrong answer0/252ms932 KiB
17Wrong answer0/243ms840 KiB
18Wrong answer0/268ms1076 KiB