# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
497467 | 2021-12-23T06:21:14 Z | Nalrimet | Bigger segments (IZhO19_segments) | C++17 | 86 ms | 32568 KB |
#include <bits/stdc++.h> #pragma GCC optimization("g", on) #pragma GCC optimize ("inline") #pragma GCC optimization("03") #pragma GCC optimization("unroll-loops") #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #define ll long long #define pb push_back #define F first #define S second using namespace std; const int N = 5 * 1e5 + 5; const int inf = 1e9 + 7; long long a[N], pref[N], dp[N], mn[N], lef[N]; vector<int> v[N]; int n; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; //8 //7 2 3 5 1 4 6 10 // pref[i] - pref[j] >= pref[j] - pref[k] // pref[i] >= 2 * pref[j] - pref[k] for(ll i = 1; i <= n; ++i){ cin >> a[i]; pref[i] = pref[i - 1] + a[i]; } for(ll i = 1; i <= n; ++i){ lef[i] = max(lef[i], lef[i - 1]); dp[i] = dp[lef[i]] + 1; int l, r, mid; l = i + 1; r = n; while(l < r){ mid = (l + r) / 2; if(2 * pref[i] - pref[lef[i]] <= pref[mid]) r = mid; else l = mid + 1; } if(2 * pref[i] - pref[lef[i]] <= pref[l]) lef[l] = max(lef[l], i); } cout << dp[n]; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 11980 KB | Output is correct |
2 | Correct | 6 ms | 12068 KB | Output is correct |
3 | Correct | 6 ms | 11980 KB | Output is correct |
4 | Correct | 7 ms | 11980 KB | Output is correct |
5 | Correct | 8 ms | 12004 KB | Output is correct |
6 | Correct | 9 ms | 12020 KB | Output is correct |
7 | Correct | 9 ms | 11980 KB | Output is correct |
8 | Correct | 6 ms | 11980 KB | Output is correct |
9 | Correct | 7 ms | 11980 KB | Output is correct |
10 | Correct | 6 ms | 11980 KB | Output is correct |
11 | Correct | 7 ms | 12092 KB | Output is correct |
12 | Correct | 6 ms | 11980 KB | Output is correct |
13 | Correct | 6 ms | 11980 KB | Output is correct |
14 | Correct | 6 ms | 11980 KB | Output is correct |
15 | Correct | 6 ms | 11980 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 11980 KB | Output is correct |
2 | Correct | 6 ms | 12068 KB | Output is correct |
3 | Correct | 6 ms | 11980 KB | Output is correct |
4 | Correct | 7 ms | 11980 KB | Output is correct |
5 | Correct | 8 ms | 12004 KB | Output is correct |
6 | Correct | 9 ms | 12020 KB | Output is correct |
7 | Correct | 9 ms | 11980 KB | Output is correct |
8 | Correct | 6 ms | 11980 KB | Output is correct |
9 | Correct | 7 ms | 11980 KB | Output is correct |
10 | Correct | 6 ms | 11980 KB | Output is correct |
11 | Correct | 7 ms | 12092 KB | Output is correct |
12 | Correct | 6 ms | 11980 KB | Output is correct |
13 | Correct | 6 ms | 11980 KB | Output is correct |
14 | Correct | 6 ms | 11980 KB | Output is correct |
15 | Correct | 6 ms | 11980 KB | Output is correct |
16 | Correct | 7 ms | 12108 KB | Output is correct |
17 | Correct | 6 ms | 12108 KB | Output is correct |
18 | Correct | 7 ms | 12108 KB | Output is correct |
19 | Correct | 6 ms | 12048 KB | Output is correct |
20 | Correct | 7 ms | 12000 KB | Output is correct |
21 | Correct | 6 ms | 12108 KB | Output is correct |
22 | Correct | 6 ms | 11980 KB | Output is correct |
23 | Correct | 6 ms | 11980 KB | Output is correct |
24 | Correct | 7 ms | 12108 KB | Output is correct |
25 | Correct | 7 ms | 12108 KB | Output is correct |
26 | Correct | 8 ms | 12108 KB | Output is correct |
27 | Correct | 6 ms | 11980 KB | Output is correct |
28 | Correct | 7 ms | 11980 KB | Output is correct |
29 | Correct | 6 ms | 12108 KB | Output is correct |
30 | Correct | 8 ms | 11980 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 11980 KB | Output is correct |
2 | Correct | 6 ms | 12068 KB | Output is correct |
3 | Correct | 6 ms | 11980 KB | Output is correct |
4 | Correct | 7 ms | 11980 KB | Output is correct |
5 | Correct | 8 ms | 12004 KB | Output is correct |
6 | Correct | 9 ms | 12020 KB | Output is correct |
7 | Correct | 9 ms | 11980 KB | Output is correct |
8 | Correct | 6 ms | 11980 KB | Output is correct |
9 | Correct | 7 ms | 11980 KB | Output is correct |
10 | Correct | 6 ms | 11980 KB | Output is correct |
11 | Correct | 7 ms | 12092 KB | Output is correct |
12 | Correct | 6 ms | 11980 KB | Output is correct |
13 | Correct | 6 ms | 11980 KB | Output is correct |
14 | Correct | 6 ms | 11980 KB | Output is correct |
15 | Correct | 6 ms | 11980 KB | Output is correct |
16 | Correct | 7 ms | 12108 KB | Output is correct |
17 | Correct | 6 ms | 12108 KB | Output is correct |
18 | Correct | 7 ms | 12108 KB | Output is correct |
19 | Correct | 6 ms | 12048 KB | Output is correct |
20 | Correct | 7 ms | 12000 KB | Output is correct |
21 | Correct | 6 ms | 12108 KB | Output is correct |
22 | Correct | 6 ms | 11980 KB | Output is correct |
23 | Correct | 6 ms | 11980 KB | Output is correct |
24 | Correct | 7 ms | 12108 KB | Output is correct |
25 | Correct | 7 ms | 12108 KB | Output is correct |
26 | Correct | 8 ms | 12108 KB | Output is correct |
27 | Correct | 6 ms | 11980 KB | Output is correct |
28 | Correct | 7 ms | 11980 KB | Output is correct |
29 | Correct | 6 ms | 12108 KB | Output is correct |
30 | Correct | 8 ms | 11980 KB | Output is correct |
31 | Correct | 7 ms | 12108 KB | Output is correct |
32 | Correct | 6 ms | 12184 KB | Output is correct |
33 | Correct | 6 ms | 12108 KB | Output is correct |
34 | Correct | 6 ms | 12108 KB | Output is correct |
35 | Correct | 7 ms | 12204 KB | Output is correct |
36 | Correct | 8 ms | 12176 KB | Output is correct |
37 | Correct | 7 ms | 12080 KB | Output is correct |
38 | Correct | 8 ms | 12108 KB | Output is correct |
39 | Correct | 7 ms | 12108 KB | Output is correct |
40 | Correct | 8 ms | 12204 KB | Output is correct |
41 | Correct | 8 ms | 12068 KB | Output is correct |
42 | Correct | 9 ms | 12108 KB | Output is correct |
43 | Correct | 8 ms | 12160 KB | Output is correct |
44 | Correct | 6 ms | 12080 KB | Output is correct |
45 | Correct | 7 ms | 12100 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 11980 KB | Output is correct |
2 | Correct | 6 ms | 12068 KB | Output is correct |
3 | Correct | 6 ms | 11980 KB | Output is correct |
4 | Correct | 7 ms | 11980 KB | Output is correct |
5 | Correct | 8 ms | 12004 KB | Output is correct |
6 | Correct | 9 ms | 12020 KB | Output is correct |
7 | Correct | 9 ms | 11980 KB | Output is correct |
8 | Correct | 6 ms | 11980 KB | Output is correct |
9 | Correct | 7 ms | 11980 KB | Output is correct |
10 | Correct | 6 ms | 11980 KB | Output is correct |
11 | Correct | 7 ms | 12092 KB | Output is correct |
12 | Correct | 6 ms | 11980 KB | Output is correct |
13 | Correct | 6 ms | 11980 KB | Output is correct |
14 | Correct | 6 ms | 11980 KB | Output is correct |
15 | Correct | 6 ms | 11980 KB | Output is correct |
16 | Correct | 7 ms | 12108 KB | Output is correct |
17 | Correct | 6 ms | 12108 KB | Output is correct |
18 | Correct | 7 ms | 12108 KB | Output is correct |
19 | Correct | 6 ms | 12048 KB | Output is correct |
20 | Correct | 7 ms | 12000 KB | Output is correct |
21 | Correct | 6 ms | 12108 KB | Output is correct |
22 | Correct | 6 ms | 11980 KB | Output is correct |
23 | Correct | 6 ms | 11980 KB | Output is correct |
24 | Correct | 7 ms | 12108 KB | Output is correct |
25 | Correct | 7 ms | 12108 KB | Output is correct |
26 | Correct | 8 ms | 12108 KB | Output is correct |
27 | Correct | 6 ms | 11980 KB | Output is correct |
28 | Correct | 7 ms | 11980 KB | Output is correct |
29 | Correct | 6 ms | 12108 KB | Output is correct |
30 | Correct | 8 ms | 11980 KB | Output is correct |
31 | Correct | 7 ms | 12108 KB | Output is correct |
32 | Correct | 6 ms | 12184 KB | Output is correct |
33 | Correct | 6 ms | 12108 KB | Output is correct |
34 | Correct | 6 ms | 12108 KB | Output is correct |
35 | Correct | 7 ms | 12204 KB | Output is correct |
36 | Correct | 8 ms | 12176 KB | Output is correct |
37 | Correct | 7 ms | 12080 KB | Output is correct |
38 | Correct | 8 ms | 12108 KB | Output is correct |
39 | Correct | 7 ms | 12108 KB | Output is correct |
40 | Correct | 8 ms | 12204 KB | Output is correct |
41 | Correct | 8 ms | 12068 KB | Output is correct |
42 | Correct | 9 ms | 12108 KB | Output is correct |
43 | Correct | 8 ms | 12160 KB | Output is correct |
44 | Correct | 6 ms | 12080 KB | Output is correct |
45 | Correct | 7 ms | 12100 KB | Output is correct |
46 | Correct | 17 ms | 15564 KB | Output is correct |
47 | Correct | 19 ms | 15720 KB | Output is correct |
48 | Correct | 21 ms | 15940 KB | Output is correct |
49 | Correct | 20 ms | 16016 KB | Output is correct |
50 | Correct | 23 ms | 16164 KB | Output is correct |
51 | Correct | 21 ms | 16068 KB | Output is correct |
52 | Correct | 16 ms | 14080 KB | Output is correct |
53 | Correct | 12 ms | 13316 KB | Output is correct |
54 | Correct | 16 ms | 15416 KB | Output is correct |
55 | Correct | 22 ms | 16160 KB | Output is correct |
56 | Correct | 16 ms | 15592 KB | Output is correct |
57 | Correct | 18 ms | 15552 KB | Output is correct |
58 | Correct | 18 ms | 15564 KB | Output is correct |
59 | Correct | 17 ms | 15696 KB | Output is correct |
60 | Correct | 17 ms | 15656 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 11980 KB | Output is correct |
2 | Correct | 6 ms | 12068 KB | Output is correct |
3 | Correct | 6 ms | 11980 KB | Output is correct |
4 | Correct | 7 ms | 11980 KB | Output is correct |
5 | Correct | 8 ms | 12004 KB | Output is correct |
6 | Correct | 9 ms | 12020 KB | Output is correct |
7 | Correct | 9 ms | 11980 KB | Output is correct |
8 | Correct | 6 ms | 11980 KB | Output is correct |
9 | Correct | 7 ms | 11980 KB | Output is correct |
10 | Correct | 6 ms | 11980 KB | Output is correct |
11 | Correct | 7 ms | 12092 KB | Output is correct |
12 | Correct | 6 ms | 11980 KB | Output is correct |
13 | Correct | 6 ms | 11980 KB | Output is correct |
14 | Correct | 6 ms | 11980 KB | Output is correct |
15 | Correct | 6 ms | 11980 KB | Output is correct |
16 | Correct | 7 ms | 12108 KB | Output is correct |
17 | Correct | 6 ms | 12108 KB | Output is correct |
18 | Correct | 7 ms | 12108 KB | Output is correct |
19 | Correct | 6 ms | 12048 KB | Output is correct |
20 | Correct | 7 ms | 12000 KB | Output is correct |
21 | Correct | 6 ms | 12108 KB | Output is correct |
22 | Correct | 6 ms | 11980 KB | Output is correct |
23 | Correct | 6 ms | 11980 KB | Output is correct |
24 | Correct | 7 ms | 12108 KB | Output is correct |
25 | Correct | 7 ms | 12108 KB | Output is correct |
26 | Correct | 8 ms | 12108 KB | Output is correct |
27 | Correct | 6 ms | 11980 KB | Output is correct |
28 | Correct | 7 ms | 11980 KB | Output is correct |
29 | Correct | 6 ms | 12108 KB | Output is correct |
30 | Correct | 8 ms | 11980 KB | Output is correct |
31 | Correct | 7 ms | 12108 KB | Output is correct |
32 | Correct | 6 ms | 12184 KB | Output is correct |
33 | Correct | 6 ms | 12108 KB | Output is correct |
34 | Correct | 6 ms | 12108 KB | Output is correct |
35 | Correct | 7 ms | 12204 KB | Output is correct |
36 | Correct | 8 ms | 12176 KB | Output is correct |
37 | Correct | 7 ms | 12080 KB | Output is correct |
38 | Correct | 8 ms | 12108 KB | Output is correct |
39 | Correct | 7 ms | 12108 KB | Output is correct |
40 | Correct | 8 ms | 12204 KB | Output is correct |
41 | Correct | 8 ms | 12068 KB | Output is correct |
42 | Correct | 9 ms | 12108 KB | Output is correct |
43 | Correct | 8 ms | 12160 KB | Output is correct |
44 | Correct | 6 ms | 12080 KB | Output is correct |
45 | Correct | 7 ms | 12100 KB | Output is correct |
46 | Correct | 17 ms | 15564 KB | Output is correct |
47 | Correct | 19 ms | 15720 KB | Output is correct |
48 | Correct | 21 ms | 15940 KB | Output is correct |
49 | Correct | 20 ms | 16016 KB | Output is correct |
50 | Correct | 23 ms | 16164 KB | Output is correct |
51 | Correct | 21 ms | 16068 KB | Output is correct |
52 | Correct | 16 ms | 14080 KB | Output is correct |
53 | Correct | 12 ms | 13316 KB | Output is correct |
54 | Correct | 16 ms | 15416 KB | Output is correct |
55 | Correct | 22 ms | 16160 KB | Output is correct |
56 | Correct | 16 ms | 15592 KB | Output is correct |
57 | Correct | 18 ms | 15552 KB | Output is correct |
58 | Correct | 18 ms | 15564 KB | Output is correct |
59 | Correct | 17 ms | 15696 KB | Output is correct |
60 | Correct | 17 ms | 15656 KB | Output is correct |
61 | Correct | 59 ms | 29720 KB | Output is correct |
62 | Correct | 69 ms | 29560 KB | Output is correct |
63 | Correct | 70 ms | 30044 KB | Output is correct |
64 | Correct | 78 ms | 32236 KB | Output is correct |
65 | Correct | 70 ms | 32568 KB | Output is correct |
66 | Correct | 80 ms | 32472 KB | Output is correct |
67 | Correct | 71 ms | 28468 KB | Output is correct |
68 | Correct | 37 ms | 20248 KB | Output is correct |
69 | Correct | 59 ms | 28732 KB | Output is correct |
70 | Correct | 86 ms | 32528 KB | Output is correct |
71 | Correct | 52 ms | 29592 KB | Output is correct |
72 | Correct | 62 ms | 29968 KB | Output is correct |
73 | Correct | 64 ms | 30596 KB | Output is correct |
74 | Correct | 60 ms | 31000 KB | Output is correct |
75 | Correct | 63 ms | 30932 KB | Output is correct |