fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define all(v) ((v).begin()), ((v).end())
  5. #define sz(v) ((int)((v).size()))
  6. #define Please_Not_Focus_To_My_Code ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  7. const int mod = 1e9 + 7;
  8. //ceil -> (n + (d - 1))/d
  9. //round+ -> (n + (d/2))/d
  10. //round- -> (n - (d/2))/d
  11.  
  12. void elwkel(){
  13. ll n , f ,a , b;cin >> n >> f >> a >> b;
  14. vector<int> arr(n + 1);
  15. for (int i = 1; i < n + 1; i++) cin >> arr[i];
  16.  
  17. bool ok = 1;
  18. for (int i{1}; i < n + 1 && ok; i++){
  19. if((arr[i] - arr[i - 1]) * a < b) f -= (arr[i] - arr[i - 1]) * a;
  20. else f -= b;
  21. if(f <= 0)ok =0;
  22. }
  23.  
  24. cout << (ok ? "YES\n" : "NO\n");
  25. }
  26.  
  27.  
  28.  
  29. int main(){
  30. Please_Not_Focus_To_My_Code;
  31. int t{};
  32. cin>> t;
  33. while(t--){
  34. elwkel();
  35. }
  36. }
Success #stdin #stdout 0.01s 5300KB
stdin
6
1 3 1 5
3
7 21 1 3
4 6 10 13 17 20 26
5 10 1 2
1 2 3 4 5
1 1000000000 1000000000 1000000000
1000000000
3 11 9 6
6 8 10
12 621526648 2585904 3566299
51789 61859 71998 73401 247675 298086 606959 663464 735972 806043 806459 919683
stdout
NO
YES
YES
NO
NO
YES