#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=100000;
map<ll,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 |
4984 KB |
Output is correct |
2 |
Correct |
6 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 |
8 ms |
4984 KB |
Output is correct |
6 |
Correct |
6 ms |
4984 KB |
Output is correct |
7 |
Correct |
6 ms |
4988 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 |
4960 KB |
Output is correct |
14 |
Correct |
6 ms |
4984 KB |
Output is correct |
15 |
Correct |
6 ms |
4984 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
4984 KB |
Output is correct |
2 |
Correct |
6 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 |
8 ms |
4984 KB |
Output is correct |
6 |
Correct |
6 ms |
4984 KB |
Output is correct |
7 |
Correct |
6 ms |
4988 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 |
4960 KB |
Output is correct |
14 |
Correct |
6 ms |
4984 KB |
Output is correct |
15 |
Correct |
6 ms |
4984 KB |
Output is correct |
16 |
Correct |
7 ms |
4984 KB |
Output is correct |
17 |
Correct |
322 ms |
11248 KB |
Output is correct |
18 |
Correct |
503 ms |
12664 KB |
Output is correct |
19 |
Correct |
391 ms |
11640 KB |
Output is correct |
20 |
Correct |
591 ms |
13048 KB |
Output is correct |
21 |
Correct |
484 ms |
12408 KB |
Output is correct |
22 |
Correct |
249 ms |
9720 KB |
Output is correct |
23 |
Correct |
99 ms |
7620 KB |
Output is correct |
24 |
Correct |
587 ms |
12380 KB |
Output is correct |
25 |
Correct |
496 ms |
12604 KB |
Output is correct |
26 |
Correct |
749 ms |
13016 KB |
Output is correct |
27 |
Correct |
217 ms |
9720 KB |
Output is correct |
28 |
Correct |
660 ms |
12732 KB |
Output is correct |
29 |
Correct |
702 ms |
13020 KB |
Output is correct |
30 |
Correct |
556 ms |
12792 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
4984 KB |
Output is correct |
2 |
Correct |
6 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 |
8 ms |
4984 KB |
Output is correct |
6 |
Correct |
6 ms |
4984 KB |
Output is correct |
7 |
Correct |
6 ms |
4988 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 |
4960 KB |
Output is correct |
14 |
Correct |
6 ms |
4984 KB |
Output is correct |
15 |
Correct |
6 ms |
4984 KB |
Output is correct |
16 |
Correct |
7 ms |
4984 KB |
Output is correct |
17 |
Correct |
322 ms |
11248 KB |
Output is correct |
18 |
Correct |
503 ms |
12664 KB |
Output is correct |
19 |
Correct |
391 ms |
11640 KB |
Output is correct |
20 |
Correct |
591 ms |
13048 KB |
Output is correct |
21 |
Correct |
484 ms |
12408 KB |
Output is correct |
22 |
Correct |
249 ms |
9720 KB |
Output is correct |
23 |
Correct |
99 ms |
7620 KB |
Output is correct |
24 |
Correct |
587 ms |
12380 KB |
Output is correct |
25 |
Correct |
496 ms |
12604 KB |
Output is correct |
26 |
Correct |
749 ms |
13016 KB |
Output is correct |
27 |
Correct |
217 ms |
9720 KB |
Output is correct |
28 |
Correct |
660 ms |
12732 KB |
Output is correct |
29 |
Correct |
702 ms |
13020 KB |
Output is correct |
30 |
Correct |
556 ms |
12792 KB |
Output is correct |
31 |
Correct |
40 ms |
5240 KB |
Output is correct |
32 |
Execution timed out |
1516 ms |
20472 KB |
Time limit exceeded |
33 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
4984 KB |
Output is correct |
2 |
Correct |
6 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 |
8 ms |
4984 KB |
Output is correct |
6 |
Correct |
6 ms |
4984 KB |
Output is correct |
7 |
Correct |
6 ms |
4988 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 |
4960 KB |
Output is correct |
14 |
Correct |
6 ms |
4984 KB |
Output is correct |
15 |
Correct |
6 ms |
4984 KB |
Output is correct |
16 |
Correct |
7 ms |
4984 KB |
Output is correct |
17 |
Correct |
322 ms |
11248 KB |
Output is correct |
18 |
Correct |
503 ms |
12664 KB |
Output is correct |
19 |
Correct |
391 ms |
11640 KB |
Output is correct |
20 |
Correct |
591 ms |
13048 KB |
Output is correct |
21 |
Correct |
484 ms |
12408 KB |
Output is correct |
22 |
Correct |
249 ms |
9720 KB |
Output is correct |
23 |
Correct |
99 ms |
7620 KB |
Output is correct |
24 |
Correct |
587 ms |
12380 KB |
Output is correct |
25 |
Correct |
496 ms |
12604 KB |
Output is correct |
26 |
Correct |
749 ms |
13016 KB |
Output is correct |
27 |
Correct |
217 ms |
9720 KB |
Output is correct |
28 |
Correct |
660 ms |
12732 KB |
Output is correct |
29 |
Correct |
702 ms |
13020 KB |
Output is correct |
30 |
Correct |
556 ms |
12792 KB |
Output is correct |
31 |
Correct |
40 ms |
5240 KB |
Output is correct |
32 |
Execution timed out |
1516 ms |
20472 KB |
Time limit exceeded |
33 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
4984 KB |
Output is correct |
2 |
Correct |
6 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 |
8 ms |
4984 KB |
Output is correct |
6 |
Correct |
6 ms |
4984 KB |
Output is correct |
7 |
Correct |
6 ms |
4988 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 |
4960 KB |
Output is correct |
14 |
Correct |
6 ms |
4984 KB |
Output is correct |
15 |
Correct |
6 ms |
4984 KB |
Output is correct |
16 |
Correct |
7 ms |
4984 KB |
Output is correct |
17 |
Correct |
322 ms |
11248 KB |
Output is correct |
18 |
Correct |
503 ms |
12664 KB |
Output is correct |
19 |
Correct |
391 ms |
11640 KB |
Output is correct |
20 |
Correct |
591 ms |
13048 KB |
Output is correct |
21 |
Correct |
484 ms |
12408 KB |
Output is correct |
22 |
Correct |
249 ms |
9720 KB |
Output is correct |
23 |
Correct |
99 ms |
7620 KB |
Output is correct |
24 |
Correct |
587 ms |
12380 KB |
Output is correct |
25 |
Correct |
496 ms |
12604 KB |
Output is correct |
26 |
Correct |
749 ms |
13016 KB |
Output is correct |
27 |
Correct |
217 ms |
9720 KB |
Output is correct |
28 |
Correct |
660 ms |
12732 KB |
Output is correct |
29 |
Correct |
702 ms |
13020 KB |
Output is correct |
30 |
Correct |
556 ms |
12792 KB |
Output is correct |
31 |
Correct |
40 ms |
5240 KB |
Output is correct |
32 |
Execution timed out |
1516 ms |
20472 KB |
Time limit exceeded |
33 |
Halted |
0 ms |
0 KB |
- |