# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
887208 |
2023-12-14T05:17:00 Z |
zeta7532 |
Cigle (COI21_cigle) |
C++17 |
|
496 ms |
524288 KB |
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
const ll mod = 998244353;
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define faster ios::sync_with_stdio(false);cin.tie(nullptr)
ll f(vector<ll> &A,ll l,ll x,ll r){
set<ll> s;
ll cnt1=0;
for(ll i=x;i>l;i--){
cnt1+=A[i];
s.insert(cnt1);
}
ll cnt2=0;
for(ll i=x+1;i<r;i++){
cnt2+=A[i];
s.insert(cnt2);
}
return (r-l-1)-(ll)s.size();
}
int main() {
ll N;
cin >> N;
vector<ll> A(N);
rep(i,N) cin >> A[i];
vector<vector<vector<ll>>> dp(N,vector<vector<ll>>(N,vector<ll>(N)));
rep(i,N) rep(j,N) rep(k,N) dp[i][j][k]=f(A,i,j,k);
vector<vector<ll>> ep(N,vector<ll>(N,0));
rep(i,N){
rep(j,N){
rep(k,N){
if(j<i) continue;
if(k<j+1) continue;
ep[j+1][k]=max(ep[j+1][k],ep[i][j]+dp[i][j][k]);
}
}
}
ll ans=0;
rep(i,N) ans=max(ans,ep[i][N-1]);
cout << ans << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
3 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
344 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
2 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
3 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
344 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
2 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
437 ms |
4696 KB |
Output is correct |
11 |
Correct |
468 ms |
4724 KB |
Output is correct |
12 |
Correct |
455 ms |
4724 KB |
Output is correct |
13 |
Correct |
435 ms |
4724 KB |
Output is correct |
14 |
Correct |
435 ms |
4732 KB |
Output is correct |
15 |
Correct |
431 ms |
4724 KB |
Output is correct |
16 |
Correct |
476 ms |
4728 KB |
Output is correct |
17 |
Correct |
496 ms |
4728 KB |
Output is correct |
18 |
Correct |
458 ms |
4700 KB |
Output is correct |
19 |
Correct |
480 ms |
4724 KB |
Output is correct |
20 |
Correct |
488 ms |
4724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
243 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
3 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
344 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
2 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
437 ms |
4696 KB |
Output is correct |
11 |
Correct |
468 ms |
4724 KB |
Output is correct |
12 |
Correct |
455 ms |
4724 KB |
Output is correct |
13 |
Correct |
435 ms |
4724 KB |
Output is correct |
14 |
Correct |
435 ms |
4732 KB |
Output is correct |
15 |
Correct |
431 ms |
4724 KB |
Output is correct |
16 |
Correct |
476 ms |
4728 KB |
Output is correct |
17 |
Correct |
496 ms |
4728 KB |
Output is correct |
18 |
Correct |
458 ms |
4700 KB |
Output is correct |
19 |
Correct |
480 ms |
4724 KB |
Output is correct |
20 |
Correct |
488 ms |
4724 KB |
Output is correct |
21 |
Runtime error |
243 ms |
524288 KB |
Execution killed with signal 9 |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
3 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
344 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
2 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
437 ms |
4696 KB |
Output is correct |
11 |
Correct |
468 ms |
4724 KB |
Output is correct |
12 |
Correct |
455 ms |
4724 KB |
Output is correct |
13 |
Correct |
435 ms |
4724 KB |
Output is correct |
14 |
Correct |
435 ms |
4732 KB |
Output is correct |
15 |
Correct |
431 ms |
4724 KB |
Output is correct |
16 |
Correct |
476 ms |
4728 KB |
Output is correct |
17 |
Correct |
496 ms |
4728 KB |
Output is correct |
18 |
Correct |
458 ms |
4700 KB |
Output is correct |
19 |
Correct |
480 ms |
4724 KB |
Output is correct |
20 |
Correct |
488 ms |
4724 KB |
Output is correct |
21 |
Runtime error |
243 ms |
524288 KB |
Execution killed with signal 9 |
22 |
Halted |
0 ms |
0 KB |
- |