Submission #867770

# Submission time Handle Problem Language Result Execution time Memory
867770 2023-10-29T12:46:14 Z dio_2 Hacker (BOI15_hac) C++17
40 / 100
1000 ms 8100 KB
#include<bits/stdc++.h>
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int N;
	cin >> N;
	
	const int NN = 3 * N;
	
	vector<int> A(N);
	for(int &x : A) cin >> x; // A[i] <= 2000

	for(int i = 0;i < N;i++) A.push_back(A[i]);
	for(int i = 0;i < N;i++) A.push_back(A[i]);
	
	vector<array<int, 3>> wids;
	auto add = [&](int s, int l, int r)->void{
		wids.push_back({s, l, r});
	};
	
	int K = (N + 1) / 2;
	int sum = 0;
	for(int i = 0;i < K;i++){
		sum += A[N-K+i+1];
	}
	
	add(sum, N-K+1, N);
	
	for(int i = N + 1;i < 3 * N;++i){
		sum += A[i];
		sum -= A[i - K];
		add(sum, i - K + 1, i);
	}
	
	vector<int> in(NN, -1), out(NN, -1);
	vector<int> sums;
	int id = 0;
	for(auto [s, l, r] : wids){
		sums.push_back(s);
		swap(l, r);
		if(in[l] == -1) in[l] = id;
		if(out[r] == -1 && in[r] != -1) out[r] = id;
		++id;
	}
	
	int ans = 0;
	
	for(int i = 0;i < NN;i++){
		int res = 1000 * NN;
		if(in[i] == -1 || out[i] == -1) continue;
		for(int j = in[i];j <= out[i];j++) res = min(res, sums[j]);
		ans = max(ans, res);
	}
	
	cout << ans << '\n';
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 452 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 360 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 452 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 360 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 7 ms 600 KB Output is correct
23 Correct 19 ms 860 KB Output is correct
24 Correct 7 ms 604 KB Output is correct
25 Correct 18 ms 844 KB Output is correct
26 Correct 18 ms 856 KB Output is correct
27 Correct 0 ms 344 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 18 ms 844 KB Output is correct
31 Correct 18 ms 1088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 18 ms 844 KB Output is correct
4 Execution timed out 1025 ms 8100 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 452 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 360 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 7 ms 600 KB Output is correct
23 Correct 19 ms 860 KB Output is correct
24 Correct 7 ms 604 KB Output is correct
25 Correct 18 ms 844 KB Output is correct
26 Correct 18 ms 856 KB Output is correct
27 Correct 0 ms 344 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 18 ms 844 KB Output is correct
31 Correct 18 ms 1088 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 18 ms 844 KB Output is correct
35 Execution timed out 1025 ms 8100 KB Time limit exceeded
36 Halted 0 ms 0 KB -