Submission #961444

# Submission time Handle Problem Language Result Execution time Memory
961444 2024-04-12T06:12:40 Z ByeWorld Cigle (COI21_cigle) C++14
9 / 100
70 ms 3420 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 l=1; l<=r; 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';
}
# Verdict Execution time Memory Grader output
1 Correct 1 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 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 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 604 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Incorrect 1 ms 604 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 42 ms 3324 KB Output is correct
2 Correct 51 ms 3412 KB Output is correct
3 Correct 42 ms 3420 KB Output is correct
4 Correct 46 ms 3252 KB Output is correct
5 Correct 45 ms 3408 KB Output is correct
6 Incorrect 70 ms 3236 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 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 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 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 604 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Incorrect 1 ms 604 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 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 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 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 604 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Incorrect 1 ms 604 KB Output isn't correct
15 Halted 0 ms 0 KB -