QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#329275 | #4935. Exchange Bottleneck | ouo# | WA | 1ms | 5592kb | C++17 | 786b | 2024-02-16 15:34:07 | 2024-02-16 15:34:08 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n;
int arr[1000005];
int dp[1000005];
int ans;
int mini;
signed main() {
ios::sync_with_stdio(0), cin.tie(0);
cin >> n;
for (int i = 1; i < n; i++) {
cin >> arr[i];
}
fill(dp, dp+n+1, 1e18);
dp[1] = 0LL;
dp[0] = 0LL;
for (int i = 1; i < n; i++) {
if (arr[i]) {
if (!dp[i]) dp[i+1] = mini+1;
else dp[i+1] = max(mini+1, dp[i]);
}else {
dp[i+1] = max(mini+1, dp[i]+1);
}
if (mini) mini = min(mini, dp[i+1]);
else mini = dp[i+1];
ans = max(dp[i+1], ans);
//cout << i+1 << " " << dp[i+1] << " " << mini << "\n";
}
cout << ans;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5592kb
input:
5 1 0 1 0
output:
3
result:
wrong answer 1st lines differ - expected: '2', found: '3'