QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#736699 | #9619. 乘积,欧拉函数,求和 | Binge | WA | 1ms | 3824kb | C++23 | 1.5kb | 2024-11-12 12:42:46 | 2024-11-12 12:42:46 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1000000 + 10;
int a[N];
int n,m;
bool check(int x)
{
vector<int>d(n+10,0);
int res=0,last=0;
for(int i=1;i<=n;i++)
{
if(d[i]>=x)continue;
if(d[i]<x&&d[i+1]<x&&i<n)
{
int op1=ceil((double)(x-d[i])/(double(a[i])));
res+=(op1-1)*2+(i-last);
if(op1==1)
{
last=i;
d[i]=x;
if(res>m)return 0;
continue;
}
last=i;
if(res>m)return 0;
d[i]=x;
d[i+1]=(op1-1)*a[i+1];
continue;
}
if(d[i]<x)
{
int op1=ceil((double)(x-d[i])/(double(a[i])));
res+=(op1-1)*2+(i-last);
if(op1==1)
{
last=i;
d[i]=x;
if(res>m)return 0;
continue;
}
last=i;
if(res>m)return 0;
d[i]=x;
}
}
return 1;
}
void se()
{
cin>>n>>m;
for(int i=1;i<=n;i++)
{
cin>>a[i];
}
//check(4);
int l=0,r=1e15;
while (l<r)
{
int mid=l+r+1>>1;
if(check(mid))l=mid;
else r=mid-1;
}
cout<<l<<endl;
}
signed main()
{
ios::sync_with_stdio(false);
cout.tie(0);
cin.tie(0);
int T;
cin>>T;
while(T--)
{
se();
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3824kb
input:
5 1 6 8 6 2
output:
24 8 8 8 8
result:
wrong answer 1st lines differ - expected: '892', found: '24'