有个地方爆了 int 自己查不出来。求帮助
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=3e5+5;
int n,a,b;
ll A[maxn];
bool check(ll x){
int k=0;
for(int i=1;i<=n;i++){
if(A[i]>=x)k+=(A[i]-x)/b;
else k-=(x-A[i]+a-1)/a;
}
return k>=0;
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>n>>a>>b;
ll l=1,r=1,mid=1,ans=1;
for(int i=1;i<=n;i++){
cin>>A[i];
r=max(r,A[i]);
}
while(l<=r){
mid=l+r>>1;
if(check(mid)){
ans=mid;
l=mid+1;
}
else r=mid-1;
}
cout<<ans;
return 0;
}