fork download
  1. //----------//
  2. // FairoozR //
  3. //----------//
  4.  
  5. #include<bits/stdc++.h>
  6. using namespace std;
  7.  
  8. #define ll long long
  9. #define fast_in_out ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  10. #define ln "\n"
  11.  
  12. const double EPS = (double) 1e-9;
  13. const double pi = acos(-1);
  14. const int mod = 1000000007;
  15. const int N = (int) 1e6;
  16. int cuda[30], price[30], dp[30][N + 1];
  17. string arr[30];
  18. int n, b;
  19. ll p;
  20.  
  21. int solve(int ind, int amount)
  22. {
  23. if(ind == n)
  24. {
  25. return 0;
  26. }
  27. if(dp[ind][amount] != -1)
  28. {
  29. return dp[ind][amount];
  30. }
  31. int res = solve(ind + 1, amount);
  32. if(price[ind] <= amount)
  33. {
  34. res = max(res, cuda[ind] + solve(ind + 1, amount - price[ind]));
  35. }
  36. return dp[ind][amount] = res;
  37. }
  38.  
  39. int main()
  40. {
  41. fast_in_out;
  42. int test;
  43. cin >> test;
  44. for(int t = 1; t <= test; t++)
  45. {
  46. cin >> n >> p >> b;
  47. for(int i = 0; i < n; i++)
  48. {
  49. cin >> arr[i] >> cuda[i] >> price[i];
  50. }
  51. memset(dp, -1, sizeof(dp));
  52. int res = solve(0, b);
  53. double hours = (double) p / (double) res;
  54. double days = hours / 24.0;
  55. cout << "Case " << t << ": " << (ll) ceil(days) << ln;
  56. }
  57. return 0;
  58. }
  59.  
  60.  
Success #stdin #stdout 0.05s 120916KB
stdin
1
4 102002358 100000
GTX1660Ti 1536 25000
RTX2060 1920 32000
GTX1050 768 15000
RTX3060 3584 45000
stdout
Case 1: 678