Участник:Berkut.kiu/GARDEN

Материал из DISCOPAL
Перейти к: навигация, поиск

задача: https://www.codechef.com/problems/ERROR5 посылка: https://www.codechef.com/viewsolution/45764924

import numpy as np
 
def garden_solver(height, beauty, N):
    garden = np.zeros(N)
    for i in range(N):
        garden[i] = beauty[i]
    for i in range(1, N):
        for j in range(i):
            if height[j] < height[i]:
                garden[i] = max(garden[i], garden[j] + beauty[i])
    maxi= 0
    for i in range(N):
        if garden[i] > maxi:
            maxi = garden[i]
    return int(maxi)
 
T = int(input())
for test in range(T):
    N = int(input())
    height = np.array(list(map(int, input().split())))
    beauty = np.array(list(map(int, input().split())))
    print(garden_solver(height, beauty, N))