QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#198216 | #6130. Plants vs. Zombies | HarryJ | Compile Error | / | / | C++23 | 1.0kb | 2023-10-03 09:53:43 | 2023-10-03 09:53:43 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;
const LL mod=998244353;
const int INF=0x3f3f3f3f;
const int N=1e5+10;
LL a[N],b[N];
LL n,m;
int check(LL x)
{
for(int i=1;i<=n;i++) b[i]=(x+a[i]-1)/a[i];
LL cnt=0;
LL last=0;
for(int i=1;i<n;i++)
{
cnt++;
b[i]--;
if(b[i]>0)
{
cnt+=b[i]*2;
b[i+1]-=b[i];
}
}
if(b[n]>0)
{
cnt++;
b[n]--;
if(b[n]>0) cnt+=2*b[n]
}
return 1;
}
void solve()
{
cin>>n>>m;
for(int i=1;i<=n;i++) cin>>a[i];
LL l=0,r=1e17;
while(l<r)
{
LL mid=(l+r+1)/2;
if(check(mid)) l=mid;
else r=mid-1;
}
cout<<l<<endl;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int tt; cin>>tt;
while(tt--) solve();
return 0;
}
Details
answer.code: In function ‘int check(LL)’: answer.code:36:31: error: expected ‘;’ before ‘}’ token 36 | if(b[n]>0) cnt+=2*b[n] | ^ | ; 37 | } | ~