fork download
  1. n,w=map(int,input().split())
  2. x=[0]*n
  3. y=[0]*n
  4.  
  5. DP = [10**9+5]*(10**5+5)
  6. DP[0] = 0
  7.  
  8. Sum = 0
  9. for i in range(n):
  10. x[i],y[i]=map(int,input().split())
  11. Sum+=y[i]
  12. for j in range(Sum,y[i]-1,-1):
  13. DP[j] = min(DP[j],DP[j-y[i]]+x[i])
  14.  
  15. for i in range(Sum,-1,-1):
  16. if DP[i]<=w:
  17. print(i)
  18. break
  19. #Accepted code
Success #stdin #stdout 0.04s 10564KB
stdin
3 8
3 30
4 50
5 60
stdout
90