61422023-11-03 20:21:32MrChipserBányász RPG (40 pont)cpp11Time limit exceeded 30/40400ms5372 KiB
#include <iostream>
#include <vector>
using namespace std;
long n;
vector<pair<long,long>> anyagok;
bool vanmeg()
{
    for(long i = 0; i < n; i++)
    {
        if(anyagok[i].second > 0)
            return true;
    }
    return false;
}

int main()
{
    cin >> n;
    for(int i = 0 ; i < n; i++)
    {
        long x;
        cin >> x;
        anyagok.push_back(make_pair(x,0));
        //cout << i << endl;
    }
    for(int i = 0 ; i < n; i++)
    {
        long x;
        cin >> x;
        anyagok[i].second = x;
        //cout << endl;
    }
    long ido = 0;
    long pontszam = 0;
    bool voltfasza = false;
    while(vanmeg())
    {
        for(int i = 0; i < n ; i++)
        {
            if(pontszam>=anyagok[i].first)
            {
                voltfasza = true;
                ido+=anyagok[i].second;
                pontszam+=anyagok[i].second;
                anyagok[i].second = 0;
            }
        }
        if(!voltfasza)
        {
            int maxim = 0;
            int index;
            for(int i = 0; i < n ; i++)
            {
                if(maxim<anyagok[i].second)
                {
                    maxim = anyagok[i].second;
                    index = i;
                }
            }
            ido+=2;
            pontszam++;
            anyagok[index].second=anyagok[index].second-1;
        }
        voltfasza = false;
    }
    cout << ido << endl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base30/40
1Accepted0/03ms1880 KiB
2Accepted0/013ms2684 KiB
3Accepted2/23ms2280 KiB
4Accepted2/23ms2548 KiB
5Time limit exceeded0/2400ms2204 KiB
6Accepted2/234ms3928 KiB
7Accepted2/214ms3004 KiB
8Accepted2/278ms3184 KiB
9Accepted3/33ms3012 KiB
10Accepted3/32ms3136 KiB
11Accepted3/32ms3104 KiB
12Accepted3/33ms3240 KiB
13Accepted4/43ms3472 KiB
14Accepted4/43ms3660 KiB
15Time limit exceeded0/2370ms4352 KiB
16Time limit exceeded0/2381ms5372 KiB
17Time limit exceeded0/2361ms4368 KiB
18Time limit exceeded0/2368ms5348 KiB