답안 #990882

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
990882 2024-05-31T17:19:14 Z ToniB Bigger segments (IZhO19_segments) C++17
27 / 100
1500 ms 35676 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 3005;
typedef long long ll;

int n, a[N], dp[N][N];
ll pre[N];

ll sum(int i, int j) {
	if (i) return pre[j] - pre[i - 1];
	return pre[j];
}

int main(){
	cin >> n;
	for (int i = 0; i < n; ++i) cin >> a[i];
	
	pre[0] = a[0];
	for (int i = 1; i < n; ++i) pre[i] = a[i] + pre[i - 1];
	
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) dp[i][j] = -1e9;
	}
	
	for (int i = 0; i < n; ++i) {
		dp[0][i] = 1;
	}
	
	for (int i = 1; i < n; ++i) {
		for (int j = i; j < n; ++j) {
			for (int k = 0; k < i; ++k) {
				if (sum(i, j) >= sum(k, i - 1)) dp[i][j] = max(dp[i][j], dp[k][i - 1] + 1);
			}
		}
	}
	
	int ans = 0;
	for (int i = 0; i < n; ++i) ans = max(ans, dp[i][n - 1]);
	
	cout << ans << "\n";
	
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 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 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 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 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 22 ms 6696 KB Output is correct
17 Correct 21 ms 6492 KB Output is correct
18 Correct 21 ms 6704 KB Output is correct
19 Correct 22 ms 6492 KB Output is correct
20 Correct 23 ms 6708 KB Output is correct
21 Correct 26 ms 6492 KB Output is correct
22 Correct 12 ms 6492 KB Output is correct
23 Correct 6 ms 4444 KB Output is correct
24 Correct 21 ms 6692 KB Output is correct
25 Correct 21 ms 6492 KB Output is correct
26 Correct 20 ms 6492 KB Output is correct
27 Correct 23 ms 6492 KB Output is correct
28 Correct 20 ms 6492 KB Output is correct
29 Correct 20 ms 6700 KB Output is correct
30 Correct 21 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 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 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 22 ms 6696 KB Output is correct
17 Correct 21 ms 6492 KB Output is correct
18 Correct 21 ms 6704 KB Output is correct
19 Correct 22 ms 6492 KB Output is correct
20 Correct 23 ms 6708 KB Output is correct
21 Correct 26 ms 6492 KB Output is correct
22 Correct 12 ms 6492 KB Output is correct
23 Correct 6 ms 4444 KB Output is correct
24 Correct 21 ms 6692 KB Output is correct
25 Correct 21 ms 6492 KB Output is correct
26 Correct 20 ms 6492 KB Output is correct
27 Correct 23 ms 6492 KB Output is correct
28 Correct 20 ms 6492 KB Output is correct
29 Correct 20 ms 6700 KB Output is correct
30 Correct 21 ms 6492 KB Output is correct
31 Execution timed out 1561 ms 35676 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 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 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 22 ms 6696 KB Output is correct
17 Correct 21 ms 6492 KB Output is correct
18 Correct 21 ms 6704 KB Output is correct
19 Correct 22 ms 6492 KB Output is correct
20 Correct 23 ms 6708 KB Output is correct
21 Correct 26 ms 6492 KB Output is correct
22 Correct 12 ms 6492 KB Output is correct
23 Correct 6 ms 4444 KB Output is correct
24 Correct 21 ms 6692 KB Output is correct
25 Correct 21 ms 6492 KB Output is correct
26 Correct 20 ms 6492 KB Output is correct
27 Correct 23 ms 6492 KB Output is correct
28 Correct 20 ms 6492 KB Output is correct
29 Correct 20 ms 6700 KB Output is correct
30 Correct 21 ms 6492 KB Output is correct
31 Execution timed out 1561 ms 35676 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 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 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 22 ms 6696 KB Output is correct
17 Correct 21 ms 6492 KB Output is correct
18 Correct 21 ms 6704 KB Output is correct
19 Correct 22 ms 6492 KB Output is correct
20 Correct 23 ms 6708 KB Output is correct
21 Correct 26 ms 6492 KB Output is correct
22 Correct 12 ms 6492 KB Output is correct
23 Correct 6 ms 4444 KB Output is correct
24 Correct 21 ms 6692 KB Output is correct
25 Correct 21 ms 6492 KB Output is correct
26 Correct 20 ms 6492 KB Output is correct
27 Correct 23 ms 6492 KB Output is correct
28 Correct 20 ms 6492 KB Output is correct
29 Correct 20 ms 6700 KB Output is correct
30 Correct 21 ms 6492 KB Output is correct
31 Execution timed out 1561 ms 35676 KB Time limit exceeded
32 Halted 0 ms 0 KB -