# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
707922 |
2023-03-10T13:47:55 Z |
penguin133 |
Cigle (COI21_cigle) |
C++17 |
|
126 ms |
4688 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pi pair<int, int>
#define pii pair<int, pi>
#define fi first
#define se second
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, q, A[5005], memo[505][505];
int dp(int x, int y){
if(y >= n)return 0;
if(memo[x][y] != -1)return memo[x][y];
int ans = 0, cur = 0, in = y - 1, cnt = 0, tmp = 0;
for(int i = y; i <= n; i++){
cnt += A[i];
while(cur < cnt && in >= x)cur += A[in--];
ans = max(ans, tmp + dp(y, i + 1));
if(cur == cnt && in >= x)tmp++;
}
return memo[x][y] = ans;
}
void solve(){
cin >> n;
for(int i=1;i<=n;i++)cin >> A[i];
memset(memo, -1, sizeof(memo));
int ans = 0;
for(int i=2;i<=n;i++)ans = max(ans, dp(1, i));// cout << dp(1, i) << ' ';
cout << ans;
}
main(){
ios::sync_with_stdio(0);cin.tie(0);
int tc = 1;
//cin >> tc;
for(int tc1=1;tc1<=tc;tc1++){
// cout << "Case #" << tc1 << ": ";
solve();
}
}
Compilation message
cigle.cpp:40:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
40 | main(){
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2260 KB |
Output is correct |
2 |
Correct |
1 ms |
2248 KB |
Output is correct |
3 |
Correct |
1 ms |
2260 KB |
Output is correct |
4 |
Correct |
1 ms |
2260 KB |
Output is correct |
5 |
Correct |
1 ms |
2252 KB |
Output is correct |
6 |
Correct |
1 ms |
2260 KB |
Output is correct |
7 |
Correct |
1 ms |
2248 KB |
Output is correct |
8 |
Correct |
1 ms |
2260 KB |
Output is correct |
9 |
Correct |
1 ms |
2260 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2260 KB |
Output is correct |
2 |
Correct |
1 ms |
2248 KB |
Output is correct |
3 |
Correct |
1 ms |
2260 KB |
Output is correct |
4 |
Correct |
1 ms |
2260 KB |
Output is correct |
5 |
Correct |
1 ms |
2252 KB |
Output is correct |
6 |
Correct |
1 ms |
2260 KB |
Output is correct |
7 |
Correct |
1 ms |
2248 KB |
Output is correct |
8 |
Correct |
1 ms |
2260 KB |
Output is correct |
9 |
Correct |
1 ms |
2260 KB |
Output is correct |
10 |
Correct |
2 ms |
2260 KB |
Output is correct |
11 |
Correct |
2 ms |
2260 KB |
Output is correct |
12 |
Correct |
2 ms |
2260 KB |
Output is correct |
13 |
Correct |
2 ms |
2260 KB |
Output is correct |
14 |
Correct |
2 ms |
2260 KB |
Output is correct |
15 |
Correct |
2 ms |
2256 KB |
Output is correct |
16 |
Correct |
2 ms |
2260 KB |
Output is correct |
17 |
Correct |
2 ms |
2252 KB |
Output is correct |
18 |
Correct |
2 ms |
2248 KB |
Output is correct |
19 |
Correct |
2 ms |
2260 KB |
Output is correct |
20 |
Correct |
2 ms |
2260 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
54 ms |
2260 KB |
Output is correct |
2 |
Correct |
52 ms |
2356 KB |
Output is correct |
3 |
Correct |
54 ms |
2360 KB |
Output is correct |
4 |
Correct |
59 ms |
2360 KB |
Output is correct |
5 |
Correct |
56 ms |
2360 KB |
Output is correct |
6 |
Correct |
104 ms |
2356 KB |
Output is correct |
7 |
Correct |
114 ms |
2260 KB |
Output is correct |
8 |
Correct |
126 ms |
2368 KB |
Output is correct |
9 |
Correct |
119 ms |
2360 KB |
Output is correct |
10 |
Correct |
61 ms |
2360 KB |
Output is correct |
11 |
Correct |
77 ms |
2344 KB |
Output is correct |
12 |
Correct |
63 ms |
2360 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2260 KB |
Output is correct |
2 |
Correct |
1 ms |
2248 KB |
Output is correct |
3 |
Correct |
1 ms |
2260 KB |
Output is correct |
4 |
Correct |
1 ms |
2260 KB |
Output is correct |
5 |
Correct |
1 ms |
2252 KB |
Output is correct |
6 |
Correct |
1 ms |
2260 KB |
Output is correct |
7 |
Correct |
1 ms |
2248 KB |
Output is correct |
8 |
Correct |
1 ms |
2260 KB |
Output is correct |
9 |
Correct |
1 ms |
2260 KB |
Output is correct |
10 |
Correct |
2 ms |
2260 KB |
Output is correct |
11 |
Correct |
2 ms |
2260 KB |
Output is correct |
12 |
Correct |
2 ms |
2260 KB |
Output is correct |
13 |
Correct |
2 ms |
2260 KB |
Output is correct |
14 |
Correct |
2 ms |
2260 KB |
Output is correct |
15 |
Correct |
2 ms |
2256 KB |
Output is correct |
16 |
Correct |
2 ms |
2260 KB |
Output is correct |
17 |
Correct |
2 ms |
2252 KB |
Output is correct |
18 |
Correct |
2 ms |
2248 KB |
Output is correct |
19 |
Correct |
2 ms |
2260 KB |
Output is correct |
20 |
Correct |
2 ms |
2260 KB |
Output is correct |
21 |
Correct |
54 ms |
2260 KB |
Output is correct |
22 |
Correct |
52 ms |
2356 KB |
Output is correct |
23 |
Correct |
54 ms |
2360 KB |
Output is correct |
24 |
Correct |
59 ms |
2360 KB |
Output is correct |
25 |
Correct |
56 ms |
2360 KB |
Output is correct |
26 |
Correct |
104 ms |
2356 KB |
Output is correct |
27 |
Correct |
114 ms |
2260 KB |
Output is correct |
28 |
Correct |
126 ms |
2368 KB |
Output is correct |
29 |
Correct |
119 ms |
2360 KB |
Output is correct |
30 |
Correct |
61 ms |
2360 KB |
Output is correct |
31 |
Correct |
77 ms |
2344 KB |
Output is correct |
32 |
Correct |
63 ms |
2360 KB |
Output is correct |
33 |
Correct |
52 ms |
2360 KB |
Output is correct |
34 |
Correct |
50 ms |
2260 KB |
Output is correct |
35 |
Correct |
55 ms |
2356 KB |
Output is correct |
36 |
Correct |
57 ms |
2360 KB |
Output is correct |
37 |
Correct |
110 ms |
2360 KB |
Output is correct |
38 |
Correct |
108 ms |
2356 KB |
Output is correct |
39 |
Correct |
126 ms |
2260 KB |
Output is correct |
40 |
Correct |
111 ms |
2356 KB |
Output is correct |
41 |
Correct |
88 ms |
2260 KB |
Output is correct |
42 |
Correct |
80 ms |
2260 KB |
Output is correct |
43 |
Correct |
75 ms |
2260 KB |
Output is correct |
44 |
Correct |
96 ms |
2360 KB |
Output is correct |
45 |
Correct |
76 ms |
2356 KB |
Output is correct |
46 |
Correct |
77 ms |
2356 KB |
Output is correct |
47 |
Correct |
110 ms |
2360 KB |
Output is correct |
48 |
Correct |
73 ms |
2260 KB |
Output is correct |
49 |
Correct |
72 ms |
2260 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2260 KB |
Output is correct |
2 |
Correct |
1 ms |
2248 KB |
Output is correct |
3 |
Correct |
1 ms |
2260 KB |
Output is correct |
4 |
Correct |
1 ms |
2260 KB |
Output is correct |
5 |
Correct |
1 ms |
2252 KB |
Output is correct |
6 |
Correct |
1 ms |
2260 KB |
Output is correct |
7 |
Correct |
1 ms |
2248 KB |
Output is correct |
8 |
Correct |
1 ms |
2260 KB |
Output is correct |
9 |
Correct |
1 ms |
2260 KB |
Output is correct |
10 |
Correct |
2 ms |
2260 KB |
Output is correct |
11 |
Correct |
2 ms |
2260 KB |
Output is correct |
12 |
Correct |
2 ms |
2260 KB |
Output is correct |
13 |
Correct |
2 ms |
2260 KB |
Output is correct |
14 |
Correct |
2 ms |
2260 KB |
Output is correct |
15 |
Correct |
2 ms |
2256 KB |
Output is correct |
16 |
Correct |
2 ms |
2260 KB |
Output is correct |
17 |
Correct |
2 ms |
2252 KB |
Output is correct |
18 |
Correct |
2 ms |
2248 KB |
Output is correct |
19 |
Correct |
2 ms |
2260 KB |
Output is correct |
20 |
Correct |
2 ms |
2260 KB |
Output is correct |
21 |
Correct |
54 ms |
2260 KB |
Output is correct |
22 |
Correct |
52 ms |
2356 KB |
Output is correct |
23 |
Correct |
54 ms |
2360 KB |
Output is correct |
24 |
Correct |
59 ms |
2360 KB |
Output is correct |
25 |
Correct |
56 ms |
2360 KB |
Output is correct |
26 |
Correct |
104 ms |
2356 KB |
Output is correct |
27 |
Correct |
114 ms |
2260 KB |
Output is correct |
28 |
Correct |
126 ms |
2368 KB |
Output is correct |
29 |
Correct |
119 ms |
2360 KB |
Output is correct |
30 |
Correct |
61 ms |
2360 KB |
Output is correct |
31 |
Correct |
77 ms |
2344 KB |
Output is correct |
32 |
Correct |
63 ms |
2360 KB |
Output is correct |
33 |
Correct |
52 ms |
2360 KB |
Output is correct |
34 |
Correct |
50 ms |
2260 KB |
Output is correct |
35 |
Correct |
55 ms |
2356 KB |
Output is correct |
36 |
Correct |
57 ms |
2360 KB |
Output is correct |
37 |
Correct |
110 ms |
2360 KB |
Output is correct |
38 |
Correct |
108 ms |
2356 KB |
Output is correct |
39 |
Correct |
126 ms |
2260 KB |
Output is correct |
40 |
Correct |
111 ms |
2356 KB |
Output is correct |
41 |
Correct |
88 ms |
2260 KB |
Output is correct |
42 |
Correct |
80 ms |
2260 KB |
Output is correct |
43 |
Correct |
75 ms |
2260 KB |
Output is correct |
44 |
Correct |
96 ms |
2360 KB |
Output is correct |
45 |
Correct |
76 ms |
2356 KB |
Output is correct |
46 |
Correct |
77 ms |
2356 KB |
Output is correct |
47 |
Correct |
110 ms |
2360 KB |
Output is correct |
48 |
Correct |
73 ms |
2260 KB |
Output is correct |
49 |
Correct |
72 ms |
2260 KB |
Output is correct |
50 |
Runtime error |
5 ms |
4688 KB |
Execution killed with signal 11 |
51 |
Halted |
0 ms |
0 KB |
- |