# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1002849 |
2024-06-19T20:34:18 Z |
Lalic |
Cigle (COI21_cigle) |
C++17 |
|
260 ms |
524288 KB |
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define mp make_pair
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef complex<double> cd;
const int MAXN = 1e5+10;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);
int dp[505][505][505];
void solve(){
int n; cin >> n;
vector<int> arr(n+1); arr[0]=0;
for(int i=1;i<=n;i++) cin >> arr[i];
for(int i=3;i<=n;i++){
int sum=arr[i];
for(int c1=i-1;c1>=0;c1--){
int tot=arr[c1], best=0;
bool ok=0;
for(int c2=c1-1;c2>=0;c2--){
if(ok && tot>sum) dp[i][c1][c2]=dp[i-1][c1][c2]+1;
else{
if(tot==sum) ok=1;
dp[i][c1][c2]=dp[i-1][c1][c2];
}
tot+=arr[c2];
best=max(best, dp[i-1][c1][c2]);
}
sum+=arr[c1];
dp[i][i][c1]=best;
}
}
int ans=0;
for(int i=0;i<n;i++) ans=max(ans, dp[n][n][i]);
cout << ans << "\n";
}
int32_t main(){
ios_base::sync_with_stdio(false); cin.tie(NULL);
int tt=1;
//~ cin >> tt;
while(tt--) solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1112 KB |
Output is correct |
2 |
Correct |
1 ms |
1368 KB |
Output is correct |
3 |
Correct |
1 ms |
1116 KB |
Output is correct |
4 |
Correct |
1 ms |
1116 KB |
Output is correct |
5 |
Correct |
1 ms |
1116 KB |
Output is correct |
6 |
Correct |
1 ms |
1116 KB |
Output is correct |
7 |
Correct |
1 ms |
1116 KB |
Output is correct |
8 |
Correct |
0 ms |
1116 KB |
Output is correct |
9 |
Correct |
0 ms |
1116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1112 KB |
Output is correct |
2 |
Correct |
1 ms |
1368 KB |
Output is correct |
3 |
Correct |
1 ms |
1116 KB |
Output is correct |
4 |
Correct |
1 ms |
1116 KB |
Output is correct |
5 |
Correct |
1 ms |
1116 KB |
Output is correct |
6 |
Correct |
1 ms |
1116 KB |
Output is correct |
7 |
Correct |
1 ms |
1116 KB |
Output is correct |
8 |
Correct |
0 ms |
1116 KB |
Output is correct |
9 |
Correct |
0 ms |
1116 KB |
Output is correct |
10 |
Correct |
5 ms |
13404 KB |
Output is correct |
11 |
Correct |
6 ms |
13404 KB |
Output is correct |
12 |
Correct |
5 ms |
13404 KB |
Output is correct |
13 |
Correct |
5 ms |
13404 KB |
Output is correct |
14 |
Correct |
5 ms |
13404 KB |
Output is correct |
15 |
Correct |
6 ms |
13404 KB |
Output is correct |
16 |
Correct |
5 ms |
13404 KB |
Output is correct |
17 |
Correct |
5 ms |
13400 KB |
Output is correct |
18 |
Correct |
4 ms |
13404 KB |
Output is correct |
19 |
Correct |
4 ms |
13404 KB |
Output is correct |
20 |
Correct |
5 ms |
13404 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
190 ms |
497492 KB |
Output is correct |
2 |
Correct |
225 ms |
497364 KB |
Output is correct |
3 |
Correct |
175 ms |
498768 KB |
Output is correct |
4 |
Correct |
173 ms |
499540 KB |
Output is correct |
5 |
Correct |
169 ms |
499540 KB |
Output is correct |
6 |
Correct |
175 ms |
499528 KB |
Output is correct |
7 |
Correct |
180 ms |
499536 KB |
Output is correct |
8 |
Correct |
178 ms |
499352 KB |
Output is correct |
9 |
Correct |
180 ms |
499540 KB |
Output is correct |
10 |
Correct |
178 ms |
499328 KB |
Output is correct |
11 |
Correct |
168 ms |
499540 KB |
Output is correct |
12 |
Correct |
175 ms |
499492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1112 KB |
Output is correct |
2 |
Correct |
1 ms |
1368 KB |
Output is correct |
3 |
Correct |
1 ms |
1116 KB |
Output is correct |
4 |
Correct |
1 ms |
1116 KB |
Output is correct |
5 |
Correct |
1 ms |
1116 KB |
Output is correct |
6 |
Correct |
1 ms |
1116 KB |
Output is correct |
7 |
Correct |
1 ms |
1116 KB |
Output is correct |
8 |
Correct |
0 ms |
1116 KB |
Output is correct |
9 |
Correct |
0 ms |
1116 KB |
Output is correct |
10 |
Correct |
5 ms |
13404 KB |
Output is correct |
11 |
Correct |
6 ms |
13404 KB |
Output is correct |
12 |
Correct |
5 ms |
13404 KB |
Output is correct |
13 |
Correct |
5 ms |
13404 KB |
Output is correct |
14 |
Correct |
5 ms |
13404 KB |
Output is correct |
15 |
Correct |
6 ms |
13404 KB |
Output is correct |
16 |
Correct |
5 ms |
13404 KB |
Output is correct |
17 |
Correct |
5 ms |
13400 KB |
Output is correct |
18 |
Correct |
4 ms |
13404 KB |
Output is correct |
19 |
Correct |
4 ms |
13404 KB |
Output is correct |
20 |
Correct |
5 ms |
13404 KB |
Output is correct |
21 |
Correct |
190 ms |
497492 KB |
Output is correct |
22 |
Correct |
225 ms |
497364 KB |
Output is correct |
23 |
Correct |
175 ms |
498768 KB |
Output is correct |
24 |
Correct |
173 ms |
499540 KB |
Output is correct |
25 |
Correct |
169 ms |
499540 KB |
Output is correct |
26 |
Correct |
175 ms |
499528 KB |
Output is correct |
27 |
Correct |
180 ms |
499536 KB |
Output is correct |
28 |
Correct |
178 ms |
499352 KB |
Output is correct |
29 |
Correct |
180 ms |
499540 KB |
Output is correct |
30 |
Correct |
178 ms |
499328 KB |
Output is correct |
31 |
Correct |
168 ms |
499540 KB |
Output is correct |
32 |
Correct |
175 ms |
499492 KB |
Output is correct |
33 |
Correct |
168 ms |
499540 KB |
Output is correct |
34 |
Correct |
164 ms |
499544 KB |
Output is correct |
35 |
Correct |
175 ms |
499536 KB |
Output is correct |
36 |
Correct |
178 ms |
499796 KB |
Output is correct |
37 |
Correct |
187 ms |
499536 KB |
Output is correct |
38 |
Correct |
163 ms |
499536 KB |
Output is correct |
39 |
Correct |
167 ms |
499540 KB |
Output is correct |
40 |
Correct |
168 ms |
499504 KB |
Output is correct |
41 |
Correct |
166 ms |
499504 KB |
Output is correct |
42 |
Correct |
172 ms |
499548 KB |
Output is correct |
43 |
Correct |
168 ms |
499540 KB |
Output is correct |
44 |
Correct |
170 ms |
499536 KB |
Output is correct |
45 |
Correct |
177 ms |
499528 KB |
Output is correct |
46 |
Correct |
174 ms |
499500 KB |
Output is correct |
47 |
Correct |
171 ms |
499540 KB |
Output is correct |
48 |
Correct |
172 ms |
499540 KB |
Output is correct |
49 |
Correct |
175 ms |
499540 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1112 KB |
Output is correct |
2 |
Correct |
1 ms |
1368 KB |
Output is correct |
3 |
Correct |
1 ms |
1116 KB |
Output is correct |
4 |
Correct |
1 ms |
1116 KB |
Output is correct |
5 |
Correct |
1 ms |
1116 KB |
Output is correct |
6 |
Correct |
1 ms |
1116 KB |
Output is correct |
7 |
Correct |
1 ms |
1116 KB |
Output is correct |
8 |
Correct |
0 ms |
1116 KB |
Output is correct |
9 |
Correct |
0 ms |
1116 KB |
Output is correct |
10 |
Correct |
5 ms |
13404 KB |
Output is correct |
11 |
Correct |
6 ms |
13404 KB |
Output is correct |
12 |
Correct |
5 ms |
13404 KB |
Output is correct |
13 |
Correct |
5 ms |
13404 KB |
Output is correct |
14 |
Correct |
5 ms |
13404 KB |
Output is correct |
15 |
Correct |
6 ms |
13404 KB |
Output is correct |
16 |
Correct |
5 ms |
13404 KB |
Output is correct |
17 |
Correct |
5 ms |
13400 KB |
Output is correct |
18 |
Correct |
4 ms |
13404 KB |
Output is correct |
19 |
Correct |
4 ms |
13404 KB |
Output is correct |
20 |
Correct |
5 ms |
13404 KB |
Output is correct |
21 |
Correct |
190 ms |
497492 KB |
Output is correct |
22 |
Correct |
225 ms |
497364 KB |
Output is correct |
23 |
Correct |
175 ms |
498768 KB |
Output is correct |
24 |
Correct |
173 ms |
499540 KB |
Output is correct |
25 |
Correct |
169 ms |
499540 KB |
Output is correct |
26 |
Correct |
175 ms |
499528 KB |
Output is correct |
27 |
Correct |
180 ms |
499536 KB |
Output is correct |
28 |
Correct |
178 ms |
499352 KB |
Output is correct |
29 |
Correct |
180 ms |
499540 KB |
Output is correct |
30 |
Correct |
178 ms |
499328 KB |
Output is correct |
31 |
Correct |
168 ms |
499540 KB |
Output is correct |
32 |
Correct |
175 ms |
499492 KB |
Output is correct |
33 |
Correct |
168 ms |
499540 KB |
Output is correct |
34 |
Correct |
164 ms |
499544 KB |
Output is correct |
35 |
Correct |
175 ms |
499536 KB |
Output is correct |
36 |
Correct |
178 ms |
499796 KB |
Output is correct |
37 |
Correct |
187 ms |
499536 KB |
Output is correct |
38 |
Correct |
163 ms |
499536 KB |
Output is correct |
39 |
Correct |
167 ms |
499540 KB |
Output is correct |
40 |
Correct |
168 ms |
499504 KB |
Output is correct |
41 |
Correct |
166 ms |
499504 KB |
Output is correct |
42 |
Correct |
172 ms |
499548 KB |
Output is correct |
43 |
Correct |
168 ms |
499540 KB |
Output is correct |
44 |
Correct |
170 ms |
499536 KB |
Output is correct |
45 |
Correct |
177 ms |
499528 KB |
Output is correct |
46 |
Correct |
174 ms |
499500 KB |
Output is correct |
47 |
Correct |
171 ms |
499540 KB |
Output is correct |
48 |
Correct |
172 ms |
499540 KB |
Output is correct |
49 |
Correct |
175 ms |
499540 KB |
Output is correct |
50 |
Runtime error |
260 ms |
524288 KB |
Execution killed with signal 9 |
51 |
Halted |
0 ms |
0 KB |
- |