fork download
  1. n,m=map(int,input().split())
  2. A=[0]*(m+1)
  3. S=0
  4. for k in range(n):
  5. i,j=map(int,input().split())
  6. S+=i
  7. for p in range(m,i-1,-1):
  8. A[p]=max(A[p],j+A[p-i])
  9. print(A[m])
  10. #Cấm copy ai giống báo admin
Success #stdin #stdout 0.04s 9848KB
stdin
3 8
3 30
4 50
5 60
stdout
90