QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#131200#4935. Exchange Bottleneckarnold518#WA 3ms4188kbC++17595b2023-07-26 17:52:202023-07-26 17:52:24

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-26 17:52:24]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:4188kb
  • [2023-07-26 17:52:20]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1e5;

int N, A[MAXN+10], ans=1;

int main()
{
	scanf("%d", &N);
	vector<int> V;
	for(int i=2; i<=N; i++)
	{
		scanf("%d", &A[i]);
		if(A[i]) V.push_back(i);
	}

	for(int i=2; i<=N; i++)
	{
		if(A[i]) continue;
		int pos=lower_bound(V.begin(), V.end(), i)-V.begin();

		int val;
		if(pos==0) val=i-1;
		else val=i-V[pos-1]+1;

		if(pos<V.size()) val=min(val, V[pos]-i+1);

		ans=max(ans, val);
	}
	printf("%d\n", ans);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3692kb

input:

5
1 0 1 0

output:

2

result:

ok single line: '2'

Test #2:

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

input:

7
1 1 1 1 1 1

output:

1

result:

ok single line: '1'

Test #3:

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

input:

2
0

output:

1

result:

ok single line: '1'

Test #4:

score: -100
Wrong Answer
time: 3ms
memory: 4188kb

input:

90580
1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 1 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 ...

output:

3

result:

wrong answer 1st lines differ - expected: '2', found: '3'