QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#456323#3306. AlchemyKevin5307WA 2ms6420kbC++231.3kb2024-06-27 18:16:362024-06-27 18:16:37

Judging History

你现在查看的是最新测评结果

  • [2024-06-27 18:16:37]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:6420kb
  • [2024-06-27 18:16:36]
  • 提交

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));
		for(int i=2;i<=mid;i++)
		{
			b[1]+=a[i]-min(a[i],(ll)mid-i);
			b[i]=min(a[i],(ll)(mid-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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3608kb

input:

1
1

output:

1

result:

ok single line: '1'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

2
0 1

output:

1

result:

ok single line: '1'

Test #3:

score: 0
Accepted
time: 2ms
memory: 6420kb

input:

6
1 0 0 0 0 1

output:

2

result:

ok single line: '2'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3668kb

input:

5
0 0 0 0 1

output:

4

result:

ok single line: '4'

Test #5:

score: 0
Accepted
time: 0ms
memory: 5744kb

input:

5
1 0 1 0 1

output:

3

result:

ok single line: '3'

Test #6:

score: -100
Wrong Answer
time: 2ms
memory: 5940kb

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:

37721

result:

wrong answer 1st lines differ - expected: '37735', found: '37721'