Submission #287917

# Submission time Handle Problem Language Result Execution time Memory
287917 2020-09-01T06:45:11 Z dvdg6566 Bigger segments (IZhO19_segments) C++14
37 / 100
1500 ms 2360 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define f first
#define s second
#define SZ(x) (ll)x.size()
#define ALL(x) x.begin(),x.end()
#define lb lower_bound
#define ub upper_bound
const ll MAXN=200001;
const ll MOD=1e9+7;
const ll INF = 3e9;

ll A[MAXN];
ll N;
ll dp[MAXN];
ll S[MAXN];

int main(){
	cin>>N;
	for(int i=1;i<=N;++i){
		cin>>A[i];
		A[i]+=A[i-1];
	}
	dp[0]=0;
	S[0]=0;
	for(int i=1;i<=N;++i){
		for(int j=1;j<=i;++j){
			// take from i to j
			ll x=A[i] - A[j-1];
			// cerr<<i<<' '<<j<<' '<<x<<'\n';
			if(x >= S[j-1]){
				if(dp[j-1]+1 >= dp[i]){
					dp[i]=dp[j-1]+1;
					S[i] = x;
				}
			}
		}
		// cerr<<i<<' '<<dp[i]<<'\n';
	}
	cout<<dp[N];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 6 ms 384 KB Output is correct
32 Correct 8 ms 384 KB Output is correct
33 Correct 9 ms 384 KB Output is correct
34 Correct 8 ms 384 KB Output is correct
35 Correct 9 ms 384 KB Output is correct
36 Correct 9 ms 384 KB Output is correct
37 Correct 7 ms 384 KB Output is correct
38 Correct 6 ms 384 KB Output is correct
39 Correct 7 ms 384 KB Output is correct
40 Correct 9 ms 384 KB Output is correct
41 Correct 8 ms 384 KB Output is correct
42 Correct 7 ms 384 KB Output is correct
43 Correct 7 ms 384 KB Output is correct
44 Correct 10 ms 384 KB Output is correct
45 Correct 8 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 6 ms 384 KB Output is correct
32 Correct 8 ms 384 KB Output is correct
33 Correct 9 ms 384 KB Output is correct
34 Correct 8 ms 384 KB Output is correct
35 Correct 9 ms 384 KB Output is correct
36 Correct 9 ms 384 KB Output is correct
37 Correct 7 ms 384 KB Output is correct
38 Correct 6 ms 384 KB Output is correct
39 Correct 7 ms 384 KB Output is correct
40 Correct 9 ms 384 KB Output is correct
41 Correct 8 ms 384 KB Output is correct
42 Correct 7 ms 384 KB Output is correct
43 Correct 7 ms 384 KB Output is correct
44 Correct 10 ms 384 KB Output is correct
45 Correct 8 ms 384 KB Output is correct
46 Execution timed out 1581 ms 2360 KB Time limit exceeded
47 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 6 ms 384 KB Output is correct
32 Correct 8 ms 384 KB Output is correct
33 Correct 9 ms 384 KB Output is correct
34 Correct 8 ms 384 KB Output is correct
35 Correct 9 ms 384 KB Output is correct
36 Correct 9 ms 384 KB Output is correct
37 Correct 7 ms 384 KB Output is correct
38 Correct 6 ms 384 KB Output is correct
39 Correct 7 ms 384 KB Output is correct
40 Correct 9 ms 384 KB Output is correct
41 Correct 8 ms 384 KB Output is correct
42 Correct 7 ms 384 KB Output is correct
43 Correct 7 ms 384 KB Output is correct
44 Correct 10 ms 384 KB Output is correct
45 Correct 8 ms 384 KB Output is correct
46 Execution timed out 1581 ms 2360 KB Time limit exceeded
47 Halted 0 ms 0 KB -