QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#456331 | #3306. Alchemy | Kevin5307 | WA | 6ms | 6200kb | C++23 | 1.3kb | 2024-06-27 18:35:36 | 2024-06-27 18:35:36 |
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));
int cnt=0;
for(int i=mid;i>=2;i--)
{
b[1]+=a[i]-min(a[i],(ll)mid-i-cnt);
b[i]=min(a[i],(ll)(mid-i-cnt));
cnt+=b[i];
}
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: 3492kb
input:
1 1
output:
1
result:
ok single line: '1'
Test #2:
score: 0
Accepted
time: 1ms
memory: 5580kb
input:
2 0 1
output:
1
result:
ok single line: '1'
Test #3:
score: 0
Accepted
time: 2ms
memory: 5088kb
input:
6 1 0 0 0 0 1
output:
2
result:
ok single line: '2'
Test #4:
score: 0
Accepted
time: 1ms
memory: 5576kb
input:
5 0 0 0 0 1
output:
4
result:
ok single line: '4'
Test #5:
score: 0
Accepted
time: 2ms
memory: 6200kb
input:
5 1 0 1 0 1
output:
3
result:
ok single line: '3'
Test #6:
score: -100
Wrong Answer
time: 6ms
memory: 5856kb
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:
37720
result:
wrong answer 1st lines differ - expected: '37735', found: '37720'