# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
491659 |
2021-12-03T17:50:24 Z |
Bench0310 |
Teams (CEOI11_tea) |
C++17 |
|
2500 ms |
43408 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1000005;
vector<array<int,2>> tree(4*N,{0,0});
void update(int idx,int l,int r,int pos,int x)
{
if(l==r) tree[idx]={x,pos};
else
{
int m=(l+r)/2;
if(pos<=m) update(2*idx,l,m,pos,x);
else update(2*idx+1,m+1,r,pos,x);
tree[idx]=max(tree[2*idx],tree[2*idx+1]);
}
}
array<int,2> query(int idx,int l,int r,int ql,int qr)
{
if(ql>qr) return {-1,0};
if(l==ql&&r==qr) return tree[idx];
int m=(l+r)/2;
return max(query(2*idx,l,m,ql,min(qr,m)),query(2*idx+1,m+1,r,max(ql,m+1),qr));
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vector<array<int,2>> a(n+1,{0,0});
for(int i=1;i<=n;i++)
{
cin >> a[i][0];
a[i][1]=i;
}
sort(a.begin(),a.end());
vector<int> p(n+1,0);
auto go=[&](int lim)->int
{
int t=0;
update(1,0,n,0,0);
for(int i=1;i<=n;i++)
{
auto [x,j]=query(1,0,n,max(0,i-lim),i-a[i][0]);
if(x==-1) update(1,0,n,i,-1);
else
{
update(1,0,n,i,x+1);
p[i]=j;
}
t=x+1;
}
for(int i=1;i<=4*n;i++) tree[i]={-1,0};
return t;
};
int cnt=go(n);
int l=0,r=n;
while(l<r-1)
{
int m=(l+r)/2;
if(go(m)==cnt) r=m;
else l=m;
}
cout << cnt << "\n";
go(r);
int idx=n;
while(idx>=1)
{
cout << idx-p[idx] << " ";
for(int i=p[idx]+1;i<=idx;i++) cout << a[i][1] << " \n"[i==idx];
idx=p[idx];
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
31564 KB |
Output is correct |
2 |
Correct |
13 ms |
31624 KB |
Output is correct |
3 |
Correct |
17 ms |
31556 KB |
Output is correct |
4 |
Correct |
12 ms |
31564 KB |
Output is correct |
5 |
Correct |
13 ms |
31564 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
31564 KB |
Output is correct |
2 |
Correct |
13 ms |
31564 KB |
Output is correct |
3 |
Correct |
13 ms |
31584 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
31564 KB |
Output is correct |
2 |
Correct |
13 ms |
31564 KB |
Output is correct |
3 |
Correct |
15 ms |
31576 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
42 ms |
31604 KB |
Output is correct |
2 |
Correct |
34 ms |
31592 KB |
Output is correct |
3 |
Correct |
32 ms |
31636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
31688 KB |
Output is correct |
2 |
Correct |
30 ms |
31684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
450 ms |
32948 KB |
Output is correct |
2 |
Correct |
506 ms |
33172 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
585 ms |
33184 KB |
Output is correct |
2 |
Correct |
475 ms |
33108 KB |
Output is correct |
3 |
Correct |
536 ms |
33604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2568 ms |
40304 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2576 ms |
43408 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2579 ms |
43288 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |