QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#404537#4935. Exchange Bottleneckkevinyang#WA 1ms5160kbC++17630b2024-05-04 05:22:202024-05-04 05:22:21

Judging History

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

  • [2024-05-04 05:22:21]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5160kb
  • [2024-05-04 05:22:20]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
	cin.tie(nullptr)->sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int>dp(n+2);
	vector<int>a(n+2);
	vector<int>dp2(n+1);
	for(int i = 2; i<=n; i++){
		cin >> a[i];
	}
	int ans = 0;
	dp[n+1] = (int)1e9;
	for(int i = n; i>=1; i--){
		dp[i] = dp[i+1]+1;
		if(a[i] == 1){
			dp[i] = 0;
		}
	}
	dp2[0] = (int)1e9;
	for(int i = 1; i<=n; i++){
		dp2[i] = dp2[i-1]+1;
		if(a[i] == 1){
			dp2[i] = 0;
		}
		if(i>1){
			int v = min({i-1,dp2[i]+1,dp[i]+1});
			ans = max(ans,v);
		}
	}
	cout << ans << '\n';
	return 0;
}

详细

Test #1:

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

input:

5
1 0 1 0

output:

2

result:

ok single line: '2'

Test #2:

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

input:

7
1 1 1 1 1 1

output:

1

result:

ok single line: '1'

Test #3:

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

input:

2
0

output:

1

result:

ok single line: '1'

Test #4:

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

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'