QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#133484#4935. Exchange BottleneckVengeful_Spirit#WA 5ms6216kbC++20679b2023-08-02 09:59:172023-08-02 09:59:20

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:59:20]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:6216kb
  • [2023-08-02 09:59:17]
  • 提交

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];
        if(i == 1) a[i] = 1;
        pr[i] = pr[i - 1];
        if(a[i] == 1) pr[i] = i;
    }
    sf[n] = 1e9;
    for(int i = n - 1; 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: 5476kb

input:

5
1 0 1 0

output:

2

result:

ok single line: '2'

Test #2:

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

input:

7
1 1 1 1 1 1

output:

1

result:

ok single line: '1'

Test #3:

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

input:

2
0

output:

1

result:

ok single line: '1'

Test #4:

score: -100
Wrong Answer
time: 5ms
memory: 6216kb

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'