# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
245738 | 2020-07-07T10:00:03 Z | Mercenary | Bigger segments (IZhO19_segments) | C++14 | 114 ms | 13048 KB |
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/trie_policy.hpp> #define pb push_back #define mp make_pair #define taskname "A" using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef long double ld; typedef pair<int,int> ii; typedef tree <pair<ll,int>,null_type,less<pair<ll,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; const int maxn = 5e5 + 5; const int mod = 1e9 + 7; int n; ll s[maxn]; int dp[maxn]; int t[maxn]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); if(fopen(taskname".INP","r")){ freopen(taskname".INP", "r",stdin); freopen(taskname".OUT", "w",stdout); } cin >> n; for(int i = 1 ; i <= n ; ++i){ cin >> s[i]; s[i] += s[i - 1]; } for(int i = 1 ; i <= n ; ++i){ t[i] = max(t[i] , t[i - 1]); dp[i] = dp[t[i]] + 1; int it = lower_bound(s + 1 , s + n + 1 , s[i] + s[i] - s[t[i]]) - s; t[it] = max(t[it] , i); } cout << dp[n]; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 4 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 384 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 384 KB | Output is correct |
11 | Correct | 5 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 384 KB | Output is correct |
13 | Correct | 5 ms | 512 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Correct | 4 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 4 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 384 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 384 KB | Output is correct |
11 | Correct | 5 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 384 KB | Output is correct |
13 | Correct | 5 ms | 512 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Correct | 4 ms | 384 KB | Output is correct |
16 | Correct | 5 ms | 384 KB | Output is correct |
17 | Correct | 5 ms | 384 KB | Output is correct |
18 | Correct | 5 ms | 384 KB | Output is correct |
19 | Correct | 5 ms | 384 KB | Output is correct |
20 | Correct | 5 ms | 384 KB | Output is correct |
21 | Correct | 5 ms | 384 KB | Output is correct |
22 | Correct | 5 ms | 384 KB | Output is correct |
23 | Correct | 5 ms | 384 KB | Output is correct |
24 | Correct | 5 ms | 384 KB | Output is correct |
25 | Correct | 5 ms | 384 KB | Output is correct |
26 | Correct | 5 ms | 384 KB | Output is correct |
27 | Correct | 4 ms | 384 KB | Output is correct |
28 | Correct | 5 ms | 384 KB | Output is correct |
29 | Correct | 5 ms | 384 KB | Output is correct |
30 | Correct | 5 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 4 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 384 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 384 KB | Output is correct |
11 | Correct | 5 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 384 KB | Output is correct |
13 | Correct | 5 ms | 512 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Correct | 4 ms | 384 KB | Output is correct |
16 | Correct | 5 ms | 384 KB | Output is correct |
17 | Correct | 5 ms | 384 KB | Output is correct |
18 | Correct | 5 ms | 384 KB | Output is correct |
19 | Correct | 5 ms | 384 KB | Output is correct |
20 | Correct | 5 ms | 384 KB | Output is correct |
21 | Correct | 5 ms | 384 KB | Output is correct |
22 | Correct | 5 ms | 384 KB | Output is correct |
23 | Correct | 5 ms | 384 KB | Output is correct |
24 | Correct | 5 ms | 384 KB | Output is correct |
25 | Correct | 5 ms | 384 KB | Output is correct |
26 | Correct | 5 ms | 384 KB | Output is correct |
27 | Correct | 4 ms | 384 KB | Output is correct |
28 | Correct | 5 ms | 384 KB | Output is correct |
29 | Correct | 5 ms | 384 KB | Output is correct |
30 | Correct | 5 ms | 384 KB | Output is correct |
31 | Correct | 5 ms | 384 KB | Output is correct |
32 | Correct | 5 ms | 384 KB | Output is correct |
33 | Correct | 6 ms | 452 KB | Output is correct |
34 | Correct | 5 ms | 384 KB | Output is correct |
35 | Correct | 5 ms | 384 KB | Output is correct |
36 | Correct | 6 ms | 384 KB | Output is correct |
37 | Correct | 5 ms | 384 KB | Output is correct |
38 | Correct | 5 ms | 384 KB | Output is correct |
39 | Correct | 5 ms | 384 KB | Output is correct |
40 | Correct | 6 ms | 384 KB | Output is correct |
41 | Correct | 5 ms | 384 KB | Output is correct |
42 | Correct | 5 ms | 384 KB | Output is correct |
43 | Correct | 5 ms | 512 KB | Output is correct |
44 | Correct | 5 ms | 384 KB | Output is correct |
45 | Correct | 6 ms | 512 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 4 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 384 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 384 KB | Output is correct |
11 | Correct | 5 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 384 KB | Output is correct |
13 | Correct | 5 ms | 512 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Correct | 4 ms | 384 KB | Output is correct |
16 | Correct | 5 ms | 384 KB | Output is correct |
17 | Correct | 5 ms | 384 KB | Output is correct |
18 | Correct | 5 ms | 384 KB | Output is correct |
19 | Correct | 5 ms | 384 KB | Output is correct |
20 | Correct | 5 ms | 384 KB | Output is correct |
21 | Correct | 5 ms | 384 KB | Output is correct |
22 | Correct | 5 ms | 384 KB | Output is correct |
23 | Correct | 5 ms | 384 KB | Output is correct |
24 | Correct | 5 ms | 384 KB | Output is correct |
25 | Correct | 5 ms | 384 KB | Output is correct |
26 | Correct | 5 ms | 384 KB | Output is correct |
27 | Correct | 4 ms | 384 KB | Output is correct |
28 | Correct | 5 ms | 384 KB | Output is correct |
29 | Correct | 5 ms | 384 KB | Output is correct |
30 | Correct | 5 ms | 384 KB | Output is correct |
31 | Correct | 5 ms | 384 KB | Output is correct |
32 | Correct | 5 ms | 384 KB | Output is correct |
33 | Correct | 6 ms | 452 KB | Output is correct |
34 | Correct | 5 ms | 384 KB | Output is correct |
35 | Correct | 5 ms | 384 KB | Output is correct |
36 | Correct | 6 ms | 384 KB | Output is correct |
37 | Correct | 5 ms | 384 KB | Output is correct |
38 | Correct | 5 ms | 384 KB | Output is correct |
39 | Correct | 5 ms | 384 KB | Output is correct |
40 | Correct | 6 ms | 384 KB | Output is correct |
41 | Correct | 5 ms | 384 KB | Output is correct |
42 | Correct | 5 ms | 384 KB | Output is correct |
43 | Correct | 5 ms | 512 KB | Output is correct |
44 | Correct | 5 ms | 384 KB | Output is correct |
45 | Correct | 6 ms | 512 KB | Output is correct |
46 | Correct | 17 ms | 2304 KB | Output is correct |
47 | Correct | 18 ms | 2432 KB | Output is correct |
48 | Correct | 23 ms | 2688 KB | Output is correct |
49 | Correct | 35 ms | 2936 KB | Output is correct |
50 | Correct | 24 ms | 2904 KB | Output is correct |
51 | Correct | 34 ms | 3064 KB | Output is correct |
52 | Correct | 14 ms | 1604 KB | Output is correct |
53 | Correct | 11 ms | 1152 KB | Output is correct |
54 | Correct | 17 ms | 2176 KB | Output is correct |
55 | Correct | 24 ms | 3064 KB | Output is correct |
56 | Correct | 21 ms | 2432 KB | Output is correct |
57 | Correct | 20 ms | 2304 KB | Output is correct |
58 | Correct | 19 ms | 2432 KB | Output is correct |
59 | Correct | 23 ms | 2560 KB | Output is correct |
60 | Correct | 22 ms | 2560 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 4 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 384 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 384 KB | Output is correct |
11 | Correct | 5 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 384 KB | Output is correct |
13 | Correct | 5 ms | 512 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Correct | 4 ms | 384 KB | Output is correct |
16 | Correct | 5 ms | 384 KB | Output is correct |
17 | Correct | 5 ms | 384 KB | Output is correct |
18 | Correct | 5 ms | 384 KB | Output is correct |
19 | Correct | 5 ms | 384 KB | Output is correct |
20 | Correct | 5 ms | 384 KB | Output is correct |
21 | Correct | 5 ms | 384 KB | Output is correct |
22 | Correct | 5 ms | 384 KB | Output is correct |
23 | Correct | 5 ms | 384 KB | Output is correct |
24 | Correct | 5 ms | 384 KB | Output is correct |
25 | Correct | 5 ms | 384 KB | Output is correct |
26 | Correct | 5 ms | 384 KB | Output is correct |
27 | Correct | 4 ms | 384 KB | Output is correct |
28 | Correct | 5 ms | 384 KB | Output is correct |
29 | Correct | 5 ms | 384 KB | Output is correct |
30 | Correct | 5 ms | 384 KB | Output is correct |
31 | Correct | 5 ms | 384 KB | Output is correct |
32 | Correct | 5 ms | 384 KB | Output is correct |
33 | Correct | 6 ms | 452 KB | Output is correct |
34 | Correct | 5 ms | 384 KB | Output is correct |
35 | Correct | 5 ms | 384 KB | Output is correct |
36 | Correct | 6 ms | 384 KB | Output is correct |
37 | Correct | 5 ms | 384 KB | Output is correct |
38 | Correct | 5 ms | 384 KB | Output is correct |
39 | Correct | 5 ms | 384 KB | Output is correct |
40 | Correct | 6 ms | 384 KB | Output is correct |
41 | Correct | 5 ms | 384 KB | Output is correct |
42 | Correct | 5 ms | 384 KB | Output is correct |
43 | Correct | 5 ms | 512 KB | Output is correct |
44 | Correct | 5 ms | 384 KB | Output is correct |
45 | Correct | 6 ms | 512 KB | Output is correct |
46 | Correct | 17 ms | 2304 KB | Output is correct |
47 | Correct | 18 ms | 2432 KB | Output is correct |
48 | Correct | 23 ms | 2688 KB | Output is correct |
49 | Correct | 35 ms | 2936 KB | Output is correct |
50 | Correct | 24 ms | 2904 KB | Output is correct |
51 | Correct | 34 ms | 3064 KB | Output is correct |
52 | Correct | 14 ms | 1604 KB | Output is correct |
53 | Correct | 11 ms | 1152 KB | Output is correct |
54 | Correct | 17 ms | 2176 KB | Output is correct |
55 | Correct | 24 ms | 3064 KB | Output is correct |
56 | Correct | 21 ms | 2432 KB | Output is correct |
57 | Correct | 20 ms | 2304 KB | Output is correct |
58 | Correct | 19 ms | 2432 KB | Output is correct |
59 | Correct | 23 ms | 2560 KB | Output is correct |
60 | Correct | 22 ms | 2560 KB | Output is correct |
61 | Correct | 66 ms | 10104 KB | Output is correct |
62 | Correct | 61 ms | 10108 KB | Output is correct |
63 | Correct | 72 ms | 10488 KB | Output is correct |
64 | Correct | 105 ms | 12792 KB | Output is correct |
65 | Correct | 104 ms | 13048 KB | Output is correct |
66 | Correct | 114 ms | 13048 KB | Output is correct |
67 | Correct | 89 ms | 10528 KB | Output is correct |
68 | Correct | 50 ms | 5368 KB | Output is correct |
69 | Correct | 67 ms | 9208 KB | Output is correct |
70 | Correct | 109 ms | 13048 KB | Output is correct |
71 | Correct | 80 ms | 10232 KB | Output is correct |
72 | Correct | 74 ms | 10528 KB | Output is correct |
73 | Correct | 83 ms | 11132 KB | Output is correct |
74 | Correct | 92 ms | 11512 KB | Output is correct |
75 | Correct | 93 ms | 11512 KB | Output is correct |