# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
681770 |
2023-01-14T08:43:53 Z |
Cross_Ratio |
Cigle (COI21_cigle) |
C++14 |
|
258 ms |
67396 KB |
#include <bits/stdc++.h>
using namespace std;
int A[5005];
int B[5005][5005];
int C[5005];
signed main() {
cin.sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int N;
cin >> N;
int i, j;
for(i=0;i<N;i++) cin >> A[i];
//A[0][0] = A[0][1] = .. = A[0][N+1] = 0
for(j=1;j<N;j++) {
for(i=0;i<=j-1;i++) C[i] = B[i][j];
for(i=0;i+1<=j-1;i++) C[i+1] = max(C[i+1], C[i]);
int val = C[j-1];
int pt = j;
int cnt = 0;
int sum1 = 0, sum2 = 0;
for(int k=j+1;k<N+1;k++) {
if(k >= j+2) sum1 += A[k-2];
while(sum2 < sum1 && pt-1>=0) {
sum2 += A[pt-1];
pt--;
}
if(k>=j+2&&sum1==sum2) {
cnt++;
}
//cout << j << ", " << k << " : " << sum1 << ' '<< sum2 << ' ' << pt << ' ' << cnt << '\n';
if(pt>=1) val = max(val, cnt + C[pt-1]);
B[j][k] = max(B[j][k], val);
}
}
int ans = 0;
for(i=0;i<N;i++) ans = max(ans, B[i][N]);
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
392 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
328 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
392 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
328 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
596 KB |
Output is correct |
11 |
Correct |
1 ms |
596 KB |
Output is correct |
12 |
Correct |
1 ms |
588 KB |
Output is correct |
13 |
Correct |
1 ms |
596 KB |
Output is correct |
14 |
Correct |
1 ms |
596 KB |
Output is correct |
15 |
Correct |
1 ms |
596 KB |
Output is correct |
16 |
Correct |
1 ms |
588 KB |
Output is correct |
17 |
Correct |
1 ms |
580 KB |
Output is correct |
18 |
Correct |
1 ms |
596 KB |
Output is correct |
19 |
Correct |
1 ms |
596 KB |
Output is correct |
20 |
Correct |
1 ms |
596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2772 KB |
Output is correct |
2 |
Correct |
2 ms |
2772 KB |
Output is correct |
3 |
Correct |
2 ms |
2772 KB |
Output is correct |
4 |
Correct |
2 ms |
2772 KB |
Output is correct |
5 |
Correct |
3 ms |
2772 KB |
Output is correct |
6 |
Correct |
3 ms |
2772 KB |
Output is correct |
7 |
Correct |
3 ms |
2772 KB |
Output is correct |
8 |
Correct |
3 ms |
2772 KB |
Output is correct |
9 |
Correct |
3 ms |
2772 KB |
Output is correct |
10 |
Correct |
3 ms |
2772 KB |
Output is correct |
11 |
Correct |
3 ms |
2772 KB |
Output is correct |
12 |
Correct |
3 ms |
2824 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
392 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
328 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
596 KB |
Output is correct |
11 |
Correct |
1 ms |
596 KB |
Output is correct |
12 |
Correct |
1 ms |
588 KB |
Output is correct |
13 |
Correct |
1 ms |
596 KB |
Output is correct |
14 |
Correct |
1 ms |
596 KB |
Output is correct |
15 |
Correct |
1 ms |
596 KB |
Output is correct |
16 |
Correct |
1 ms |
588 KB |
Output is correct |
17 |
Correct |
1 ms |
580 KB |
Output is correct |
18 |
Correct |
1 ms |
596 KB |
Output is correct |
19 |
Correct |
1 ms |
596 KB |
Output is correct |
20 |
Correct |
1 ms |
596 KB |
Output is correct |
21 |
Correct |
3 ms |
2772 KB |
Output is correct |
22 |
Correct |
2 ms |
2772 KB |
Output is correct |
23 |
Correct |
2 ms |
2772 KB |
Output is correct |
24 |
Correct |
2 ms |
2772 KB |
Output is correct |
25 |
Correct |
3 ms |
2772 KB |
Output is correct |
26 |
Correct |
3 ms |
2772 KB |
Output is correct |
27 |
Correct |
3 ms |
2772 KB |
Output is correct |
28 |
Correct |
3 ms |
2772 KB |
Output is correct |
29 |
Correct |
3 ms |
2772 KB |
Output is correct |
30 |
Correct |
3 ms |
2772 KB |
Output is correct |
31 |
Correct |
3 ms |
2772 KB |
Output is correct |
32 |
Correct |
3 ms |
2824 KB |
Output is correct |
33 |
Correct |
2 ms |
2772 KB |
Output is correct |
34 |
Correct |
3 ms |
2772 KB |
Output is correct |
35 |
Correct |
3 ms |
2772 KB |
Output is correct |
36 |
Correct |
3 ms |
2772 KB |
Output is correct |
37 |
Correct |
3 ms |
2760 KB |
Output is correct |
38 |
Correct |
3 ms |
2772 KB |
Output is correct |
39 |
Correct |
3 ms |
2772 KB |
Output is correct |
40 |
Correct |
3 ms |
2772 KB |
Output is correct |
41 |
Correct |
3 ms |
2772 KB |
Output is correct |
42 |
Correct |
3 ms |
2772 KB |
Output is correct |
43 |
Correct |
3 ms |
2760 KB |
Output is correct |
44 |
Correct |
3 ms |
2756 KB |
Output is correct |
45 |
Correct |
3 ms |
2772 KB |
Output is correct |
46 |
Correct |
3 ms |
2772 KB |
Output is correct |
47 |
Correct |
3 ms |
2772 KB |
Output is correct |
48 |
Correct |
5 ms |
2772 KB |
Output is correct |
49 |
Correct |
3 ms |
2772 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
392 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
328 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
596 KB |
Output is correct |
11 |
Correct |
1 ms |
596 KB |
Output is correct |
12 |
Correct |
1 ms |
588 KB |
Output is correct |
13 |
Correct |
1 ms |
596 KB |
Output is correct |
14 |
Correct |
1 ms |
596 KB |
Output is correct |
15 |
Correct |
1 ms |
596 KB |
Output is correct |
16 |
Correct |
1 ms |
588 KB |
Output is correct |
17 |
Correct |
1 ms |
580 KB |
Output is correct |
18 |
Correct |
1 ms |
596 KB |
Output is correct |
19 |
Correct |
1 ms |
596 KB |
Output is correct |
20 |
Correct |
1 ms |
596 KB |
Output is correct |
21 |
Correct |
3 ms |
2772 KB |
Output is correct |
22 |
Correct |
2 ms |
2772 KB |
Output is correct |
23 |
Correct |
2 ms |
2772 KB |
Output is correct |
24 |
Correct |
2 ms |
2772 KB |
Output is correct |
25 |
Correct |
3 ms |
2772 KB |
Output is correct |
26 |
Correct |
3 ms |
2772 KB |
Output is correct |
27 |
Correct |
3 ms |
2772 KB |
Output is correct |
28 |
Correct |
3 ms |
2772 KB |
Output is correct |
29 |
Correct |
3 ms |
2772 KB |
Output is correct |
30 |
Correct |
3 ms |
2772 KB |
Output is correct |
31 |
Correct |
3 ms |
2772 KB |
Output is correct |
32 |
Correct |
3 ms |
2824 KB |
Output is correct |
33 |
Correct |
2 ms |
2772 KB |
Output is correct |
34 |
Correct |
3 ms |
2772 KB |
Output is correct |
35 |
Correct |
3 ms |
2772 KB |
Output is correct |
36 |
Correct |
3 ms |
2772 KB |
Output is correct |
37 |
Correct |
3 ms |
2760 KB |
Output is correct |
38 |
Correct |
3 ms |
2772 KB |
Output is correct |
39 |
Correct |
3 ms |
2772 KB |
Output is correct |
40 |
Correct |
3 ms |
2772 KB |
Output is correct |
41 |
Correct |
3 ms |
2772 KB |
Output is correct |
42 |
Correct |
3 ms |
2772 KB |
Output is correct |
43 |
Correct |
3 ms |
2760 KB |
Output is correct |
44 |
Correct |
3 ms |
2756 KB |
Output is correct |
45 |
Correct |
3 ms |
2772 KB |
Output is correct |
46 |
Correct |
3 ms |
2772 KB |
Output is correct |
47 |
Correct |
3 ms |
2772 KB |
Output is correct |
48 |
Correct |
5 ms |
2772 KB |
Output is correct |
49 |
Correct |
3 ms |
2772 KB |
Output is correct |
50 |
Correct |
180 ms |
67348 KB |
Output is correct |
51 |
Correct |
210 ms |
67280 KB |
Output is correct |
52 |
Correct |
191 ms |
67224 KB |
Output is correct |
53 |
Correct |
193 ms |
67272 KB |
Output is correct |
54 |
Correct |
198 ms |
67228 KB |
Output is correct |
55 |
Correct |
193 ms |
67272 KB |
Output is correct |
56 |
Correct |
219 ms |
67224 KB |
Output is correct |
57 |
Correct |
232 ms |
67232 KB |
Output is correct |
58 |
Correct |
227 ms |
67276 KB |
Output is correct |
59 |
Correct |
258 ms |
67340 KB |
Output is correct |
60 |
Correct |
233 ms |
67236 KB |
Output is correct |
61 |
Correct |
208 ms |
67292 KB |
Output is correct |
62 |
Correct |
210 ms |
67356 KB |
Output is correct |
63 |
Correct |
207 ms |
67368 KB |
Output is correct |
64 |
Correct |
250 ms |
67280 KB |
Output is correct |
65 |
Correct |
209 ms |
67292 KB |
Output is correct |
66 |
Correct |
217 ms |
67248 KB |
Output is correct |
67 |
Correct |
217 ms |
67240 KB |
Output is correct |
68 |
Correct |
195 ms |
67228 KB |
Output is correct |
69 |
Correct |
199 ms |
67324 KB |
Output is correct |
70 |
Correct |
239 ms |
67396 KB |
Output is correct |
71 |
Correct |
233 ms |
67320 KB |
Output is correct |
72 |
Correct |
219 ms |
67328 KB |
Output is correct |