# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1002908 |
2024-06-19T21:18:35 Z |
Lalic |
Cigle (COI21_cigle) |
C++17 |
|
1000 ms |
357716 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
#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 = 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;
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 |
600 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 |
604 KB |
Output is correct |
6 |
Correct |
0 ms |
456 KB |
Output is correct |
7 |
Correct |
0 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
604 KB |
Output is correct |
9 |
Correct |
0 ms |
600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
600 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 |
604 KB |
Output is correct |
6 |
Correct |
0 ms |
456 KB |
Output is correct |
7 |
Correct |
0 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
604 KB |
Output is correct |
9 |
Correct |
0 ms |
600 KB |
Output is correct |
10 |
Correct |
1 ms |
1116 KB |
Output is correct |
11 |
Correct |
1 ms |
1116 KB |
Output is correct |
12 |
Correct |
1 ms |
1372 KB |
Output is correct |
13 |
Correct |
1 ms |
1240 KB |
Output is correct |
14 |
Correct |
1 ms |
1372 KB |
Output is correct |
15 |
Correct |
2 ms |
1372 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 |
1116 KB |
Output is correct |
19 |
Correct |
1 ms |
1116 KB |
Output is correct |
20 |
Correct |
1 ms |
1116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
10588 KB |
Output is correct |
2 |
Correct |
24 ms |
10588 KB |
Output is correct |
3 |
Correct |
26 ms |
10504 KB |
Output is correct |
4 |
Correct |
22 ms |
10568 KB |
Output is correct |
5 |
Correct |
20 ms |
10664 KB |
Output is correct |
6 |
Correct |
19 ms |
10528 KB |
Output is correct |
7 |
Correct |
19 ms |
10524 KB |
Output is correct |
8 |
Correct |
21 ms |
10588 KB |
Output is correct |
9 |
Correct |
20 ms |
10600 KB |
Output is correct |
10 |
Correct |
21 ms |
10548 KB |
Output is correct |
11 |
Correct |
19 ms |
10580 KB |
Output is correct |
12 |
Correct |
18 ms |
10588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
600 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 |
604 KB |
Output is correct |
6 |
Correct |
0 ms |
456 KB |
Output is correct |
7 |
Correct |
0 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
604 KB |
Output is correct |
9 |
Correct |
0 ms |
600 KB |
Output is correct |
10 |
Correct |
1 ms |
1116 KB |
Output is correct |
11 |
Correct |
1 ms |
1116 KB |
Output is correct |
12 |
Correct |
1 ms |
1372 KB |
Output is correct |
13 |
Correct |
1 ms |
1240 KB |
Output is correct |
14 |
Correct |
1 ms |
1372 KB |
Output is correct |
15 |
Correct |
2 ms |
1372 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 |
1116 KB |
Output is correct |
19 |
Correct |
1 ms |
1116 KB |
Output is correct |
20 |
Correct |
1 ms |
1116 KB |
Output is correct |
21 |
Correct |
21 ms |
10588 KB |
Output is correct |
22 |
Correct |
24 ms |
10588 KB |
Output is correct |
23 |
Correct |
26 ms |
10504 KB |
Output is correct |
24 |
Correct |
22 ms |
10568 KB |
Output is correct |
25 |
Correct |
20 ms |
10664 KB |
Output is correct |
26 |
Correct |
19 ms |
10528 KB |
Output is correct |
27 |
Correct |
19 ms |
10524 KB |
Output is correct |
28 |
Correct |
21 ms |
10588 KB |
Output is correct |
29 |
Correct |
20 ms |
10600 KB |
Output is correct |
30 |
Correct |
21 ms |
10548 KB |
Output is correct |
31 |
Correct |
19 ms |
10580 KB |
Output is correct |
32 |
Correct |
18 ms |
10588 KB |
Output is correct |
33 |
Correct |
18 ms |
10588 KB |
Output is correct |
34 |
Correct |
20 ms |
10576 KB |
Output is correct |
35 |
Correct |
19 ms |
10576 KB |
Output is correct |
36 |
Correct |
20 ms |
10588 KB |
Output is correct |
37 |
Correct |
20 ms |
10588 KB |
Output is correct |
38 |
Correct |
20 ms |
10480 KB |
Output is correct |
39 |
Correct |
16 ms |
10596 KB |
Output is correct |
40 |
Correct |
14 ms |
9052 KB |
Output is correct |
41 |
Correct |
14 ms |
10076 KB |
Output is correct |
42 |
Correct |
14 ms |
10332 KB |
Output is correct |
43 |
Correct |
13 ms |
10092 KB |
Output is correct |
44 |
Correct |
14 ms |
9308 KB |
Output is correct |
45 |
Correct |
14 ms |
10072 KB |
Output is correct |
46 |
Correct |
14 ms |
10096 KB |
Output is correct |
47 |
Correct |
13 ms |
9624 KB |
Output is correct |
48 |
Correct |
13 ms |
9820 KB |
Output is correct |
49 |
Correct |
13 ms |
10076 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
600 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 |
604 KB |
Output is correct |
6 |
Correct |
0 ms |
456 KB |
Output is correct |
7 |
Correct |
0 ms |
604 KB |
Output is correct |
8 |
Correct |
0 ms |
604 KB |
Output is correct |
9 |
Correct |
0 ms |
600 KB |
Output is correct |
10 |
Correct |
1 ms |
1116 KB |
Output is correct |
11 |
Correct |
1 ms |
1116 KB |
Output is correct |
12 |
Correct |
1 ms |
1372 KB |
Output is correct |
13 |
Correct |
1 ms |
1240 KB |
Output is correct |
14 |
Correct |
1 ms |
1372 KB |
Output is correct |
15 |
Correct |
2 ms |
1372 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 |
1116 KB |
Output is correct |
19 |
Correct |
1 ms |
1116 KB |
Output is correct |
20 |
Correct |
1 ms |
1116 KB |
Output is correct |
21 |
Correct |
21 ms |
10588 KB |
Output is correct |
22 |
Correct |
24 ms |
10588 KB |
Output is correct |
23 |
Correct |
26 ms |
10504 KB |
Output is correct |
24 |
Correct |
22 ms |
10568 KB |
Output is correct |
25 |
Correct |
20 ms |
10664 KB |
Output is correct |
26 |
Correct |
19 ms |
10528 KB |
Output is correct |
27 |
Correct |
19 ms |
10524 KB |
Output is correct |
28 |
Correct |
21 ms |
10588 KB |
Output is correct |
29 |
Correct |
20 ms |
10600 KB |
Output is correct |
30 |
Correct |
21 ms |
10548 KB |
Output is correct |
31 |
Correct |
19 ms |
10580 KB |
Output is correct |
32 |
Correct |
18 ms |
10588 KB |
Output is correct |
33 |
Correct |
18 ms |
10588 KB |
Output is correct |
34 |
Correct |
20 ms |
10576 KB |
Output is correct |
35 |
Correct |
19 ms |
10576 KB |
Output is correct |
36 |
Correct |
20 ms |
10588 KB |
Output is correct |
37 |
Correct |
20 ms |
10588 KB |
Output is correct |
38 |
Correct |
20 ms |
10480 KB |
Output is correct |
39 |
Correct |
16 ms |
10596 KB |
Output is correct |
40 |
Correct |
14 ms |
9052 KB |
Output is correct |
41 |
Correct |
14 ms |
10076 KB |
Output is correct |
42 |
Correct |
14 ms |
10332 KB |
Output is correct |
43 |
Correct |
13 ms |
10092 KB |
Output is correct |
44 |
Correct |
14 ms |
9308 KB |
Output is correct |
45 |
Correct |
14 ms |
10072 KB |
Output is correct |
46 |
Correct |
14 ms |
10096 KB |
Output is correct |
47 |
Correct |
13 ms |
9624 KB |
Output is correct |
48 |
Correct |
13 ms |
9820 KB |
Output is correct |
49 |
Correct |
13 ms |
10076 KB |
Output is correct |
50 |
Execution timed out |
1033 ms |
357716 KB |
Time limit exceeded |
51 |
Halted |
0 ms |
0 KB |
- |