QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#133443 | #4935. Exchange Bottleneck | Vengeful_Spirit# | WA | 10ms | 8280kb | C++20 | 679b | 2023-08-02 09:31:07 | 2023-08-02 09:31:11 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int a[N], pr[N], sf[N];
int main() {
int n;
cin >> n;
for(int i = 1; i < n; ++i) {
cin >> a[i];
if(i == 1) a[i] = 1;
pr[i] = pr[i - 1];
if(a[i] == 1) pr[i] = i;
}
sf[n + 1] = 1e9;
for(int i = n; i >= 1; --i) {
if(a[i] == 1) sf[i] = i;
else sf[i] = sf[i + 1];
}
int ans = 0;
// assert(a[1]);
for(int i = 1; i < n; ++i) {
int pos = min(i - pr[i] + 1, sf[i] - i + 1);
// cerr << i << " " << pos << "\n";
ans = max(ans, pos);
}
cout << ans << "\n";
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 5456kb
input:
5 1 0 1 0
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 2ms
memory: 5496kb
input:
7 1 1 1 1 1 1
output:
1
result:
ok single line: '1'
Test #3:
score: 0
Accepted
time: 2ms
memory: 5572kb
input:
2 0
output:
1
result:
ok single line: '1'
Test #4:
score: -100
Wrong Answer
time: 10ms
memory: 8280kb
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'