# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1024209 |
2024-07-15T16:17:50 Z |
MarwenElarbi |
Cigle (COI21_cigle) |
C++17 |
|
1000 ms |
98132 KB |
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#define ll long long
#define fi first
#define se second
#define pb push_back
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int nax=5e5+5;
signed main(){
iostream::sync_with_stdio(false);
int n;
cin>>n;
int tab[n];
for (int i = 0; i < n; ++i)
{
cin>>tab[i];
}
int dp[n][n];
memset(dp,0,sizeof dp);
for (int i = 0; i < n; ++i)
{
for (int j = i; j < n; ++j)
{
int cnt=0;
int cur=i;
int a=0;
int b=0;
//cout <<i<<" "<<j<<endl;
for (int k = i-1; k >= 0 ; --k)
{
a+=tab[k];
while(cur<=j&&b<a){
b+=tab[cur++];
}
//cout <<k<<" "<<a<<" "<<b<<" "<<cur<<" "<<dp[k][i-1]<<endl;
dp[i][j]=max(dp[i][j],dp[k][i-1]+cnt);
if(a==b&&k>0&&cur<=j) cnt++;
}
}
}
int ans=0;
for (int i = 0; i < n; ++i)
{
//cout <<dp[i][n-1]<<endl;
ans=max(ans,dp[i][n-1]);
}cout <<ans<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
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 |
1 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 |
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 |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
87 ms |
1416 KB |
Output is correct |
2 |
Correct |
84 ms |
1624 KB |
Output is correct |
3 |
Correct |
84 ms |
1372 KB |
Output is correct |
4 |
Correct |
86 ms |
1620 KB |
Output is correct |
5 |
Correct |
83 ms |
1368 KB |
Output is correct |
6 |
Correct |
87 ms |
1368 KB |
Output is correct |
7 |
Correct |
84 ms |
1368 KB |
Output is correct |
8 |
Correct |
96 ms |
1416 KB |
Output is correct |
9 |
Correct |
83 ms |
1372 KB |
Output is correct |
10 |
Correct |
83 ms |
1372 KB |
Output is correct |
11 |
Correct |
82 ms |
1372 KB |
Output is correct |
12 |
Correct |
83 ms |
1372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
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 |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
87 ms |
1416 KB |
Output is correct |
22 |
Correct |
84 ms |
1624 KB |
Output is correct |
23 |
Correct |
84 ms |
1372 KB |
Output is correct |
24 |
Correct |
86 ms |
1620 KB |
Output is correct |
25 |
Correct |
83 ms |
1368 KB |
Output is correct |
26 |
Correct |
87 ms |
1368 KB |
Output is correct |
27 |
Correct |
84 ms |
1368 KB |
Output is correct |
28 |
Correct |
96 ms |
1416 KB |
Output is correct |
29 |
Correct |
83 ms |
1372 KB |
Output is correct |
30 |
Correct |
83 ms |
1372 KB |
Output is correct |
31 |
Correct |
82 ms |
1372 KB |
Output is correct |
32 |
Correct |
83 ms |
1372 KB |
Output is correct |
33 |
Correct |
85 ms |
1372 KB |
Output is correct |
34 |
Correct |
85 ms |
1372 KB |
Output is correct |
35 |
Correct |
83 ms |
1372 KB |
Output is correct |
36 |
Correct |
85 ms |
1372 KB |
Output is correct |
37 |
Correct |
87 ms |
1372 KB |
Output is correct |
38 |
Correct |
88 ms |
1372 KB |
Output is correct |
39 |
Correct |
79 ms |
1368 KB |
Output is correct |
40 |
Correct |
78 ms |
1416 KB |
Output is correct |
41 |
Correct |
79 ms |
1372 KB |
Output is correct |
42 |
Correct |
83 ms |
1368 KB |
Output is correct |
43 |
Correct |
80 ms |
1368 KB |
Output is correct |
44 |
Correct |
78 ms |
1412 KB |
Output is correct |
45 |
Correct |
79 ms |
1368 KB |
Output is correct |
46 |
Correct |
78 ms |
1368 KB |
Output is correct |
47 |
Correct |
78 ms |
1368 KB |
Output is correct |
48 |
Correct |
79 ms |
1372 KB |
Output is correct |
49 |
Correct |
80 ms |
1368 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
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 |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
87 ms |
1416 KB |
Output is correct |
22 |
Correct |
84 ms |
1624 KB |
Output is correct |
23 |
Correct |
84 ms |
1372 KB |
Output is correct |
24 |
Correct |
86 ms |
1620 KB |
Output is correct |
25 |
Correct |
83 ms |
1368 KB |
Output is correct |
26 |
Correct |
87 ms |
1368 KB |
Output is correct |
27 |
Correct |
84 ms |
1368 KB |
Output is correct |
28 |
Correct |
96 ms |
1416 KB |
Output is correct |
29 |
Correct |
83 ms |
1372 KB |
Output is correct |
30 |
Correct |
83 ms |
1372 KB |
Output is correct |
31 |
Correct |
82 ms |
1372 KB |
Output is correct |
32 |
Correct |
83 ms |
1372 KB |
Output is correct |
33 |
Correct |
85 ms |
1372 KB |
Output is correct |
34 |
Correct |
85 ms |
1372 KB |
Output is correct |
35 |
Correct |
83 ms |
1372 KB |
Output is correct |
36 |
Correct |
85 ms |
1372 KB |
Output is correct |
37 |
Correct |
87 ms |
1372 KB |
Output is correct |
38 |
Correct |
88 ms |
1372 KB |
Output is correct |
39 |
Correct |
79 ms |
1368 KB |
Output is correct |
40 |
Correct |
78 ms |
1416 KB |
Output is correct |
41 |
Correct |
79 ms |
1372 KB |
Output is correct |
42 |
Correct |
83 ms |
1368 KB |
Output is correct |
43 |
Correct |
80 ms |
1368 KB |
Output is correct |
44 |
Correct |
78 ms |
1412 KB |
Output is correct |
45 |
Correct |
79 ms |
1368 KB |
Output is correct |
46 |
Correct |
78 ms |
1368 KB |
Output is correct |
47 |
Correct |
78 ms |
1368 KB |
Output is correct |
48 |
Correct |
79 ms |
1372 KB |
Output is correct |
49 |
Correct |
80 ms |
1368 KB |
Output is correct |
50 |
Execution timed out |
1018 ms |
98132 KB |
Time limit exceeded |
51 |
Halted |
0 ms |
0 KB |
- |