# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
696074 |
2023-02-05T10:29:45 Z |
Makarooni |
Hacker (BOI15_hac) |
C++17 |
|
474 ms |
22324 KB |
/* IN THE NAME OF GOD */
/* |\/| /-\ |\| | |\/| /-\ */
#include "bits/stdc++.h"
using namespace std;
#define sz(x) (int)x.size()
#define endl '\n'
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define mr make_pair
//#define int long long
#define pii pair<int, int>
typedef long double ld;
typedef long long ll;
mt19937 rng (chrono::high_resolution_clock::now().time_since_epoch().count());
const int N = 5e5 + 10;
const int MOD = 1e9 + 7;
const int inf = 1e9 + 1;
const ll INF = 3e18;
int a[N], ps[N], seg[N * 4], lz[N * 4];
void shift(int id, int s, int e){
if(s == e)
return;
seg[id * 2] = min(seg[id * 2], lz[id]);
seg[id * 2 + 1] = min(seg[id * 2 + 1], lz[id]);
lz[id * 2] = min(lz[id], lz[id * 2]);
lz[id * 2 + 1] = min(lz[id], lz[id * 2 + 1]);
}
void upd(int id, int s, int e, int l, int r, int x){
shift(id, s, e);
if(s > r || e < l)
return;
if(l <= s && e <= r){
seg[id] = min(seg[id], x);
lz[id] = min(lz[id], x);
return;
}
int mid = (s + e) / 2;
upd(id * 2, s, mid, l, r, x);
upd(id * 2 + 1, mid + 1, e, l, r, x);
seg[id] = min(seg[id * 2], seg[id * 2 + 1]);
}
int get(int id, int s, int e, int p){
shift(id, s, e);
if(s > p || e < p)
return inf;
if(s == e && e == p)
return seg[id];
int mid = (s + e) / 2;
return min(get(id * 2, s, mid, p), get(id * 2 + 1, mid + 1, e, p));
}
int32_t main(){
ios_base:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
int n;
cin >> n;
int t = n / 2 + (n % 2);
for(int i = 1; i < 4 * N; i++){
seg[i] = inf;
lz[i] = inf;
}
for(int i = 1; i <= n; i++){
cin >> a[i];
ps[i] = ps[i - 1] + a[i];
}
for(int i = 1; i <= n; i++){
if(i >= t)
upd(1, 1, n, i - t + 1, i, ps[i] - ps[i - t]);
else{
upd(1, 1, n, 1, i, ps[i] + ps[n] - ps[n - (t - i)]);
upd(1, 1, n, n - (t - i) + 1, n, ps[i] + ps[n] - ps[n - (t - i)]);
}
}
int ans = 0;
for(int i = 1; i <= n; i++)
ans = max(ans, get(1, 1, n, i));
cout << ans << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
15956 KB |
Output is correct |
2 |
Correct |
7 ms |
15956 KB |
Output is correct |
3 |
Correct |
7 ms |
15956 KB |
Output is correct |
4 |
Correct |
8 ms |
15948 KB |
Output is correct |
5 |
Correct |
8 ms |
15956 KB |
Output is correct |
6 |
Correct |
9 ms |
15956 KB |
Output is correct |
7 |
Correct |
8 ms |
15956 KB |
Output is correct |
8 |
Correct |
8 ms |
16000 KB |
Output is correct |
9 |
Correct |
8 ms |
15956 KB |
Output is correct |
10 |
Correct |
11 ms |
15956 KB |
Output is correct |
11 |
Correct |
9 ms |
15956 KB |
Output is correct |
12 |
Correct |
7 ms |
15956 KB |
Output is correct |
13 |
Correct |
7 ms |
15996 KB |
Output is correct |
14 |
Correct |
7 ms |
15952 KB |
Output is correct |
15 |
Correct |
8 ms |
15956 KB |
Output is correct |
16 |
Correct |
7 ms |
15928 KB |
Output is correct |
17 |
Correct |
7 ms |
15956 KB |
Output is correct |
18 |
Correct |
7 ms |
15956 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
15956 KB |
Output is correct |
2 |
Correct |
7 ms |
15956 KB |
Output is correct |
3 |
Correct |
7 ms |
15956 KB |
Output is correct |
4 |
Correct |
8 ms |
15948 KB |
Output is correct |
5 |
Correct |
8 ms |
15956 KB |
Output is correct |
6 |
Correct |
9 ms |
15956 KB |
Output is correct |
7 |
Correct |
8 ms |
15956 KB |
Output is correct |
8 |
Correct |
8 ms |
16000 KB |
Output is correct |
9 |
Correct |
8 ms |
15956 KB |
Output is correct |
10 |
Correct |
11 ms |
15956 KB |
Output is correct |
11 |
Correct |
9 ms |
15956 KB |
Output is correct |
12 |
Correct |
7 ms |
15956 KB |
Output is correct |
13 |
Correct |
7 ms |
15996 KB |
Output is correct |
14 |
Correct |
7 ms |
15952 KB |
Output is correct |
15 |
Correct |
8 ms |
15956 KB |
Output is correct |
16 |
Correct |
7 ms |
15928 KB |
Output is correct |
17 |
Correct |
7 ms |
15956 KB |
Output is correct |
18 |
Correct |
7 ms |
15956 KB |
Output is correct |
19 |
Correct |
7 ms |
15952 KB |
Output is correct |
20 |
Correct |
9 ms |
15892 KB |
Output is correct |
21 |
Correct |
8 ms |
15912 KB |
Output is correct |
22 |
Correct |
9 ms |
15956 KB |
Output is correct |
23 |
Correct |
10 ms |
15956 KB |
Output is correct |
24 |
Correct |
9 ms |
15956 KB |
Output is correct |
25 |
Correct |
11 ms |
16036 KB |
Output is correct |
26 |
Correct |
10 ms |
16024 KB |
Output is correct |
27 |
Correct |
7 ms |
15956 KB |
Output is correct |
28 |
Correct |
8 ms |
15948 KB |
Output is correct |
29 |
Correct |
7 ms |
15956 KB |
Output is correct |
30 |
Correct |
10 ms |
15956 KB |
Output is correct |
31 |
Correct |
10 ms |
15956 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
15956 KB |
Output is correct |
2 |
Correct |
7 ms |
16012 KB |
Output is correct |
3 |
Correct |
11 ms |
15956 KB |
Output is correct |
4 |
Correct |
74 ms |
16852 KB |
Output is correct |
5 |
Correct |
191 ms |
18304 KB |
Output is correct |
6 |
Correct |
213 ms |
19024 KB |
Output is correct |
7 |
Correct |
274 ms |
19692 KB |
Output is correct |
8 |
Correct |
464 ms |
22052 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
15956 KB |
Output is correct |
2 |
Correct |
7 ms |
15956 KB |
Output is correct |
3 |
Correct |
7 ms |
15956 KB |
Output is correct |
4 |
Correct |
8 ms |
15948 KB |
Output is correct |
5 |
Correct |
8 ms |
15956 KB |
Output is correct |
6 |
Correct |
9 ms |
15956 KB |
Output is correct |
7 |
Correct |
8 ms |
15956 KB |
Output is correct |
8 |
Correct |
8 ms |
16000 KB |
Output is correct |
9 |
Correct |
8 ms |
15956 KB |
Output is correct |
10 |
Correct |
11 ms |
15956 KB |
Output is correct |
11 |
Correct |
9 ms |
15956 KB |
Output is correct |
12 |
Correct |
7 ms |
15956 KB |
Output is correct |
13 |
Correct |
7 ms |
15996 KB |
Output is correct |
14 |
Correct |
7 ms |
15952 KB |
Output is correct |
15 |
Correct |
8 ms |
15956 KB |
Output is correct |
16 |
Correct |
7 ms |
15928 KB |
Output is correct |
17 |
Correct |
7 ms |
15956 KB |
Output is correct |
18 |
Correct |
7 ms |
15956 KB |
Output is correct |
19 |
Correct |
7 ms |
15952 KB |
Output is correct |
20 |
Correct |
9 ms |
15892 KB |
Output is correct |
21 |
Correct |
8 ms |
15912 KB |
Output is correct |
22 |
Correct |
9 ms |
15956 KB |
Output is correct |
23 |
Correct |
10 ms |
15956 KB |
Output is correct |
24 |
Correct |
9 ms |
15956 KB |
Output is correct |
25 |
Correct |
11 ms |
16036 KB |
Output is correct |
26 |
Correct |
10 ms |
16024 KB |
Output is correct |
27 |
Correct |
7 ms |
15956 KB |
Output is correct |
28 |
Correct |
8 ms |
15948 KB |
Output is correct |
29 |
Correct |
7 ms |
15956 KB |
Output is correct |
30 |
Correct |
10 ms |
15956 KB |
Output is correct |
31 |
Correct |
10 ms |
15956 KB |
Output is correct |
32 |
Correct |
8 ms |
15956 KB |
Output is correct |
33 |
Correct |
7 ms |
16012 KB |
Output is correct |
34 |
Correct |
11 ms |
15956 KB |
Output is correct |
35 |
Correct |
74 ms |
16852 KB |
Output is correct |
36 |
Correct |
191 ms |
18304 KB |
Output is correct |
37 |
Correct |
213 ms |
19024 KB |
Output is correct |
38 |
Correct |
274 ms |
19692 KB |
Output is correct |
39 |
Correct |
464 ms |
22052 KB |
Output is correct |
40 |
Correct |
15 ms |
16084 KB |
Output is correct |
41 |
Correct |
21 ms |
16156 KB |
Output is correct |
42 |
Correct |
31 ms |
16364 KB |
Output is correct |
43 |
Correct |
179 ms |
18420 KB |
Output is correct |
44 |
Correct |
447 ms |
22056 KB |
Output is correct |
45 |
Correct |
87 ms |
17220 KB |
Output is correct |
46 |
Correct |
269 ms |
19632 KB |
Output is correct |
47 |
Correct |
474 ms |
22060 KB |
Output is correct |
48 |
Correct |
465 ms |
22324 KB |
Output is correct |
49 |
Correct |
437 ms |
21456 KB |
Output is correct |
50 |
Correct |
450 ms |
21460 KB |
Output is correct |