# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1024554 |
2024-07-16T07:24:28 Z |
MarwenElarbi |
Cigle (COI21_cigle) |
C++17 |
|
129 ms |
196696 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=5005;
long long dp[nax][nax];
int mx[nax];
signed main(){
iostream::sync_with_stdio(false);
int n;
cin>>n;
memset(dp,-1,sizeof dp);
int tab[n];
for (int i = 1; i <= n; ++i)
{
cin>>tab[i];
}
for (int i = 1; i <= n; ++i)
{
for (int j = 1; j <= i-1; ++j)
{
mx[j]=dp[j][i-1];
}
for (int j = 1; j <= i-1; ++j)
{
mx[j]=max(mx[j],mx[j-1]);
}
int a=0,b=0,x=0,pct=0,pos=i-1;
for (int j = i; j <= n; ++j)
{
b+=tab[j];
while(pos>0&&a<b) {
a+=tab[pos];
pos--;
}
if (pos>0&& a==b) {
pct++;
x=max(x,mx[pos]+pct);
}
dp[i][j+1]=x;
}
}
ll res=0;
for (int i = 1; i <= n; ++i)
{
res=max(res,dp[i][n]);
}
cout <<res<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
196432 KB |
Output is correct |
2 |
Correct |
22 ms |
196432 KB |
Output is correct |
3 |
Correct |
22 ms |
196432 KB |
Output is correct |
4 |
Correct |
24 ms |
196500 KB |
Output is correct |
5 |
Correct |
22 ms |
196348 KB |
Output is correct |
6 |
Correct |
22 ms |
196516 KB |
Output is correct |
7 |
Correct |
23 ms |
196444 KB |
Output is correct |
8 |
Correct |
22 ms |
196308 KB |
Output is correct |
9 |
Correct |
22 ms |
196432 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
196432 KB |
Output is correct |
2 |
Correct |
22 ms |
196432 KB |
Output is correct |
3 |
Correct |
22 ms |
196432 KB |
Output is correct |
4 |
Correct |
24 ms |
196500 KB |
Output is correct |
5 |
Correct |
22 ms |
196348 KB |
Output is correct |
6 |
Correct |
22 ms |
196516 KB |
Output is correct |
7 |
Correct |
23 ms |
196444 KB |
Output is correct |
8 |
Correct |
22 ms |
196308 KB |
Output is correct |
9 |
Correct |
22 ms |
196432 KB |
Output is correct |
10 |
Correct |
22 ms |
196436 KB |
Output is correct |
11 |
Correct |
22 ms |
196296 KB |
Output is correct |
12 |
Correct |
22 ms |
196444 KB |
Output is correct |
13 |
Correct |
22 ms |
196436 KB |
Output is correct |
14 |
Correct |
22 ms |
196400 KB |
Output is correct |
15 |
Correct |
22 ms |
196448 KB |
Output is correct |
16 |
Correct |
22 ms |
196400 KB |
Output is correct |
17 |
Correct |
22 ms |
196432 KB |
Output is correct |
18 |
Correct |
22 ms |
196436 KB |
Output is correct |
19 |
Correct |
22 ms |
196512 KB |
Output is correct |
20 |
Correct |
22 ms |
196436 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
196444 KB |
Output is correct |
2 |
Correct |
23 ms |
196444 KB |
Output is correct |
3 |
Correct |
23 ms |
196432 KB |
Output is correct |
4 |
Correct |
23 ms |
196492 KB |
Output is correct |
5 |
Correct |
23 ms |
196444 KB |
Output is correct |
6 |
Correct |
23 ms |
196444 KB |
Output is correct |
7 |
Correct |
23 ms |
196440 KB |
Output is correct |
8 |
Correct |
23 ms |
196312 KB |
Output is correct |
9 |
Correct |
23 ms |
196436 KB |
Output is correct |
10 |
Correct |
25 ms |
196444 KB |
Output is correct |
11 |
Correct |
23 ms |
196444 KB |
Output is correct |
12 |
Correct |
23 ms |
196432 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
196432 KB |
Output is correct |
2 |
Correct |
22 ms |
196432 KB |
Output is correct |
3 |
Correct |
22 ms |
196432 KB |
Output is correct |
4 |
Correct |
24 ms |
196500 KB |
Output is correct |
5 |
Correct |
22 ms |
196348 KB |
Output is correct |
6 |
Correct |
22 ms |
196516 KB |
Output is correct |
7 |
Correct |
23 ms |
196444 KB |
Output is correct |
8 |
Correct |
22 ms |
196308 KB |
Output is correct |
9 |
Correct |
22 ms |
196432 KB |
Output is correct |
10 |
Correct |
22 ms |
196436 KB |
Output is correct |
11 |
Correct |
22 ms |
196296 KB |
Output is correct |
12 |
Correct |
22 ms |
196444 KB |
Output is correct |
13 |
Correct |
22 ms |
196436 KB |
Output is correct |
14 |
Correct |
22 ms |
196400 KB |
Output is correct |
15 |
Correct |
22 ms |
196448 KB |
Output is correct |
16 |
Correct |
22 ms |
196400 KB |
Output is correct |
17 |
Correct |
22 ms |
196432 KB |
Output is correct |
18 |
Correct |
22 ms |
196436 KB |
Output is correct |
19 |
Correct |
22 ms |
196512 KB |
Output is correct |
20 |
Correct |
22 ms |
196436 KB |
Output is correct |
21 |
Correct |
23 ms |
196444 KB |
Output is correct |
22 |
Correct |
23 ms |
196444 KB |
Output is correct |
23 |
Correct |
23 ms |
196432 KB |
Output is correct |
24 |
Correct |
23 ms |
196492 KB |
Output is correct |
25 |
Correct |
23 ms |
196444 KB |
Output is correct |
26 |
Correct |
23 ms |
196444 KB |
Output is correct |
27 |
Correct |
23 ms |
196440 KB |
Output is correct |
28 |
Correct |
23 ms |
196312 KB |
Output is correct |
29 |
Correct |
23 ms |
196436 KB |
Output is correct |
30 |
Correct |
25 ms |
196444 KB |
Output is correct |
31 |
Correct |
23 ms |
196444 KB |
Output is correct |
32 |
Correct |
23 ms |
196432 KB |
Output is correct |
33 |
Correct |
23 ms |
196440 KB |
Output is correct |
34 |
Correct |
23 ms |
196436 KB |
Output is correct |
35 |
Correct |
23 ms |
196436 KB |
Output is correct |
36 |
Correct |
23 ms |
196516 KB |
Output is correct |
37 |
Correct |
23 ms |
196520 KB |
Output is correct |
38 |
Correct |
25 ms |
196444 KB |
Output is correct |
39 |
Correct |
23 ms |
196316 KB |
Output is correct |
40 |
Correct |
23 ms |
196440 KB |
Output is correct |
41 |
Correct |
23 ms |
196432 KB |
Output is correct |
42 |
Correct |
23 ms |
196400 KB |
Output is correct |
43 |
Correct |
23 ms |
196476 KB |
Output is correct |
44 |
Correct |
23 ms |
196436 KB |
Output is correct |
45 |
Correct |
24 ms |
196436 KB |
Output is correct |
46 |
Correct |
23 ms |
196444 KB |
Output is correct |
47 |
Correct |
23 ms |
196348 KB |
Output is correct |
48 |
Correct |
23 ms |
196444 KB |
Output is correct |
49 |
Correct |
23 ms |
196332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
196432 KB |
Output is correct |
2 |
Correct |
22 ms |
196432 KB |
Output is correct |
3 |
Correct |
22 ms |
196432 KB |
Output is correct |
4 |
Correct |
24 ms |
196500 KB |
Output is correct |
5 |
Correct |
22 ms |
196348 KB |
Output is correct |
6 |
Correct |
22 ms |
196516 KB |
Output is correct |
7 |
Correct |
23 ms |
196444 KB |
Output is correct |
8 |
Correct |
22 ms |
196308 KB |
Output is correct |
9 |
Correct |
22 ms |
196432 KB |
Output is correct |
10 |
Correct |
22 ms |
196436 KB |
Output is correct |
11 |
Correct |
22 ms |
196296 KB |
Output is correct |
12 |
Correct |
22 ms |
196444 KB |
Output is correct |
13 |
Correct |
22 ms |
196436 KB |
Output is correct |
14 |
Correct |
22 ms |
196400 KB |
Output is correct |
15 |
Correct |
22 ms |
196448 KB |
Output is correct |
16 |
Correct |
22 ms |
196400 KB |
Output is correct |
17 |
Correct |
22 ms |
196432 KB |
Output is correct |
18 |
Correct |
22 ms |
196436 KB |
Output is correct |
19 |
Correct |
22 ms |
196512 KB |
Output is correct |
20 |
Correct |
22 ms |
196436 KB |
Output is correct |
21 |
Correct |
23 ms |
196444 KB |
Output is correct |
22 |
Correct |
23 ms |
196444 KB |
Output is correct |
23 |
Correct |
23 ms |
196432 KB |
Output is correct |
24 |
Correct |
23 ms |
196492 KB |
Output is correct |
25 |
Correct |
23 ms |
196444 KB |
Output is correct |
26 |
Correct |
23 ms |
196444 KB |
Output is correct |
27 |
Correct |
23 ms |
196440 KB |
Output is correct |
28 |
Correct |
23 ms |
196312 KB |
Output is correct |
29 |
Correct |
23 ms |
196436 KB |
Output is correct |
30 |
Correct |
25 ms |
196444 KB |
Output is correct |
31 |
Correct |
23 ms |
196444 KB |
Output is correct |
32 |
Correct |
23 ms |
196432 KB |
Output is correct |
33 |
Correct |
23 ms |
196440 KB |
Output is correct |
34 |
Correct |
23 ms |
196436 KB |
Output is correct |
35 |
Correct |
23 ms |
196436 KB |
Output is correct |
36 |
Correct |
23 ms |
196516 KB |
Output is correct |
37 |
Correct |
23 ms |
196520 KB |
Output is correct |
38 |
Correct |
25 ms |
196444 KB |
Output is correct |
39 |
Correct |
23 ms |
196316 KB |
Output is correct |
40 |
Correct |
23 ms |
196440 KB |
Output is correct |
41 |
Correct |
23 ms |
196432 KB |
Output is correct |
42 |
Correct |
23 ms |
196400 KB |
Output is correct |
43 |
Correct |
23 ms |
196476 KB |
Output is correct |
44 |
Correct |
23 ms |
196436 KB |
Output is correct |
45 |
Correct |
24 ms |
196436 KB |
Output is correct |
46 |
Correct |
23 ms |
196444 KB |
Output is correct |
47 |
Correct |
23 ms |
196348 KB |
Output is correct |
48 |
Correct |
23 ms |
196444 KB |
Output is correct |
49 |
Correct |
23 ms |
196332 KB |
Output is correct |
50 |
Correct |
92 ms |
196436 KB |
Output is correct |
51 |
Correct |
92 ms |
196460 KB |
Output is correct |
52 |
Correct |
97 ms |
196576 KB |
Output is correct |
53 |
Correct |
91 ms |
196696 KB |
Output is correct |
54 |
Correct |
96 ms |
196436 KB |
Output is correct |
55 |
Correct |
97 ms |
196572 KB |
Output is correct |
56 |
Correct |
125 ms |
196488 KB |
Output is correct |
57 |
Correct |
126 ms |
196432 KB |
Output is correct |
58 |
Correct |
129 ms |
196696 KB |
Output is correct |
59 |
Correct |
123 ms |
196432 KB |
Output is correct |
60 |
Correct |
117 ms |
196576 KB |
Output is correct |
61 |
Correct |
107 ms |
196436 KB |
Output is correct |
62 |
Correct |
105 ms |
196572 KB |
Output is correct |
63 |
Correct |
97 ms |
196580 KB |
Output is correct |
64 |
Correct |
99 ms |
196436 KB |
Output is correct |
65 |
Correct |
93 ms |
196440 KB |
Output is correct |
66 |
Correct |
99 ms |
196444 KB |
Output is correct |
67 |
Correct |
90 ms |
196576 KB |
Output is correct |
68 |
Correct |
92 ms |
196360 KB |
Output is correct |
69 |
Correct |
100 ms |
196444 KB |
Output is correct |
70 |
Correct |
116 ms |
196436 KB |
Output is correct |
71 |
Correct |
119 ms |
196436 KB |
Output is correct |
72 |
Correct |
109 ms |
196688 KB |
Output is correct |