QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#133431 | #4935. Exchange Bottleneck | Vengeful_Spirit# | RE | 1ms | 5508kb | C++20 | 646b | 2023-08-02 09:24:49 | 2023-08-02 09:24:53 |
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];
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: 1ms
memory: 5380kb
input:
5 1 0 1 0
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 1ms
memory: 5508kb
input:
7 1 1 1 1 1 1
output:
1
result:
ok single line: '1'
Test #3:
score: -100
Dangerous Syscalls
input:
2 0