# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
251760 |
2020-07-22T09:31:29 Z |
tutis |
Hacker (BOI15_hac) |
C++17 |
|
382 ms |
29920 KB |
/*input
4
7 6 8 4
*/
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename K>
using ordered_map = tree<T, K, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int n;
cin >> n;
ll h[n];
for (int i = 0; i < n; i++)
cin >> h[i];
ll s[2 * n + 1];
s[0] = h[0];
for (int i = 1; i <= 2 * n; i++)
s[i] = s[i - 1] + h[i % n];
ll k = (n + 1) / 2;
vector<ll>X;
for (int i = k; i <= 2 * n; i++)
X.push_back(s[i] - s[i - k]);
multiset<ll>A;
for (int i = 0; i < k; i++)
A.insert(X[i]);
ll ans = *A.begin();
for (int i = k; i < (int)X.size(); i++)
{
A.insert(X[i]);
A.erase(A.find(X[i - k]));
ans = max(ans, *A.begin());
}
cout << ans << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
0 ms |
384 KB |
Output is correct |
16 |
Correct |
0 ms |
384 KB |
Output is correct |
17 |
Correct |
0 ms |
384 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
0 ms |
384 KB |
Output is correct |
16 |
Correct |
0 ms |
384 KB |
Output is correct |
17 |
Correct |
0 ms |
384 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
2 ms |
512 KB |
Output is correct |
23 |
Correct |
3 ms |
640 KB |
Output is correct |
24 |
Correct |
2 ms |
512 KB |
Output is correct |
25 |
Correct |
2 ms |
640 KB |
Output is correct |
26 |
Correct |
3 ms |
640 KB |
Output is correct |
27 |
Correct |
1 ms |
384 KB |
Output is correct |
28 |
Correct |
0 ms |
384 KB |
Output is correct |
29 |
Correct |
0 ms |
384 KB |
Output is correct |
30 |
Correct |
2 ms |
640 KB |
Output is correct |
31 |
Correct |
3 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
640 KB |
Output is correct |
4 |
Correct |
40 ms |
5112 KB |
Output is correct |
5 |
Correct |
126 ms |
12136 KB |
Output is correct |
6 |
Correct |
172 ms |
15072 KB |
Output is correct |
7 |
Correct |
180 ms |
17888 KB |
Output is correct |
8 |
Correct |
382 ms |
29652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
0 ms |
384 KB |
Output is correct |
16 |
Correct |
0 ms |
384 KB |
Output is correct |
17 |
Correct |
0 ms |
384 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
2 ms |
512 KB |
Output is correct |
23 |
Correct |
3 ms |
640 KB |
Output is correct |
24 |
Correct |
2 ms |
512 KB |
Output is correct |
25 |
Correct |
2 ms |
640 KB |
Output is correct |
26 |
Correct |
3 ms |
640 KB |
Output is correct |
27 |
Correct |
1 ms |
384 KB |
Output is correct |
28 |
Correct |
0 ms |
384 KB |
Output is correct |
29 |
Correct |
0 ms |
384 KB |
Output is correct |
30 |
Correct |
2 ms |
640 KB |
Output is correct |
31 |
Correct |
3 ms |
640 KB |
Output is correct |
32 |
Correct |
0 ms |
384 KB |
Output is correct |
33 |
Correct |
0 ms |
384 KB |
Output is correct |
34 |
Correct |
3 ms |
640 KB |
Output is correct |
35 |
Correct |
40 ms |
5112 KB |
Output is correct |
36 |
Correct |
126 ms |
12136 KB |
Output is correct |
37 |
Correct |
172 ms |
15072 KB |
Output is correct |
38 |
Correct |
180 ms |
17888 KB |
Output is correct |
39 |
Correct |
382 ms |
29652 KB |
Output is correct |
40 |
Correct |
5 ms |
896 KB |
Output is correct |
41 |
Correct |
10 ms |
1536 KB |
Output is correct |
42 |
Correct |
15 ms |
2044 KB |
Output is correct |
43 |
Correct |
119 ms |
12136 KB |
Output is correct |
44 |
Correct |
338 ms |
29652 KB |
Output is correct |
45 |
Correct |
52 ms |
6252 KB |
Output is correct |
46 |
Correct |
175 ms |
17960 KB |
Output is correct |
47 |
Correct |
370 ms |
29620 KB |
Output is correct |
48 |
Correct |
250 ms |
29920 KB |
Output is correct |
49 |
Correct |
230 ms |
29780 KB |
Output is correct |
50 |
Correct |
234 ms |
29656 KB |
Output is correct |