답안 #1015605

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1015605 2024-07-06T15:04:13 Z elitewantsyou Bigger segments (IZhO19_segments) C++14
27 / 100
43 ms 2396 KB
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

#define fi first
#define se second

const int N = 505;
const int mod = 998244353;

using namespace std;

const long long inf = 1e18;

int n;
int a[N];
long long s[N];
long long d[N][N];

int main() {
    ios_base::sync_with_stdio(0);
    #ifdef zxc
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        s[i] = s[i - 1] + a[i];
        d[0][i] = inf;
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            d[i][j] = inf;
        }
        d[i][1] = s[i];
        for (int j = 2; j <= i; j++) {
            for (int h = i; h >= 1; h--) {
                if (d[h - 1][j - 1] <= s[i] - s[h - 1]) {
                    d[i][j] = min(d[i][j], s[i] - s[h - 1]);
                }
            }
            if (d[i][j] == inf) {
                break;
            }
            /*
            if (d[i][j - 1] < d[i][j]) {
                cout << i << " " << j << " " << d[i][j - 1] << " " << d[i][j] << "\n";
                exit(0);
            }
            */
            assert (d[i][j] <= d[i][j - 1]);
        }
    }
    int res = n;
    while (d[n][res] == inf) {
        res -= 1;
    }
    cout << res << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 2 ms 2396 KB Output is correct
18 Correct 8 ms 2300 KB Output is correct
19 Correct 34 ms 2220 KB Output is correct
20 Correct 43 ms 2384 KB Output is correct
21 Correct 5 ms 2392 KB Output is correct
22 Correct 3 ms 1884 KB Output is correct
23 Correct 2 ms 1628 KB Output is correct
24 Correct 5 ms 2396 KB Output is correct
25 Correct 5 ms 2360 KB Output is correct
26 Correct 42 ms 2320 KB Output is correct
27 Correct 19 ms 2252 KB Output is correct
28 Correct 10 ms 2320 KB Output is correct
29 Correct 41 ms 2224 KB Output is correct
30 Correct 37 ms 2264 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 2 ms 2396 KB Output is correct
18 Correct 8 ms 2300 KB Output is correct
19 Correct 34 ms 2220 KB Output is correct
20 Correct 43 ms 2384 KB Output is correct
21 Correct 5 ms 2392 KB Output is correct
22 Correct 3 ms 1884 KB Output is correct
23 Correct 2 ms 1628 KB Output is correct
24 Correct 5 ms 2396 KB Output is correct
25 Correct 5 ms 2360 KB Output is correct
26 Correct 42 ms 2320 KB Output is correct
27 Correct 19 ms 2252 KB Output is correct
28 Correct 10 ms 2320 KB Output is correct
29 Correct 41 ms 2224 KB Output is correct
30 Correct 37 ms 2264 KB Output is correct
31 Runtime error 1 ms 600 KB Execution killed with signal 11
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 2 ms 2396 KB Output is correct
18 Correct 8 ms 2300 KB Output is correct
19 Correct 34 ms 2220 KB Output is correct
20 Correct 43 ms 2384 KB Output is correct
21 Correct 5 ms 2392 KB Output is correct
22 Correct 3 ms 1884 KB Output is correct
23 Correct 2 ms 1628 KB Output is correct
24 Correct 5 ms 2396 KB Output is correct
25 Correct 5 ms 2360 KB Output is correct
26 Correct 42 ms 2320 KB Output is correct
27 Correct 19 ms 2252 KB Output is correct
28 Correct 10 ms 2320 KB Output is correct
29 Correct 41 ms 2224 KB Output is correct
30 Correct 37 ms 2264 KB Output is correct
31 Runtime error 1 ms 600 KB Execution killed with signal 11
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 2 ms 2396 KB Output is correct
18 Correct 8 ms 2300 KB Output is correct
19 Correct 34 ms 2220 KB Output is correct
20 Correct 43 ms 2384 KB Output is correct
21 Correct 5 ms 2392 KB Output is correct
22 Correct 3 ms 1884 KB Output is correct
23 Correct 2 ms 1628 KB Output is correct
24 Correct 5 ms 2396 KB Output is correct
25 Correct 5 ms 2360 KB Output is correct
26 Correct 42 ms 2320 KB Output is correct
27 Correct 19 ms 2252 KB Output is correct
28 Correct 10 ms 2320 KB Output is correct
29 Correct 41 ms 2224 KB Output is correct
30 Correct 37 ms 2264 KB Output is correct
31 Runtime error 1 ms 600 KB Execution killed with signal 11
32 Halted 0 ms 0 KB -