Submission #338900

# Submission time Handle Problem Language Result Execution time Memory
338900 2020-12-24T07:32:31 Z nandonathaniel Bigger segments (IZhO19_segments) C++14
27 / 100
1500 ms 71148 KB
#include<bits/stdc++.h>
using namespace std;
const int MAXN=3005;
 
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 36 ms 71020 KB Output is correct
2 Correct 36 ms 71020 KB Output is correct
3 Correct 36 ms 71020 KB Output is correct
4 Correct 39 ms 71020 KB Output is correct
5 Correct 37 ms 71020 KB Output is correct
6 Correct 36 ms 71020 KB Output is correct
7 Correct 36 ms 71020 KB Output is correct
8 Correct 36 ms 71020 KB Output is correct
9 Correct 37 ms 71020 KB Output is correct
10 Correct 37 ms 71020 KB Output is correct
11 Correct 38 ms 71020 KB Output is correct
12 Correct 37 ms 71020 KB Output is correct
13 Correct 37 ms 71020 KB Output is correct
14 Correct 36 ms 70948 KB Output is correct
15 Correct 36 ms 71020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 71020 KB Output is correct
2 Correct 36 ms 71020 KB Output is correct
3 Correct 36 ms 71020 KB Output is correct
4 Correct 39 ms 71020 KB Output is correct
5 Correct 37 ms 71020 KB Output is correct
6 Correct 36 ms 71020 KB Output is correct
7 Correct 36 ms 71020 KB Output is correct
8 Correct 36 ms 71020 KB Output is correct
9 Correct 37 ms 71020 KB Output is correct
10 Correct 37 ms 71020 KB Output is correct
11 Correct 38 ms 71020 KB Output is correct
12 Correct 37 ms 71020 KB Output is correct
13 Correct 37 ms 71020 KB Output is correct
14 Correct 36 ms 70948 KB Output is correct
15 Correct 36 ms 71020 KB Output is correct
16 Correct 104 ms 71020 KB Output is correct
17 Correct 102 ms 71020 KB Output is correct
18 Correct 93 ms 71020 KB Output is correct
19 Correct 64 ms 71020 KB Output is correct
20 Correct 38 ms 71020 KB Output is correct
21 Correct 101 ms 71148 KB Output is correct
22 Correct 68 ms 71020 KB Output is correct
23 Correct 48 ms 71020 KB Output is correct
24 Correct 98 ms 71020 KB Output is correct
25 Correct 97 ms 71148 KB Output is correct
26 Correct 39 ms 71020 KB Output is correct
27 Correct 94 ms 71148 KB Output is correct
28 Correct 90 ms 71020 KB Output is correct
29 Correct 38 ms 71020 KB Output is correct
30 Correct 50 ms 71148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 71020 KB Output is correct
2 Correct 36 ms 71020 KB Output is correct
3 Correct 36 ms 71020 KB Output is correct
4 Correct 39 ms 71020 KB Output is correct
5 Correct 37 ms 71020 KB Output is correct
6 Correct 36 ms 71020 KB Output is correct
7 Correct 36 ms 71020 KB Output is correct
8 Correct 36 ms 71020 KB Output is correct
9 Correct 37 ms 71020 KB Output is correct
10 Correct 37 ms 71020 KB Output is correct
11 Correct 38 ms 71020 KB Output is correct
12 Correct 37 ms 71020 KB Output is correct
13 Correct 37 ms 71020 KB Output is correct
14 Correct 36 ms 70948 KB Output is correct
15 Correct 36 ms 71020 KB Output is correct
16 Correct 104 ms 71020 KB Output is correct
17 Correct 102 ms 71020 KB Output is correct
18 Correct 93 ms 71020 KB Output is correct
19 Correct 64 ms 71020 KB Output is correct
20 Correct 38 ms 71020 KB Output is correct
21 Correct 101 ms 71148 KB Output is correct
22 Correct 68 ms 71020 KB Output is correct
23 Correct 48 ms 71020 KB Output is correct
24 Correct 98 ms 71020 KB Output is correct
25 Correct 97 ms 71148 KB Output is correct
26 Correct 39 ms 71020 KB Output is correct
27 Correct 94 ms 71148 KB Output is correct
28 Correct 90 ms 71020 KB Output is correct
29 Correct 38 ms 71020 KB Output is correct
30 Correct 50 ms 71148 KB Output is correct
31 Execution timed out 1598 ms 71020 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 36 ms 71020 KB Output is correct
2 Correct 36 ms 71020 KB Output is correct
3 Correct 36 ms 71020 KB Output is correct
4 Correct 39 ms 71020 KB Output is correct
5 Correct 37 ms 71020 KB Output is correct
6 Correct 36 ms 71020 KB Output is correct
7 Correct 36 ms 71020 KB Output is correct
8 Correct 36 ms 71020 KB Output is correct
9 Correct 37 ms 71020 KB Output is correct
10 Correct 37 ms 71020 KB Output is correct
11 Correct 38 ms 71020 KB Output is correct
12 Correct 37 ms 71020 KB Output is correct
13 Correct 37 ms 71020 KB Output is correct
14 Correct 36 ms 70948 KB Output is correct
15 Correct 36 ms 71020 KB Output is correct
16 Correct 104 ms 71020 KB Output is correct
17 Correct 102 ms 71020 KB Output is correct
18 Correct 93 ms 71020 KB Output is correct
19 Correct 64 ms 71020 KB Output is correct
20 Correct 38 ms 71020 KB Output is correct
21 Correct 101 ms 71148 KB Output is correct
22 Correct 68 ms 71020 KB Output is correct
23 Correct 48 ms 71020 KB Output is correct
24 Correct 98 ms 71020 KB Output is correct
25 Correct 97 ms 71148 KB Output is correct
26 Correct 39 ms 71020 KB Output is correct
27 Correct 94 ms 71148 KB Output is correct
28 Correct 90 ms 71020 KB Output is correct
29 Correct 38 ms 71020 KB Output is correct
30 Correct 50 ms 71148 KB Output is correct
31 Execution timed out 1598 ms 71020 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 36 ms 71020 KB Output is correct
2 Correct 36 ms 71020 KB Output is correct
3 Correct 36 ms 71020 KB Output is correct
4 Correct 39 ms 71020 KB Output is correct
5 Correct 37 ms 71020 KB Output is correct
6 Correct 36 ms 71020 KB Output is correct
7 Correct 36 ms 71020 KB Output is correct
8 Correct 36 ms 71020 KB Output is correct
9 Correct 37 ms 71020 KB Output is correct
10 Correct 37 ms 71020 KB Output is correct
11 Correct 38 ms 71020 KB Output is correct
12 Correct 37 ms 71020 KB Output is correct
13 Correct 37 ms 71020 KB Output is correct
14 Correct 36 ms 70948 KB Output is correct
15 Correct 36 ms 71020 KB Output is correct
16 Correct 104 ms 71020 KB Output is correct
17 Correct 102 ms 71020 KB Output is correct
18 Correct 93 ms 71020 KB Output is correct
19 Correct 64 ms 71020 KB Output is correct
20 Correct 38 ms 71020 KB Output is correct
21 Correct 101 ms 71148 KB Output is correct
22 Correct 68 ms 71020 KB Output is correct
23 Correct 48 ms 71020 KB Output is correct
24 Correct 98 ms 71020 KB Output is correct
25 Correct 97 ms 71148 KB Output is correct
26 Correct 39 ms 71020 KB Output is correct
27 Correct 94 ms 71148 KB Output is correct
28 Correct 90 ms 71020 KB Output is correct
29 Correct 38 ms 71020 KB Output is correct
30 Correct 50 ms 71148 KB Output is correct
31 Execution timed out 1598 ms 71020 KB Time limit exceeded
32 Halted 0 ms 0 KB -