// LUOGU_RID: 199860249
#include<bits/stdc++.h>
using namespace std;
namespace fastio{
struct reader{
template<typename T>reader&operator>>(T&x){
char c=getchar();short f=1;
while(c<'0'||c>'9'){if(c=='-')f*=-1;c=getchar();}
x=0;while(c>='0'&&c<='9'){
x=(x<<1)+(x<<3)+(c^48);
c=getchar();
}x*=f;return *this;
}
}cin;
struct writer{
template<typename T>writer&operator<<(T x){
if(x==0)return putchar('0'),*this;
if(x<0)putchar('-'),x=-x;
static int sta[45];int top=0;
while(x)sta[++top]=x%10,x/=10;
while(top)putchar(sta[top]+'0'),--top;
return*this;
}
}cout;
};
#define cin fastio::cin
#define cout fastio::cout
__int128 n,p[200020];
__int128 ans,m;
int main(){
cin>>n>>m;
for(int i=1;i<=n;++i){
cin>>p[i];
}
__int128 l=0,r=m;
while(l<=r){
__int128 mid=(l+r)/2;
__int128 sum=0,ansN=0;
bool check=1;
for(int i=1;i<=n;++i){
__int128 P=mid/p[i];
__int128 N=(P+1)>>1;
if(N>0&&N*p[i]>m/N){
check=0;
break;
}
ansN+=N;
sum+=(__int128)N*N*p[i];
if(sum>=(__int128)1e19) {
check=0;
break;
}
if(sum>m){
check=0;
break;
}
}
if(check==1&&sum>=(__int128)1e22)check=0;
if(check)l=mid+1,ans=ansN;
else r=mid-1;
}
cout<<ans;
return 0;
}
悬赏:关注 1 个