#include <bits/stdc++.h>
using namespace std;
int n,a[500005],sp[500005],k;
vector<int> adg[500005],del[500005];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n;
k = n / 2 + n % 2;
for (int i = 1; i <= n; i++)
cin >> a[i];
for (int i = 1; i <= n; i++)
sp[i] = sp[i - 1] + a[i];
for (int i = 1; i <= n; i++)
{
if (i + k - 1 <= n)
{
int vl = sp[i + k - 1] - sp[i - 1];
adg[i].push_back(vl);
del[i + k].push_back(vl);
}
else
{
int vl = sp[n] - sp[i - 1] + sp[i + k - 1 - n];
adg[i].push_back(vl);
adg[1].push_back(vl);
del[i + k - n].push_back(vl);
}
}
multiset<int> ms;
int mxm = 0;
for (int i = 1; i <= n; i++)
{
for (auto it : adg[i])
ms.insert(it);
for (auto it : del[i])
ms.erase(ms.find(it));
mxm = max(mxm,*ms.begin());
}
cout << mxm;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
27224 KB |
Output is correct |
2 |
Correct |
7 ms |
27224 KB |
Output is correct |
3 |
Correct |
6 ms |
27304 KB |
Output is correct |
4 |
Correct |
6 ms |
27228 KB |
Output is correct |
5 |
Correct |
6 ms |
27228 KB |
Output is correct |
6 |
Correct |
6 ms |
27276 KB |
Output is correct |
7 |
Correct |
6 ms |
27228 KB |
Output is correct |
8 |
Correct |
6 ms |
27228 KB |
Output is correct |
9 |
Correct |
7 ms |
27228 KB |
Output is correct |
10 |
Correct |
6 ms |
27228 KB |
Output is correct |
11 |
Correct |
7 ms |
27336 KB |
Output is correct |
12 |
Correct |
6 ms |
27228 KB |
Output is correct |
13 |
Correct |
6 ms |
27228 KB |
Output is correct |
14 |
Correct |
6 ms |
27228 KB |
Output is correct |
15 |
Correct |
6 ms |
27228 KB |
Output is correct |
16 |
Correct |
6 ms |
27228 KB |
Output is correct |
17 |
Correct |
6 ms |
27228 KB |
Output is correct |
18 |
Correct |
7 ms |
27340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
27224 KB |
Output is correct |
2 |
Correct |
7 ms |
27224 KB |
Output is correct |
3 |
Correct |
6 ms |
27304 KB |
Output is correct |
4 |
Correct |
6 ms |
27228 KB |
Output is correct |
5 |
Correct |
6 ms |
27228 KB |
Output is correct |
6 |
Correct |
6 ms |
27276 KB |
Output is correct |
7 |
Correct |
6 ms |
27228 KB |
Output is correct |
8 |
Correct |
6 ms |
27228 KB |
Output is correct |
9 |
Correct |
7 ms |
27228 KB |
Output is correct |
10 |
Correct |
6 ms |
27228 KB |
Output is correct |
11 |
Correct |
7 ms |
27336 KB |
Output is correct |
12 |
Correct |
6 ms |
27228 KB |
Output is correct |
13 |
Correct |
6 ms |
27228 KB |
Output is correct |
14 |
Correct |
6 ms |
27228 KB |
Output is correct |
15 |
Correct |
6 ms |
27228 KB |
Output is correct |
16 |
Correct |
6 ms |
27228 KB |
Output is correct |
17 |
Correct |
6 ms |
27228 KB |
Output is correct |
18 |
Correct |
7 ms |
27340 KB |
Output is correct |
19 |
Correct |
6 ms |
27224 KB |
Output is correct |
20 |
Correct |
6 ms |
27228 KB |
Output is correct |
21 |
Correct |
6 ms |
27228 KB |
Output is correct |
22 |
Correct |
7 ms |
27484 KB |
Output is correct |
23 |
Correct |
9 ms |
27592 KB |
Output is correct |
24 |
Correct |
7 ms |
27416 KB |
Output is correct |
25 |
Correct |
8 ms |
27740 KB |
Output is correct |
26 |
Correct |
8 ms |
27740 KB |
Output is correct |
27 |
Correct |
6 ms |
27228 KB |
Output is correct |
28 |
Correct |
6 ms |
27228 KB |
Output is correct |
29 |
Correct |
6 ms |
27228 KB |
Output is correct |
30 |
Correct |
8 ms |
27576 KB |
Output is correct |
31 |
Correct |
7 ms |
27740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
27304 KB |
Output is correct |
2 |
Correct |
6 ms |
27228 KB |
Output is correct |
3 |
Correct |
8 ms |
27740 KB |
Output is correct |
4 |
Correct |
37 ms |
34516 KB |
Output is correct |
5 |
Correct |
93 ms |
45616 KB |
Output is correct |
6 |
Correct |
121 ms |
50380 KB |
Output is correct |
7 |
Correct |
139 ms |
55016 KB |
Output is correct |
8 |
Correct |
296 ms |
73928 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
27224 KB |
Output is correct |
2 |
Correct |
7 ms |
27224 KB |
Output is correct |
3 |
Correct |
6 ms |
27304 KB |
Output is correct |
4 |
Correct |
6 ms |
27228 KB |
Output is correct |
5 |
Correct |
6 ms |
27228 KB |
Output is correct |
6 |
Correct |
6 ms |
27276 KB |
Output is correct |
7 |
Correct |
6 ms |
27228 KB |
Output is correct |
8 |
Correct |
6 ms |
27228 KB |
Output is correct |
9 |
Correct |
7 ms |
27228 KB |
Output is correct |
10 |
Correct |
6 ms |
27228 KB |
Output is correct |
11 |
Correct |
7 ms |
27336 KB |
Output is correct |
12 |
Correct |
6 ms |
27228 KB |
Output is correct |
13 |
Correct |
6 ms |
27228 KB |
Output is correct |
14 |
Correct |
6 ms |
27228 KB |
Output is correct |
15 |
Correct |
6 ms |
27228 KB |
Output is correct |
16 |
Correct |
6 ms |
27228 KB |
Output is correct |
17 |
Correct |
6 ms |
27228 KB |
Output is correct |
18 |
Correct |
7 ms |
27340 KB |
Output is correct |
19 |
Correct |
6 ms |
27224 KB |
Output is correct |
20 |
Correct |
6 ms |
27228 KB |
Output is correct |
21 |
Correct |
6 ms |
27228 KB |
Output is correct |
22 |
Correct |
7 ms |
27484 KB |
Output is correct |
23 |
Correct |
9 ms |
27592 KB |
Output is correct |
24 |
Correct |
7 ms |
27416 KB |
Output is correct |
25 |
Correct |
8 ms |
27740 KB |
Output is correct |
26 |
Correct |
8 ms |
27740 KB |
Output is correct |
27 |
Correct |
6 ms |
27228 KB |
Output is correct |
28 |
Correct |
6 ms |
27228 KB |
Output is correct |
29 |
Correct |
6 ms |
27228 KB |
Output is correct |
30 |
Correct |
8 ms |
27576 KB |
Output is correct |
31 |
Correct |
7 ms |
27740 KB |
Output is correct |
32 |
Correct |
6 ms |
27304 KB |
Output is correct |
33 |
Correct |
6 ms |
27228 KB |
Output is correct |
34 |
Correct |
8 ms |
27740 KB |
Output is correct |
35 |
Correct |
37 ms |
34516 KB |
Output is correct |
36 |
Correct |
93 ms |
45616 KB |
Output is correct |
37 |
Correct |
121 ms |
50380 KB |
Output is correct |
38 |
Correct |
139 ms |
55016 KB |
Output is correct |
39 |
Correct |
296 ms |
73928 KB |
Output is correct |
40 |
Correct |
11 ms |
27992 KB |
Output is correct |
41 |
Correct |
14 ms |
29156 KB |
Output is correct |
42 |
Correct |
18 ms |
30044 KB |
Output is correct |
43 |
Correct |
96 ms |
45752 KB |
Output is correct |
44 |
Correct |
243 ms |
74000 KB |
Output is correct |
45 |
Correct |
45 ms |
36212 KB |
Output is correct |
46 |
Correct |
138 ms |
54980 KB |
Output is correct |
47 |
Correct |
266 ms |
73928 KB |
Output is correct |
48 |
Correct |
207 ms |
74268 KB |
Output is correct |
49 |
Correct |
189 ms |
73384 KB |
Output is correct |
50 |
Correct |
190 ms |
73352 KB |
Output is correct |