# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1002915 |
2024-06-19T21:20:36 Z |
Lalic |
Cigle (COI21_cigle) |
C++17 |
|
1000 ms |
244796 KB |
#include <bits/stdc++.h>
#pragma GCC optimize "Ofast"
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
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef complex<double> cd;
const int MAXN = 5005;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);
int tree[MAXN][4*MAXN], lazy[MAXN][4*MAXN];
void lazyP(int id, int node, int l, int r){
if(!lazy[id][node]) return;
tree[id][node]+=lazy[id][node];
if(l!=r){
lazy[id][node*2]+=lazy[id][node];
lazy[id][node*2+1]+=lazy[id][node];
}
lazy[id][node]=0;
}
void upd(int id, int node, int l, int r, int p, int q, int val){
lazyP(id, node, l, r);
if(r<p || l>q) return;
if(l>=p && r<=q){
lazy[id][node]+=val;
lazyP(id, node, l, r);
return;
}
int mid=(l+r)>>1;
upd(id, node*2, l, mid, p, q, val);
upd(id, node*2+1, mid+1, r, p, q, val);
tree[id][node]=max(tree[id][node*2], tree[id][node*2+1]);
}
int query(int id, int node, int l, int r, int p, int q){
lazyP(id, node, l, r);
if(r<p || l>q) return 0;
if(l>=p && r<=q) return tree[id][node];
int mid=(l+r)>>1;
if(r<=mid) return query(id, node*2, l, mid, p, q);
if(l>=mid+1) return query(id, node*2+1, mid+1, r, p, q);
return max(query(id, node*2, l, mid, p, q), query(id, node*2+1, mid+1, r, p, q));
}
void solve(){
int n; cin >> n;
vector<int> arr(n+1);
for(int i=1;i<=n;i++) cin >> arr[i];
for(int i=3;i<=n;i++){
int sum=arr[i], c2=i-2, tot=arr[i-1];
for(int c1=i-1;c1>=0;c1--){
upd(i, 1, 0, n, c1, c1, query(c1, 1, 0, n, 0, n));
while(c2>0 && tot<sum){
tot+=arr[c2];
c2--;
}
if(tot==sum && c2>0) upd(c1, 1, 0, n, 0, c2-1, 1);
sum+=arr[c1];
tot-=arr[c1];
}
}
cout << query(n, 1, 0, n, 0, n) << "\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 |
0 ms |
604 KB |
Output is correct |
2 |
Correct |
0 ms |
604 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
604 KB |
Output is correct |
5 |
Correct |
0 ms |
468 KB |
Output is correct |
6 |
Correct |
0 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
464 KB |
Output is correct |
9 |
Correct |
0 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
604 KB |
Output is correct |
2 |
Correct |
0 ms |
604 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
604 KB |
Output is correct |
5 |
Correct |
0 ms |
468 KB |
Output is correct |
6 |
Correct |
0 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
464 KB |
Output is correct |
9 |
Correct |
0 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
1180 KB |
Output is correct |
11 |
Correct |
1 ms |
1240 KB |
Output is correct |
12 |
Correct |
1 ms |
1116 KB |
Output is correct |
13 |
Correct |
1 ms |
1116 KB |
Output is correct |
14 |
Correct |
1 ms |
1116 KB |
Output is correct |
15 |
Correct |
1 ms |
1116 KB |
Output is correct |
16 |
Correct |
1 ms |
1116 KB |
Output is correct |
17 |
Correct |
1 ms |
1116 KB |
Output is correct |
18 |
Correct |
1 ms |
1112 KB |
Output is correct |
19 |
Correct |
1 ms |
1116 KB |
Output is correct |
20 |
Correct |
1 ms |
1228 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
7436 KB |
Output is correct |
2 |
Correct |
19 ms |
7416 KB |
Output is correct |
3 |
Correct |
18 ms |
7516 KB |
Output is correct |
4 |
Correct |
33 ms |
7464 KB |
Output is correct |
5 |
Correct |
19 ms |
7516 KB |
Output is correct |
6 |
Correct |
19 ms |
7536 KB |
Output is correct |
7 |
Correct |
19 ms |
7516 KB |
Output is correct |
8 |
Correct |
17 ms |
7516 KB |
Output is correct |
9 |
Correct |
25 ms |
7540 KB |
Output is correct |
10 |
Correct |
16 ms |
7516 KB |
Output is correct |
11 |
Correct |
17 ms |
7516 KB |
Output is correct |
12 |
Correct |
18 ms |
7516 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
604 KB |
Output is correct |
2 |
Correct |
0 ms |
604 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
604 KB |
Output is correct |
5 |
Correct |
0 ms |
468 KB |
Output is correct |
6 |
Correct |
0 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
464 KB |
Output is correct |
9 |
Correct |
0 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
1180 KB |
Output is correct |
11 |
Correct |
1 ms |
1240 KB |
Output is correct |
12 |
Correct |
1 ms |
1116 KB |
Output is correct |
13 |
Correct |
1 ms |
1116 KB |
Output is correct |
14 |
Correct |
1 ms |
1116 KB |
Output is correct |
15 |
Correct |
1 ms |
1116 KB |
Output is correct |
16 |
Correct |
1 ms |
1116 KB |
Output is correct |
17 |
Correct |
1 ms |
1116 KB |
Output is correct |
18 |
Correct |
1 ms |
1112 KB |
Output is correct |
19 |
Correct |
1 ms |
1116 KB |
Output is correct |
20 |
Correct |
1 ms |
1228 KB |
Output is correct |
21 |
Correct |
20 ms |
7436 KB |
Output is correct |
22 |
Correct |
19 ms |
7416 KB |
Output is correct |
23 |
Correct |
18 ms |
7516 KB |
Output is correct |
24 |
Correct |
33 ms |
7464 KB |
Output is correct |
25 |
Correct |
19 ms |
7516 KB |
Output is correct |
26 |
Correct |
19 ms |
7536 KB |
Output is correct |
27 |
Correct |
19 ms |
7516 KB |
Output is correct |
28 |
Correct |
17 ms |
7516 KB |
Output is correct |
29 |
Correct |
25 ms |
7540 KB |
Output is correct |
30 |
Correct |
16 ms |
7516 KB |
Output is correct |
31 |
Correct |
17 ms |
7516 KB |
Output is correct |
32 |
Correct |
18 ms |
7516 KB |
Output is correct |
33 |
Correct |
17 ms |
7516 KB |
Output is correct |
34 |
Correct |
17 ms |
7516 KB |
Output is correct |
35 |
Correct |
18 ms |
7512 KB |
Output is correct |
36 |
Correct |
16 ms |
7516 KB |
Output is correct |
37 |
Correct |
19 ms |
7516 KB |
Output is correct |
38 |
Correct |
23 ms |
7344 KB |
Output is correct |
39 |
Correct |
14 ms |
7472 KB |
Output is correct |
40 |
Correct |
12 ms |
6748 KB |
Output is correct |
41 |
Correct |
13 ms |
7196 KB |
Output is correct |
42 |
Correct |
12 ms |
7256 KB |
Output is correct |
43 |
Correct |
12 ms |
7252 KB |
Output is correct |
44 |
Correct |
12 ms |
6824 KB |
Output is correct |
45 |
Correct |
13 ms |
7256 KB |
Output is correct |
46 |
Correct |
13 ms |
7260 KB |
Output is correct |
47 |
Correct |
13 ms |
7004 KB |
Output is correct |
48 |
Correct |
13 ms |
7004 KB |
Output is correct |
49 |
Correct |
12 ms |
7304 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
604 KB |
Output is correct |
2 |
Correct |
0 ms |
604 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
604 KB |
Output is correct |
5 |
Correct |
0 ms |
468 KB |
Output is correct |
6 |
Correct |
0 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
464 KB |
Output is correct |
9 |
Correct |
0 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
1180 KB |
Output is correct |
11 |
Correct |
1 ms |
1240 KB |
Output is correct |
12 |
Correct |
1 ms |
1116 KB |
Output is correct |
13 |
Correct |
1 ms |
1116 KB |
Output is correct |
14 |
Correct |
1 ms |
1116 KB |
Output is correct |
15 |
Correct |
1 ms |
1116 KB |
Output is correct |
16 |
Correct |
1 ms |
1116 KB |
Output is correct |
17 |
Correct |
1 ms |
1116 KB |
Output is correct |
18 |
Correct |
1 ms |
1112 KB |
Output is correct |
19 |
Correct |
1 ms |
1116 KB |
Output is correct |
20 |
Correct |
1 ms |
1228 KB |
Output is correct |
21 |
Correct |
20 ms |
7436 KB |
Output is correct |
22 |
Correct |
19 ms |
7416 KB |
Output is correct |
23 |
Correct |
18 ms |
7516 KB |
Output is correct |
24 |
Correct |
33 ms |
7464 KB |
Output is correct |
25 |
Correct |
19 ms |
7516 KB |
Output is correct |
26 |
Correct |
19 ms |
7536 KB |
Output is correct |
27 |
Correct |
19 ms |
7516 KB |
Output is correct |
28 |
Correct |
17 ms |
7516 KB |
Output is correct |
29 |
Correct |
25 ms |
7540 KB |
Output is correct |
30 |
Correct |
16 ms |
7516 KB |
Output is correct |
31 |
Correct |
17 ms |
7516 KB |
Output is correct |
32 |
Correct |
18 ms |
7516 KB |
Output is correct |
33 |
Correct |
17 ms |
7516 KB |
Output is correct |
34 |
Correct |
17 ms |
7516 KB |
Output is correct |
35 |
Correct |
18 ms |
7512 KB |
Output is correct |
36 |
Correct |
16 ms |
7516 KB |
Output is correct |
37 |
Correct |
19 ms |
7516 KB |
Output is correct |
38 |
Correct |
23 ms |
7344 KB |
Output is correct |
39 |
Correct |
14 ms |
7472 KB |
Output is correct |
40 |
Correct |
12 ms |
6748 KB |
Output is correct |
41 |
Correct |
13 ms |
7196 KB |
Output is correct |
42 |
Correct |
12 ms |
7256 KB |
Output is correct |
43 |
Correct |
12 ms |
7252 KB |
Output is correct |
44 |
Correct |
12 ms |
6824 KB |
Output is correct |
45 |
Correct |
13 ms |
7256 KB |
Output is correct |
46 |
Correct |
13 ms |
7260 KB |
Output is correct |
47 |
Correct |
13 ms |
7004 KB |
Output is correct |
48 |
Correct |
13 ms |
7004 KB |
Output is correct |
49 |
Correct |
12 ms |
7304 KB |
Output is correct |
50 |
Execution timed out |
1028 ms |
244796 KB |
Time limit exceeded |
51 |
Halted |
0 ms |
0 KB |
- |