답안 #151340

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
151340 2019-09-02T13:36:22 Z theboatman Bigger segments (IZhO19_segments) C++17
27 / 100
1500 ms 35548 KB
#include <bits/stdc++.h>

#define y1 theboatman
#define make_struct(args...) {args}

using namespace std;

typedef long long ll;

const long long INF = 1e18 + 10;
const int inf = 1e9 + 10;
const int N = 1e6 + 10;

int dp[3000][3000];
vector <ll> pref;

ll get(int l, int r) {
    ll res = pref[r];

    return (l ? res - pref[l - 1] : res);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);

    int n;
    cin >> n;

    vector <int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            dp[i][j] = -inf;
        }
    }

    for(int i = 0; i < n; i++) {
        dp[0][i] = 1;
    }

    pref.resize(n);
    for(int i = 0; i < n; i++) {
        pref[i] = (i ? pref[i - 1] + a[i] : a[i]);
    }

    for(int i = 0; i < n; i++) {
        for(int j = i; j < n; j++) {
            for(int to = j + 1; to < n; to++) {
                if (get(i, j) <= get(j + 1, to)) {

                    dp[j + 1][to] = max(dp[j + 1][to], dp[i][j] + 1);
                }
            }
        }
    }

    int ans = 0;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            ans = max(ans, dp[i][j]);
        }
    }

    cout << ans << "\n";
    return 0;
}
/*
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 1 ms 504 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 504 KB Output is correct
14 Correct 2 ms 504 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 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 1 ms 504 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 504 KB Output is correct
14 Correct 2 ms 504 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 37 ms 3320 KB Output is correct
17 Correct 37 ms 3320 KB Output is correct
18 Correct 37 ms 3320 KB Output is correct
19 Correct 34 ms 3320 KB Output is correct
20 Correct 37 ms 3292 KB Output is correct
21 Correct 37 ms 3320 KB Output is correct
22 Correct 21 ms 2552 KB Output is correct
23 Correct 11 ms 1912 KB Output is correct
24 Correct 37 ms 3320 KB Output is correct
25 Correct 37 ms 3320 KB Output is correct
26 Correct 41 ms 3320 KB Output is correct
27 Correct 34 ms 3320 KB Output is correct
28 Correct 39 ms 3320 KB Output is correct
29 Correct 40 ms 3320 KB Output is correct
30 Correct 39 ms 3320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 1 ms 504 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 504 KB Output is correct
14 Correct 2 ms 504 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 37 ms 3320 KB Output is correct
17 Correct 37 ms 3320 KB Output is correct
18 Correct 37 ms 3320 KB Output is correct
19 Correct 34 ms 3320 KB Output is correct
20 Correct 37 ms 3292 KB Output is correct
21 Correct 37 ms 3320 KB Output is correct
22 Correct 21 ms 2552 KB Output is correct
23 Correct 11 ms 1912 KB Output is correct
24 Correct 37 ms 3320 KB Output is correct
25 Correct 37 ms 3320 KB Output is correct
26 Correct 41 ms 3320 KB Output is correct
27 Correct 34 ms 3320 KB Output is correct
28 Correct 39 ms 3320 KB Output is correct
29 Correct 40 ms 3320 KB Output is correct
30 Correct 39 ms 3320 KB Output is correct
31 Execution timed out 1549 ms 35548 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 1 ms 504 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 504 KB Output is correct
14 Correct 2 ms 504 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 37 ms 3320 KB Output is correct
17 Correct 37 ms 3320 KB Output is correct
18 Correct 37 ms 3320 KB Output is correct
19 Correct 34 ms 3320 KB Output is correct
20 Correct 37 ms 3292 KB Output is correct
21 Correct 37 ms 3320 KB Output is correct
22 Correct 21 ms 2552 KB Output is correct
23 Correct 11 ms 1912 KB Output is correct
24 Correct 37 ms 3320 KB Output is correct
25 Correct 37 ms 3320 KB Output is correct
26 Correct 41 ms 3320 KB Output is correct
27 Correct 34 ms 3320 KB Output is correct
28 Correct 39 ms 3320 KB Output is correct
29 Correct 40 ms 3320 KB Output is correct
30 Correct 39 ms 3320 KB Output is correct
31 Execution timed out 1549 ms 35548 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 1 ms 504 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 504 KB Output is correct
14 Correct 2 ms 504 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 37 ms 3320 KB Output is correct
17 Correct 37 ms 3320 KB Output is correct
18 Correct 37 ms 3320 KB Output is correct
19 Correct 34 ms 3320 KB Output is correct
20 Correct 37 ms 3292 KB Output is correct
21 Correct 37 ms 3320 KB Output is correct
22 Correct 21 ms 2552 KB Output is correct
23 Correct 11 ms 1912 KB Output is correct
24 Correct 37 ms 3320 KB Output is correct
25 Correct 37 ms 3320 KB Output is correct
26 Correct 41 ms 3320 KB Output is correct
27 Correct 34 ms 3320 KB Output is correct
28 Correct 39 ms 3320 KB Output is correct
29 Correct 40 ms 3320 KB Output is correct
30 Correct 39 ms 3320 KB Output is correct
31 Execution timed out 1549 ms 35548 KB Time limit exceeded
32 Halted 0 ms 0 KB -