213912026-01-12 23:08:03algoproBányász RPG (40 pont)pypy3Runtime error 36/40143ms32000 KiB
# UUID: 4f4c8c76-2632-4471-80f2-6f178a971ccc
from array import array

def solvx():
    N = int(input())
    A = array('I', [int(x) for x in input().split()])
    B = array('I', [int(x) for x in input().split()])

    idx = list(range(N))
    idx.sort(key=lambda i: A[i])

    total_second = sum(B)
    ketpercesek = 0

    running_prefix = total_second

    for pos in range(N - 1, -1, -1):
        i = idx[pos]

        running_prefix -= B[i]

        if A[i] > ketpercesek + running_prefix:
            need = A[i] - (ketpercesek + running_prefix)
            if need < B[i]:
                ketpercesek += need
            else:
                ketpercesek += B[i]

    print(ketpercesek + total_second)

solvx()
SubtaskSumTestVerdictTimeMemory
base36/40
1Accepted0/039ms19428 KiB
2Accepted0/070ms23012 KiB
3Accepted2/245ms19684 KiB
4Accepted2/248ms21188 KiB
5Accepted2/265ms22872 KiB
6Accepted2/264ms25876 KiB
7Accepted2/259ms21988 KiB
8Accepted2/252ms22260 KiB
9Accepted3/345ms19492 KiB
10Accepted3/345ms19524 KiB
11Accepted3/339ms19484 KiB
12Accepted3/343ms21184 KiB
13Accepted4/450ms21224 KiB
14Accepted4/443ms21132 KiB
15Accepted2/2143ms28376 KiB
16Runtime error0/268ms32000 KiB
17Accepted2/2141ms29148 KiB
18Runtime error0/268ms32000 KiB