QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#835185#9920. Money Game 2ucup-team5318#TL 3198ms44052kbC++144.6kb2024-12-28 10:19:582024-12-28 10:19:59

Judging History

This is the latest submission verdict.

  • [2024-12-31 22:17:02]
  • hack成功,自动添加数据
  • (/hack/1322)
  • [2024-12-31 21:57:13]
  • hack成功,自动添加数据
  • (/hack/1321)
  • [2024-12-28 10:19:59]
  • Judged
  • Verdict: TL
  • Time: 3198ms
  • Memory: 44052kb
  • [2024-12-28 10:19:58]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+5,B=30,M=N/B+5;
bool stt;
int T,n,a[N];
namespace work1
{
	const int N=2e3+5;
	int r[N][N],l[N][N];
	ll ans[N];
	void solve()
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=0;j<n;j++)
			{
				int giv=0;
				for(int k=i+j;k>i;k--)giv=(giv+a[k])/2;
				r[i][j]=giv;
			}
		}
		for(int i=1;i<=n;i++)
		{
			for(int j=0;j<n;j++)
			{
				int giv=0;
				for(int k=i+n-j;k<i+n;k++)giv=(giv+a[k])/2;
				l[i][j]=giv;
			}
		}
		for(int i=1;i<=n;i++)ans[i]=0;
		for(int i=1;i<=n;i++)for(int j=0;j<n;j++)ans[i]=max(ans[i],(ll)a[i]+l[i][j]+r[i][n-1-j]);
		for(int i=1;i<=n;i++)printf("%lld ",ans[i]);printf("\n");
	}
}
namespace work2
{
	int bel[N],L[N],R[N],aa[M],b[M],ar[N],p[M][16][2],br[N],al[N],bl[N];
	int ask(int nl,int nr)
	{
		if(bel[nl]+1>=bel[nr])
		//if(1)
		{
			//cout<<"?"<<nl<<" "<<nr<<endl;
			int giv=0;
			for(int i=nr;i>=nl;i--)giv=(giv+a[i])>>1;
			return giv;
		}
		else
		{
			int giv=0;
			for(int i=nr;bel[i]==bel[nr];i--)giv=(giv+a[i])>>1;
			int nl1=bel[nl]+1,nr1=bel[nr]-1,tp=(giv>=b[nr1]);
			if(nl1<=nr1)
			{
				//cout<<tp<<" "<<nl1<<" "<<nr1<<endl;
				//cout<<p[4][1][1]<<endl;
				for(int i=15;i>=0;i--)if(nr1-(1<<i)>=nl1)tp=p[nr1][i][tp],nr1-=(1<<i);
				giv=aa[nl1]+tp;
				//cout<<tp<<endl;
			}
			for(int i=R[bel[nl]];i>=nl;i--)giv=(giv+a[i])>>1;
			return giv;
		}
	}
	ll ans[N];
	void solve()
	{
		for(int i=1;i<=n*2;i++)bel[i]=(i-1)/B+1;
		for(int i=1;i<=bel[n*2];i++)L[i]=(i-1)*B+1,R[i]=min(i*B,n*2);
		for(int i=1;i<=bel[n*2];i++)
		{
			int giv=0;
			for(int j=R[i];j>=L[i];j--)giv=(giv+a[j])>>1;
			aa[i]=giv;
			int nl=1,nr=1e9,res=1e9+1;
			while(nl<=nr)
			{
				int mid=nl+nr>>1,giv1=mid;
				for(int j=R[i];j>=L[i];j--)giv1=(giv1+a[j])>>1;
				if(giv1>giv)res=mid,nr=mid-1;
				else nl=mid+1;
			}
			b[i]=res;
		}
		for(int i=1;i<=bel[n*2];i++)
		{
			if(aa[i]>=b[i-1])p[i][0][0]=1;else p[i][0][0]=0;
			if(aa[i]+1>=b[i-1])p[i][0][1]=1;else p[i][0][1]=0;
			for(int j=1;j<=15;j++)if(i-(1<<j-1)>=0)for(int k=0;k<2;k++)p[i][j][k]=p[i-(1<<j-1)][j-1][p[i][j-1][k]];
		}
		//cout<<p[4][1][1]<<endl;
		//cout<<p[4][0][1]<<" "<<p[]endl;
		//cout<<ask(4,17)<<endl;
		//cout<<bel[4]<<" "<<bel[17]<<endl;
		//for(int i=2;i<=4;i++)cout<<aa[i]<<" "<<b[i]<<endl;
		for(int i=1;i<=n;i++)
		{
			ar[i]=ask(i+1,i+B);
			int nl=i+B+1,nr=i+n-1,res=i+n;
			while(nl<=nr)
			{
				int mid=nl+nr>>1;
				if(ask(i+1,mid)>ar[i])res=mid,nr=mid-1;
				else nl=mid+1;
			}
			br[i]=res;
		}

		reverse(a+1,a+n+1);for(int i=1;i<=n;i++)a[i+n]=a[i];
		for(int i=1;i<=bel[n*2];i++)
		{
			//cout<<i<<" "<<R[i]<<" "<<L[i]<<endl;
			int giv=0;
			for(int j=R[i];j>=L[i];j--)giv=(giv+a[j])>>1;
			aa[i]=giv;
			int nl=1,nr=1e9,res=1e9+1;
			while(nl<=nr)
			{
				int mid=nl+nr>>1,giv1=mid;
				for(int j=R[i];j>=L[i];j--)giv1=(giv1+a[j])>>1;
				if(giv1>giv)res=mid,nr=mid-1;
				else nl=mid+1;
			}
			b[i]=res;
		}
		//cout<<aa[6]<<" "<<b[6]<<endl;
		for(int i=1;i<=bel[n*2];i++)
		{
			if(aa[i]>=b[i-1])p[i][0][0]=1;else p[i][0][0]=0;
			if(aa[i]+1>=b[i-1])p[i][0][1]=1;else p[i][0][1]=0;
			for(int j=1;j<=15;j++)if(i-(1<<j-1)>=0)for(int k=0;k<2;k++)p[i][j][k]=p[i-(1<<j-1)][j-1][p[i][j-1][k]];
		}
		//cout<<ask(20,25)<<endl;
		//cout<<bel[20]<<" "<<bel[25]<<endl;
		for(int i=1;i<=n;i++)
		{
			al[n-i+1]=ask(i+1,i+B);
			int nl=i+B+1,nr=i+n-1,res=i+n;
			while(nl<=nr)
			{
				int mid=nl+nr>>1;
				if(ask(i+1,mid)>al[n-i+1])res=mid,nr=mid-1;
				else nl=mid+1;
			}
			bl[n-i+1]=n-i+1+n-(res-i);
		}
		reverse(a+1,a+n+1);for(int i=1;i<=n;i++)a[i+n]=a[i];

		for(int i=1;i<=n;i++)
		{
			//cout<<al[i]<<" "<<ar[i]<<" "<<bl[i]<<" "<<br[i]<<" "<<a[i]<<endl;
			ans[i]=al[i]+ar[i];
			if(br[i]<bl[i])ans[i]=max(ans[i],(ll)al[i]+ar[i]+2);
			if(br[i]<i+n-B)ans[i]=max(ans[i],(ll)al[i]+ar[i]+1);
			else if(br[i]<i+n)
			{
				int giv=0;
				for(int j=br[i]+1;j<i+n;j++)giv=(giv+a[j])>>1;
				ans[i]=max(ans[i],(ll)ar[i]+1+giv);
			}
			if(bl[i]>i+B)ans[i]=max(ans[i],(ll)al[i]+ar[i]+1);
			else if(bl[i]>i)
			{
				int giv=0;
				for(int j=br[i]+1;j<i+n;j++)giv=(giv+a[j])>>1;
				ans[i]=max(ans[i],(ll)al[i]+1+giv);
			}
			ans[i]+=a[i];
		}
		for(int i=1;i<=n;i++)printf("%lld ",ans[i]);printf("\n");
	}
}
void solve()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),a[i+n]=a[i];
	if(n<=300){work1::solve();return ;}
	work2::solve();
}
bool edd;
int main()
{
	cerr<<((&stt)-(&edd))/1024.0/1024<<"\n";
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d",&T);
	while(T--)solve();
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 9944kb

input:

3
5
2 1 4 3 5
5
2 1 3 1 2
1
1000000000

output:

6 5 7 8 8 
4 4 5 4 4 
1000000000 

result:

ok 11 numbers

Test #2:

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

input:

1
10
8 15 18 15 13 4 14 4 17 5

output:

30 37 41 39 34 27 29 26 31 27 

result:

ok 10 numbers

Test #3:

score: 0
Accepted
time: 2ms
memory: 9972kb

input:

1000
4
8 9 7 9
1
9
1
10
2
3 9
3
4 3 2
4
0 4 3 1
4
10 8 4 6
1
9
1
4
4
10 10 1 6
1
9
1
0
2
4 6
4
8 1 6 7
2
5 10
4
9 2 1 4
3
5 5 9
3
9 8 9
4
4 8 5 6
2
10 1
1
7
3
9 2 4
4
2 4 1 2
3
5 2 1
1
4
3
2 0 9
4
7 3 10 1
3
4 1 2
2
6 4
1
2
3
3 1 5
3
5 8 4
2
9 3
4
5 9 10 3
4
6 5 4 0
1
6
4
3 1 10 1
4
1 9 5 7
4
8 1 6 ...

output:

18 18 17 18 
9 
10 
7 10 
6 6 5 
3 5 5 3 
18 16 13 15 
9 
4 
18 17 11 14 
9 
0 
7 8 
13 9 11 14 
10 12 
12 7 6 9 
11 11 13 
17 16 17 
12 14 13 12 
10 6 
7 
12 8 9 
5 6 4 4 
6 4 4 
4 
6 5 10 
11 11 13 10 
5 4 4 
8 7 
2 
5 4 6 
11 12 10 
10 7 
13 17 16 12 
9 10 8 6 
6 
6 7 11 7 
9 13 12 11 
14 10 12 1...

result:

ok 2420 numbers

Test #4:

score: 0
Accepted
time: 2ms
memory: 10028kb

input:

1000
2
45733740 736448710
1
384264719
4
658671808 379716865 553196572 534986092
1
668964623
4
711670857 237459905 849354895 187613938
2
394629064 371184128
2
616819808 937720703
1
43217931
3
934395080 888433507 810476236
1
587663687
2
542163302 508453558
4
313836277 584869499 445629251 225398284
4
2...

output:

413958095 759315580 
384264719 
1254322429 1119397578 1175216002 1235849498 
668964623 
1136546502 1064876265 1239809530 1027491789 
580221128 568498660 
1085680159 1246130607 
43217931 
1783849951 1760869165 1721890529 
587663687 
796390081 779535209 
830377481 1020951833 929222211 751348422 
70477...

result:

ok 2440 numbers

Test #5:

score: 0
Accepted
time: 933ms
memory: 44024kb

input:

1
500000
2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 ...

result:

ok 500000 numbers

Test #6:

score: 0
Accepted
time: 953ms
memory: 43920kb

input:

1
499999
2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 ...

result:

ok 499999 numbers

Test #7:

score: 0
Accepted
time: 938ms
memory: 43980kb

input:

1
499800
2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 ...

result:

ok 499800 numbers

Test #8:

score: 0
Accepted
time: 755ms
memory: 43920kb

input:

1
500000
50831937 44675374 26273308 55922669 39121681 59988372 34492729 33442351 51180456 41692596 39437453 54897084 38001252 46544549 55093280 38264131 54229588 51914925 28566111 46796223 48610138 48548724 51107017 44611895 37985173 46091996 45517937 53008497 48179451 47964156 42155259 47184755 267...

output:

137137494 130644721 122461248 136098437 133900842 139971148 126044470 123400935 132294341 130564235 131577353 139222968 134134442 139111260 143826886 137816035 143317006 139132099 126640855 134620873 139716994 141756406 141850936 136210410 131757247 136204948 139617130 144560973 142272557 138851244 ...

result:

ok 500000 numbers

Test #9:

score: 0
Accepted
time: 676ms
memory: 43964kb

input:

1
500000
25452585 60227199 37756030 41287924 48217237 52318161 46751058 48760576 45326727 50656052 42012818 49755082 50064918 39821656 41870920 49087328 53628763 49607632 27859818 29150585 58180124 43787581 54102015 41307343 45882355 44562399 32249571 47861371 54219662 44016656 52635402 44018938 369...

output:

122077771 137295072 130819111 133118661 140045656 144669625 143151165 143081702 141412226 142458774 138750631 141398577 140113190 133787022 134621881 139961301 141650380 133721506 118241937 120093611 138266213 138301736 141806757 135062134 133887565 130833246 126351953 136672280 143536692 140839958 ...

result:

ok 500000 numbers

Test #10:

score: 0
Accepted
time: 675ms
memory: 44052kb

input:

1
500000
50077500 57462422 30708014 58310827 32563574 43315826 53400776 52368101 32196492 41610551 53797342 43848605 47176214 52736999 37077497 57580160 33273499 50017090 51287872 38575250 33970872 41050429 47332854 62688024 30029626 50837045 28881546 45104946 52887401 45535679 51980189 44643837 464...

output:

142897147 144399000 131906720 139305780 128891491 134077587 141328738 139143094 127976847 132504286 140868042 138969806 140783567 142224791 135672912 141341245 131309961 137023409 136222928 126602103 122419456 128490229 137230474 143586676 127704181 130629339 122613599 132582341 141184835 141048645 ...

result:

ok 500000 numbers

Test #11:

score: 0
Accepted
time: 679ms
memory: 43980kb

input:

1
500000
50990079 48693213 38486675 52357538 47585564 46899198 45489174 49673180 50114681 32504665 53579548 39409968 47465702 51608057 48059738 41865634 41938584 49570423 51076776 45761549 56164212 33467947 50568038 52412481 52335534 31075296 55678331 36469490 61117776 25861594 49142780 48449043 467...

output:

134813829 137015630 134685428 141967928 141698085 140898940 140200468 141368470 138710938 130236855 138124202 134704329 139521670 142901293 140319478 135807796 136401562 142288234 144963390 143505077 145156980 135141056 142493741 145241240 141990638 131232054 139476554 133941836 140673801 126066004 ...

result:

ok 500000 numbers

Test #12:

score: 0
Accepted
time: 68ms
memory: 10096kb

input:

100000
5
0 0 0 0 0
5
1 0 0 0 0
5
2 0 0 0 0
5
3 0 0 0 0
5
4 0 0 0 0
5
5 0 0 0 0
5
6 0 0 0 0
5
7 0 0 0 0
5
8 0 0 0 0
5
9 0 0 0 0
5
10 0 0 0 0
5
0 1 0 0 0
5
1 1 0 0 0
5
2 1 0 0 0
5
3 1 0 0 0
5
4 1 0 0 0
5
5 1 0 0 0
5
6 1 0 0 0
5
7 1 0 0 0
5
8 1 0 0 0
5
9 1 0 0 0
5
10 1 0 0 0
5
0 2 0 0 0
5
1 2 0 0 0
5
2...

output:

0 0 0 0 0 
1 0 0 0 0 
2 1 0 0 1 
3 1 0 0 1 
4 2 1 1 2 
5 2 1 1 2 
6 3 1 1 3 
7 3 1 1 3 
8 4 2 2 4 
9 4 2 2 4 
10 5 2 2 5 
0 1 0 0 0 
1 1 0 0 0 
2 2 1 0 1 
3 2 1 0 1 
4 3 1 1 2 
5 3 1 1 2 
6 4 2 1 3 
7 4 2 1 3 
8 5 2 2 4 
9 5 2 2 4 
10 6 3 2 5 
1 2 1 0 0 
2 2 1 0 1 
3 3 1 0 1 
4 3 1 1 2 
5 4 2 1 2 
6...

result:

ok 500000 numbers

Test #13:

score: 0
Accepted
time: 70ms
memory: 10080kb

input:

83333
6
0 0 0 0 0 0
6
1 0 0 0 0 0
6
2 0 0 0 0 0
6
3 0 0 0 0 0
6
4 0 0 0 0 0
6
5 0 0 0 0 0
6
6 0 0 0 0 0
6
7 0 0 0 0 0
6
0 1 0 0 0 0
6
1 1 0 0 0 0
6
2 1 0 0 0 0
6
3 1 0 0 0 0
6
4 1 0 0 0 0
6
5 1 0 0 0 0
6
6 1 0 0 0 0
6
7 1 0 0 0 0
6
0 2 0 0 0 0
6
1 2 0 0 0 0
6
2 2 0 0 0 0
6
3 2 0 0 0 0
6
4 2 0 0 0 0
...

output:

0 0 0 0 0 0 
1 0 0 0 0 0 
2 1 0 0 0 1 
3 1 0 0 0 1 
4 2 1 0 1 2 
5 2 1 0 1 2 
6 3 1 0 1 3 
7 3 1 0 1 3 
0 1 0 0 0 0 
1 1 0 0 0 0 
2 2 1 0 0 1 
3 2 1 0 0 1 
4 3 1 0 1 2 
5 3 1 0 1 2 
6 4 2 1 1 3 
7 4 2 1 1 3 
1 2 1 0 0 0 
2 2 1 0 0 1 
3 3 1 0 0 1 
4 3 1 0 1 2 
5 4 2 1 1 2 
6 4 2 1 1 3 
7 5 2 1 1 3 
8...

result:

ok 499998 numbers

Test #14:

score: 0
Accepted
time: 88ms
memory: 10028kb

input:

50000
10
0 0 0 0 0 0 0 0 0 0
10
1 0 0 0 0 0 0 0 0 0
10
2 0 0 0 0 0 0 0 0 0
10
3 0 0 0 0 0 0 0 0 0
10
0 1 0 0 0 0 0 0 0 0
10
1 1 0 0 0 0 0 0 0 0
10
2 1 0 0 0 0 0 0 0 0
10
3 1 0 0 0 0 0 0 0 0
10
0 2 0 0 0 0 0 0 0 0
10
1 2 0 0 0 0 0 0 0 0
10
2 2 0 0 0 0 0 0 0 0
10
3 2 0 0 0 0 0 0 0 0
10
0 3 0 0 0 0 0 0...

output:

0 0 0 0 0 0 0 0 0 0 
1 0 0 0 0 0 0 0 0 0 
2 1 0 0 0 0 0 0 0 1 
3 1 0 0 0 0 0 0 0 1 
0 1 0 0 0 0 0 0 0 0 
1 1 0 0 0 0 0 0 0 0 
2 2 1 0 0 0 0 0 0 1 
3 2 1 0 0 0 0 0 0 1 
1 2 1 0 0 0 0 0 0 0 
2 2 1 0 0 0 0 0 0 1 
3 3 1 0 0 0 0 0 0 1 
4 3 1 0 0 0 0 0 1 2 
1 3 1 0 0 0 0 0 0 0 
2 3 1 0 0 0 0 0 0 1 
3 4 2 ...

result:

ok 500000 numbers

Test #15:

score: 0
Accepted
time: 794ms
memory: 43892kb

input:

1
500000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...

result:

ok 500000 numbers

Test #16:

score: 0
Accepted
time: 776ms
memory: 42004kb

input:

1
500000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...

result:

ok 500000 numbers

Test #17:

score: 0
Accepted
time: 52ms
memory: 12144kb

input:

100
100
794974775 319599082 534896702 531754666 188594127 850473183 123918434 373201410 225872804 613716798 968781728 301153078 825870015 884186067 176436571 186242378 945348477 268902499 377384194 741515217 603747317 191514668 970240757 395857046 362569599 184766332 969655538 859867689 631912620 44...

output:

1666573856 1443381594 1462481506 1410477119 1266079292 1471829922 1137785740 1186756776 1269304087 1647694236 1929356306 1722523937 1925223920 1851730842 1377824086 1328174516 1663248638 1411924364 1463208524 1680020655 1624570288 1475784090 1777617936 1512899615 1410845534 1470359822 1987904523 204...

result:

ok 6467 numbers

Test #18:

score: 0
Accepted
time: 51ms
memory: 12124kb

input:

100
47
169 607 144 992 214 4 217 742 702 199 403 933 295 143 990 337 204 988 792 969 233 215 922 528 821 386 40 877 141 243 504 797 928 714 685 81 821 752 689 896 541 270 227 947 388 632 143
100
637 262 990 971 34 350 433 62 485 709 215 980 971 787 567 243 25 913 451 773 130 400 796 450 830 401 157 ...

output:

1017 1243 1182 1495 1069 858 1069 1490 1543 1314 1444 1692 1387 1334 1734 1517 1554 2063 2122 2054 1559 1495 1856 1763 1759 1403 1169 1461 1169 1251 1595 1981 2162 2032 1848 1561 1933 2041 2042 2031 1692 1388 1373 1705 1469 1385 1046 
1580 1577 1969 1860 1225 1153 1133 1031 1351 1620 1635 2146 2259 ...

result:

ok 6437 numbers

Test #19:

score: 0
Accepted
time: 788ms
memory: 43972kb

input:

1
500000
24841375 70408158 383749601 464340548 878516021 768949056 248134065 16161835 570858860 837034359 159517214 395243059 870018128 416856566 407199519 172196845 895527702 104605059 18516437 632654234 388463765 676004662 314539734 654303478 717140829 748002985 500557057 941392792 659256800 37790...

output:

727863872 778903793 1113783373 1429930239 1764531403 1663624237 1241105607 1066938682 1401998347 1581768897 1296872356 1421136173 1663103489 1431595357 1290600055 1184105503 1411368436 1001024035 934284063 1306911469 1384013259 1570426030 1528044825 1777876432 1935191037 1984389919 1903779283 202422...

result:

ok 500000 numbers

Test #20:

score: 0
Accepted
time: 732ms
memory: 43908kb

input:

2
21213
368244095 497132781 81730541 535678187 361569652 450755120 252527963 67394035 961089805 712650577 223580683 154828531 762981028 73412229 175538423 498650115 847156548 666098615 787498182 753803722 288704722 845903412 142372110 752646303 118076240 674838277 886227243 351246422 717775358 77382...

output:

1278648860 1213524170 1009462393 1187536002 1155860331 1159760348 1067407860 1129967358 1656419482 1569446641 1198221256 1090735475 1296374636 1005729573 1107830953 1500540176 1895544315 1967585790 2024272237 1911847530 1624641006 1716697902 1398248631 1565365511 1386195692 1723009360 1909070292 172...

result:

ok 500000 numbers

Test #21:

score: 0
Accepted
time: 640ms
memory: 36908kb

input:

10
19312
157980378 90684709 74945569 274240280 973887747 534855885 400523144 675086143 844722412 581862308 626150876 206795276 57971909 518092132 129234349 27120862 509228380 223886217 617775330 529169739 456932699 470128969 333660591 960377529 296669366 517769470 562401944 537579283 169980416 55091...

output:

799481009 688823133 786549760 1165132915 1714922108 1661340735 1636145903 1828239308 1921823153 1709234957 1478470778 1047715673 830625492 941890194 746961796 731662772 1041513842 1108279263 1393354991 1448445220 1434003451 1451164359 1488713995 1770129742 1496044067 1524976376 1539742669 1480777381...

result:

ok 500000 numbers

Test #22:

score: 0
Accepted
time: 564ms
memory: 36880kb

input:

100
739
45862042 246766280 79325150 991817688 417418982 943404093 13665290 854448681 523991720 412977563 315606258 597975534 785858169 519879466 164596874 498650062 188106395 738672699 266681313 72841157 204190955 553944867 333260481 840096897 179655852 927516693 600253287 312421637 882598219 398055...

output:

646114661 823150090 1041611145 1661890048 1625387442 1775450085 1398131632 1699381059 1568647995 1436251349 1402514033 1596624348 1692083536 1454797240 1165090365 1211033362 1114517948 1293101915 1010227792 832445596 961624463 1265329129 1370781059 1661732798 1523405591 1877297401 1778562872 1668729...

result:

ok 500000 numbers

Test #23:

score: 0
Accepted
time: 3198ms
memory: 30600kb

input:

1000
255
254290272 472177015 375173192 909396072 740480708 206876414 618914831 578128820 112386446 797007681 374628755 593411208 642252316 509914603 226345837 415871870 297246513 386640010 573764004 866544758 716919549 601411488 822916067 814164102 573058369 697706879 776346912 381470133 998084589 9...

output:

1203009328 1371601522 1517728956 1859961080 1768079636 1449516949 1545398115 1485606094 1301423890 1599373963 1501499497 1592431647 1589462810 1417846905 1190282549 1218340712 1231761428 1415193089 1726261279 2039814102 2073456841 2068448677 2195547620 2186046272 2048321909 2075170946 2093045138 199...

result:

ok 500000 numbers

Test #24:

score: -100
Time Limit Exceeded

input:

10000
68
590553052 325833626 474795587 458205191 758621341 568191007 387199148 557590252 478151753 41825603 695387020 996508908 735352920 816393555 191340581 659142958 860916414 92938299 224405819 67691103 372326110 842344381 982795205 487897564 952786136 439055521 513126356 263659470 624577499 7428...

output:

1725738611 1489733411 1509844477 1572684401 1734558740 1625780437 1477605842 1487435447 1404597399 1306830422 1799740252 2149439679 2079095584 1945269901 1559488836 1666441318 1617900023 1086934119 960027826 976526718 1379752315 1914364906 2142643380 1968050737 2045637117 1716862852 1587936731 14832...

result: