# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
336450 | 2020-12-15T10:50:25 Z | tengiz05 | Bigger segments (IZhO19_segments) | C++17 | 118 ms | 20060 KB |
#include <bits/stdc++.h> using namespace std; #define int long long #define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define all(x) (x).begin(), (x).end() #define pb push_back #define pii pair<int, int> #define ff first #define ss second #define PI acos(-1) #define ld long double const int mod = 1e9+7, N = 5e5+5, inf = 1e18; int msb(int val){return sizeof(int)*8-__builtin_clzll(val);} int a[N], n, m, k; int pr[N]; int dp[N]; void solve(int test_case){ int i, j; scanf("%d",&n); for(i=1;i<=n;i++){ scanf("%d",&a[i]); pr[i]=a[i];pr[i]+=pr[i-1]; } priority_queue<pii, vector<pii>, greater<pii>> q; q.push({0,0}); int tmp=0; for(i=1;i<=n;i++){ while(!q.empty() && q.top().ff <= pr[i]){ if(dp[q.top().ss] > dp[tmp]){ tmp = q.top().ss; }else if(dp[q.top().ss] == dp[tmp]){ tmp = max(tmp, q.top().ss); }q.pop(); }q.push({pr[i]*2-pr[tmp], i}); dp[i] = dp[tmp]+1; }cout << dp[n] << '\n'; return; } signed main(){ FASTIO; #define MULTITEST 0 #if MULTITEST int ___T; cin >> ___T; for(int T_CASE = 1; T_CASE <= ___T; T_CASE++) solve(T_CASE); #else solve(1); #endif return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 0 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 0 ms | 364 KB | Output is correct |
11 | Correct | 0 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 0 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 0 ms | 364 KB | Output is correct |
11 | Correct | 0 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
16 | Correct | 1 ms | 364 KB | Output is correct |
17 | Correct | 1 ms | 364 KB | Output is correct |
18 | Correct | 1 ms | 364 KB | Output is correct |
19 | Correct | 1 ms | 364 KB | Output is correct |
20 | Correct | 1 ms | 512 KB | Output is correct |
21 | Correct | 1 ms | 364 KB | Output is correct |
22 | Correct | 1 ms | 364 KB | Output is correct |
23 | Correct | 1 ms | 364 KB | Output is correct |
24 | Correct | 1 ms | 364 KB | Output is correct |
25 | Correct | 1 ms | 492 KB | Output is correct |
26 | Correct | 1 ms | 364 KB | Output is correct |
27 | Correct | 1 ms | 364 KB | Output is correct |
28 | Correct | 1 ms | 364 KB | Output is correct |
29 | Correct | 1 ms | 364 KB | Output is correct |
30 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 0 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 0 ms | 364 KB | Output is correct |
11 | Correct | 0 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
16 | Correct | 1 ms | 364 KB | Output is correct |
17 | Correct | 1 ms | 364 KB | Output is correct |
18 | Correct | 1 ms | 364 KB | Output is correct |
19 | Correct | 1 ms | 364 KB | Output is correct |
20 | Correct | 1 ms | 512 KB | Output is correct |
21 | Correct | 1 ms | 364 KB | Output is correct |
22 | Correct | 1 ms | 364 KB | Output is correct |
23 | Correct | 1 ms | 364 KB | Output is correct |
24 | Correct | 1 ms | 364 KB | Output is correct |
25 | Correct | 1 ms | 492 KB | Output is correct |
26 | Correct | 1 ms | 364 KB | Output is correct |
27 | Correct | 1 ms | 364 KB | Output is correct |
28 | Correct | 1 ms | 364 KB | Output is correct |
29 | Correct | 1 ms | 364 KB | Output is correct |
30 | Correct | 1 ms | 364 KB | Output is correct |
31 | Correct | 1 ms | 492 KB | Output is correct |
32 | Correct | 1 ms | 492 KB | Output is correct |
33 | Correct | 1 ms | 492 KB | Output is correct |
34 | Correct | 1 ms | 492 KB | Output is correct |
35 | Correct | 1 ms | 364 KB | Output is correct |
36 | Correct | 1 ms | 492 KB | Output is correct |
37 | Correct | 1 ms | 364 KB | Output is correct |
38 | Correct | 1 ms | 364 KB | Output is correct |
39 | Correct | 1 ms | 492 KB | Output is correct |
40 | Correct | 1 ms | 492 KB | Output is correct |
41 | Correct | 1 ms | 364 KB | Output is correct |
42 | Correct | 1 ms | 492 KB | Output is correct |
43 | Correct | 1 ms | 492 KB | Output is correct |
44 | Correct | 1 ms | 364 KB | Output is correct |
45 | Correct | 1 ms | 492 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 0 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 0 ms | 364 KB | Output is correct |
11 | Correct | 0 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
16 | Correct | 1 ms | 364 KB | Output is correct |
17 | Correct | 1 ms | 364 KB | Output is correct |
18 | Correct | 1 ms | 364 KB | Output is correct |
19 | Correct | 1 ms | 364 KB | Output is correct |
20 | Correct | 1 ms | 512 KB | Output is correct |
21 | Correct | 1 ms | 364 KB | Output is correct |
22 | Correct | 1 ms | 364 KB | Output is correct |
23 | Correct | 1 ms | 364 KB | Output is correct |
24 | Correct | 1 ms | 364 KB | Output is correct |
25 | Correct | 1 ms | 492 KB | Output is correct |
26 | Correct | 1 ms | 364 KB | Output is correct |
27 | Correct | 1 ms | 364 KB | Output is correct |
28 | Correct | 1 ms | 364 KB | Output is correct |
29 | Correct | 1 ms | 364 KB | Output is correct |
30 | Correct | 1 ms | 364 KB | Output is correct |
31 | Correct | 1 ms | 492 KB | Output is correct |
32 | Correct | 1 ms | 492 KB | Output is correct |
33 | Correct | 1 ms | 492 KB | Output is correct |
34 | Correct | 1 ms | 492 KB | Output is correct |
35 | Correct | 1 ms | 364 KB | Output is correct |
36 | Correct | 1 ms | 492 KB | Output is correct |
37 | Correct | 1 ms | 364 KB | Output is correct |
38 | Correct | 1 ms | 364 KB | Output is correct |
39 | Correct | 1 ms | 492 KB | Output is correct |
40 | Correct | 1 ms | 492 KB | Output is correct |
41 | Correct | 1 ms | 364 KB | Output is correct |
42 | Correct | 1 ms | 492 KB | Output is correct |
43 | Correct | 1 ms | 492 KB | Output is correct |
44 | Correct | 1 ms | 364 KB | Output is correct |
45 | Correct | 1 ms | 492 KB | Output is correct |
46 | Correct | 15 ms | 4584 KB | Output is correct |
47 | Correct | 22 ms | 3052 KB | Output is correct |
48 | Correct | 21 ms | 2796 KB | Output is correct |
49 | Correct | 17 ms | 3056 KB | Output is correct |
50 | Correct | 20 ms | 2668 KB | Output is correct |
51 | Correct | 23 ms | 2688 KB | Output is correct |
52 | Correct | 12 ms | 1516 KB | Output is correct |
53 | Correct | 7 ms | 1132 KB | Output is correct |
54 | Correct | 21 ms | 2668 KB | Output is correct |
55 | Correct | 23 ms | 2668 KB | Output is correct |
56 | Correct | 14 ms | 2668 KB | Output is correct |
57 | Correct | 17 ms | 3692 KB | Output is correct |
58 | Correct | 17 ms | 3308 KB | Output is correct |
59 | Correct | 14 ms | 2668 KB | Output is correct |
60 | Correct | 17 ms | 2668 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 0 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 0 ms | 364 KB | Output is correct |
11 | Correct | 0 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
16 | Correct | 1 ms | 364 KB | Output is correct |
17 | Correct | 1 ms | 364 KB | Output is correct |
18 | Correct | 1 ms | 364 KB | Output is correct |
19 | Correct | 1 ms | 364 KB | Output is correct |
20 | Correct | 1 ms | 512 KB | Output is correct |
21 | Correct | 1 ms | 364 KB | Output is correct |
22 | Correct | 1 ms | 364 KB | Output is correct |
23 | Correct | 1 ms | 364 KB | Output is correct |
24 | Correct | 1 ms | 364 KB | Output is correct |
25 | Correct | 1 ms | 492 KB | Output is correct |
26 | Correct | 1 ms | 364 KB | Output is correct |
27 | Correct | 1 ms | 364 KB | Output is correct |
28 | Correct | 1 ms | 364 KB | Output is correct |
29 | Correct | 1 ms | 364 KB | Output is correct |
30 | Correct | 1 ms | 364 KB | Output is correct |
31 | Correct | 1 ms | 492 KB | Output is correct |
32 | Correct | 1 ms | 492 KB | Output is correct |
33 | Correct | 1 ms | 492 KB | Output is correct |
34 | Correct | 1 ms | 492 KB | Output is correct |
35 | Correct | 1 ms | 364 KB | Output is correct |
36 | Correct | 1 ms | 492 KB | Output is correct |
37 | Correct | 1 ms | 364 KB | Output is correct |
38 | Correct | 1 ms | 364 KB | Output is correct |
39 | Correct | 1 ms | 492 KB | Output is correct |
40 | Correct | 1 ms | 492 KB | Output is correct |
41 | Correct | 1 ms | 364 KB | Output is correct |
42 | Correct | 1 ms | 492 KB | Output is correct |
43 | Correct | 1 ms | 492 KB | Output is correct |
44 | Correct | 1 ms | 364 KB | Output is correct |
45 | Correct | 1 ms | 492 KB | Output is correct |
46 | Correct | 15 ms | 4584 KB | Output is correct |
47 | Correct | 22 ms | 3052 KB | Output is correct |
48 | Correct | 21 ms | 2796 KB | Output is correct |
49 | Correct | 17 ms | 3056 KB | Output is correct |
50 | Correct | 20 ms | 2668 KB | Output is correct |
51 | Correct | 23 ms | 2688 KB | Output is correct |
52 | Correct | 12 ms | 1516 KB | Output is correct |
53 | Correct | 7 ms | 1132 KB | Output is correct |
54 | Correct | 21 ms | 2668 KB | Output is correct |
55 | Correct | 23 ms | 2668 KB | Output is correct |
56 | Correct | 14 ms | 2668 KB | Output is correct |
57 | Correct | 17 ms | 3692 KB | Output is correct |
58 | Correct | 17 ms | 3308 KB | Output is correct |
59 | Correct | 14 ms | 2668 KB | Output is correct |
60 | Correct | 17 ms | 2668 KB | Output is correct |
61 | Correct | 71 ms | 20060 KB | Output is correct |
62 | Correct | 89 ms | 16096 KB | Output is correct |
63 | Correct | 116 ms | 13796 KB | Output is correct |
64 | Correct | 94 ms | 12012 KB | Output is correct |
65 | Correct | 87 ms | 12012 KB | Output is correct |
66 | Correct | 118 ms | 12156 KB | Output is correct |
67 | Correct | 94 ms | 9836 KB | Output is correct |
68 | Correct | 47 ms | 5100 KB | Output is correct |
69 | Correct | 100 ms | 12140 KB | Output is correct |
70 | Correct | 114 ms | 12140 KB | Output is correct |
71 | Correct | 63 ms | 12012 KB | Output is correct |
72 | Correct | 87 ms | 15344 KB | Output is correct |
73 | Correct | 76 ms | 13412 KB | Output is correct |
74 | Correct | 72 ms | 12012 KB | Output is correct |
75 | Correct | 76 ms | 12140 KB | Output is correct |