61412023-11-03 20:20:18MrChipserBányász RPG (40 pont)cpp11Wrong answer 0/40400ms5492 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
base0/40
1Wrong answer0/03ms1876 KiB
2Wrong answer0/075ms2740 KiB
3Wrong answer0/23ms2308 KiB
4Wrong answer0/24ms2524 KiB
5Time limit exceeded0/2400ms2060 KiB
6Wrong answer0/289ms3748 KiB
7Wrong answer0/218ms2924 KiB
8Wrong answer0/286ms2980 KiB
9Wrong answer0/33ms2812 KiB
10Wrong answer0/33ms3060 KiB
11Wrong answer0/33ms3392 KiB
12Wrong answer0/34ms3416 KiB
13Wrong answer0/44ms3512 KiB
14Wrong answer0/44ms3704 KiB
15Time limit exceeded0/2370ms4140 KiB
16Time limit exceeded0/2365ms5256 KiB
17Time limit exceeded0/2361ms4304 KiB
18Time limit exceeded0/2352ms5492 KiB