# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
334202 | 2020-12-08T15:50:53 Z | BeanZ | Bigger segments (IZhO19_segments) | C++14 | 90 ms | 71020 KB |
// I_Love_LPL #include <bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' const int N = 3e3 + 5; long long mod = 1e9 + 7; const int lim = 5e5; const int lg = 20; const int base = 311; const long double eps = 1e-6; ll a[N], sum[N], dp[N][N]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); if (fopen("test.inp", "r")){ freopen("test.inp", "r", stdin); freopen("test.out", "w", stdout); } ll n; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i], sum[i] = sum[i - 1] + a[i]; for (int i = 1; i <= n; i++){ for (int j = 1; j <= n; j++){ dp[i][j] = -1e9; } } for (int i = 1; i <= n; i++) dp[1][i] = 1; for (int i = 2; i <= n; i++){ ll best = -1e9; ll l = i - 1; for (int j = i; j <= n; j++){ ll tot = sum[j] - sum[i - 1]; while (l > 0 && (sum[i - 1] - sum[l - 1]) <= tot){ best = max(best, dp[l][i - 1]); l--; } dp[i][j] = best + 1; } } //cout << dp[1][1] << " " << dp[2][3] << endl; ll ans = 0; for (int i = 1; i <= n; i++){ ans = max(ans, dp[i][n]); } cout << ans; } /* Ans: Out: */
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 | 1 ms | 492 KB | Output is correct |
5 | Correct | 1 ms | 512 KB | Output is correct |
6 | Correct | 1 ms | 512 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 | 492 KB | Output is correct |
10 | Correct | 1 ms | 492 KB | Output is correct |
11 | Correct | 1 ms | 512 KB | Output is correct |
12 | Correct | 1 ms | 492 KB | Output is correct |
13 | Correct | 1 ms | 492 KB | Output is correct |
14 | Correct | 1 ms | 492 KB | Output is correct |
15 | 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 | 1 ms | 492 KB | Output is correct |
5 | Correct | 1 ms | 512 KB | Output is correct |
6 | Correct | 1 ms | 512 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 | 492 KB | Output is correct |
10 | Correct | 1 ms | 492 KB | Output is correct |
11 | Correct | 1 ms | 512 KB | Output is correct |
12 | Correct | 1 ms | 492 KB | Output is correct |
13 | Correct | 1 ms | 492 KB | Output is correct |
14 | Correct | 1 ms | 492 KB | Output is correct |
15 | Correct | 1 ms | 492 KB | Output is correct |
16 | Correct | 3 ms | 4332 KB | Output is correct |
17 | Correct | 3 ms | 4332 KB | Output is correct |
18 | Correct | 3 ms | 4332 KB | Output is correct |
19 | Correct | 3 ms | 4332 KB | Output is correct |
20 | Correct | 3 ms | 4332 KB | Output is correct |
21 | Correct | 3 ms | 4332 KB | Output is correct |
22 | Correct | 3 ms | 3180 KB | Output is correct |
23 | Correct | 2 ms | 2284 KB | Output is correct |
24 | Correct | 4 ms | 4332 KB | Output is correct |
25 | Correct | 3 ms | 4332 KB | Output is correct |
26 | Correct | 3 ms | 4332 KB | Output is correct |
27 | Correct | 3 ms | 4332 KB | Output is correct |
28 | Correct | 3 ms | 4332 KB | Output is correct |
29 | Correct | 3 ms | 4332 KB | Output is correct |
30 | Correct | 3 ms | 4332 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 | 1 ms | 492 KB | Output is correct |
5 | Correct | 1 ms | 512 KB | Output is correct |
6 | Correct | 1 ms | 512 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 | 492 KB | Output is correct |
10 | Correct | 1 ms | 492 KB | Output is correct |
11 | Correct | 1 ms | 512 KB | Output is correct |
12 | Correct | 1 ms | 492 KB | Output is correct |
13 | Correct | 1 ms | 492 KB | Output is correct |
14 | Correct | 1 ms | 492 KB | Output is correct |
15 | Correct | 1 ms | 492 KB | Output is correct |
16 | Correct | 3 ms | 4332 KB | Output is correct |
17 | Correct | 3 ms | 4332 KB | Output is correct |
18 | Correct | 3 ms | 4332 KB | Output is correct |
19 | Correct | 3 ms | 4332 KB | Output is correct |
20 | Correct | 3 ms | 4332 KB | Output is correct |
21 | Correct | 3 ms | 4332 KB | Output is correct |
22 | Correct | 3 ms | 3180 KB | Output is correct |
23 | Correct | 2 ms | 2284 KB | Output is correct |
24 | Correct | 4 ms | 4332 KB | Output is correct |
25 | Correct | 3 ms | 4332 KB | Output is correct |
26 | Correct | 3 ms | 4332 KB | Output is correct |
27 | Correct | 3 ms | 4332 KB | Output is correct |
28 | Correct | 3 ms | 4332 KB | Output is correct |
29 | Correct | 3 ms | 4332 KB | Output is correct |
30 | Correct | 3 ms | 4332 KB | Output is correct |
31 | Correct | 63 ms | 70892 KB | Output is correct |
32 | Correct | 60 ms | 70892 KB | Output is correct |
33 | Correct | 76 ms | 70892 KB | Output is correct |
34 | Correct | 52 ms | 71020 KB | Output is correct |
35 | Correct | 62 ms | 71020 KB | Output is correct |
36 | Correct | 71 ms | 71020 KB | Output is correct |
37 | Correct | 53 ms | 59244 KB | Output is correct |
38 | Correct | 35 ms | 39660 KB | Output is correct |
39 | Correct | 75 ms | 70892 KB | Output is correct |
40 | Correct | 63 ms | 71020 KB | Output is correct |
41 | Correct | 89 ms | 71020 KB | Output is correct |
42 | Correct | 63 ms | 70892 KB | Output is correct |
43 | Correct | 90 ms | 70892 KB | Output is correct |
44 | Correct | 69 ms | 70892 KB | Output is correct |
45 | Correct | 59 ms | 70892 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 | 1 ms | 492 KB | Output is correct |
5 | Correct | 1 ms | 512 KB | Output is correct |
6 | Correct | 1 ms | 512 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 | 492 KB | Output is correct |
10 | Correct | 1 ms | 492 KB | Output is correct |
11 | Correct | 1 ms | 512 KB | Output is correct |
12 | Correct | 1 ms | 492 KB | Output is correct |
13 | Correct | 1 ms | 492 KB | Output is correct |
14 | Correct | 1 ms | 492 KB | Output is correct |
15 | Correct | 1 ms | 492 KB | Output is correct |
16 | Correct | 3 ms | 4332 KB | Output is correct |
17 | Correct | 3 ms | 4332 KB | Output is correct |
18 | Correct | 3 ms | 4332 KB | Output is correct |
19 | Correct | 3 ms | 4332 KB | Output is correct |
20 | Correct | 3 ms | 4332 KB | Output is correct |
21 | Correct | 3 ms | 4332 KB | Output is correct |
22 | Correct | 3 ms | 3180 KB | Output is correct |
23 | Correct | 2 ms | 2284 KB | Output is correct |
24 | Correct | 4 ms | 4332 KB | Output is correct |
25 | Correct | 3 ms | 4332 KB | Output is correct |
26 | Correct | 3 ms | 4332 KB | Output is correct |
27 | Correct | 3 ms | 4332 KB | Output is correct |
28 | Correct | 3 ms | 4332 KB | Output is correct |
29 | Correct | 3 ms | 4332 KB | Output is correct |
30 | Correct | 3 ms | 4332 KB | Output is correct |
31 | Correct | 63 ms | 70892 KB | Output is correct |
32 | Correct | 60 ms | 70892 KB | Output is correct |
33 | Correct | 76 ms | 70892 KB | Output is correct |
34 | Correct | 52 ms | 71020 KB | Output is correct |
35 | Correct | 62 ms | 71020 KB | Output is correct |
36 | Correct | 71 ms | 71020 KB | Output is correct |
37 | Correct | 53 ms | 59244 KB | Output is correct |
38 | Correct | 35 ms | 39660 KB | Output is correct |
39 | Correct | 75 ms | 70892 KB | Output is correct |
40 | Correct | 63 ms | 71020 KB | Output is correct |
41 | Correct | 89 ms | 71020 KB | Output is correct |
42 | Correct | 63 ms | 70892 KB | Output is correct |
43 | Correct | 90 ms | 70892 KB | Output is correct |
44 | Correct | 69 ms | 70892 KB | Output is correct |
45 | Correct | 59 ms | 70892 KB | Output is correct |
46 | Runtime error | 5 ms | 748 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
47 | Halted | 0 ms | 0 KB | - |
# | 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 | 1 ms | 492 KB | Output is correct |
5 | Correct | 1 ms | 512 KB | Output is correct |
6 | Correct | 1 ms | 512 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 | 492 KB | Output is correct |
10 | Correct | 1 ms | 492 KB | Output is correct |
11 | Correct | 1 ms | 512 KB | Output is correct |
12 | Correct | 1 ms | 492 KB | Output is correct |
13 | Correct | 1 ms | 492 KB | Output is correct |
14 | Correct | 1 ms | 492 KB | Output is correct |
15 | Correct | 1 ms | 492 KB | Output is correct |
16 | Correct | 3 ms | 4332 KB | Output is correct |
17 | Correct | 3 ms | 4332 KB | Output is correct |
18 | Correct | 3 ms | 4332 KB | Output is correct |
19 | Correct | 3 ms | 4332 KB | Output is correct |
20 | Correct | 3 ms | 4332 KB | Output is correct |
21 | Correct | 3 ms | 4332 KB | Output is correct |
22 | Correct | 3 ms | 3180 KB | Output is correct |
23 | Correct | 2 ms | 2284 KB | Output is correct |
24 | Correct | 4 ms | 4332 KB | Output is correct |
25 | Correct | 3 ms | 4332 KB | Output is correct |
26 | Correct | 3 ms | 4332 KB | Output is correct |
27 | Correct | 3 ms | 4332 KB | Output is correct |
28 | Correct | 3 ms | 4332 KB | Output is correct |
29 | Correct | 3 ms | 4332 KB | Output is correct |
30 | Correct | 3 ms | 4332 KB | Output is correct |
31 | Correct | 63 ms | 70892 KB | Output is correct |
32 | Correct | 60 ms | 70892 KB | Output is correct |
33 | Correct | 76 ms | 70892 KB | Output is correct |
34 | Correct | 52 ms | 71020 KB | Output is correct |
35 | Correct | 62 ms | 71020 KB | Output is correct |
36 | Correct | 71 ms | 71020 KB | Output is correct |
37 | Correct | 53 ms | 59244 KB | Output is correct |
38 | Correct | 35 ms | 39660 KB | Output is correct |
39 | Correct | 75 ms | 70892 KB | Output is correct |
40 | Correct | 63 ms | 71020 KB | Output is correct |
41 | Correct | 89 ms | 71020 KB | Output is correct |
42 | Correct | 63 ms | 70892 KB | Output is correct |
43 | Correct | 90 ms | 70892 KB | Output is correct |
44 | Correct | 69 ms | 70892 KB | Output is correct |
45 | Correct | 59 ms | 70892 KB | Output is correct |
46 | Runtime error | 5 ms | 748 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
47 | Halted | 0 ms | 0 KB | - |