QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#456347#3306. AlchemyKevin5307WA 6ms5712kbC++231.4kb2024-06-27 19:13:402024-06-27 19:13:41

Judging History

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

  • [2024-06-27 19:13:41]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:5712kb
  • [2024-06-27 19:13:40]
  • 提交

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-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: 1ms
memory: 5616kb

input:

1
1

output:

1

result:

ok single line: '1'

Test #2:

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

input:

2
0 1

output:

1

result:

ok single line: '1'

Test #3:

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

input:

6
1 0 0 0 0 1

output:

2

result:

ok single line: '2'

Test #4:

score: 0
Accepted
time: 1ms
memory: 5712kb

input:

5
0 0 0 0 1

output:

4

result:

ok single line: '4'

Test #5:

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

input:

5
1 0 1 0 1

output:

3

result:

ok single line: '3'

Test #6:

score: -100
Wrong Answer
time: 6ms
memory: 5508kb

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'