225542026-01-15 11:06:20vyrallBányász RPG (40 pont)python3Time limit exceeded 11/40400ms19508 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 n*[0] != [i[1] for i in mats]:
    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/016ms3312 KiB
2Time limit exceeded0/0382ms6076 KiB
3Accepted2/265ms3124 KiB
4Time limit exceeded0/2382ms3124 KiB
5Time limit exceeded0/2400ms5680 KiB
6Time limit exceeded0/2384ms8024 KiB
7Time limit exceeded0/2386ms3648 KiB
8Time limit exceeded0/2386ms3892 KiB
9Accepted3/316ms3124 KiB
10Accepted3/361ms3124 KiB
11Accepted3/3238ms3048 KiB
12Time limit exceeded0/3381ms3124 KiB
13Time limit exceeded0/4381ms3124 KiB
14Time limit exceeded0/4379ms3124 KiB
15Time limit exceeded0/2379ms12272 KiB
16Time limit exceeded0/2389ms15624 KiB
17Time limit exceeded0/2381ms12872 KiB
18Time limit exceeded0/2388ms19508 KiB