fork(3) download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define int int64_t
  6.  
  7. bool lose(int A, int X, int B, int Y, int Z) {
  8. int t1 = (Z - A + X - 1) / X;
  9. int t2 = (Z - B + Y - 1) / Y;
  10. return t1 >= t2;
  11. }
  12.  
  13. void solve() {
  14. int N, A, B, X, Y, Z;
  15. cin >> N >> A >> B >> X >> Y >> Z;
  16. priority_queue<int> C;
  17. for(int i = 0; i < N; i++) {
  18. int t;
  19. cin >> t;
  20. C.push(t);
  21. }
  22. int ans = 0;
  23. while(C.top() != 0 && lose(A, X, B, Y, Z)) {
  24. ans++;
  25. A += C.top();
  26. C.push(C.top() / 2);
  27. C.pop();
  28. }
  29. if(lose(A, X, B, Y, Z)) {
  30. cout << "RIP" << endl;
  31. } else {
  32. cout << ans << endl;
  33. }
  34. }
  35.  
  36. signed main() {
  37. //freopen("input.txt", "r", stdin);
  38. ios::sync_with_stdio(0);
  39. cin.tie(0);
  40. int t;
  41. cin >> t;
  42. while(t--) {
  43. solve();
  44. }
  45. return 0;
  46. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
Standard output is empty