225482026-01-15 11:02:05vyrallBányász RPG (40 pont)python3Time limit exceeded 11/40400ms19444 KiB
n = int(input())
lvls = list(map(int, input().split()))
needed = list(map(int, input().split()))
mats = [[lvls[i], needed[i]] for i in range(n)]
mats.sort(key=lambda x: x[0])
lvl = 0
time = 0

l = 0
r = len(mats) - 1

while max([row[1] for row in mats]) != 0:
    if mats[l][0] <= lvl:
        mats[l][1] -= 1
        time += 1
        if mats[l][1] == 0:
            l += 1
    else:
        mats[r][1] -= 1
        time += 2
        if mats[r][1] == 0:
            r -= 1
    lvl += 1

print(time)
SubtaskSumTestVerdictTimeMemory
base11/40
1Accepted0/016ms3260 KiB
2Time limit exceeded0/0375ms5876 KiB
3Accepted2/279ms3120 KiB
4Time limit exceeded0/2377ms3124 KiB
5Time limit exceeded0/2400ms5536 KiB
6Time limit exceeded0/2381ms7760 KiB
7Time limit exceeded0/2388ms3624 KiB
8Time limit exceeded0/2388ms3892 KiB
9Accepted3/317ms2932 KiB
10Accepted3/375ms3132 KiB
11Accepted3/3291ms3124 KiB
12Time limit exceeded0/3381ms3128 KiB
13Time limit exceeded0/4388ms3120 KiB
14Time limit exceeded0/4388ms3124 KiB
15Time limit exceeded0/2400ms11932 KiB
16Time limit exceeded0/2391ms15516 KiB
17Time limit exceeded0/2384ms12824 KiB
18Time limit exceeded0/2384ms19444 KiB