답안 #961458

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
961458 2024-04-12T06:35:47 Z ByeWorld Cigle (COI21_cigle) C++14
48 / 100
1000 ms 13912 KB
#include <bits/stdc++.h>
#include <random>
#define ll long long
#define int long long
#define fi first
#define se second
#define pb push_back
#define md ((l+r)>>1)
#define lf (id<<1)
#define rg ((id<<1)|1)
#define ld long double
using namespace std;
typedef pair<int,int> pii;
typedef pair<pii,pii> ipii;
const int MAXN = 5e3+10;
const int MAXA = 1e6+10;
const int INF = 2e9+10;
const int LOG = 30;
const int MOD = 1e9+7;
void chmx(int &a, int b){
	a = max(a, b);
}

int n;
int a[MAXN], pr[MAXN], dp[MAXN][MAXN];

signed main() {
	// ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> n;
	for(int i=1; i<=n; i++){
		cin >> a[i];
		pr[i] = pr[i-1] + a[i];
	}
	for(int r=1; r<=n; r++){
		for(int k=r-1; k>=1; k--) chmx(dp[r][r], dp[k][r-1]);
		
		for(int l=1; l<=r-1; l++){
			// build dp[l][r], row atas

			int down = 0, idx = l, add = 0;
			for(int k=l-1; k>=1; k--){
				// cek dp[k][l], row bawah
				chmx(dp[l][r], dp[k][l-1]+add);

				down += a[k];
				while(idx+1<=r-1 && pr[idx]-pr[l-1] < down){ // r gk boleh dipake
					// atas masi kurang
					idx++;
				} 
				if(pr[idx]-pr[l-1] == down) add++; // kena 4
			}
		}
	}

	int ANS = 0;
	for(int i=1; i<=n; i++) ANS = max(ANS, dp[i][n]);
	cout << ANS << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 1 ms 600 KB Output is correct
17 Correct 1 ms 600 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 3448 KB Output is correct
2 Correct 48 ms 3412 KB Output is correct
3 Correct 44 ms 3408 KB Output is correct
4 Correct 50 ms 3308 KB Output is correct
5 Correct 47 ms 3352 KB Output is correct
6 Correct 79 ms 3408 KB Output is correct
7 Correct 70 ms 3404 KB Output is correct
8 Correct 75 ms 3408 KB Output is correct
9 Correct 72 ms 3268 KB Output is correct
10 Correct 67 ms 3408 KB Output is correct
11 Correct 63 ms 3420 KB Output is correct
12 Correct 51 ms 3204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 1 ms 600 KB Output is correct
17 Correct 1 ms 600 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 600 KB Output is correct
21 Correct 47 ms 3448 KB Output is correct
22 Correct 48 ms 3412 KB Output is correct
23 Correct 44 ms 3408 KB Output is correct
24 Correct 50 ms 3308 KB Output is correct
25 Correct 47 ms 3352 KB Output is correct
26 Correct 79 ms 3408 KB Output is correct
27 Correct 70 ms 3404 KB Output is correct
28 Correct 75 ms 3408 KB Output is correct
29 Correct 72 ms 3268 KB Output is correct
30 Correct 67 ms 3408 KB Output is correct
31 Correct 63 ms 3420 KB Output is correct
32 Correct 51 ms 3204 KB Output is correct
33 Correct 56 ms 3332 KB Output is correct
34 Correct 47 ms 3532 KB Output is correct
35 Correct 48 ms 3408 KB Output is correct
36 Correct 50 ms 3412 KB Output is correct
37 Correct 71 ms 3412 KB Output is correct
38 Correct 72 ms 3408 KB Output is correct
39 Correct 99 ms 3380 KB Output is correct
40 Correct 97 ms 3308 KB Output is correct
41 Correct 77 ms 3368 KB Output is correct
42 Correct 69 ms 3412 KB Output is correct
43 Correct 72 ms 3308 KB Output is correct
44 Correct 100 ms 3236 KB Output is correct
45 Correct 71 ms 3556 KB Output is correct
46 Correct 74 ms 3364 KB Output is correct
47 Correct 101 ms 3404 KB Output is correct
48 Correct 78 ms 3368 KB Output is correct
49 Correct 63 ms 3264 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 1 ms 600 KB Output is correct
17 Correct 1 ms 600 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 600 KB Output is correct
21 Correct 47 ms 3448 KB Output is correct
22 Correct 48 ms 3412 KB Output is correct
23 Correct 44 ms 3408 KB Output is correct
24 Correct 50 ms 3308 KB Output is correct
25 Correct 47 ms 3352 KB Output is correct
26 Correct 79 ms 3408 KB Output is correct
27 Correct 70 ms 3404 KB Output is correct
28 Correct 75 ms 3408 KB Output is correct
29 Correct 72 ms 3268 KB Output is correct
30 Correct 67 ms 3408 KB Output is correct
31 Correct 63 ms 3420 KB Output is correct
32 Correct 51 ms 3204 KB Output is correct
33 Correct 56 ms 3332 KB Output is correct
34 Correct 47 ms 3532 KB Output is correct
35 Correct 48 ms 3408 KB Output is correct
36 Correct 50 ms 3412 KB Output is correct
37 Correct 71 ms 3412 KB Output is correct
38 Correct 72 ms 3408 KB Output is correct
39 Correct 99 ms 3380 KB Output is correct
40 Correct 97 ms 3308 KB Output is correct
41 Correct 77 ms 3368 KB Output is correct
42 Correct 69 ms 3412 KB Output is correct
43 Correct 72 ms 3308 KB Output is correct
44 Correct 100 ms 3236 KB Output is correct
45 Correct 71 ms 3556 KB Output is correct
46 Correct 74 ms 3364 KB Output is correct
47 Correct 101 ms 3404 KB Output is correct
48 Correct 78 ms 3368 KB Output is correct
49 Correct 63 ms 3264 KB Output is correct
50 Execution timed out 1058 ms 13912 KB Time limit exceeded
51 Halted 0 ms 0 KB -