QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#329266#4935. Exchange Bottleneckouo#WA 5ms9908kbC++17793b2024-02-16 15:28:172024-02-16 15:28:18

Judging History

你现在查看的是最新测评结果

  • [2024-02-16 15:28:18]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:9908kb
  • [2024-02-16 15:28:17]
  • 提交

answer

#include <bits/stdc++.h>
#define F first
#define S second

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, 1e9);
    dp[1] = 0;
    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        if (arr[i]) {
            if (!dp[i]) dp[i+1] = mini+1;
            else dp[i+1] = min(mini+1, dp[i]);
        }else {
            dp[i+1] = min(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: 100
Accepted
time: 1ms
memory: 5636kb

input:

5
1 0 1 0

output:

2

result:

ok single line: '2'

Test #2:

score: 0
Accepted
time: 1ms
memory: 5720kb

input:

7
1 1 1 1 1 1

output:

1

result:

ok single line: '1'

Test #3:

score: 0
Accepted
time: 0ms
memory: 5640kb

input:

2
0

output:

1

result:

ok single line: '1'

Test #4:

score: 0
Accepted
time: 4ms
memory: 5988kb

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:

2

result:

ok single line: '2'

Test #5:

score: 0
Accepted
time: 5ms
memory: 9908kb

input:

83502
0 1 1 1 0 0 0 0 1 1 0 1 0 1 0 1 1 1 1 0 1 1 1 1 0 1 0 1 1 1 0 1 0 0 0 1 1 1 1 1 1 0 1 0 1 0 1 1 1 1 0 1 1 0 0 0 0 1 1 0 0 1 0 1 0 0 1 1 1 1 1 1 1 0 0 0 1 1 0 1 0 0 1 0 1 1 0 0 0 1 1 1 1 0 1 0 1 1 1 1 1 1 1 0 0 0 1 0 0 0 0 0 1 1 0 1 0 0 1 0 0 1 1 1 1 0 0 1 0 1 1 0 1 0 1 0 0 0 0 1 0 1 0 1 0 0 0 ...

output:

2

result:

ok single line: '2'

Test #6:

score: -100
Wrong Answer
time: 0ms
memory: 5828kb

input:

12702
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 ...

output:

2

result:

wrong answer 1st lines differ - expected: '18', found: '2'