# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
990817 |
2024-05-31T12:24:29 Z |
ChottuF |
Hacker (BOI15_hac) |
C++17 |
|
91 ms |
13500 KB |
#include <bits/stdc++.h>
using namespace std;
deque<int> q;
void ins(int x){
while (!q.empty() && q.back() > x){
q.pop_back();
}
q.push_back(x);
}
void ers(int x){
if (!q.empty() && q.front() == x){
q.pop_front();
}
}
int getmn(){
return q.front();
}
int main() {
int n;
cin >> n;
vector<int> a(2*n);
for (int i = 0; i<n; i++){
cin >> a[i];
a[n+i] = a[i];
}
vector<int> res;
int k = (n+1)/2;
int sm = 0;
for (int i = 0; i<k; i++){
sm += a[i];
}
res.push_back(sm);
for (int i = k; i<n+k-1; i++){
sm -= a[i-k];
sm += a[i];
res.push_back(sm);
}
for (int i = 0; i<n; i++){
res.push_back(res[i]);
}
vector<int> ans(n, 1e9);
for (int i = 0; i<k; i++){
ins(res[i]);
}
ans[k-1] = getmn();
for (int i = k; i<2*n; i++){
ers(res[i-k]);
ins(res[i]);
int ind = i; if (ind >= n) ind -= n;
ans[ind] = getmn();
}
int mx = 0;
for (auto u : ans){
mx = max(mx,u);
}
cout << mx << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
344 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 |
348 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 |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
344 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 |
348 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 |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
456 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
604 KB |
Output is correct |
24 |
Correct |
1 ms |
416 KB |
Output is correct |
25 |
Correct |
1 ms |
604 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
15 ms |
2516 KB |
Output is correct |
5 |
Correct |
32 ms |
5048 KB |
Output is correct |
6 |
Correct |
48 ms |
6208 KB |
Output is correct |
7 |
Correct |
52 ms |
9156 KB |
Output is correct |
8 |
Correct |
83 ms |
12220 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
344 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 |
348 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 |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
456 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
604 KB |
Output is correct |
24 |
Correct |
1 ms |
416 KB |
Output is correct |
25 |
Correct |
1 ms |
604 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
1 ms |
348 KB |
Output is correct |
32 |
Correct |
0 ms |
344 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |
34 |
Correct |
1 ms |
348 KB |
Output is correct |
35 |
Correct |
15 ms |
2516 KB |
Output is correct |
36 |
Correct |
32 ms |
5048 KB |
Output is correct |
37 |
Correct |
48 ms |
6208 KB |
Output is correct |
38 |
Correct |
52 ms |
9156 KB |
Output is correct |
39 |
Correct |
83 ms |
12220 KB |
Output is correct |
40 |
Correct |
2 ms |
604 KB |
Output is correct |
41 |
Correct |
3 ms |
860 KB |
Output is correct |
42 |
Correct |
5 ms |
1116 KB |
Output is correct |
43 |
Correct |
34 ms |
5060 KB |
Output is correct |
44 |
Correct |
84 ms |
12380 KB |
Output is correct |
45 |
Correct |
17 ms |
2716 KB |
Output is correct |
46 |
Correct |
55 ms |
9156 KB |
Output is correct |
47 |
Correct |
91 ms |
12224 KB |
Output is correct |
48 |
Correct |
88 ms |
13500 KB |
Output is correct |
49 |
Correct |
69 ms |
12756 KB |
Output is correct |
50 |
Correct |
69 ms |
12732 KB |
Output is correct |