답안 #265520

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
265520 2020-08-15T00:02:07 Z Segtree Bigger segments (IZhO19_segments) C++14
37 / 100
650 ms 71356 KB
#include<iostream>
#include<algorithm>
#include<vector>
#include<fstream>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define N 3010
ll n,a[N],s[N];
ll dp[N][N];
int main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cin>>n;
	rep(i,n)cin>>a[i];
	s[0]=0;
	rep(i,n)s[i+1]=s[i]+a[i];
	rep(i,n+1)dp[i][0]=1e18;
	dp[0][0]=0;
	for(int k=1;k<=n;k++){
		vector<ll> score,place;
		//scoreは単調増加
		for(int i=0;i<=n;i++){
			ll l=-1,r=score.size(),mid;
			while(l<r-1){
				mid=(l+r)>>1;
				if(s[i]>=score[mid])l=mid;
				else r=mid;
			}
			if(l>=0){
				dp[i][k]=s[i]-s[place[l]];
			}
			else dp[i][k]=1e18;
			ll sc=dp[i][k-1]+s[i];
			while(score.size()>0){
				if(score.back()>=sc){
					score.pop_back();
					place.pop_back();
				}
				else break;
			}
			score.push_back(sc);
			place.push_back(i);
		}
	}
	ll ans=1;
	for(int k=1;k<=n;k++){
		if(dp[n][k]<1e18)ans=k;
	}
	cout<<ans<<endl;
}
# 결과 실행 시간 메모리 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 1 ms 512 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 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 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 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 1 ms 512 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 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 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 11 ms 4352 KB Output is correct
17 Correct 9 ms 4352 KB Output is correct
18 Correct 9 ms 4352 KB Output is correct
19 Correct 10 ms 4352 KB Output is correct
20 Correct 9 ms 4352 KB Output is correct
21 Correct 12 ms 4352 KB Output is correct
22 Correct 7 ms 3200 KB Output is correct
23 Correct 4 ms 2304 KB Output is correct
24 Correct 11 ms 4352 KB Output is correct
25 Correct 10 ms 4352 KB Output is correct
26 Correct 8 ms 4352 KB Output is correct
27 Correct 13 ms 4352 KB Output is correct
28 Correct 9 ms 4352 KB Output is correct
29 Correct 8 ms 4352 KB Output is correct
30 Correct 10 ms 4352 KB Output is correct
# 결과 실행 시간 메모리 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 1 ms 512 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 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 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 11 ms 4352 KB Output is correct
17 Correct 9 ms 4352 KB Output is correct
18 Correct 9 ms 4352 KB Output is correct
19 Correct 10 ms 4352 KB Output is correct
20 Correct 9 ms 4352 KB Output is correct
21 Correct 12 ms 4352 KB Output is correct
22 Correct 7 ms 3200 KB Output is correct
23 Correct 4 ms 2304 KB Output is correct
24 Correct 11 ms 4352 KB Output is correct
25 Correct 10 ms 4352 KB Output is correct
26 Correct 8 ms 4352 KB Output is correct
27 Correct 13 ms 4352 KB Output is correct
28 Correct 9 ms 4352 KB Output is correct
29 Correct 8 ms 4352 KB Output is correct
30 Correct 10 ms 4352 KB Output is correct
31 Correct 650 ms 71160 KB Output is correct
32 Correct 615 ms 71224 KB Output is correct
33 Correct 614 ms 71288 KB Output is correct
34 Correct 574 ms 71288 KB Output is correct
35 Correct 506 ms 71288 KB Output is correct
36 Correct 608 ms 71256 KB Output is correct
37 Correct 428 ms 59384 KB Output is correct
38 Correct 254 ms 39788 KB Output is correct
39 Correct 604 ms 71164 KB Output is correct
40 Correct 605 ms 71356 KB Output is correct
41 Correct 479 ms 71160 KB Output is correct
42 Correct 572 ms 71224 KB Output is correct
43 Correct 597 ms 71160 KB Output is correct
44 Correct 517 ms 71288 KB Output is correct
45 Correct 513 ms 71312 KB Output is correct
# 결과 실행 시간 메모리 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 1 ms 512 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 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 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 11 ms 4352 KB Output is correct
17 Correct 9 ms 4352 KB Output is correct
18 Correct 9 ms 4352 KB Output is correct
19 Correct 10 ms 4352 KB Output is correct
20 Correct 9 ms 4352 KB Output is correct
21 Correct 12 ms 4352 KB Output is correct
22 Correct 7 ms 3200 KB Output is correct
23 Correct 4 ms 2304 KB Output is correct
24 Correct 11 ms 4352 KB Output is correct
25 Correct 10 ms 4352 KB Output is correct
26 Correct 8 ms 4352 KB Output is correct
27 Correct 13 ms 4352 KB Output is correct
28 Correct 9 ms 4352 KB Output is correct
29 Correct 8 ms 4352 KB Output is correct
30 Correct 10 ms 4352 KB Output is correct
31 Correct 650 ms 71160 KB Output is correct
32 Correct 615 ms 71224 KB Output is correct
33 Correct 614 ms 71288 KB Output is correct
34 Correct 574 ms 71288 KB Output is correct
35 Correct 506 ms 71288 KB Output is correct
36 Correct 608 ms 71256 KB Output is correct
37 Correct 428 ms 59384 KB Output is correct
38 Correct 254 ms 39788 KB Output is correct
39 Correct 604 ms 71164 KB Output is correct
40 Correct 605 ms 71356 KB Output is correct
41 Correct 479 ms 71160 KB Output is correct
42 Correct 572 ms 71224 KB Output is correct
43 Correct 597 ms 71160 KB Output is correct
44 Correct 517 ms 71288 KB Output is correct
45 Correct 513 ms 71312 KB Output is correct
46 Correct 3 ms 1920 KB Output is correct
47 Incorrect 332 ms 47476 KB Output isn't correct
48 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 ms 512 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 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 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 11 ms 4352 KB Output is correct
17 Correct 9 ms 4352 KB Output is correct
18 Correct 9 ms 4352 KB Output is correct
19 Correct 10 ms 4352 KB Output is correct
20 Correct 9 ms 4352 KB Output is correct
21 Correct 12 ms 4352 KB Output is correct
22 Correct 7 ms 3200 KB Output is correct
23 Correct 4 ms 2304 KB Output is correct
24 Correct 11 ms 4352 KB Output is correct
25 Correct 10 ms 4352 KB Output is correct
26 Correct 8 ms 4352 KB Output is correct
27 Correct 13 ms 4352 KB Output is correct
28 Correct 9 ms 4352 KB Output is correct
29 Correct 8 ms 4352 KB Output is correct
30 Correct 10 ms 4352 KB Output is correct
31 Correct 650 ms 71160 KB Output is correct
32 Correct 615 ms 71224 KB Output is correct
33 Correct 614 ms 71288 KB Output is correct
34 Correct 574 ms 71288 KB Output is correct
35 Correct 506 ms 71288 KB Output is correct
36 Correct 608 ms 71256 KB Output is correct
37 Correct 428 ms 59384 KB Output is correct
38 Correct 254 ms 39788 KB Output is correct
39 Correct 604 ms 71164 KB Output is correct
40 Correct 605 ms 71356 KB Output is correct
41 Correct 479 ms 71160 KB Output is correct
42 Correct 572 ms 71224 KB Output is correct
43 Correct 597 ms 71160 KB Output is correct
44 Correct 517 ms 71288 KB Output is correct
45 Correct 513 ms 71312 KB Output is correct
46 Correct 3 ms 1920 KB Output is correct
47 Incorrect 332 ms 47476 KB Output isn't correct
48 Halted 0 ms 0 KB -