225582026-01-15 11:10:04vyrallBányász RPG (40 pont)python3Time limit exceeded 13/40400ms19428 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 l <= r:
    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
base13/40
1Accepted0/017ms2936 KiB
2Time limit exceeded0/0400ms5900 KiB
3Accepted2/228ms3080 KiB
4Accepted2/2247ms3048 KiB
5Time limit exceeded0/2398ms5368 KiB
6Time limit exceeded0/2400ms7628 KiB
7Time limit exceeded0/2400ms3660 KiB
8Time limit exceeded0/2400ms3952 KiB
9Accepted3/317ms3120 KiB
10Accepted3/327ms3044 KiB
11Accepted3/386ms3124 KiB
12Time limit exceeded0/3400ms3128 KiB
13Time limit exceeded0/4381ms3124 KiB
14Time limit exceeded0/4389ms3136 KiB
15Time limit exceeded0/2379ms12012 KiB
16Time limit exceeded0/2388ms15516 KiB
17Time limit exceeded0/2377ms12824 KiB
18Time limit exceeded0/2386ms19428 KiB