94452024-02-21 19:18:40petergalambosBányász RPG (40 pont)python3Wrong answer 26/40196ms58052 KiB
from sys import stdin,stdout

def main():
    N = int(input())
    R = [(int(i),index) for index,i in enumerate(stdin.readline().split(),start = 1)]
    R.sort()
    A = [0]+[int(i) for i in stdin.readline().split()]

    S = 0
    T = 0

    for r in R:
        db = A[r[1]]
        if T < r[0]:
            k = (r[0]-T)%(db+1)
            S += k*2+(db-k)*1
        else:
            S += db
        T += db
##        print(r,S)
    stdout.write(str(S))
    
main()
SubtaskSumTestVerdictTimeMemory
base26/40
1Wrong answer0/018ms11324 KiB
2Accepted0/043ms19552 KiB
3Accepted2/217ms11848 KiB
4Accepted2/218ms12456 KiB
5Wrong answer0/232ms18456 KiB
6Accepted2/252ms25420 KiB
7Wrong answer0/221ms14396 KiB
8Wrong answer0/224ms15360 KiB
9Accepted3/317ms12700 KiB
10Accepted3/317ms13016 KiB
11Accepted3/317ms13284 KiB
12Accepted3/317ms13276 KiB
13Accepted4/418ms13880 KiB
14Accepted4/418ms13748 KiB
15Wrong answer0/2115ms36488 KiB
16Wrong answer0/2164ms47312 KiB
17Wrong answer0/2129ms38604 KiB
18Wrong answer0/2196ms58052 KiB