Advertisement
Guest User

Untitled

a guest
Jan 18th, 2021
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.33 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define rep(i,x,y) for(int i=x;i<y;i++)
  5. #define repr(i,x,y) for(int i=x;i>=y;i--)
  6. #define int long long
  7. #define pb push_back
  8. #define ff first
  9. #define ss second
  10. #define sz(x) ((int)x.size())
  11. #define all(x) begin(x), end(x)
  12. #define memo(x,y) memset((x),(y),sizeof((x)))
  13. #define line cout<<"[At "<<__LINE__<<"]"<<endl;
  14.  
  15. using pii = pair<int,int>;
  16. using vi = vector<int>;
  17. using vii = vector<pair<int,int>>;
  18.  
  19. constexpr int mod = 1e9 + 7 , N = 2e5 + 5;
  20. constexpr long long inf = 1e18;
  21. constexpr long double eps = 1e-6;
  22.  
  23. void Onigiri()
  24. {
  25.   int n,x,y;
  26.   cin>>n>>x>>y;
  27.   int c[n];
  28.   rep(i,0,n){
  29.     cin>>c[i];
  30.   }
  31.  
  32.   int l=0,r=1e9,ans=-1;
  33.   while(l<=r){
  34.     int m=(l+r)/2;
  35.     int cnt=m;
  36.     for(int i=0;i<n;i++){
  37.       if(c[i]>y*m){
  38.         cnt-=(c[i]-y*m+x-y-1)/(x-y);
  39.       }
  40.     }
  41.     if(cnt>=0){
  42.       ans=m;
  43.       r=m-1;
  44.     }else l=m+1;
  45.   }
  46.   cout<<ans;
  47. }
  48. signed main()
  49. {
  50.    ios_base::sync_with_stdio(false);cin.tie(NULL);
  51.    //cout.precision(10);cout<<fixed;
  52.    #ifdef Zoro
  53.    freopen("/home/pritish/Competitive/in", "r", stdin);
  54.    freopen("/home/pritish/Competitive/out", "w", stdout);
  55.    #endif  
  56.  
  57.    int t=1;
  58.    cin>>t;
  59.    while(t--)
  60.    {Onigiri();cout<<"\n";}
  61.  
  62.    cerr<<"\n"<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;
  63.    return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement