def solve(n: int, h: np.array, a: np.array) -> typing.NoReturn:
    fw = np.zeros((n + 1), dtype=np.int64)
    mx = 0
    for i in range(n):
        v = get_mx(fw, (h[i] - 1))
        set_val(fw, h[i], (v + a[i]))
    print(get_mx(fw, n))
def solve(n: int, h: np.array, a: np.array) -> typing.NoReturn:
    fw = np.zeros((n + 1), dtype=np.int64)
    mx = 0
    for i in range(n):
        v = get_mx(fw, (h[i] - 1))
        set_val(fw, h[i], (v + a[i]))
    print(get_mx(fw, n))