fork download
  1. /*
  2.   shool : Cu Chi High School
  3.   participant : Ngo Quoc Binh
  4. */
  5. #include <bits/stdc++.h>
  6. using namespace std;
  7.  
  8. #define debug(x) cerr << #x << " = " << x << "\n";
  9. #define vdebug(a) cerr << #a << " = "; for(auto x : a) cout << x << " "; cout << "\n";
  10. #define TIME cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
  11. #define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  12. #define hashmap unordered_map
  13. #define hashset unordered_set
  14. #define all(x) (x).begin(),(x).end()
  15. #define rall(x) (x).rbegin(),(x).rend()
  16. #define rev(x) reverse(all(x))
  17. #define sz(x) ((int)((x).size()))
  18. #define max_arr(x) *max_element(all(x))
  19. #define min_arr(x) *min_element(all(x))
  20.  
  21. #define pb push_back
  22. #define pf push_front
  23. #define PB pop_back
  24. #define PF pop_front
  25. #define en '\n'
  26. #define ff first
  27. #define ss second
  28. #define task "wtf"
  29.  
  30. using ll = long long;
  31. using ull = unsigned long long;
  32. using ld = long double;
  33.  
  34. mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
  35.  
  36. void solve()
  37. {
  38. int t;
  39. cin >> t;
  40. int ans = 1e9;
  41. while(t--)
  42. {
  43. ans = 1e9;
  44. int n,u,m;
  45. cin >> n >> u >> m;
  46.  
  47. vector<ll> a(n);
  48. for(int i = 0 ; i < n ; i++) cin >> a[i];
  49.  
  50. ll sum = accumulate(all(a),0);
  51. bitset<1000005> dp;
  52. dp[0] = 1;
  53. for(int i = 0 ; i < n ; i++)
  54. {
  55. dp |= (dp << a[i]);
  56. }
  57.  
  58. for(int i = 0 ; i <= sum ; i++)
  59. {
  60. if(dp[i])
  61. {
  62. int j = sum - i;
  63. int a = (i + u - 1)/u, b = (j + m - 1)/m;
  64.  
  65. ans = min(ans, max(a, b));
  66. }
  67. }
  68.  
  69. cout << ans << endl;
  70. }
  71.  
  72. }
  73.  
  74. int main()
  75. {
  76. fastIO
  77.  
  78. solve();
  79.  
  80. return 0;
  81. }
  82.  
Success #stdin #stdout 0.01s 5324KB
stdin
Standard input is empty
stdout
Standard output is empty