88282024-01-31 18:21:36NagyLeoBányász RPG (40 pont)python3Time limit exceeded 13/40386ms28316 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
base13/40
1Accepted0/017ms11364 KiB
2Time limit exceeded0/0347ms7632 KiB
3Accepted2/225ms11808 KiB
4Accepted2/2184ms12368 KiB
5Time limit exceeded0/2368ms7676 KiB
6Time limit exceeded0/2368ms10964 KiB
7Time limit exceeded0/2375ms6308 KiB
8Time limit exceeded0/2379ms6844 KiB
9Accepted3/317ms13444 KiB
10Accepted3/325ms13800 KiB
11Accepted3/367ms13940 KiB
12Time limit exceeded0/3356ms6428 KiB
13Time limit exceeded0/4351ms6556 KiB
14Time limit exceeded0/4367ms6468 KiB
15Time limit exceeded0/2386ms17440 KiB
16Time limit exceeded0/2370ms22280 KiB
17Time limit exceeded0/2356ms19968 KiB
18Time limit exceeded0/2377ms28316 KiB