QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#131200 | #4935. Exchange Bottleneck | arnold518# | WA | 3ms | 4188kb | C++17 | 595b | 2023-07-26 17:52:20 | 2023-07-26 17:52:24 |
Judging History
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'