답안 #159066

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
159066 2019-10-20T12:37:09 Z mrboorger Bigger segments (IZhO19_segments) C++17
37 / 100
119 ms 57848 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#include "interactive.h"

#define pb push_back
#define F first
#define S second
#define ll long long
#define ld long double
#define sqr(x) (x) * (x)
//#define all(a) a.begin(), a.end()

using namespace std;

const int maxn = 3005;
const int inf = 10000000;

int dp[maxn][maxn];
int a[maxn];
ll sum[maxn];

ll f(int l, int r)
{
    return sum[r] - sum[l - 1];
}

int main()
{
#ifdef LOCAL
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // LOCAL
//    ios_base::sync_with_stdio(0);
//    cin.tie(0);
//    cout.tie(0);
    int n;
    cin >> n;
    for(int i = 0; i < n; ++i)
    {
        cin >> a[i];
        sum[i + 1] = a[i] + sum[i];
    }
    for(int i = 0; i <= n; ++i)
        for(int j = 0; j <= i + 1; ++j)
            dp[i][j] = inf;
    dp[0][0] = 0;
    dp[1][1] = 1;
    for(int i = 1; i < n; ++i)
        for(int j = 0; j <= i + 1; ++j)
    {
        if (dp[i][j] == inf) continue;
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + 1);
        {
            ll q = f(i - dp[i][j] + 1, i);
            int l = i + 1, r = n;
            int b = inf;
            while(l <= r)
            {
                int m = (l + r) / 2;
                if (f(i + 1, m) >= q)
                {
                    b = min(b, m);
                    r = m - 1;
                }
                else
                {
                    l = m + 1;
                }
            }
            if (b < inf)
            {
                dp[b][j + 1] = min(dp[b][j + 1], b - i);
            }
        }
    }
    int ans = 0;
    for(int j = 1; j <= n; ++j)
        if (dp[n][j] != inf) ans = max(ans, j);
    cout << ans << endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 4 ms 2808 KB Output is correct
17 Correct 4 ms 2808 KB Output is correct
18 Correct 5 ms 2808 KB Output is correct
19 Correct 6 ms 2780 KB Output is correct
20 Correct 6 ms 2808 KB Output is correct
21 Correct 5 ms 2808 KB Output is correct
22 Correct 4 ms 2300 KB Output is correct
23 Correct 3 ms 1784 KB Output is correct
24 Correct 4 ms 2808 KB Output is correct
25 Correct 5 ms 2808 KB Output is correct
26 Correct 6 ms 2808 KB Output is correct
27 Correct 5 ms 2808 KB Output is correct
28 Correct 5 ms 2808 KB Output is correct
29 Correct 6 ms 2808 KB Output is correct
30 Correct 6 ms 2808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 4 ms 2808 KB Output is correct
17 Correct 4 ms 2808 KB Output is correct
18 Correct 5 ms 2808 KB Output is correct
19 Correct 6 ms 2780 KB Output is correct
20 Correct 6 ms 2808 KB Output is correct
21 Correct 5 ms 2808 KB Output is correct
22 Correct 4 ms 2300 KB Output is correct
23 Correct 3 ms 1784 KB Output is correct
24 Correct 4 ms 2808 KB Output is correct
25 Correct 5 ms 2808 KB Output is correct
26 Correct 6 ms 2808 KB Output is correct
27 Correct 5 ms 2808 KB Output is correct
28 Correct 5 ms 2808 KB Output is correct
29 Correct 6 ms 2808 KB Output is correct
30 Correct 6 ms 2808 KB Output is correct
31 Correct 30 ms 28024 KB Output is correct
32 Correct 31 ms 28024 KB Output is correct
33 Correct 42 ms 28024 KB Output is correct
34 Correct 91 ms 28048 KB Output is correct
35 Correct 119 ms 28060 KB Output is correct
36 Correct 41 ms 28024 KB Output is correct
37 Correct 31 ms 22136 KB Output is correct
38 Correct 23 ms 16504 KB Output is correct
39 Correct 39 ms 28024 KB Output is correct
40 Correct 42 ms 28024 KB Output is correct
41 Correct 116 ms 28024 KB Output is correct
42 Correct 101 ms 28044 KB Output is correct
43 Correct 50 ms 28024 KB Output is correct
44 Correct 116 ms 28024 KB Output is correct
45 Correct 114 ms 28152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 4 ms 2808 KB Output is correct
17 Correct 4 ms 2808 KB Output is correct
18 Correct 5 ms 2808 KB Output is correct
19 Correct 6 ms 2780 KB Output is correct
20 Correct 6 ms 2808 KB Output is correct
21 Correct 5 ms 2808 KB Output is correct
22 Correct 4 ms 2300 KB Output is correct
23 Correct 3 ms 1784 KB Output is correct
24 Correct 4 ms 2808 KB Output is correct
25 Correct 5 ms 2808 KB Output is correct
26 Correct 6 ms 2808 KB Output is correct
27 Correct 5 ms 2808 KB Output is correct
28 Correct 5 ms 2808 KB Output is correct
29 Correct 6 ms 2808 KB Output is correct
30 Correct 6 ms 2808 KB Output is correct
31 Correct 30 ms 28024 KB Output is correct
32 Correct 31 ms 28024 KB Output is correct
33 Correct 42 ms 28024 KB Output is correct
34 Correct 91 ms 28048 KB Output is correct
35 Correct 119 ms 28060 KB Output is correct
36 Correct 41 ms 28024 KB Output is correct
37 Correct 31 ms 22136 KB Output is correct
38 Correct 23 ms 16504 KB Output is correct
39 Correct 39 ms 28024 KB Output is correct
40 Correct 42 ms 28024 KB Output is correct
41 Correct 116 ms 28024 KB Output is correct
42 Correct 101 ms 28044 KB Output is correct
43 Correct 50 ms 28024 KB Output is correct
44 Correct 116 ms 28024 KB Output is correct
45 Correct 114 ms 28152 KB Output is correct
46 Runtime error 111 ms 57848 KB Execution killed with signal 11 (could be triggered by violating memory limits)
47 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 4 ms 2808 KB Output is correct
17 Correct 4 ms 2808 KB Output is correct
18 Correct 5 ms 2808 KB Output is correct
19 Correct 6 ms 2780 KB Output is correct
20 Correct 6 ms 2808 KB Output is correct
21 Correct 5 ms 2808 KB Output is correct
22 Correct 4 ms 2300 KB Output is correct
23 Correct 3 ms 1784 KB Output is correct
24 Correct 4 ms 2808 KB Output is correct
25 Correct 5 ms 2808 KB Output is correct
26 Correct 6 ms 2808 KB Output is correct
27 Correct 5 ms 2808 KB Output is correct
28 Correct 5 ms 2808 KB Output is correct
29 Correct 6 ms 2808 KB Output is correct
30 Correct 6 ms 2808 KB Output is correct
31 Correct 30 ms 28024 KB Output is correct
32 Correct 31 ms 28024 KB Output is correct
33 Correct 42 ms 28024 KB Output is correct
34 Correct 91 ms 28048 KB Output is correct
35 Correct 119 ms 28060 KB Output is correct
36 Correct 41 ms 28024 KB Output is correct
37 Correct 31 ms 22136 KB Output is correct
38 Correct 23 ms 16504 KB Output is correct
39 Correct 39 ms 28024 KB Output is correct
40 Correct 42 ms 28024 KB Output is correct
41 Correct 116 ms 28024 KB Output is correct
42 Correct 101 ms 28044 KB Output is correct
43 Correct 50 ms 28024 KB Output is correct
44 Correct 116 ms 28024 KB Output is correct
45 Correct 114 ms 28152 KB Output is correct
46 Runtime error 111 ms 57848 KB Execution killed with signal 11 (could be triggered by violating memory limits)
47 Halted 0 ms 0 KB -