Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define nl "\n"
- void files(){
- ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
- #endif
- }
- void solve(){
- ll n,a,b; cin>>n>>a>>b;
- vector<ll> v(n);
- for(ll &x: v) cin>>x;
- ll l = 1, r = 1e12, ans = 1e12;
- auto check = [&](ll mid){
- ll sum = 0;
- for(auto x:v){
- if(x <= b*mid) continue;
- ll num = x - b*mid;
- ll den = a - b;
- ll need = (num + den - 1) / den;
- sum += need;
- if(sum > mid) return false;
- }
- return sum <= mid;
- };
- while(l <= r){
- ll mid = l + (r-l)/2;
- if(check(mid)){
- ans = mid;
- r = mid - 1;
- }else l = mid + 1;
- }
- cout<<ans<<nl;
- }
- int main(){
- files();
- int t = 1;
- //cin>>t;
- while(t--) solve();
- return 0;
- }
Add Comment
Please, Sign In to add comment