pastebin

Paste Search Dynamic
Recent pastes
max happiness
  1. n = int(input())
  2. lost = [0]+list(map(int, input().split()))
  3. happiness = [0]+list(map(int, input().split()))
  4. dp = [[0] * 100 for _ in range(n+1)]
  5. for i in range(1,n+1):
  6.     for j in range(1, 100):
  7.         if lost[i] <= j:
  8.             dp[i][j] = max(happiness[i] + dp[i-1][j - lost[i]], dp[i-1][j])
  9.         else:
  10.             dp[i][j] = dp[i-1][j]
  11. for k in dp:
  12.     print(*k)
Parsed in 0.006 seconds