QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#472834#7939. High Towersucup-team052AC ✓211ms47916kbC++234.4kb2024-07-11 19:44:032024-07-11 19:44:04

Judging History

你现在查看的是最新测评结果

  • [2024-07-11 19:44:04]
  • 评测
  • 测评结果:AC
  • 用时:211ms
  • 内存:47916kb
  • [2024-07-11 19:44:03]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define mod 998244353
#define ll long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
void print(vector<int> x){for(int i=0;i<(int)x.size();i++) printf("%d%c",x[i]," \n"[i==(int)x.size()-1]);}
#define N 500005
int a[N],n,ans[N];
struct SMT
{
	#define ls (u<<1)
	#define rs (u<<1|1)
	#define mid ((l+r)/2)
	int mx[N*4],tag[N*4];
	void build(int u,int l,int r)
	{
		tag[u]=0;
		if(l==r)
		{
			mx[u]=a[l];
			return ;
		}
		build(ls,l,mid),build(rs,mid+1,r);
		mx[u]=max(mx[ls],mx[rs]);
	}
	void upd(int u,int v) {mx[u]+=v,tag[u]+=v;}
	void pushdown(int u)
	{
		upd(ls,tag[u]),upd(rs,tag[u]);
		tag[u]=0;
	}
	void update(int u,int l,int r,int L,int R,int v)
	{
		if(L<1||R>n) exit(1);
		if(L>R) return ;
		if(L<=l&&r<=R) return upd(u,v);
		pushdown(u);
		if(mid>=L) update(ls,l,mid,L,R,v);
		if(mid<R) update(rs,mid+1,r,L,R,v);
		mx[u]=max(mx[ls],mx[rs]);
	}
	int qval(int u,int l,int r,int pos)
	{
		if(pos<1||pos>n) exit(1);
		if(l==r) return mx[u];
		pushdown(u);
		if(pos<=mid) return qval(ls,l,mid,pos);
		else return qval(rs,mid+1,r,pos);
	}
	int qval(int x) {return qval(1,1,n,x);}
	int qmax(int u,int l,int r,int L,int R,int val)
	{
		if(L<1||R>n) exit(1);
		if(L<=l&&r<=R)
		{
			if(mx[u]<=val) return -1;
			if(l==r) return l;
			pushdown(u);
			int res=qmax(ls,l,mid,L,R,val);
			if(res==-1) return qmax(rs,mid+1,r,L,R,val);
			else return res;
		}
		pushdown(u);
		if(mid>=L)
		{
			int res=qmax(ls,l,mid,L,R,val);
			if(res!=-1) return res;
		}
		if(mid<R) return qmax(rs,mid+1,r,L,R,val);
		return -1;
	}
	#undef mid
}smt;
int solve(int l,int r,int ad)
{
	// printf("solveing %d %d :\n",l,r);
	// for(int i=l;i<=r;i++) printf("%d%c",smt.qval(i)," \n"[i==r]);
	if(r>n) exit(1);
	if(l>r) return 0;
	if(l==r)
	{
		ans[l]=ad+1;
		return ans[l];
	}
	int mid=smt.qmax(1,1,n,l+1,r,smt.qval(l));
	// printf("%d %d %d\n",l,r,mid);
	if(mid==-1)
	{
		ans[l]=ad+(r-l+1);
		// for(int i=l+1;i<=r;i++) a[i]--;
		smt.update(1,1,n,l+1,r,-1);
		solve(l+1,r,ad);
		return ans[l];
	}
	else
	{
		int premxcnt=smt.qval(l)-(mid-l);
		int ansmx=0;
		int w=mid-l;
		// ans[l]=ans[mid]=ad+w;
		// for(int i=l+1;i<=mid-1;i++) a[i]-=premxcnt+2;
		smt.update(1,1,n,l+1,mid-1,-(premxcnt+2));
		ansmx=max(ansmx,solve(l+1,mid-1,ad));
		ad+=w;
		// a[mid]-=w;
		smt.update(1,1,n,mid,mid,-w);
		int cur=mid;
		// solving [cur + 1, r]
		vector<int> tmppos; tmppos.push_back(cur); tmppos.push_back(l);
		for(int i=0;i<premxcnt;)
		{
			int nw=cur+(smt.qval(cur)-premxcnt+i);
			// printf("%d %d - %d ",l,r,nw);
			if(smt.qval(nw)>nw-cur+premxcnt-i)
			{ // h[nw]=h[cur]
				// printf("=\n");
				// for(int j=cur+1;j<=nw-1;j++) a[j]-=premxcnt-i+1;
				smt.update(1,1,n,cur+1,nw-1,-(premxcnt-i+2));
				ansmx=max(ansmx,solve(cur+1,nw-1,ad));
				tmppos.push_back(nw);
				// a[nw]-=(nw-cur);
				smt.update(1,1,n,nw,nw,-(nw-cur));
				cur=nw;
			}
			else
			{ // h[nw+1] is premx
				// printf(">\n");
				// for(int j=cur+1;j<=nw;j++) a[j]-=premxcnt-i+1;
				smt.update(1,1,n,cur+1,nw,-(premxcnt-i+1));
				ansmx=max(ansmx,solve(cur+1,nw,ad));
				ansmx++;
				for(int i:tmppos) ans[i]=ansmx;
				tmppos.clear();
				tmppos.push_back(nw+1);
				ad=ansmx;
				// a[nw+1]-=(nw+1-l);
				smt.update(1,1,n,nw+1,nw+1,-(nw+1-l));
				cur=nw+1;
				i++;
			}
		}
		while(cur<r)
		{
			int nw=cur+smt.qval(cur);
			if(nw<r)
			{
				// for(int i=cur+1;i<nw;i++) a[i]-=2;
				smt.update(1,1,n,cur+1,nw-1,-2);
				ansmx=max(ansmx,solve(cur+1,nw-1,ad));
				// a[nw]-=(nw-cur);
				smt.update(1,1,n,nw,nw,-(nw-cur));
				cur=nw;
				tmppos.push_back(cur);
			}
			else
			{
				// for(int i=cur+1;i<=r;i++) a[i]--;
				smt.update(1,1,n,cur+1,r,-1);
				ansmx=max(ansmx,solve(cur+1,r,ad));
				cur=r+1;
			}
		}
		assert(tmppos.size()>=1);
		ansmx++;
		for(int i:tmppos) ans[i]=ansmx;
		return ansmx;
	}
}
signed main()
{
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	smt.build(1,1,n);
	solve(1,n,0);
	for(int i=1;i<=n;i++) printf("%d%c",ans[i]," \n"[i==n]);
	return 0;
}



这程序好像有点Bug,我给组数据试试?

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 9892kb

input:

6
3 3 4 2 5 1

output:

4 1 4 3 6 5

result:

ok 

Test #2:

score: 0
Accepted
time: 0ms
memory: 9892kb

input:

4
3 3 3 3

output:

4 3 2 1

result:

ok 

Test #3:

score: 0
Accepted
time: 85ms
memory: 18756kb

input:

264668
5 5 5 5 9 5 5 5 7 3 5 3 11 9 9 9 8 9 8 9 12 4 4 9 5 5 6 4 12 4 7 5 6 5 18 12 6 12 11 11 11 11 11 11 12 19 5 5 8 6 6 6 26 7 7 7 8 6 7 6 6 12 10 6 9 8 8 8 10 4 22 4 4 6 3 6 4 4 8 5 5 5 7 3 8 6 6 6 6 8 3 5 3 6 4 4 8 5 5 5 10 6 6 6 6 17 4 12 5 11 6 10 7 9 8 8 16 5 5 5 8 4 4 12 8 7 7 8 6 9 4 14 5 ...

output:

53 3 2 1 53 7 6 5 53 5 53 5 53 11 10 9 7 7 6 8 53 6 5 53 8 5 8 7 53 9 9 8 8 7 53 14 12 12 11 10 9 8 7 6 13 53 10 5 10 9 8 7 53 10 6 5 10 10 10 9 8 16 16 15 15 14 13 12 16 11 53 6 5 53 5 53 6 5 53 7 6 5 53 5 53 8 7 6 5 53 5 53 5 53 6 5 53 7 6 5 53 8 7 6 5 53 14 14 13 13 12 12 11 11 10 9 53 7 6 5 53 6...

result:

ok 

Test #4:

score: 0
Accepted
time: 126ms
memory: 21364kb

input:

409115
2 4 3 7 4 5 4 7 3 6 4 4 7 4 4 6 3 11 6 6 6 9 6 6 6 11 3 10 8 5 8 7 7 7 10 3 5 3 8 6 6 6 6 8 3 8 6 6 6 6 10 5 5 5 8 4 4 8 4 5 4 7 3 5 3 6 4 4 8 5 5 5 9 4 5 4 8 4 4 7 4 4 8 5 5 5 8 4 4 7 4 4 6 3 9 4 7 6 6 6 9 3 6 4 4 28 7 7 7 12 8 8 9 7 12 7 7 12 8 8 9 7 9 24 7 7 7 8 4 34 8 8 8 8 8 10 5 5 13 4 ...

output:

26 26 2 26 4 4 3 26 2 26 3 2 26 3 2 26 2 26 8 3 2 8 7 6 5 26 2 26 7 6 6 5 4 3 26 2 26 2 26 5 4 3 2 26 2 26 5 4 3 2 26 4 3 2 26 3 2 26 4 4 3 26 2 26 2 26 3 2 26 4 3 2 26 4 4 3 26 3 2 26 3 2 26 4 3 2 26 3 2 26 3 2 26 2 26 6 6 5 4 3 26 2 26 3 2 26 10 3 2 10 8 5 8 7 10 6 5 10 8 5 8 7 9 14 13 12 11 14 11...

result:

ok 

Test #5:

score: 0
Accepted
time: 138ms
memory: 21028kb

input:

430320
2 5 4 4 8 5 5 5 18 7 7 7 9 6 7 5 14 5 7 6 6 18 4 5 4 14 6 6 6 10 7 7 7 7 31 4 12 7 7 10 8 8 9 6 13 5 7 5 7 5 7 5 7 5 5 28 5 6 5 7 4 12 6 6 6 6 13 4 8 6 6 7 5 11 4 4 7 4 4 6 3 7 5 5 5 10 4 6 5 5 9 4 4 8 5 5 5 7 3 6 4 4 8 5 5 5 15 7 7 8 6 8 11 6 6 6 18 5 5 8 6 6 6 11 4 4 6 3 27 12 8 8 8 9 8 7 8...

output:

38 38 3 2 38 4 3 2 38 6 3 2 6 5 6 5 11 10 10 9 8 38 4 4 3 38 9 3 2 9 8 7 6 5 38 8 8 7 3 7 6 5 7 5 8 3 8 3 8 3 8 3 8 4 3 38 4 4 3 6 5 38 5 4 3 2 38 7 7 6 3 6 5 38 3 2 38 3 2 38 2 38 4 3 2 38 5 5 4 3 38 3 2 38 4 3 2 38 2 38 3 2 38 4 3 2 38 5 2 5 4 6 10 9 8 7 38 7 2 7 6 5 4 38 3 2 38 2 38 21 6 3 2 6 6 ...

result:

ok 

Test #6:

score: 0
Accepted
time: 142ms
memory: 19096kb

input:

445524
4 4 6 4 4 32 6 6 6 10 7 7 7 21 7 10 9 9 9 11 10 9 9 9 11 7 7 20 5 6 5 45 8 11 10 10 10 11 13 7 7 14 7 6 6 19 5 6 5 35 6 6 6 11 8 7 8 7 9 9 7 7 7 8 5 19 3 5 3 17 5 7 6 6 15 6 6 11 6 9 8 8 8 64 6 6 7 5 12 8 8 8 8 12 7 7 7 11 6 7 6 10 6 6 10 7 7 7 17 13 13 13 13 11 13 12 12 13 19 6 9 7 8 7 15 9 ...

output:

5 1 5 4 3 92 18 7 6 18 11 10 9 18 13 13 12 11 10 17 17 16 15 14 17 15 14 18 11 11 10 92 10 10 9 8 7 11 14 13 12 17 17 16 15 21 20 20 19 92 14 7 6 14 12 11 11 10 14 14 13 10 9 13 12 92 6 92 6 92 9 9 8 7 18 17 10 17 16 16 15 14 13 92 9 6 9 8 19 13 12 11 10 19 12 11 10 19 12 12 11 19 11 10 19 12 11 10 ...

result:

ok 

Test #7:

score: 0
Accepted
time: 169ms
memory: 19264kb

input:

481648
4 4 13 8 10 9 9 11 7 11 11 11 74 4 13 8 8 8 12 9 9 9 9 13 48 28 18 11 11 18 13 14 13 14 16 12 12 28 16 14 14 14 16 13 13 16 17 9 30 7 24 16 11 11 16 14 14 14 14 14 18 9 10 11 10 10 10 22 49 5 7 5 5 69 4 8 6 7 6 7 21 8 8 8 9 9 8 8 8 12 14 5 5 17 4 4 19 5 6 5 10 7 7 7 13 9 8 8 8 9 6 131 10 10 1...

output:

12 1 12 6 6 5 4 8 7 9 10 11 173 52 52 21 15 14 21 20 19 18 17 52 52 51 35 23 14 23 18 18 17 19 22 21 20 35 34 30 26 25 30 29 28 31 34 33 51 37 51 49 44 37 44 43 42 41 40 39 49 46 49 49 48 47 46 50 52 14 52 15 14 173 18 18 16 16 15 17 173 19 14 13 19 19 18 17 16 20 23 22 21 173 14 13 173 15 15 14 22 ...

result:

ok 

Test #8:

score: 0
Accepted
time: 139ms
memory: 21300kb

input:

421202
5 5 7 5 5 10 4 5 4 43 5 16 13 10 10 13 11 11 11 13 15 7 7 34 11 9 9 11 9 9 12 6 14 6 13 6 11 7 10 9 9 9 71 8 8 8 8 13 8 8 9 7 12 7 7 13 8 9 8 10 7 16 10 9 10 9 10 10 31 6 6 12 9 9 9 9 9 10 4 68 7 7 7 8 13 6 12 7 11 8 10 9 9 31 6 9 8 8 8 12 7 7 10 7 7 10 7 7 7 36 4 6 5 5 34 5 6 5 29 9 9 9 9 9 ...

output:

5 1 5 4 3 9 8 8 7 158 22 22 21 16 11 16 15 14 13 17 21 20 19 39 30 27 23 27 26 25 30 29 38 31 38 37 37 36 36 35 34 33 158 20 12 11 10 20 17 14 17 16 20 15 14 20 16 16 15 18 17 20 19 16 16 15 17 18 26 22 21 26 25 24 23 22 21 26 21 158 21 11 10 21 21 20 20 19 19 18 18 17 16 31 26 26 25 24 23 30 28 27 ...

result:

ok 

Test #9:

score: 0
Accepted
time: 159ms
memory: 21540kb

input:

480658
15 8 8 8 10 7 7 15 8 8 9 7 9 16 3 40 5 5 9 7 7 7 15 11 9 11 10 10 11 11 14 6 6 11 7 7 7 8 5 27 3 11 6 7 6 7 9 5 5 13 4 5 4 8 4 4 6 3 10 5 8 7 7 7 8 18 9 7 7 9 7 7 11 5 5 27 7 7 7 7 12 8 8 8 8 13 7 7 7 8 5 43 5 5 8 6 6 24 9 10 9 11 8 12 7 17 8 10 9 9 14 9 9 9 9 22 4 42 5 5 16 11 8 10 9 10 8 12...

output:

15 6 2 1 6 5 4 12 10 7 10 9 11 15 14 68 25 16 25 20 19 18 25 24 21 21 20 19 22 23 25 19 18 25 22 19 18 22 21 68 16 68 18 18 17 19 22 21 20 68 18 18 17 68 17 16 68 16 68 20 20 19 18 17 21 68 24 20 16 20 19 18 24 23 22 68 25 18 17 16 25 23 22 21 20 25 24 21 20 24 23 68 30 16 30 19 18 30 20 20 19 22 21...

result:

ok 

Test #10:

score: 0
Accepted
time: 140ms
memory: 21004kb

input:

430417
5 5 5 27 7 7 7 11 8 7 8 7 24 8 8 12 8 10 9 9 16 8 9 8 9 16 34 4 5 4 8 5 5 5 430416 5 5 8 5 6 5 17 6 6 6 11 5 8 6 7 6 18 73 6 8 7 7 33 9 9 11 9 9 15 8 10 9 9 29 10 10 13 10 11 10 17 11 11 11 11 19 8 8 72 8 12 11 10 11 10 12 24 10 11 10 16 12 12 12 13 10 17 8 17 42 8 9 8 11 8 8 22 9 9 12 10 10 ...

output:

26 2 1 26 11 5 4 11 10 9 9 8 25 18 12 18 17 17 16 15 23 21 21 20 22 24 34 29 29 28 33 32 31 30 475 40 35 40 39 39 38 50 49 42 41 49 48 48 47 47 46 474 474 54 54 53 52 80 59 55 59 58 57 64 63 63 62 61 79 70 65 70 69 69 68 75 74 73 72 71 78 77 76 120 86 86 85 84 84 83 87 100 90 90 89 96 95 92 91 95 94...

result:

ok 

Test #11:

score: 0
Accepted
time: 165ms
memory: 19152kb

input:

480452
5 9 8 8 8 8 9 13 5 6 5 6 22 9 7 9 8 8 9 9 10 3 480451 5 5 8 6 6 6 10 4 4 31 6 7 6 7 22 7 9 8 8 15 10 9 10 9 11 7 18 7 7 7 231 10 10 10 10 11 7 30 9 14 13 11 13 12 12 15 8 24 11 11 11 12 9 15 10 10 10 40 13 10 10 13 11 11 11 13 14 6 41 9 7 7 8 6 113 12 15 14 14 14 15 16 10 37 23 15 15 15 21 15...

output:

6 6 5 4 3 2 7 12 10 10 9 11 22 21 16 16 15 14 17 18 21 20 544 28 23 28 27 26 25 31 30 29 543 34 34 33 35 51 39 39 38 37 46 45 42 42 41 45 44 50 49 48 47 543 37 34 33 32 37 36 57 44 44 43 42 42 41 40 46 45 56 51 48 47 51 50 55 54 53 52 68 67 63 58 63 62 61 60 64 67 66 144 144 72 69 72 71 144 73 73 72...

result:

ok 

Test #12:

score: 0
Accepted
time: 151ms
memory: 19208kb

input:

448826
6 6 6 10 7 7 7 7 26 8 8 8 15 8 10 9 9 12 8 8 16 5 18 5 5 28 3 3 52 5 6 5 17 6 8 7 7 14 6 10 8 8 9 7 24 5 5 9 5 7 6 6 448797 3 18 17 6 9 7 8 7 17 7 12 9 10 9 11 8 12 125 12 10 10 11 9 12 8 16 9 9 9 9 18 6 6 68 9 12 11 11 11 13 8 36 11 18 15 15 15 15 17 13 13 19 10 20 9 29 16 13 13 13 13 16 12 ...

output:

8 2 1 8 7 6 5 4 25 19 10 9 19 15 15 14 13 18 17 16 21 20 24 23 22 28 27 26 770 31 31 30 43 35 35 34 33 42 41 41 40 37 40 39 51 50 44 50 49 49 48 47 770 45 45 44 34 34 33 33 32 43 41 41 38 38 37 40 39 42 769 57 49 46 49 48 51 50 57 56 55 54 53 60 59 58 110 65 65 64 63 62 67 66 91 76 76 75 71 70 69 75...

result:

ok 

Test #13:

score: 0
Accepted
time: 154ms
memory: 19180kb

input:

466137
1 466136 5 5 5 5 6 6 4 5 4 10 6 6 6 6 12 7 7 7 7 7 10 4 4 8 5 5 5 9 5 5 5 12 6 6 6 8 5 5 16 5 5 9 7 7 7 7 13 5 5 5 11 7 6 6 7 5 11 5 5 5 10 4 6 5 5 14 9 9 9 9 8 9 8 12 4 4 9 5 5 6 4 18 4 5 6 5 11 9 9 9 9 9 9 16 4 4 12 9 6 6 9 7 7 7 11 3 7 4 5 4 7 3 20 6 6 6 18 6 7 6 9 6 12 8 8 8 10 7 7 22 5 5...

output:

34 34 33 4 3 2 33 33 8 8 7 33 9 8 7 6 33 10 9 8 7 6 33 7 6 33 8 7 6 33 8 7 6 33 11 7 6 11 10 9 33 12 6 12 11 10 9 8 33 8 7 6 33 10 9 6 9 8 33 8 7 6 33 9 9 8 7 33 12 11 10 9 8 8 7 33 7 6 33 9 6 9 8 33 13 13 13 7 13 12 11 10 9 8 7 33 7 6 33 12 11 6 11 10 9 8 33 6 33 8 8 7 33 6 33 19 7 6 19 11 11 10 18...

result:

ok 

Test #14:

score: 0
Accepted
time: 151ms
memory: 21156kb

input:

447669
3 3 29 3 6 5 5 13 10 9 9 9 10 7 10 12 4 6 4 8 5 6 5 11 7 5 7 6 6 447668 3 6 4 5 4 11 6 6 6 6 7 5 4 4 9 4 6 5 5 11 5 5 6 4 21 4 5 9 7 7 8 6 13 7 8 7 8 9 4 46 4 9 6 7 7 6 11 6 6 9 6 6 14 6 11 8 10 9 9 10 18 6 9 8 8 9 6 11 4 40 5 5 6 5 6 5 6 4 21 4 12 7 7 7 11 8 8 8 8 19 4 8 7 7 7 7 19 4 12 5 11...

output:

12 1 12 11 11 5 4 11 10 8 5 4 8 7 9 11 4 11 4 11 6 6 5 11 8 7 7 6 5 96 17 17 16 16 15 95 21 20 19 18 95 95 19 18 95 21 21 20 19 95 21 18 21 20 95 23 23 23 22 19 22 21 23 21 21 20 22 23 19 95 26 26 21 21 21 20 26 20 19 26 20 19 26 25 25 23 23 22 21 24 26 22 22 21 20 22 20 26 19 95 21 18 21 21 21 20 2...

result:

ok 

Test #15:

score: 0
Accepted
time: 137ms
memory: 21056kb

input:

408826
1 408825 3 4 3 7 4 4 26 18 12 9 9 12 9 10 9 17 10 10 10 10 11 6 23 6 6 8 6 6 25 3 9 5 6 5 7 4 10 4 4 13 4 9 8 8 8 8 9 4 20 6 6 6 9 6 6 8 5 5 21 5 5 11 9 9 9 9 9 9 26 4 9 8 8 8 8 15 7 7 7 10 7 7 7 28 11 11 8 8 11 8 9 8 13 5 5 19 5 5 7 5 5 10 4 4 22 5 8 7 7 7 12 7 7 7 13 9 9 9 9 9 10 4 21 3 11 ...

output:

61 61 4 4 3 60 6 5 60 25 16 10 5 10 9 9 8 16 15 14 13 12 16 12 25 24 20 24 23 22 60 5 60 7 7 6 9 8 60 6 5 60 10 10 9 8 7 6 10 6 60 10 6 5 10 9 8 10 9 8 60 13 5 13 12 11 10 9 8 7 60 13 13 9 8 7 6 13 12 7 6 12 11 10 9 60 15 11 10 5 10 9 9 8 15 14 13 60 9 5 9 8 7 60 6 5 60 9 9 8 7 6 15 12 11 10 15 14 1...

result:

ok 

Test #16:

score: 0
Accepted
time: 161ms
memory: 19252kb

input:

486362
2 8 5 5 5 7 4 4 10 2 3 486351 5 5 5 6 14 9 7 7 9 7 7 13 5 6 6 5 27 11 6 7 6 9 6 8 6 6 15 4 5 4 6 5 4 4 15 5 5 6 6 5 9 6 7 6 7 25 6 6 8 6 6 13 8 8 8 8 9 4 49 27 9 27 10 14 12 13 12 16 12 12 14 11 18 11 12 12 13 12 13 11 27 27 28 8 7 7 7 36 7 7 7 8 5 54 4 19 7 7 7 8 11 10 8 9 9 8 14 6 7 7 6 23 ...

output:

8 8 7 3 2 7 6 5 93 9 93 93 22 10 9 22 22 21 16 12 16 15 14 21 20 20 20 19 92 31 25 25 24 28 26 28 27 26 92 25 25 24 92 92 24 23 92 29 23 29 29 25 29 27 27 26 28 92 27 23 27 26 25 32 31 30 29 28 32 28 92 49 29 29 28 28 27 27 26 28 26 25 28 25 28 27 27 27 27 26 27 26 30 31 49 49 48 47 46 55 54 51 50 5...

result:

ok 

Test #17:

score: 0
Accepted
time: 143ms
memory: 19032kb

input:

444506
1 444505 2 3 22 4 10 9 7 8 8 7 15 7 7 9 7 7 14 6 7 7 6 8 23 3 6 4 4 13 10 10 10 10 10 10 10 10 16 7 5 7 6 6 10 4 4 10 7 7 7 7 7 9 3 8 6 6 6 6 10 4 5 4 7 3 7 5 5 5 9 5 5 5 7 3 6 4 4 6 3 5 3 8 6 6 6 6 8 3 5 3 5 3 8 6 6 6 6 8 3 5 3 6 4 4 8 5 5 5 13 9 9 9 9 9 9 9 12 4 4 10 7 5 7 6 6 9 3 6 4 4 9 6...

output:

28 28 27 27 27 9 9 8 6 6 6 5 9 8 4 8 7 6 9 6 6 6 5 7 27 3 27 4 3 27 10 9 8 7 6 5 4 3 27 7 6 6 5 4 27 4 3 27 7 6 5 4 3 27 3 27 6 5 4 3 27 5 5 4 27 3 27 5 4 3 27 5 4 3 27 3 27 4 3 27 3 27 3 27 6 5 4 3 27 3 27 3 27 3 27 6 5 4 3 27 3 27 3 27 4 3 27 5 4 3 27 9 8 7 6 5 4 3 27 4 3 27 7 6 6 5 4 27 3 27 4 3 ...

result:

ok 

Test #18:

score: 0
Accepted
time: 127ms
memory: 18980kb

input:

416777
1 416776 4 4 4 8 4 5 4 7 3 7 5 5 5 11 7 7 7 7 7 10 4 4 8 5 5 5 9 4 5 4 9 5 5 5 11 6 6 6 7 4 10 4 4 10 7 7 7 7 7 11 5 5 5 8 4 4 8 5 5 5 11 5 5 7 5 5 11 5 5 5 8 4 4 7 4 4 7 4 4 8 5 5 5 8 4 4 7 4 4 8 5 5 5 10 6 6 6 6 13 8 8 8 7 8 7 11 4 4 6 3 6 4 4 7 4 4 9 6 6 6 6 12 7 5 7 6 6 10 4 4 6 3 5 3 6 4...

output:

28 28 27 3 2 27 7 7 6 27 5 27 7 6 5 27 9 8 7 6 5 27 6 5 27 7 6 5 27 7 7 6 27 7 6 5 27 9 6 5 9 8 27 6 5 27 9 8 7 6 5 27 7 6 5 27 6 5 27 7 6 5 27 9 5 9 8 7 27 7 6 5 27 6 5 27 6 5 27 6 5 27 7 6 5 27 6 5 27 6 5 27 7 6 5 27 8 7 6 5 27 10 9 8 7 7 6 27 6 5 27 5 27 6 5 27 6 5 27 8 7 6 5 27 9 8 8 7 6 27 6 5 ...

result:

ok 

Test #19:

score: 0
Accepted
time: 1ms
memory: 10188kb

input:

15
7 7 7 7 9 5 5 11 4 4 13 3 4 2 14

output:

7 3 2 1 7 6 5 10 9 8 12 11 12 11 13

result:

ok 

Test #20:

score: 0
Accepted
time: 0ms
memory: 9892kb

input:

17
7 7 7 7 9 5 5 11 4 4 13 3 5 3 4 2 16

output:

7 3 2 1 7 6 5 10 9 8 12 11 12 11 12 11 13

result:

ok 

Test #21:

score: 0
Accepted
time: 1ms
memory: 9896kb

input:

15
9 8 8 9 7 10 5 12 5 5 13 3 13 14 1

output:

7 4 1 4 3 7 6 10 9 8 12 11 13 15 14

result:

ok 

Test #22:

score: 0
Accepted
time: 0ms
memory: 9936kb

input:

15
2 6 5 5 5 8 4 4 4 11 2 5 3 3 3

output:

5 5 4 3 2 5 4 3 2 9 6 9 8 7 6

result:

ok 

Test #23:

score: 0
Accepted
time: 204ms
memory: 42620kb

input:

500000
499996 499995 499994 499993 499992 499991 499990 499989 499988 499987 499986 499985 499984 499983 499982 499981 499980 499979 499978 499977 499976 499975 499974 499973 499972 499971 499970 499969 499968 499967 499966 499965 499964 499963 499962 499961 499960 499959 499958 499957 499956 499955...

output:

500000 499995 499992 499989 499986 499983 499980 499977 499974 499971 499968 499965 499962 499959 499956 499953 499950 499947 499944 499941 499938 499935 499932 499929 499926 499923 499920 499917 499914 499911 499908 499905 499902 499899 499896 499893 499890 499887 499884 499881 499878 499875 499872...

result:

ok 

Test #24:

score: 0
Accepted
time: 211ms
memory: 47916kb

input:

500000
2 3 2 499999 3 499996 5 499995 7 499994 9 499993 11 499992 13 499991 15 499990 17 499989 19 499988 21 499987 23 499986 25 499985 27 499984 29 499983 31 499982 33 499981 35 499980 37 499979 39 499978 41 499977 43 499976 45 499975 47 499974 49 499973 51 499972 53 499971 55 499970 57 499969 59 4...

output:

3 3 2 500000 499998 499998 499996 499996 499994 499994 499992 499992 499990 499990 499988 499988 499986 499986 499984 499984 499982 499982 499980 499980 499978 499978 499976 499976 499974 499974 499972 499972 499970 499970 499968 499968 499966 499966 499964 499964 499962 499962 499960 499960 499958 ...

result:

ok 

Test #25:

score: 0
Accepted
time: 146ms
memory: 19440kb

input:

500000
250000 250000 250001 249999 250002 249998 250003 249997 250004 249996 250005 249995 250006 249994 250007 249993 250008 249992 250009 249991 250010 249990 250011 249989 250012 249988 250013 249987 250014 249986 250015 249985 250016 249984 250017 249983 250018 249982 250019 249981 250020 249980...

output:

4 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15 18 17 20 19 22 21 24 23 26 25 28 27 30 29 32 31 34 33 36 35 38 37 40 39 42 41 44 43 46 45 48 47 50 49 52 51 54 53 56 55 58 57 60 59 62 61 64 63 66 65 68 67 70 69 72 71 74 73 76 75 78 77 80 79 82 81 84 83 86 85 88 87 90 89 92 91 94 93 96 95 98 97 100 99 102 101 ...

result:

ok 

Test #26:

score: 0
Accepted
time: 142ms
memory: 21292kb

input:

500000
249759 249759 249760 249758 249761 249757 249762 249756 249763 249755 249764 249754 249765 249753 249766 249752 249767 249751 249768 249750 249769 249749 249770 249748 249771 249747 249772 249746 249773 249745 249774 249744 249775 249743 249776 249742 249777 249741 249778 249740 249779 249739...

output:

4 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15 18 17 20 19 22 21 24 23 26 25 28 27 30 29 32 31 34 33 36 35 38 37 40 39 42 41 44 43 46 45 48 47 50 49 52 51 54 53 56 55 58 57 60 59 62 61 64 63 66 65 68 67 70 69 72 71 74 73 76 75 78 77 80 79 82 81 84 83 86 85 88 87 90 89 92 91 94 93 96 95 98 97 100 99 102 101 ...

result:

ok 

Extra Test:

score: 0
Extra Test Passed