QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#781105#4935. Exchange Bottleneckstd_abs#WA 3ms3852kbC++20852b2024-11-25 14:48:462024-11-25 14:48:47

Judging History

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

  • [2024-11-25 14:48:47]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3852kb
  • [2024-11-25 14:48:46]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) ((int)a.size())
const int mod = 998244353, N = 100007;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	int n;
	cin >> n, --n;
	vector <int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	int ans = 1;
	vector <int> lst(n, -1);
	for (int i = n - 1; ~i; --i) {
		if (i + 1 < n) {
			lst[i] = lst[i + 1];
		}
		if (a[i] == 1) {
			lst[i] = i;
		}
	}
	int prev = -1;
	for (int i = 0; i < n; ++i) {
		if (a[i] == 0) {
			int closet = i + 1;
			if (prev != -1) closet = min(closet, i - prev + 1);
			if (lst[i] != -1) closet = min(closet, lst[i] - i + 1);
			ans = max(ans, closet);
		} else {
			prev = i;
		}
	}
	cout << ans << '\n';
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3552kb

input:

5
1 0 1 0

output:

2

result:

ok single line: '2'

Test #2:

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

input:

7
1 1 1 1 1 1

output:

1

result:

ok single line: '1'

Test #3:

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

input:

2
0

output:

1

result:

ok single line: '1'

Test #4:

score: -100
Wrong Answer
time: 3ms
memory: 3848kb

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'