88292024-01-31 18:22:03NagyLeoBányász RPG (40 pont)pypy3Time limit exceeded 26/40375ms101772 KiB
def main():
    N = int(input())
    exp = list(map(int, input().split()))
    mat = list(map(int, input().split()))

    time = 0
    whole = []
    experience = 0
    cheapest = N - 1
    expensive = 0

    for i in range(0, N):
        whole.append([mat[i], exp[i]])

    all1 = sum(mat)
    whole.sort(key=lambda x: -x[1])

    while all1 != experience:
        if whole[cheapest][1] <= experience:
            whole[cheapest][0] -= 1
            time += 1
            experience += 1
            if whole[cheapest][0] == 0:
                cheapest -= 1
        else:
            whole[expensive][0] -= 1
            time += 2
            experience += 1
            if whole[expensive][0] == 0:
                expensive += 1

    return time


print(main())
SubtaskSumTestVerdictTimeMemory
base26/40
1Accepted0/048ms76732 KiB
2Time limit exceeded0/0344ms28084 KiB
3Accepted2/246ms86016 KiB
4Accepted2/261ms87708 KiB
5Time limit exceeded0/2375ms28188 KiB
6Time limit exceeded0/2370ms31580 KiB
7Accepted2/276ms89464 KiB
8Time limit exceeded0/2347ms26272 KiB
9Accepted3/341ms78464 KiB
10Accepted3/348ms87376 KiB
11Accepted3/356ms87364 KiB
12Accepted3/368ms87228 KiB
13Accepted4/4159ms88740 KiB
14Accepted4/4104ms87552 KiB
15Runtime error0/274ms101772 KiB
16Runtime error0/259ms99104 KiB
17Runtime error0/272ms100824 KiB
18Runtime error0/261ms95652 KiB