# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1002714 |
2024-06-19T18:32:52 Z |
Sofiatpc |
Cigle (COI21_cigle) |
C++14 |
|
993 ms |
2632 KB |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 505;
int dp[MAXN][MAXN], dp1[MAXN][MAXN], d[MAXN], sp[MAXN];
int sum(int i, int j){
return sp[j] - sp[i-1];
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n; cin>>n;
for(int i = 1; i <= n; i++){
cin>>d[i];
sp[i] = sp[i-1]+d[i];
}
int ans = 0;
for(int l = n-1; l >= 1; l--)
for(int r = n-1; r >= l; r--){
set<int> st;
for(int i = l; i < r; i++)st.insert(sum(i+1,r));
//cout<<l<<" "<<r<<": ";
//for(int x : st)cout<<x<<" "; cout<<" | ";
int qtd = 0;
for(int j = r+1; j < n; j++)
if(st.find(sum(r+1,j)) != st.end()){
qtd++;
dp[l][r] = max(dp[l][r], dp1[r+1][j+1]+qtd);
}
//cout<<dp[l][r]<<" "<<qtd<<"\n";
ans = max(ans,dp[l][r]);
dp1[l][r] = max(dp1[l][r+1],dp[l][r]);
}
cout<<ans<<"\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 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 |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 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 |
0 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 |
3 ms |
604 KB |
Output is correct |
11 |
Correct |
3 ms |
716 KB |
Output is correct |
12 |
Correct |
3 ms |
728 KB |
Output is correct |
13 |
Correct |
3 ms |
604 KB |
Output is correct |
14 |
Correct |
3 ms |
604 KB |
Output is correct |
15 |
Correct |
4 ms |
604 KB |
Output is correct |
16 |
Correct |
4 ms |
604 KB |
Output is correct |
17 |
Correct |
3 ms |
720 KB |
Output is correct |
18 |
Correct |
3 ms |
604 KB |
Output is correct |
19 |
Correct |
3 ms |
604 KB |
Output is correct |
20 |
Correct |
4 ms |
716 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
861 ms |
2336 KB |
Output is correct |
2 |
Correct |
846 ms |
2344 KB |
Output is correct |
3 |
Correct |
836 ms |
2432 KB |
Output is correct |
4 |
Correct |
856 ms |
2384 KB |
Output is correct |
5 |
Correct |
880 ms |
2420 KB |
Output is correct |
6 |
Correct |
933 ms |
2388 KB |
Output is correct |
7 |
Correct |
885 ms |
2400 KB |
Output is correct |
8 |
Correct |
993 ms |
2632 KB |
Output is correct |
9 |
Correct |
993 ms |
2380 KB |
Output is correct |
10 |
Correct |
927 ms |
2428 KB |
Output is correct |
11 |
Correct |
978 ms |
2356 KB |
Output is correct |
12 |
Correct |
906 ms |
2400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 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 |
0 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 |
3 ms |
604 KB |
Output is correct |
11 |
Correct |
3 ms |
716 KB |
Output is correct |
12 |
Correct |
3 ms |
728 KB |
Output is correct |
13 |
Correct |
3 ms |
604 KB |
Output is correct |
14 |
Correct |
3 ms |
604 KB |
Output is correct |
15 |
Correct |
4 ms |
604 KB |
Output is correct |
16 |
Correct |
4 ms |
604 KB |
Output is correct |
17 |
Correct |
3 ms |
720 KB |
Output is correct |
18 |
Correct |
3 ms |
604 KB |
Output is correct |
19 |
Correct |
3 ms |
604 KB |
Output is correct |
20 |
Correct |
4 ms |
716 KB |
Output is correct |
21 |
Correct |
861 ms |
2336 KB |
Output is correct |
22 |
Correct |
846 ms |
2344 KB |
Output is correct |
23 |
Correct |
836 ms |
2432 KB |
Output is correct |
24 |
Correct |
856 ms |
2384 KB |
Output is correct |
25 |
Correct |
880 ms |
2420 KB |
Output is correct |
26 |
Correct |
933 ms |
2388 KB |
Output is correct |
27 |
Correct |
885 ms |
2400 KB |
Output is correct |
28 |
Correct |
993 ms |
2632 KB |
Output is correct |
29 |
Correct |
993 ms |
2380 KB |
Output is correct |
30 |
Correct |
927 ms |
2428 KB |
Output is correct |
31 |
Correct |
978 ms |
2356 KB |
Output is correct |
32 |
Correct |
906 ms |
2400 KB |
Output is correct |
33 |
Correct |
882 ms |
2384 KB |
Output is correct |
34 |
Correct |
900 ms |
2380 KB |
Output is correct |
35 |
Correct |
867 ms |
2328 KB |
Output is correct |
36 |
Correct |
891 ms |
2332 KB |
Output is correct |
37 |
Correct |
901 ms |
2388 KB |
Output is correct |
38 |
Correct |
900 ms |
2304 KB |
Output is correct |
39 |
Correct |
905 ms |
2224 KB |
Output is correct |
40 |
Correct |
905 ms |
2132 KB |
Output is correct |
41 |
Correct |
820 ms |
2308 KB |
Output is correct |
42 |
Correct |
837 ms |
2248 KB |
Output is correct |
43 |
Correct |
815 ms |
2228 KB |
Output is correct |
44 |
Correct |
839 ms |
2384 KB |
Output is correct |
45 |
Correct |
805 ms |
2356 KB |
Output is correct |
46 |
Correct |
829 ms |
2292 KB |
Output is correct |
47 |
Correct |
842 ms |
2328 KB |
Output is correct |
48 |
Correct |
812 ms |
2428 KB |
Output is correct |
49 |
Correct |
846 ms |
2292 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 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 |
0 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 |
3 ms |
604 KB |
Output is correct |
11 |
Correct |
3 ms |
716 KB |
Output is correct |
12 |
Correct |
3 ms |
728 KB |
Output is correct |
13 |
Correct |
3 ms |
604 KB |
Output is correct |
14 |
Correct |
3 ms |
604 KB |
Output is correct |
15 |
Correct |
4 ms |
604 KB |
Output is correct |
16 |
Correct |
4 ms |
604 KB |
Output is correct |
17 |
Correct |
3 ms |
720 KB |
Output is correct |
18 |
Correct |
3 ms |
604 KB |
Output is correct |
19 |
Correct |
3 ms |
604 KB |
Output is correct |
20 |
Correct |
4 ms |
716 KB |
Output is correct |
21 |
Correct |
861 ms |
2336 KB |
Output is correct |
22 |
Correct |
846 ms |
2344 KB |
Output is correct |
23 |
Correct |
836 ms |
2432 KB |
Output is correct |
24 |
Correct |
856 ms |
2384 KB |
Output is correct |
25 |
Correct |
880 ms |
2420 KB |
Output is correct |
26 |
Correct |
933 ms |
2388 KB |
Output is correct |
27 |
Correct |
885 ms |
2400 KB |
Output is correct |
28 |
Correct |
993 ms |
2632 KB |
Output is correct |
29 |
Correct |
993 ms |
2380 KB |
Output is correct |
30 |
Correct |
927 ms |
2428 KB |
Output is correct |
31 |
Correct |
978 ms |
2356 KB |
Output is correct |
32 |
Correct |
906 ms |
2400 KB |
Output is correct |
33 |
Correct |
882 ms |
2384 KB |
Output is correct |
34 |
Correct |
900 ms |
2380 KB |
Output is correct |
35 |
Correct |
867 ms |
2328 KB |
Output is correct |
36 |
Correct |
891 ms |
2332 KB |
Output is correct |
37 |
Correct |
901 ms |
2388 KB |
Output is correct |
38 |
Correct |
900 ms |
2304 KB |
Output is correct |
39 |
Correct |
905 ms |
2224 KB |
Output is correct |
40 |
Correct |
905 ms |
2132 KB |
Output is correct |
41 |
Correct |
820 ms |
2308 KB |
Output is correct |
42 |
Correct |
837 ms |
2248 KB |
Output is correct |
43 |
Correct |
815 ms |
2228 KB |
Output is correct |
44 |
Correct |
839 ms |
2384 KB |
Output is correct |
45 |
Correct |
805 ms |
2356 KB |
Output is correct |
46 |
Correct |
829 ms |
2292 KB |
Output is correct |
47 |
Correct |
842 ms |
2328 KB |
Output is correct |
48 |
Correct |
812 ms |
2428 KB |
Output is correct |
49 |
Correct |
846 ms |
2292 KB |
Output is correct |
50 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
51 |
Halted |
0 ms |
0 KB |
- |