QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#456346 | #3306. Alchemy | Kevin5307 | WA | 2ms | 6444kb | C++23 | 1.4kb | 2024-06-27 19:13:11 | 2024-06-27 19:13:12 |
Judging History
answer
//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
ll a[200200];
ll b[200200];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin>>n;
n--;
for(int i=0;i<=n;i++)
cin>>a[i];
if(accumulate(a,a+n+1,0ll)==1)
{
cout<<max(1,(int)(max_element(a,a+n+1)-a))<<endl;
return 0;
}
int L=1,R=100000+1000;
while(L<R)
{
int mid=(L+R+1)/2;
memset(b,0,sizeof(b));
ll cnt=0;
for(int i=mid;i>=2;i--)
{
b[1]+=a[i]-min(a[i],cnt);
b[i]=min(a[i],cnt);
cnt=cnt*2+1+mid-i-b[i]*2;
cnt=min(cnt,1ll*inf*inf);
}
b[1]+=a[0]+a[1];
for(int i=mid+1;i<=n;i++)
b[1]+=a[i];
for(int i=2;i<=mid;i++)
b[i]+=b[i-1]/2;
if(b[mid])
L=mid;
else
R=mid-1;
}
cout<<L<<endl;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3548kb
input:
1 1
output:
1
result:
ok single line: '1'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3468kb
input:
2 0 1
output:
1
result:
ok single line: '1'
Test #3:
score: 0
Accepted
time: 2ms
memory: 5236kb
input:
6 1 0 0 0 0 1
output:
2
result:
ok single line: '2'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
5 0 0 0 0 1
output:
4
result:
ok single line: '4'
Test #5:
score: 0
Accepted
time: 2ms
memory: 5812kb
input:
5 1 0 1 0 1
output:
3
result:
ok single line: '3'
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 6444kb
input:
37720 451489069 134056336 620111578 342027410 502394496 867334619 610344031 578827762 547285146 267992868 980119426 496668202 432397098 278008842 790299797 27195229 983722405 177368018 498316364 787982913 98623319 974381888 186181726 669284760 932969833 209389252 84919178 953916913 910171707 4407773...
output:
37749
result:
wrong answer 1st lines differ - expected: '37735', found: '37749'