SHARE
TWEET

Untitled

Bad_Programist Feb 20th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. N, M = list(map(int, input().split()))
  2. W = list(map(int, input().split()))
  3. A = [[0] * (M + 1) for i in range(N + 1)]
  4. for i in range(1, N + 1):
  5.     for j in range(1, M + 1):
  6.         if W[i - 1] > j - A[i - 1][j]:
  7.             A[i][j] = A[i - 1][j]
  8.         else:
  9.             A[i][j] = A[i - 1][j] + W[i - 1]
  10. print(A[-1][-1])
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top