225492026-01-15 11:02:26vyrallBányász RPG (40 pont)pypy3Time limit exceeded 11/40402ms32000 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/043ms19420 KiB
2Time limit exceeded0/0391ms28124 KiB
3Accepted2/267ms22256 KiB
4Time limit exceeded0/2391ms22224 KiB
5Time limit exceeded0/2379ms26340 KiB
6Runtime error0/286ms32000 KiB
7Time limit exceeded0/2381ms23016 KiB
8Time limit exceeded0/2391ms23784 KiB
9Accepted3/346ms21512 KiB
10Accepted3/364ms22340 KiB
11Accepted3/3112ms22572 KiB
12Time limit exceeded0/3381ms22248 KiB
13Time limit exceeded0/4395ms22172 KiB
14Time limit exceeded0/4402ms21940 KiB
15Runtime error0/272ms32000 KiB
16Runtime error0/275ms32000 KiB
17Runtime error0/264ms32000 KiB
18Runtime error0/265ms32000 KiB