Submission #338808

# Submission time Handle Problem Language Result Execution time Memory
338808 2020-12-24T02:49:03 Z nandonathaniel Bigger segments (IZhO19_segments) C++14
27 / 100
68 ms 4588 KB
#include<bits/stdc++.h>
using namespace std;
const int MAXN=505;

long long dp[MAXN][MAXN],pref[MAXN];
int a[MAXN];
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >> a[i];
		pref[i]=pref[i-1]+a[i];
	}
	memset(dp,-1,sizeof(dp));
	dp[0][0]=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=i;j++){
			for(int k=i-1;k>=0;k--){
				if(dp[k][j-1]!=-1 && pref[k]-pref[dp[k][j-1]-1]<=pref[i]-pref[k]){
					dp[i][j]=k+1;
					break;
				}
			}
		}
	}
	for(int j=n;j>=1;j--){
		if(dp[n][j]!=-1){
			cout << j << '\n';
			break;
		}
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2284 KB Output is correct
2 Correct 1 ms 2284 KB Output is correct
3 Correct 1 ms 2284 KB Output is correct
4 Correct 1 ms 2284 KB Output is correct
5 Correct 1 ms 2304 KB Output is correct
6 Correct 1 ms 2296 KB Output is correct
7 Correct 1 ms 2284 KB Output is correct
8 Correct 2 ms 2284 KB Output is correct
9 Correct 1 ms 2284 KB Output is correct
10 Correct 1 ms 2284 KB Output is correct
11 Correct 1 ms 2284 KB Output is correct
12 Correct 1 ms 2284 KB Output is correct
13 Correct 2 ms 2284 KB Output is correct
14 Correct 1 ms 2284 KB Output is correct
15 Correct 1 ms 2284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2284 KB Output is correct
2 Correct 1 ms 2284 KB Output is correct
3 Correct 1 ms 2284 KB Output is correct
4 Correct 1 ms 2284 KB Output is correct
5 Correct 1 ms 2304 KB Output is correct
6 Correct 1 ms 2296 KB Output is correct
7 Correct 1 ms 2284 KB Output is correct
8 Correct 2 ms 2284 KB Output is correct
9 Correct 1 ms 2284 KB Output is correct
10 Correct 1 ms 2284 KB Output is correct
11 Correct 1 ms 2284 KB Output is correct
12 Correct 1 ms 2284 KB Output is correct
13 Correct 2 ms 2284 KB Output is correct
14 Correct 1 ms 2284 KB Output is correct
15 Correct 1 ms 2284 KB Output is correct
16 Correct 68 ms 2284 KB Output is correct
17 Correct 66 ms 2284 KB Output is correct
18 Correct 61 ms 2412 KB Output is correct
19 Correct 30 ms 2284 KB Output is correct
20 Correct 3 ms 2284 KB Output is correct
21 Correct 63 ms 2284 KB Output is correct
22 Correct 31 ms 2284 KB Output is correct
23 Correct 13 ms 2284 KB Output is correct
24 Correct 62 ms 2412 KB Output is correct
25 Correct 65 ms 2412 KB Output is correct
26 Correct 4 ms 2284 KB Output is correct
27 Correct 59 ms 2284 KB Output is correct
28 Correct 54 ms 2284 KB Output is correct
29 Correct 3 ms 2284 KB Output is correct
30 Correct 13 ms 2284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2284 KB Output is correct
2 Correct 1 ms 2284 KB Output is correct
3 Correct 1 ms 2284 KB Output is correct
4 Correct 1 ms 2284 KB Output is correct
5 Correct 1 ms 2304 KB Output is correct
6 Correct 1 ms 2296 KB Output is correct
7 Correct 1 ms 2284 KB Output is correct
8 Correct 2 ms 2284 KB Output is correct
9 Correct 1 ms 2284 KB Output is correct
10 Correct 1 ms 2284 KB Output is correct
11 Correct 1 ms 2284 KB Output is correct
12 Correct 1 ms 2284 KB Output is correct
13 Correct 2 ms 2284 KB Output is correct
14 Correct 1 ms 2284 KB Output is correct
15 Correct 1 ms 2284 KB Output is correct
16 Correct 68 ms 2284 KB Output is correct
17 Correct 66 ms 2284 KB Output is correct
18 Correct 61 ms 2412 KB Output is correct
19 Correct 30 ms 2284 KB Output is correct
20 Correct 3 ms 2284 KB Output is correct
21 Correct 63 ms 2284 KB Output is correct
22 Correct 31 ms 2284 KB Output is correct
23 Correct 13 ms 2284 KB Output is correct
24 Correct 62 ms 2412 KB Output is correct
25 Correct 65 ms 2412 KB Output is correct
26 Correct 4 ms 2284 KB Output is correct
27 Correct 59 ms 2284 KB Output is correct
28 Correct 54 ms 2284 KB Output is correct
29 Correct 3 ms 2284 KB Output is correct
30 Correct 13 ms 2284 KB Output is correct
31 Runtime error 6 ms 4588 KB Execution killed with signal 11 (could be triggered by violating memory limits)
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2284 KB Output is correct
2 Correct 1 ms 2284 KB Output is correct
3 Correct 1 ms 2284 KB Output is correct
4 Correct 1 ms 2284 KB Output is correct
5 Correct 1 ms 2304 KB Output is correct
6 Correct 1 ms 2296 KB Output is correct
7 Correct 1 ms 2284 KB Output is correct
8 Correct 2 ms 2284 KB Output is correct
9 Correct 1 ms 2284 KB Output is correct
10 Correct 1 ms 2284 KB Output is correct
11 Correct 1 ms 2284 KB Output is correct
12 Correct 1 ms 2284 KB Output is correct
13 Correct 2 ms 2284 KB Output is correct
14 Correct 1 ms 2284 KB Output is correct
15 Correct 1 ms 2284 KB Output is correct
16 Correct 68 ms 2284 KB Output is correct
17 Correct 66 ms 2284 KB Output is correct
18 Correct 61 ms 2412 KB Output is correct
19 Correct 30 ms 2284 KB Output is correct
20 Correct 3 ms 2284 KB Output is correct
21 Correct 63 ms 2284 KB Output is correct
22 Correct 31 ms 2284 KB Output is correct
23 Correct 13 ms 2284 KB Output is correct
24 Correct 62 ms 2412 KB Output is correct
25 Correct 65 ms 2412 KB Output is correct
26 Correct 4 ms 2284 KB Output is correct
27 Correct 59 ms 2284 KB Output is correct
28 Correct 54 ms 2284 KB Output is correct
29 Correct 3 ms 2284 KB Output is correct
30 Correct 13 ms 2284 KB Output is correct
31 Runtime error 6 ms 4588 KB Execution killed with signal 11 (could be triggered by violating memory limits)
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2284 KB Output is correct
2 Correct 1 ms 2284 KB Output is correct
3 Correct 1 ms 2284 KB Output is correct
4 Correct 1 ms 2284 KB Output is correct
5 Correct 1 ms 2304 KB Output is correct
6 Correct 1 ms 2296 KB Output is correct
7 Correct 1 ms 2284 KB Output is correct
8 Correct 2 ms 2284 KB Output is correct
9 Correct 1 ms 2284 KB Output is correct
10 Correct 1 ms 2284 KB Output is correct
11 Correct 1 ms 2284 KB Output is correct
12 Correct 1 ms 2284 KB Output is correct
13 Correct 2 ms 2284 KB Output is correct
14 Correct 1 ms 2284 KB Output is correct
15 Correct 1 ms 2284 KB Output is correct
16 Correct 68 ms 2284 KB Output is correct
17 Correct 66 ms 2284 KB Output is correct
18 Correct 61 ms 2412 KB Output is correct
19 Correct 30 ms 2284 KB Output is correct
20 Correct 3 ms 2284 KB Output is correct
21 Correct 63 ms 2284 KB Output is correct
22 Correct 31 ms 2284 KB Output is correct
23 Correct 13 ms 2284 KB Output is correct
24 Correct 62 ms 2412 KB Output is correct
25 Correct 65 ms 2412 KB Output is correct
26 Correct 4 ms 2284 KB Output is correct
27 Correct 59 ms 2284 KB Output is correct
28 Correct 54 ms 2284 KB Output is correct
29 Correct 3 ms 2284 KB Output is correct
30 Correct 13 ms 2284 KB Output is correct
31 Runtime error 6 ms 4588 KB Execution killed with signal 11 (could be triggered by violating memory limits)
32 Halted 0 ms 0 KB -