Submission #853536

# Submission time Handle Problem Language Result Execution time Memory
853536 2023-09-24T14:29:13 Z NK_ Hacker (BOI15_hac) C++17
100 / 100
234 ms 30012 KB
// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>
 
using namespace std;
 
#define nl '\n'
#define pb push_back
#define pf push_front
 
#define mp make_pair
#define f first
#define s second
#define sz(x) int(x.size())
 
template<class T> using V = vector<T>;
using pi = pair<int, int>;
using vi = V<int>;
using vpi = V<pi>;
 
using ll = long long;
using pl = pair<ll, ll>;
using vpl = V<pl>;
using vl = V<ll>;
 
using db = long double;
 
template<class T> using pq = priority_queue<T, V<T>, greater<T>>;
 
const int MOD = 1e9 + 7;
const ll INFL = ll(1e17);
const int LG = 18;

int main() {
	cin.tie(0)->sync_with_stdio(0);

	int N; cin >> N;
	vi A(N); for(auto& x : A) cin >> x;

	for(int i = 0; i < N; i++) A.pb(A[i]);

	vl P = {0}; for(int i = 0; i < 2*N; i++) P.pb(P.back() + A[i]);

	auto qry = [&](int l, int r) {
		return P[r+1] - P[l];
	};

	int M = (N + 1) / 2;

	vi S;
	for(int i = 0; (i+M-1) < 2*N; i++) S.pb(qry(i, i + M - 1));

	multiset<int> MN;

	int ans = 0;
	for(int i = 0; i < sz(S); i++) {
		MN.insert(S[i]);
		if (i-M >= 0) MN.erase(MN.find(S[i-M]));

		if (sz(MN) == M) ans = max(ans, *begin(MN));
	}

	cout << ans << nl;

	exit(0-0);
} 	


# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 472 KB Output is correct
23 Correct 2 ms 600 KB Output is correct
24 Correct 1 ms 604 KB Output is correct
25 Correct 2 ms 600 KB Output is correct
26 Correct 2 ms 600 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 2 ms 600 KB Output is correct
31 Correct 2 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 25 ms 4884 KB Output is correct
5 Correct 75 ms 12356 KB Output is correct
6 Correct 107 ms 14972 KB Output is correct
7 Correct 110 ms 19968 KB Output is correct
8 Correct 233 ms 30012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 472 KB Output is correct
23 Correct 2 ms 600 KB Output is correct
24 Correct 1 ms 604 KB Output is correct
25 Correct 2 ms 600 KB Output is correct
26 Correct 2 ms 600 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 2 ms 600 KB Output is correct
31 Correct 2 ms 600 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 2 ms 604 KB Output is correct
35 Correct 25 ms 4884 KB Output is correct
36 Correct 75 ms 12356 KB Output is correct
37 Correct 107 ms 14972 KB Output is correct
38 Correct 110 ms 19968 KB Output is correct
39 Correct 233 ms 30012 KB Output is correct
40 Correct 3 ms 980 KB Output is correct
41 Correct 6 ms 1496 KB Output is correct
42 Correct 9 ms 2000 KB Output is correct
43 Correct 85 ms 12140 KB Output is correct
44 Correct 207 ms 29596 KB Output is correct
45 Correct 32 ms 6088 KB Output is correct
46 Correct 111 ms 18284 KB Output is correct
47 Correct 234 ms 29352 KB Output is correct
48 Correct 168 ms 29596 KB Output is correct
49 Correct 157 ms 29588 KB Output is correct
50 Correct 166 ms 28572 KB Output is correct