QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#133462#4935. Exchange BottleneckPanC_ake#WA 4ms4292kbC++20647b2023-08-02 09:44:042023-08-02 09:44:06

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-02 09:44:06]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:4292kb
  • [2023-08-02 09:44:04]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long 

const int maxn = 200050;
const int inf = 0x3f3f3f3f3f3f3f3f;

int n, a[maxn];

void solve() {
    cin >> n;
    for(int i = 2; i <= n; i++) cin >> a[i];
    int ans = 1;
    for(int i = 2; i <= n; i++) {
        if(a[i] == 1) continue;
        int j = i;
        while(j + 1 <= n && a[j + 1] == 0) {
            j++;
        }
        ans = max(ans, j - i + 1 + a[i - 1]);
        i = j;
    }
    cout << ans;
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int t = 1;
    while(t--) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3424kb

input:

5
1 0 1 0

output:

2

result:

ok single line: '2'

Test #2:

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

input:

7
1 1 1 1 1 1

output:

1

result:

ok single line: '1'

Test #3:

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

input:

2
0

output:

1

result:

ok single line: '1'

Test #4:

score: -100
Wrong Answer
time: 4ms
memory: 4292kb

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:

5

result:

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