WA*2。
这回又只过 4 题,小丑了。
#include<iostream>
#include<queue>
#define int long long
using namespace std;
int n,m,a[200010];
int chk(int x)
{
int sum=0,cnt=0;
for(int i=1;i<=n;i++)
{
int k=x/a[i];
if(k%2==0)k--;
k=(k+1)/2;
if(k>1e9)return -1;
if((__int128_t)k*k*a[i]>m-sum)return -1;
sum+=k*k*a[i];
cnt+=k;
}
return cnt;
}
signed main()
{
cin>>n>>m;
for(int i=1;i<=n;i++)cin>>a[i];
int l=0,r=m,ans=0;
while(l<=r)
{
int mid=(l+r)/2;
int now=chk(mid);
if(now>=0)l=mid+1,ans=now;
else r=mid-1;
}
cout<<ans<<endl;
return 0;
}