QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#404537 | #4935. Exchange Bottleneck | kevinyang# | WA | 1ms | 5160kb | C++17 | 630b | 2024-05-04 05:22:20 | 2024-05-04 05:22:21 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
cin.tie(nullptr)->sync_with_stdio(false);
int n;
cin >> n;
vector<int>dp(n+2);
vector<int>a(n+2);
vector<int>dp2(n+1);
for(int i = 2; i<=n; i++){
cin >> a[i];
}
int ans = 0;
dp[n+1] = (int)1e9;
for(int i = n; i>=1; i--){
dp[i] = dp[i+1]+1;
if(a[i] == 1){
dp[i] = 0;
}
}
dp2[0] = (int)1e9;
for(int i = 1; i<=n; i++){
dp2[i] = dp2[i-1]+1;
if(a[i] == 1){
dp2[i] = 0;
}
if(i>1){
int v = min({i-1,dp2[i]+1,dp[i]+1});
ans = max(ans,v);
}
}
cout << ans << '\n';
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3740kb
input:
5 1 0 1 0
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3484kb
input:
7 1 1 1 1 1 1
output:
1
result:
ok single line: '1'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
2 0
output:
1
result:
ok single line: '1'
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 5160kb
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'