92852024-02-19 19:42:20antiBányász RPG (40 pont)cpp17Wrong answer 0/40381ms5852 KiB
#include <iostream>
#include <algorithm>

using namespace std;

struct alapanyag{
    int l, m;
    int ido = 2;
    bool kesz = false;
};

bool kisebb(alapanyag A1, alapanyag A2){
    return A1.l < A2.l;
}

int main()
{
    int n;
    cin >> n;
    alapanyag A[n];
    for(int i=0; i<n; i++){
        cin >> A[i].l;
    }
    for(int i=0; i<n; i++){
        cin >> A[i].m;
    }
    sort(A, A+n, kisebb);

    cout << endl;
    for(int i=0; i<n; i++){
        cout << A[i].l << " ";
    }
    cout << endl;
    for(int i=0; i<n; i++){
        cout << A[i].m << " ";
    }
    cout << endl << endl;

    int t=0;

    int h=0, k=n-1;
    int c, xp = 0;
    while(h!=k){
        c = A[h].l;
        while(A[k].m - c < 0){
            c -= A[k].m;
            t += 2 * A[k].m;
            xp = A[k].m;
            k--;
        }
        A[k].m -= c;
        t += 2 * c;
        xp += c;
        while(xp >= A[h].l && h<=k){
            t += A[h].m;
            xp += A[h].m;
            h++;
        }
        h--;
    }
    cout << xp << endl;
    cout << t << endl;
}

/*
5
2 3 5 6 7
4 2 2 6 5
*/
SubtaskSumTestVerdictTimeMemory
base0/40
1Wrong answer0/03ms1876 KiB
2Wrong answer0/017ms2568 KiB
3Wrong answer0/23ms2276 KiB
4Wrong answer0/23ms2404 KiB
5Wrong answer0/214ms2784 KiB
6Wrong answer0/228ms3580 KiB
7Wrong answer0/24ms2984 KiB
8Wrong answer0/27ms3212 KiB
9Wrong answer0/33ms3376 KiB
10Wrong answer0/33ms3464 KiB
11Wrong answer0/33ms3328 KiB
12Wrong answer0/33ms3332 KiB
13Wrong answer0/43ms3336 KiB
14Wrong answer0/43ms3464 KiB
15Wrong answer0/252ms5128 KiB
16Time limit exceeded0/2381ms5852 KiB
17Wrong answer0/257ms5264 KiB
18Time limit exceeded0/2374ms5792 KiB