fork download
  1. #include <algorithm>
  2. #include <cassert>
  3. #include <sstream>
  4. #include <cmath>
  5. #include <cstdio>
  6. #include <cstring>
  7. #include <iostream>
  8. #include <map>
  9. #include <set>
  10. #include <string>
  11. #include <vector>
  12.  
  13. using namespace std;
  14. #pragma warning(disable:4996)
  15.  
  16. long long dp[10005];
  17.  
  18. int main() {
  19. int n, m;
  20.  
  21. double _m;
  22. while(1) {
  23. cin >> n >> _m;
  24. if(!n) break;
  25. m = (int)(_m * 100 + 1e-9);
  26.  
  27. memset(dp, 0, sizeof(dp));
  28.  
  29. for(int i = 0; i < n; ++ i) {
  30. int c; double _p; int p;
  31. cin >> c >> _p;
  32. p = (int)(_p * 100 + 1e-9);
  33.  
  34. for(int j = p; j <= m; ++ j) {
  35. dp[j] = max(dp[j], dp[j - p] + c);
  36. }
  37. }
  38.  
  39. cout << *max_element(dp, dp + m + 1) << endl;
  40. }
  41.  
  42. return 0;
  43. }
Success #stdin #stdout 0s 3552KB
stdin
1 0.28
100 0.29
0 0
stdout
0