#include<bits/stdc++.h>
using namespace std;
long long sum[3001][3001];
long long minsc[3001][3006];
const long long MAX=1e17;
void bin(int begnum,int ennum,int begfrom,int endfrom,int cur) {
if(begnum>ennum)return;
int mid=(begnum+ennum)/2;
int ind;
int indmax=endfrom;
for(ind=begfrom;ind<=endfrom;ind++) {
if(sum[ind+1][cur]>=minsc[ind][mid-1] && sum[ind+1][cur]<minsc[cur][mid]) {
minsc[cur][mid]=sum[ind+1][cur];
indmax=ind;
}
}
if(begnum==ennum)return;
if(mid!=begnum)bin(begnum,mid,begfrom,indmax,cur);
bin(mid+1,ennum,indmax,endfrom,cur);
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;cin>>n;
long long a[n+5];
for(int i=0;i<n;i++)cin>>a[i];
for(int i=0;i<n;i++) {
long long su=0;
for(int j=i;j<n;j++) {
su+=a[j];
sum[i][j]=su;
}
}
for(int i=0;i<n;i++) {
for(int j=0;j<=n;j++) {
minsc[i][j]=MAX;
}
}
int ans=1;
for(int i=0;i<n;i++) {
minsc[i][1]=sum[0][i];
if(i==0)continue;
bin(1,i+1,0,i-1,i);
for(int j=1;j<=i+1;j++) {
if(minsc[i][j]!=MAX)ans=max(ans,j);
}
}
cout<<ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
468 KB |
Output is correct |
5 |
Correct |
0 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
468 KB |
Output is correct |
13 |
Correct |
0 ms |
468 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
0 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
468 KB |
Output is correct |
5 |
Correct |
0 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
468 KB |
Output is correct |
13 |
Correct |
0 ms |
468 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
0 ms |
468 KB |
Output is correct |
16 |
Correct |
5 ms |
7252 KB |
Output is correct |
17 |
Correct |
6 ms |
7252 KB |
Output is correct |
18 |
Correct |
6 ms |
7308 KB |
Output is correct |
19 |
Correct |
6 ms |
7252 KB |
Output is correct |
20 |
Correct |
8 ms |
7380 KB |
Output is correct |
21 |
Correct |
6 ms |
7304 KB |
Output is correct |
22 |
Correct |
5 ms |
5332 KB |
Output is correct |
23 |
Correct |
3 ms |
3796 KB |
Output is correct |
24 |
Correct |
8 ms |
7252 KB |
Output is correct |
25 |
Correct |
6 ms |
7252 KB |
Output is correct |
26 |
Correct |
6 ms |
7260 KB |
Output is correct |
27 |
Correct |
7 ms |
7252 KB |
Output is correct |
28 |
Correct |
7 ms |
7252 KB |
Output is correct |
29 |
Correct |
6 ms |
7252 KB |
Output is correct |
30 |
Correct |
6 ms |
7252 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
468 KB |
Output is correct |
5 |
Correct |
0 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
468 KB |
Output is correct |
13 |
Correct |
0 ms |
468 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
0 ms |
468 KB |
Output is correct |
16 |
Correct |
5 ms |
7252 KB |
Output is correct |
17 |
Correct |
6 ms |
7252 KB |
Output is correct |
18 |
Correct |
6 ms |
7308 KB |
Output is correct |
19 |
Correct |
6 ms |
7252 KB |
Output is correct |
20 |
Correct |
8 ms |
7380 KB |
Output is correct |
21 |
Correct |
6 ms |
7304 KB |
Output is correct |
22 |
Correct |
5 ms |
5332 KB |
Output is correct |
23 |
Correct |
3 ms |
3796 KB |
Output is correct |
24 |
Correct |
8 ms |
7252 KB |
Output is correct |
25 |
Correct |
6 ms |
7252 KB |
Output is correct |
26 |
Correct |
6 ms |
7260 KB |
Output is correct |
27 |
Correct |
7 ms |
7252 KB |
Output is correct |
28 |
Correct |
7 ms |
7252 KB |
Output is correct |
29 |
Correct |
6 ms |
7252 KB |
Output is correct |
30 |
Correct |
6 ms |
7252 KB |
Output is correct |
31 |
Correct |
841 ms |
117208 KB |
Output is correct |
32 |
Correct |
813 ms |
117164 KB |
Output is correct |
33 |
Correct |
809 ms |
117172 KB |
Output is correct |
34 |
Correct |
773 ms |
117168 KB |
Output is correct |
35 |
Correct |
808 ms |
117172 KB |
Output is correct |
36 |
Correct |
805 ms |
117176 KB |
Output is correct |
37 |
Correct |
550 ms |
93660 KB |
Output is correct |
38 |
Correct |
332 ms |
63364 KB |
Output is correct |
39 |
Correct |
828 ms |
117164 KB |
Output is correct |
40 |
Correct |
849 ms |
117172 KB |
Output is correct |
41 |
Correct |
812 ms |
117164 KB |
Output is correct |
42 |
Correct |
780 ms |
117176 KB |
Output is correct |
43 |
Correct |
528 ms |
117164 KB |
Output is correct |
44 |
Correct |
810 ms |
117196 KB |
Output is correct |
45 |
Correct |
845 ms |
117172 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
468 KB |
Output is correct |
5 |
Correct |
0 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
468 KB |
Output is correct |
13 |
Correct |
0 ms |
468 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
0 ms |
468 KB |
Output is correct |
16 |
Correct |
5 ms |
7252 KB |
Output is correct |
17 |
Correct |
6 ms |
7252 KB |
Output is correct |
18 |
Correct |
6 ms |
7308 KB |
Output is correct |
19 |
Correct |
6 ms |
7252 KB |
Output is correct |
20 |
Correct |
8 ms |
7380 KB |
Output is correct |
21 |
Correct |
6 ms |
7304 KB |
Output is correct |
22 |
Correct |
5 ms |
5332 KB |
Output is correct |
23 |
Correct |
3 ms |
3796 KB |
Output is correct |
24 |
Correct |
8 ms |
7252 KB |
Output is correct |
25 |
Correct |
6 ms |
7252 KB |
Output is correct |
26 |
Correct |
6 ms |
7260 KB |
Output is correct |
27 |
Correct |
7 ms |
7252 KB |
Output is correct |
28 |
Correct |
7 ms |
7252 KB |
Output is correct |
29 |
Correct |
6 ms |
7252 KB |
Output is correct |
30 |
Correct |
6 ms |
7252 KB |
Output is correct |
31 |
Correct |
841 ms |
117208 KB |
Output is correct |
32 |
Correct |
813 ms |
117164 KB |
Output is correct |
33 |
Correct |
809 ms |
117172 KB |
Output is correct |
34 |
Correct |
773 ms |
117168 KB |
Output is correct |
35 |
Correct |
808 ms |
117172 KB |
Output is correct |
36 |
Correct |
805 ms |
117176 KB |
Output is correct |
37 |
Correct |
550 ms |
93660 KB |
Output is correct |
38 |
Correct |
332 ms |
63364 KB |
Output is correct |
39 |
Correct |
828 ms |
117164 KB |
Output is correct |
40 |
Correct |
849 ms |
117172 KB |
Output is correct |
41 |
Correct |
812 ms |
117164 KB |
Output is correct |
42 |
Correct |
780 ms |
117176 KB |
Output is correct |
43 |
Correct |
528 ms |
117164 KB |
Output is correct |
44 |
Correct |
810 ms |
117196 KB |
Output is correct |
45 |
Correct |
845 ms |
117172 KB |
Output is correct |
46 |
Runtime error |
228 ms |
144900 KB |
Execution killed with signal 11 |
47 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
468 KB |
Output is correct |
5 |
Correct |
0 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
468 KB |
Output is correct |
13 |
Correct |
0 ms |
468 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
0 ms |
468 KB |
Output is correct |
16 |
Correct |
5 ms |
7252 KB |
Output is correct |
17 |
Correct |
6 ms |
7252 KB |
Output is correct |
18 |
Correct |
6 ms |
7308 KB |
Output is correct |
19 |
Correct |
6 ms |
7252 KB |
Output is correct |
20 |
Correct |
8 ms |
7380 KB |
Output is correct |
21 |
Correct |
6 ms |
7304 KB |
Output is correct |
22 |
Correct |
5 ms |
5332 KB |
Output is correct |
23 |
Correct |
3 ms |
3796 KB |
Output is correct |
24 |
Correct |
8 ms |
7252 KB |
Output is correct |
25 |
Correct |
6 ms |
7252 KB |
Output is correct |
26 |
Correct |
6 ms |
7260 KB |
Output is correct |
27 |
Correct |
7 ms |
7252 KB |
Output is correct |
28 |
Correct |
7 ms |
7252 KB |
Output is correct |
29 |
Correct |
6 ms |
7252 KB |
Output is correct |
30 |
Correct |
6 ms |
7252 KB |
Output is correct |
31 |
Correct |
841 ms |
117208 KB |
Output is correct |
32 |
Correct |
813 ms |
117164 KB |
Output is correct |
33 |
Correct |
809 ms |
117172 KB |
Output is correct |
34 |
Correct |
773 ms |
117168 KB |
Output is correct |
35 |
Correct |
808 ms |
117172 KB |
Output is correct |
36 |
Correct |
805 ms |
117176 KB |
Output is correct |
37 |
Correct |
550 ms |
93660 KB |
Output is correct |
38 |
Correct |
332 ms |
63364 KB |
Output is correct |
39 |
Correct |
828 ms |
117164 KB |
Output is correct |
40 |
Correct |
849 ms |
117172 KB |
Output is correct |
41 |
Correct |
812 ms |
117164 KB |
Output is correct |
42 |
Correct |
780 ms |
117176 KB |
Output is correct |
43 |
Correct |
528 ms |
117164 KB |
Output is correct |
44 |
Correct |
810 ms |
117196 KB |
Output is correct |
45 |
Correct |
845 ms |
117172 KB |
Output is correct |
46 |
Runtime error |
228 ms |
144900 KB |
Execution killed with signal 11 |
47 |
Halted |
0 ms |
0 KB |
- |