#include <bits/stdc++.h>
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define int long long
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int mod = 1e9 + 7;
const int LOG = 20;
const int maxn = 1e5 + 5;
const double eps = 1e-9;
int32_t main() {
ios_base::sync_with_stdio(false);
cout.tie(0); cin.tie(0);
int n;
cin >> n;
vector<int> v(n+1);
vector<ll> pref(n+1);
for(int i=1; i<=n; i++) {
cin >> v[i];
pref[i] = pref[i-1] + v[i];
}
int dp[n+1][n+1];
for(int i=0; i<=n; i++)
for(int j=0; j<=n; j++) dp[i][j] = -1e9;
for(int i=1; i<=n; i++) dp[1][i] = 1;
for(int i=2; i<=n; i++)
for(int j=i; j<=n; j++)
for(int k=1; k<i; k++)
if(pref[j] + pref[k-1] >= 2 * pref[i-1]) dp[i][j] = max(dp[i][j], dp[k][i-1] + 1);
int ans = 0;
for(int i=1; i<=n; i++) ans = max(ans, dp[i][n]);
cout << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
24 ms |
2392 KB |
Output is correct |
17 |
Correct |
24 ms |
2396 KB |
Output is correct |
18 |
Correct |
24 ms |
2428 KB |
Output is correct |
19 |
Correct |
26 ms |
2420 KB |
Output is correct |
20 |
Correct |
24 ms |
2420 KB |
Output is correct |
21 |
Correct |
31 ms |
2396 KB |
Output is correct |
22 |
Correct |
13 ms |
1628 KB |
Output is correct |
23 |
Correct |
6 ms |
1116 KB |
Output is correct |
24 |
Correct |
24 ms |
2396 KB |
Output is correct |
25 |
Correct |
23 ms |
2392 KB |
Output is correct |
26 |
Correct |
27 ms |
2396 KB |
Output is correct |
27 |
Correct |
21 ms |
2396 KB |
Output is correct |
28 |
Correct |
26 ms |
2396 KB |
Output is correct |
29 |
Correct |
25 ms |
2396 KB |
Output is correct |
30 |
Correct |
24 ms |
2392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
24 ms |
2392 KB |
Output is correct |
17 |
Correct |
24 ms |
2396 KB |
Output is correct |
18 |
Correct |
24 ms |
2428 KB |
Output is correct |
19 |
Correct |
26 ms |
2420 KB |
Output is correct |
20 |
Correct |
24 ms |
2420 KB |
Output is correct |
21 |
Correct |
31 ms |
2396 KB |
Output is correct |
22 |
Correct |
13 ms |
1628 KB |
Output is correct |
23 |
Correct |
6 ms |
1116 KB |
Output is correct |
24 |
Correct |
24 ms |
2396 KB |
Output is correct |
25 |
Correct |
23 ms |
2392 KB |
Output is correct |
26 |
Correct |
27 ms |
2396 KB |
Output is correct |
27 |
Correct |
21 ms |
2396 KB |
Output is correct |
28 |
Correct |
26 ms |
2396 KB |
Output is correct |
29 |
Correct |
25 ms |
2396 KB |
Output is correct |
30 |
Correct |
24 ms |
2392 KB |
Output is correct |
31 |
Execution timed out |
1578 ms |
70740 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
24 ms |
2392 KB |
Output is correct |
17 |
Correct |
24 ms |
2396 KB |
Output is correct |
18 |
Correct |
24 ms |
2428 KB |
Output is correct |
19 |
Correct |
26 ms |
2420 KB |
Output is correct |
20 |
Correct |
24 ms |
2420 KB |
Output is correct |
21 |
Correct |
31 ms |
2396 KB |
Output is correct |
22 |
Correct |
13 ms |
1628 KB |
Output is correct |
23 |
Correct |
6 ms |
1116 KB |
Output is correct |
24 |
Correct |
24 ms |
2396 KB |
Output is correct |
25 |
Correct |
23 ms |
2392 KB |
Output is correct |
26 |
Correct |
27 ms |
2396 KB |
Output is correct |
27 |
Correct |
21 ms |
2396 KB |
Output is correct |
28 |
Correct |
26 ms |
2396 KB |
Output is correct |
29 |
Correct |
25 ms |
2396 KB |
Output is correct |
30 |
Correct |
24 ms |
2392 KB |
Output is correct |
31 |
Execution timed out |
1578 ms |
70740 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
24 ms |
2392 KB |
Output is correct |
17 |
Correct |
24 ms |
2396 KB |
Output is correct |
18 |
Correct |
24 ms |
2428 KB |
Output is correct |
19 |
Correct |
26 ms |
2420 KB |
Output is correct |
20 |
Correct |
24 ms |
2420 KB |
Output is correct |
21 |
Correct |
31 ms |
2396 KB |
Output is correct |
22 |
Correct |
13 ms |
1628 KB |
Output is correct |
23 |
Correct |
6 ms |
1116 KB |
Output is correct |
24 |
Correct |
24 ms |
2396 KB |
Output is correct |
25 |
Correct |
23 ms |
2392 KB |
Output is correct |
26 |
Correct |
27 ms |
2396 KB |
Output is correct |
27 |
Correct |
21 ms |
2396 KB |
Output is correct |
28 |
Correct |
26 ms |
2396 KB |
Output is correct |
29 |
Correct |
25 ms |
2396 KB |
Output is correct |
30 |
Correct |
24 ms |
2392 KB |
Output is correct |
31 |
Execution timed out |
1578 ms |
70740 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |