94442024-02-21 19:16:01petergalambosBányász RPG (40 pont)python3Wrong answer 26/40195ms57384 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
            S += k*2+(db-k)*1
        else:
            S += db
        T += db
    stdout.write(str(S))
    
main()
SubtaskSumTestVerdictTimeMemory
base26/40
1Accepted0/017ms11132 KiB
2Accepted0/043ms19880 KiB
3Accepted2/217ms11664 KiB
4Accepted2/219ms12364 KiB
5Wrong answer0/232ms18272 KiB
6Accepted2/250ms24912 KiB
7Wrong answer0/221ms13808 KiB
8Wrong answer0/223ms14816 KiB
9Accepted3/317ms12632 KiB
10Accepted3/317ms12484 KiB
11Accepted3/317ms12388 KiB
12Accepted3/317ms12892 KiB
13Accepted4/417ms13072 KiB
14Accepted4/417ms12736 KiB
15Wrong answer0/2108ms35884 KiB
16Wrong answer0/2145ms46688 KiB
17Wrong answer0/2125ms37788 KiB
18Wrong answer0/2195ms57384 KiB