fork(9) download
  1. #include<iostream>
  2. #include<vector>
  3. using namespace std;
  4. const long long maxwei = 1e11;
  5. int n,limit, wei,val,sumval;
  6. int main(){
  7. cin >> n >> limit;
  8.  
  9. vector<long long> Max(100001, maxwei);
  10. Max[0] = 0;
  11. for (int i = 0; i < n; ++i){
  12. cin >> wei >> val;
  13. sumval+=val;
  14. for (int j = sumval; j >= val; --j)
  15. Max[j]= min(Max[j], Max[j - val] + wei);
  16. }
  17. for(val= sumval; val>0; --val){
  18. if(Max[val]<=limit)
  19. return cout<<val, 0;
  20. }
  21. }
Success #stdin #stdout 0s 5628KB
stdin
Standard input is empty
stdout
Standard output is empty