#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=100000;
map<int,int> dp[maxn];
int main() {
ll sum=0;
int n;
cin>>n;
vector<int>a(n);
for(int i=0;i<n;i++)cin>>a[i];
for(int i=0;i<n;i++){
sum+=a[i];
dp[i][sum]=1;
}
for(int i=1;i<n;i++){
sum=0;
for(int j=i;j>=1;j--){
sum+=a[j];
for(auto t:dp[j-1]){
if(t.first<=sum){
dp[i][sum]=max(dp[i][sum],t.second+1);
}
}
}
}
int ans=0;
for(auto t:dp[n-1]){
ans=max(ans,t.second);
}
cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
5060 KB |
Output is correct |
2 |
Correct |
14 ms |
4984 KB |
Output is correct |
3 |
Correct |
7 ms |
4984 KB |
Output is correct |
4 |
Correct |
7 ms |
4984 KB |
Output is correct |
5 |
Correct |
0 ms |
4984 KB |
Output is correct |
6 |
Correct |
7 ms |
4984 KB |
Output is correct |
7 |
Correct |
7 ms |
4984 KB |
Output is correct |
8 |
Correct |
6 ms |
4984 KB |
Output is correct |
9 |
Correct |
6 ms |
4984 KB |
Output is correct |
10 |
Correct |
6 ms |
4984 KB |
Output is correct |
11 |
Correct |
6 ms |
4984 KB |
Output is correct |
12 |
Correct |
6 ms |
4984 KB |
Output is correct |
13 |
Correct |
7 ms |
4984 KB |
Output is correct |
14 |
Correct |
7 ms |
5112 KB |
Output is correct |
15 |
Correct |
8 ms |
4984 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
5060 KB |
Output is correct |
2 |
Correct |
14 ms |
4984 KB |
Output is correct |
3 |
Correct |
7 ms |
4984 KB |
Output is correct |
4 |
Correct |
7 ms |
4984 KB |
Output is correct |
5 |
Correct |
0 ms |
4984 KB |
Output is correct |
6 |
Correct |
7 ms |
4984 KB |
Output is correct |
7 |
Correct |
7 ms |
4984 KB |
Output is correct |
8 |
Correct |
6 ms |
4984 KB |
Output is correct |
9 |
Correct |
6 ms |
4984 KB |
Output is correct |
10 |
Correct |
6 ms |
4984 KB |
Output is correct |
11 |
Correct |
6 ms |
4984 KB |
Output is correct |
12 |
Correct |
6 ms |
4984 KB |
Output is correct |
13 |
Correct |
7 ms |
4984 KB |
Output is correct |
14 |
Correct |
7 ms |
5112 KB |
Output is correct |
15 |
Correct |
8 ms |
4984 KB |
Output is correct |
16 |
Correct |
8 ms |
5112 KB |
Output is correct |
17 |
Incorrect |
819 ms |
10752 KB |
Output isn't correct |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
5060 KB |
Output is correct |
2 |
Correct |
14 ms |
4984 KB |
Output is correct |
3 |
Correct |
7 ms |
4984 KB |
Output is correct |
4 |
Correct |
7 ms |
4984 KB |
Output is correct |
5 |
Correct |
0 ms |
4984 KB |
Output is correct |
6 |
Correct |
7 ms |
4984 KB |
Output is correct |
7 |
Correct |
7 ms |
4984 KB |
Output is correct |
8 |
Correct |
6 ms |
4984 KB |
Output is correct |
9 |
Correct |
6 ms |
4984 KB |
Output is correct |
10 |
Correct |
6 ms |
4984 KB |
Output is correct |
11 |
Correct |
6 ms |
4984 KB |
Output is correct |
12 |
Correct |
6 ms |
4984 KB |
Output is correct |
13 |
Correct |
7 ms |
4984 KB |
Output is correct |
14 |
Correct |
7 ms |
5112 KB |
Output is correct |
15 |
Correct |
8 ms |
4984 KB |
Output is correct |
16 |
Correct |
8 ms |
5112 KB |
Output is correct |
17 |
Incorrect |
819 ms |
10752 KB |
Output isn't correct |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
5060 KB |
Output is correct |
2 |
Correct |
14 ms |
4984 KB |
Output is correct |
3 |
Correct |
7 ms |
4984 KB |
Output is correct |
4 |
Correct |
7 ms |
4984 KB |
Output is correct |
5 |
Correct |
0 ms |
4984 KB |
Output is correct |
6 |
Correct |
7 ms |
4984 KB |
Output is correct |
7 |
Correct |
7 ms |
4984 KB |
Output is correct |
8 |
Correct |
6 ms |
4984 KB |
Output is correct |
9 |
Correct |
6 ms |
4984 KB |
Output is correct |
10 |
Correct |
6 ms |
4984 KB |
Output is correct |
11 |
Correct |
6 ms |
4984 KB |
Output is correct |
12 |
Correct |
6 ms |
4984 KB |
Output is correct |
13 |
Correct |
7 ms |
4984 KB |
Output is correct |
14 |
Correct |
7 ms |
5112 KB |
Output is correct |
15 |
Correct |
8 ms |
4984 KB |
Output is correct |
16 |
Correct |
8 ms |
5112 KB |
Output is correct |
17 |
Incorrect |
819 ms |
10752 KB |
Output isn't correct |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
5060 KB |
Output is correct |
2 |
Correct |
14 ms |
4984 KB |
Output is correct |
3 |
Correct |
7 ms |
4984 KB |
Output is correct |
4 |
Correct |
7 ms |
4984 KB |
Output is correct |
5 |
Correct |
0 ms |
4984 KB |
Output is correct |
6 |
Correct |
7 ms |
4984 KB |
Output is correct |
7 |
Correct |
7 ms |
4984 KB |
Output is correct |
8 |
Correct |
6 ms |
4984 KB |
Output is correct |
9 |
Correct |
6 ms |
4984 KB |
Output is correct |
10 |
Correct |
6 ms |
4984 KB |
Output is correct |
11 |
Correct |
6 ms |
4984 KB |
Output is correct |
12 |
Correct |
6 ms |
4984 KB |
Output is correct |
13 |
Correct |
7 ms |
4984 KB |
Output is correct |
14 |
Correct |
7 ms |
5112 KB |
Output is correct |
15 |
Correct |
8 ms |
4984 KB |
Output is correct |
16 |
Correct |
8 ms |
5112 KB |
Output is correct |
17 |
Incorrect |
819 ms |
10752 KB |
Output isn't correct |
18 |
Halted |
0 ms |
0 KB |
- |