QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#385183#7456. rdCcotzhouhuanyi100 ✓1244ms133512kbC++144.4kb2024-04-10 16:15:562024-04-10 16:15:56

Judging History

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

  • [2024-04-10 16:15:56]
  • 评测
  • 测评结果:100
  • 用时:1244ms
  • 内存:133512kb
  • [2024-04-10 16:15:56]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#define N 300000
#define M 600000
#define W 1048576
using namespace std;
const int inf=(int)(1e9);
int read()
{
	char c=0;
	int sum=0;
	while (c<'0'||c>'9') c=getchar();
	while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
	return sum;
}
struct rds
{
	int num,data,snum;
	bool operator < (const rds &t)const
	{
		return data<t.data;
	}
};
rds st[N+1];
int n,m,C,limit,srt,leng,wp[N+1],rk[N+1],depth[N+1],smz,sz[N+1],szt[N+1],dis[N+1],maxp[N+1],ans[M+1],sl[N+1],sr[N+1],delta[N+1];
vector<int>E[N+1];
vector<rds>v[N+1];
vector<rds>p[N+1];
bool used[N+1],vis[N+1];
bool cmp(int x,int y)
{
	return depth[x]<depth[y];
}
void add_edge(int x,int y)
{
	E[x].push_back(y),E[y].push_back(x);
	return;
}
void dfs(int x)
{
	used[x]=1;
	for (int i=0;i<E[x].size();++i)
		if (!used[E[x][i]])
			depth[E[x][i]]=depth[x]+1,dfs(E[x][i]);
	return;
}
void get_rt(int x)
{
	sz[x]=vis[x]=1,maxp[x]=0;
	for (int i=0;i<E[x].size();++i)
		if (!used[E[x][i]]&&!vis[E[x][i]])
			get_rt(E[x][i]),sz[x]+=sz[E[x][i]],maxp[x]=max(maxp[x],sz[E[x][i]]);
	maxp[x]=max(maxp[x],smz-sz[x]),vis[x]=0;
	if (maxp[x]<maxp[srt]) srt=x;
	return;
}
void dfs2(int x)
{
	st[++leng]=(rds){x,dis[x]},vis[x]=szt[x]=1;
	for (int i=0;i<E[x].size();++i)
		if (!used[E[x][i]]&&!vis[E[x][i]])
			dis[E[x][i]]=dis[x]+1,dfs2(E[x][i]),szt[x]+=szt[E[x][i]];
	vis[x]=0;
	return;
}
struct seg
{
	int wl[W+1],wr[W+1],num[W+1],snum[W+1],minn[W+1];
	void build(int k,int l,int r)
	{
		wl[k]=l,wr[k]=r,snum[k]=0,minn[k]=inf;
		if (l==r)
		{
			num[l]=k,snum[k]=l;
			return;
		}
		int mid=(l+r)>>1;
		build(k<<1,l,mid),build(k<<1|1,mid+1,r);
		return;
	}
	void push_up(int k)
	{
		minn[k]=min(minn[k<<1],minn[k<<1|1]);
		return;
	}
	void change(int x,int d)
	{
		x=num[x],minn[x]=d;
		while (x!=1) x>>=1,push_up(x);
		return;
	}
	int find(int x,int d)
	{
		if (minn[1]>=d) return -1;
		int k=-1;
		x=num[x];
		while (x!=1)
		{
			if (x&1)
			{
				if (minn[x^1]<d)
				{
					k=x^1;
					break;
				}
			}
			x>>=1;
		}
		if (k==-1) return -1;
		while (!snum[k])
		{
			if (minn[k<<1|1]<d) k=k<<1|1;
			else k<<=1;
		}
		return snum[k];
	}
	int find2(int x,int d)
	{
		if (minn[1]>=d) return -1;
		int k=-1;
		x=num[x];
		while (x!=1)
		{
			if (!(x&1))
			{
				if (minn[x^1]<d)
				{
					k=x^1;
					break;
				}
			}
			x>>=1;
		}
		if (k==-1) return -1;
		while (!snum[k])
		{
			if (minn[k<<1]<d) k<<=1;
			else k=k<<1|1;
		}
		return snum[k];
	}
};
seg T;
bool cmp2(rds x,rds y)
{
	return x.num<y.num;
}
void solve(int x)
{
	int d,ps=0;
	leng=0,used[x]=1,dis[x]=0,dfs2(x),sort(st+1,st+leng+1,cmp2);
	for (int i=1;i<=leng;++i) st[i].snum=i,delta[i]=st[i].num;
	sort(st+1,st+leng+1),limit=1;
	while (limit<leng) limit<<=1;
	T.build(1,1,limit);
	for (int i=leng;i>=1;--i)
	{
		while (ps+1<=leng&&st[ps+1].data+st[i].data<=C) ++ps,T.change(st[ps].snum,rk[st[ps].num]);
		if (ps)
		{
			d=T.find(st[i].snum,rk[st[i].num]);
			if (d!=-1) sl[st[i].num]=max(sl[st[i].num],delta[d]);
			d=T.find2(st[i].snum,rk[st[i].num]);
			if (d!=-1) sr[st[i].num]=min(sr[st[i].num],delta[d]);
		}
	}
	for (int i=0;i<E[x].size();++i)
		if (!used[E[x][i]])
			srt=0,smz=szt[E[x][i]],get_rt(E[x][i]),solve(srt);
	return;
}
int c[N+1];
int lowbit(int x)
{
	return x&(-x);
}
void add(int x,int d)
{
	x=n-x+1;
	for (;x<=n;x+=lowbit(x)) c[x]+=d;
	return;
}
int query(int x)
{
	x=n-x+1;
	int res=0;
	for (;x>=1;x-=lowbit(x)) res+=c[x];
	return res;
}
int main()
{
	int l,r,x;
	n=read(),m=read(),C=read(),maxp[0]=inf;
	for (int i=2;i<=n;++i) x=read(),add_edge(x,i);
	depth[1]=1,dfs(1);
	for (int i=1;i<=n;++i) wp[i]=i,sl[i]=-inf,sr[i]=inf,used[i]=0;
	sort(wp+1,wp+n+1,cmp);
	for (int i=1;i<=n;++i) rk[wp[i]]=i;
	srt=0,smz=n,get_rt(1),solve(srt);
	for (int i=1;i<=m;++i) l=read(),r=read(),v[r].push_back((rds){i,l});
	for (int i=1;i<=n;++i)
	{
		if (sl[i]!=-inf) p[i].push_back((rds){sl[i],1});
		if (sr[i]!=inf) p[sr[i]].push_back((rds){i,1});
		if (sl[i]!=-inf&&sr[i]!=inf) p[sr[i]].push_back((rds){sl[i],-1});
	}
	for (int i=1;i<=n;++i)
	{
		for (int j=0;j<p[i].size();++j) add(p[i][j].num,p[i][j].data);
		for (int j=0;j<v[i].size();++j) ans[v[i][j].num]=i-v[i][j].data+1-query(v[i][j].data);
	}
	for (int i=1;i<=m;++i) printf("%d\n",ans[i]);
	return 0;
}

詳細信息

Subtask #1:

score: 4
Accepted

Test #1:

score: 4
Accepted
time: 3ms
memory: 50984kb

input:

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

output:

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

result:

ok 100 numbers

Subtask #2:

score: 4
Accepted

Test #2:

score: 4
Accepted
time: 825ms
memory: 105752kb

input:

300000 600000 299999
54689 163735 190742 294221 59884 139917 96072 2577 78182 823 116367 142307 60808 79158 165576 16795 133183 293293 135566 178321 178838 276793 25254 199292 283980 166691 6950 151813 30260 153594 41853 22418 97099 60279 251545 287861 176463 15943 257315 25750 64891 238782 215012 2...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 600000 numbers

Subtask #3:

score: 16
Accepted

Test #3:

score: 16
Accepted
time: 805ms
memory: 105804kb

input:

300000 600000 299900
275908 242561 279434 22147 22850 44627 185131 271000 115019 266044 181265 178564 72508 38997 236987 37465 154831 290467 136480 149628 245773 187248 46113 167958 99170 31088 248444 154173 47163 66859 195090 89740 83929 77842 109147 142120 55954 131989 296566 107565 4488 208098 22...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 600000 numbers

Test #4:

score: 0
Accepted
time: 995ms
memory: 130236kb

input:

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

output:

2
2
2
1
1
2
1
2
2
1
2
2
2
1
1
2
2
2
2
1
2
2
2
2
2
1
2
2
2
1
2
2
2
1
1
2
2
2
2
2
2
2
1
2
2
2
2
2
2
1
1
2
1
2
1
1
2
2
1
2
1
2
2
2
2
2
2
1
2
2
2
2
2
2
2
1
2
1
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
1
2
1
2
2
2
1
2
2
2
2
1
2
1
2
2
1
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
1
1
1
1
2
2
2
2
2
2
2
2
1
...

result:

ok 600000 numbers

Test #5:

score: 0
Accepted
time: 980ms
memory: 130756kb

input:

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

output:

2
2
2
2
2
2
2
2
2
2
1
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
1
2
2
2
2
2
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
1
2
2
2
1
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
1
2
1
2
2
1
2
2
2
1
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
1
2
2
1
2
2
2
1
1
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
...

result:

ok 600000 numbers

Test #6:

score: 0
Accepted
time: 1000ms
memory: 129656kb

input:

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

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 600000 numbers

Test #7:

score: 0
Accepted
time: 1012ms
memory: 132424kb

input:

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

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 600000 numbers

Subtask #4:

score: 4
Accepted

Test #8:

score: 4
Accepted
time: 620ms
memory: 93092kb

input:

300000 600000 1
196208 212926 148911 130413 285394 299608 174690 194347 296651 63048 190567 129371 5945 153445 80159 113039 190233 298862 146033 3972 154693 236257 259021 129019 165652 73964 30809 178090 157090 70227 262652 271457 11819 262122 10301 47927 282407 102319 230866 105104 134969 152272 15...

output:

75104
72984
63343
73236
72434
56813
53012
74300
70738
34588
74932
49561
53549
71797
50762
72758
54608
74307
74860
21190
67335
72138
72905
71753
75047
49298
66847
51122
39223
54306
37778
53327
74551
73268
74211
63480
2887
72370
16737
40356
40616
39828
61654
74740
62374
21338
72975
68226
53927
70971
5...

result:

ok 600000 numbers

Subtask #5:

score: 8
Accepted

Dependency #4:

100%
Accepted

Test #9:

score: 8
Accepted
time: 217ms
memory: 105384kb

input:

300000 600000 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 ...

output:

5
3
2
3
4
4
6
3
2
4
2
5
1
2
4
4
3
3
2
1
2
5
5
3
5
1
3
4
2
2
5
2
4
5
3
4
1
3
3
4
4
1
2
2
4
1
1
4
5
3
5
1
3
1
2
2
5
2
2
2
1
1
2
6
4
3
4
3
4
3
2
2
2
5
2
3
2
3
4
2
3
2
760
4
5
1
2
2
2
4
4
2
3
4
3
3
2
4
4
5
1
5
1
2
1
3
237
4
3
2
3
4
5
4
4
2
3
1
3
1357
2
5
3
3
5
1
5
1
4
4
2
3
454
5
2
2
5
4
3
1587
5
1
2
3
...

result:

ok 600000 numbers

Test #10:

score: 0
Accepted
time: 798ms
memory: 97812kb

input:

300000 600000 2
73480 73510 212 841 73399 502 328 414 304 73479 691 73582 469 704 901 225 201 553 73608 591 158 321 144 73648 802 73590 73635 731 641 234 73457 73558 73444 73672 514 272 73381 25 73458 336 614 667 229 178 154 73476 73580 381 405 592 73583 73593 73482 73465 751 580 323 404 821 73433 8...

output:

20669
11930
20705
17982
4880
14243
25608
15296
6249
5143
8545
23515
26033
18641
23263
20068
11915
14609
6293
11010
20548
23083
23276
14224
18857
20957
22273
10707
15016
14642
16720
15294
17380
16489
8386
13207
15012
15102
13212
9876
23833
16246
22159
464
21022
14490
14851
21161
19284
19448
19631
135...

result:

ok 600000 numbers

Subtask #6:

score: 8
Accepted

Dependency #5:

100%
Accepted

Test #11:

score: 8
Accepted
time: 292ms
memory: 105384kb

input:

300000 600000 2
1 95895 95895 1 95895 1 1 95895 95895 95895 1 95895 95895 1 95895 95895 95895 95895 1 95895 95895 1 1 1 1 1 1 1 95895 95895 1 95895 1 95895 1 95895 1 95895 95895 95895 95895 1 95895 1 95895 95895 95895 95895 95895 95895 95895 1 95895 1 1 95895 1 95895 95895 1 95895 1 1 95895 95895 1 ...

output:

39
39
35
31
2
41
14
33
13
12
25
48
34
30
36
4
28
30
17
42
35
42
53
39
38
46
44
34
31
54
40
28
43
36
33
8
43
42
27
27
32
6
29
11
19
39
43
71
35
29
16
35
39
6
35
48
7
36
35
3
24
41
47
19
42
30
49
39
35
41
29
24
2
28
37
37
32
25
31
29
35
3
32
29
38
32
35
38
37
24
12
41
35
32
33
47
32
32
14
36
39
30
21
...

result:

ok 600000 numbers

Test #12:

score: 0
Accepted
time: 819ms
memory: 99644kb

input:

300000 600000 3
112999 113964 2257 2947 3134 115717 113542 114722 115764 113009 114462 1322 113810 115981 115838 115200 115619 763 113436 114281 318 112867 2901 2322 131 114608 3231 112860 113698 2579 115276 2515 1754 176 114509 115611 114137 205 112578 114227 2723 115920 115906 71 112725 113093 113...

output:

9620
784
14341
3831
3737
12890
10761
18758
17060
17111
18905
5781
18259
3364
14506
5071
16929
9577
8637
16258
17954
17371
2440
14733
15606
13591
16136
5178
18074
7630
4330
3878
12858
17142
11179
4615
10511
17279
15983
9138
16221
13739
13158
16929
15374
16291
16993
18047
12404
10568
13267
14787
18188...

result:

ok 600000 numbers

Subtask #7:

score: 8
Accepted

Dependency #6:

100%
Accepted

Test #13:

score: 8
Accepted
time: 269ms
memory: 105548kb

input:

300000 600000 2
69598 58726 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927 299927...

output:

127
129
227
314
111
76
56
79
18
70
46
67
13
71
3
48
49
204
11
126
61
30
111
32
87
43
99
65
45
276
112
141
35
64
74
87
174
44
64
129
137
165
318
80
32
232
315
129
29
49
68
148
49
249
180
96
185
76
165
132
157
49
287
68
226
52
37
41
91
53
9
140
97
14
43
8
158
70
17
39
75
138
90
45
49
280
127
299
33
25...

result:

ok 600000 numbers

Test #14:

score: 0
Accepted
time: 836ms
memory: 101452kb

input:

300000 600000 4
996 263 503 262714 634 815 262012 263087 892 359 262090 262098 929 262451 216 262296 504 262187 261892 672 261889 262994 216 409 262651 240497 311 261757 398 503 60 262769 639 854 261730 610 733 570 219400 418 182 143 261845 126 261742 115 143 468 103 310 993 262557 731 600 262496 35...

output:

6733
4647
3401
168
3116
9706
4453
2150
9447
6231
6910
6924
7526
10053
9653
2767
7067
6456
8779
1167
8235
2113
8929
8434
1621
9086
10689
4930
7852
6626
3305
9008
4797
5084
5374
9051
7443
2809
9217
4703
3420
2826
7442
9893
8721
4000
3324
8244
10025
8303
7535
9278
5940
345
10060
7471
6582
8207
7073
888...

result:

ok 600000 numbers

Subtask #8:

score: 8
Accepted

Test #15:

score: 8
Accepted
time: 283ms
memory: 83488kb

input:

100000 100000 7
3 87695 6 4 7 2 10 51981 85695 13 85698 22473 33773 14 15 75237 20 18 35318 22 23 19 67326 26 24 30 56391 84768 84771 33 34 32 84484 37 17018 36 39 91935 42 43 44 45 41 65104 40 51 25723 52 5250 17947 48 24228 58 59 55 56 57 53 61 64 63 84776 62 60 24088 69 45861 68 82869 82870 77 72...

output:

3367
3131
1643
3371
1904
3754
3619
1930
2574
1758
685
3622
1805
2280
3823
2221
1982
2419
1233
2922
2826
3271
2805
1046
959
3645
1057
3741
1239
2631
996
3733
2907
400
1033
3227
3308
3156
3278
2773
3324
2236
3688
3413
2999
3735
3006
3371
1401
2415
1433
3236
3745
3328
3383
1977
619
3416
3757
3187
2766
...

result:

ok 100000 numbers

Test #16:

score: 0
Accepted
time: 265ms
memory: 80364kb

input:

100000 100000 12
11 45267 5 45264 2 10 4 7 6308 9 6 16 6547 13 14 15 17 20 18 22 24 21 26 23 27 29 55168 45460 56028 35 34 48824 36 33 38 31 37 44 47 42 47456 45 40 41 39 43 53 58 49 23719 57 83266 59 48 96221 50 96229 55 63 62 39642 61 60 96558 96555 71 73 72 69 74 68 68996 70 71957 78 86 84 85 81 ...

output:

1745
1142
820
1401
1
1288
1629
1465
953
1741
291
1116
1464
2085
2047
1712
1727
2098
94
2095
1125
513
1439
1540
1840
415
174
548
2127
999
399
2050
2163
2035
1447
1550
1914
686
2098
1420
2162
1934
2114
1962
938
950
941
2165
2087
1834
1587
1338
996
1687
2143
530
1219
905
584
2040
1402
1085
1536
1695
19...

result:

ok 100000 numbers

Test #17:

score: 0
Accepted
time: 269ms
memory: 83160kb

input:

100000 100000 234
97 119 71 133 42 132 154 130 143 58 92 4 160 90 124 48 51 39 34 14 114 120 99 113 84 38 127 98 60 88 140 109 8 31 53 138 76 129 57 148 73 107 46 91 13 150 131 72 145 26 79 29 32 134 158 159 104 52 75840 77 121 85 115 110 23 70 40 16 93 24 68 100 61 161 41 33 20 86 157 144 152 54 49...

output:

94
60
94
97
85
13
76
77
113
100
96
33
106
106
61
62
75
70
39
89
86
49
101
24
32
6
49
38
68
83
56
78
26
108
52
62
43
105
75
110
74
35
52
10
36
112
75
29
73
82
95
72
35
89
18
14
59
8
79
4
97
33
96
106
27
80
53
107
42
32
37
69
61
14
88
79
71
104
99
102
90
43
71
32
29
105
94
91
63
105
29
91
105
30
20
10...

result:

ok 100000 numbers

Test #18:

score: 0
Accepted
time: 308ms
memory: 74512kb

input:

100000 100000 1152
1018 860 558 245 582 14 91 900 364 898 825 569 928 667 77 657 205 607 101 743 398 133 1023 649 858 965 389 805 207 354 637 451 179 862 14926 213 785 420 1059 218 393 812 787 1017 1027 377 118 712 37 156 820 694 70 588 376 408 261 214 148 546 313 385 36 770 799 796 792 269 367 606 ...

output:

12
17
15
14
13
2
21
19
22
13
14
23
21
21
21
17
24
12
8
3
26
10
21
19
13
7
26
25
10
27
19
8
21
1
8
13
13
5
6
27
24
26
28
26
9
2
15
18
11
13
22
20
7
5
15
19
26
8
3
6
19
11
22
20
22
1
6
21
18
25
19
22
11
23
26
5
8
2
6
23
23
7
13
28
13
25
21
21
8
2
18
14
26
8
21
26
13
26
22
12
11
26
22
6
23
20
2
23
21
8...

result:

ok 100000 numbers

Test #19:

score: 0
Accepted
time: 358ms
memory: 83072kb

input:

100000 100000 10133
392 523 127 156 339 402 529 521 281 625 324 310 93 151 499 136 372 29 53 333 641 217 429 166 137 112 592 569 580 362 636 586 461 543 247 388 474 512 239 623 326 661 181 185 227 31 330 176 198 659 441 645 254 540 169 261 489 68 456 215 342 343 299 444 492 646 195 133 146 532 211 2...

output:

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

result:

ok 100000 numbers

Subtask #9:

score: 4
Accepted

Dependency #8:

100%
Accepted

Test #20:

score: 4
Accepted
time: 1071ms
memory: 129476kb

input:

300000 600000 7
6 4 38447 2 3 10 12 26878 134369 8 13 26876 255212 255210 19 183423 16 21 22 20 17 24 110798 262581 25 29 157966 28 31 138382 70996 36 30 33 34 188791 37 143928 42 44 46 234913 43 40 41 56433 47 48 53 281329 50 263638 57 56 229029 55 54 163950 62 48562 61 65 63 66 111250 64 67 73 134...

output:

6188
10902
11172
7292
10083
8712
6431
7252
11017
10862
10416
5821
5216
639
10502
5665
5763
80
11203
11201
8937
10338
11160
8599
10334
2921
10819
10899
4144
10401
11194
1705
8289
9398
7890
7648
7340
10160
3797
4079
4208
11032
10336
9413
11244
7664
228
820
4446
9217
11076
9039
10666
3276
7282
6807
112...

result:

ok 600000 numbers

Test #21:

score: 0
Accepted
time: 1021ms
memory: 130760kb

input:

300000 600000 12
7 5 3 248681 2 4 16 219922 12 219921 13 8 9 293162 14 261062 24 21 22 23 297814 18 20 19 27 28 30 229846 29 26 33 234709 32 34 35 153546 94023 38 42 39 44 153545 41 49 205379 45 47 46 184082 59 58 52 57 51 54 53 55 50 62 60 104329 61 66 70 65 64 69 144067 68 72 71518 78 80 82 77 81 ...

output:

5872
3374
3842
6332
6461
6015
4215
5904
6293
2961
6400
6259
5227
1374
6062
5300
5421
1829
4858
1153
6433
3203
2259
6366
5357
6471
4836
4742
2501
65
6138
6391
6212
2996
2020
4940
6348
3823
5478
6003
6202
6331
6294
2431
6217
898
6432
3220
6446
5532
3059
6392
5650
3446
5459
6157
6481
4254
474
988
6328
...

result:

ok 600000 numbers

Test #22:

score: 0
Accepted
time: 961ms
memory: 133248kb

input:

300000 600000 234
47 13 9 16 10 44 32 37 19 40 7 51 18 6 28 56 22 55 42 15 23 2 25 33 3 38 35 70466 49 12 45 36 50 29 34 52 26 41 39 4 53 11 17 27 30 5 46 24 8 43 20 31 21 14 54 91 77 133 63 110 88 62 97 84 112 78 126 107 105 95 86 129 137 59 100314 99 114 89 92 135 68 100 72 125 123 71 64 87 136 11...

output:

291
205
306
323
216
258
192
297
296
143
223
45
301
299
291
244
210
56
70
319
279
160
288
269
200
103
247
277
226
138
221
305
274
289
186
124
304
291
257
291
280
37
228
1
252
42
292
219
233
240
172
87
137
134
92
279
300
324
3
309
305
211
269
128
306
305
81
259
196
307
165
221
311
258
275
285
303
42
2...

result:

ok 600000 numbers

Test #23:

score: 0
Accepted
time: 1060ms
memory: 133512kb

input:

300000 600000 1152
134 362 406 272 544 684 448 483 776 273 877 702 500 370 271 694 151 20 388 133 677 470 740 296 457 274 918 334 127 734 232 96 8 298 924 722 339 196 28 102 227 32 410 741 119 607 787 24 269 628 154 553 167 546 587 813 604 576 800 907 678 661 912 520 30 346 575 611 468 902 428 31 47...

output:

34
32
24
62
66
32
59
59
56
58
25
64
31
57
43
56
65
39
58
56
19
51
32
47
17
61
6
55
49
60
61
39
58
61
61
17
62
56
14
16
59
12
24
51
20
64
33
30
40
54
64
48
11
39
59
66
40
48
51
31
55
45
61
32
55
21
42
61
65
43
42
50
40
3
49
8
56
47
56
46
61
39
59
55
23
58
13
48
39
19
45
69
13
58
62
16
53
51
63
38
49
...

result:

ok 600000 numbers

Test #24:

score: 0
Accepted
time: 1244ms
memory: 133484kb

input:

300000 600000 10133
380 2442 567 94 3155 925 2222 3685 3056 2918 523 1893 616 2116 1358 3315 3186 114 1647 3101 1472 3716 468 1717 997 1842 1226 1812 2294 2141 2363 3805 1936 2195 1506 1214 1514 482 634 2571 3604 2156 2778 3770 81 3812 1014 2365 1454 911 1087 2344 3464 1601 3735 2594 2955 2422 2327 ...

output:

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

result:

ok 600000 numbers

Subtask #10:

score: 8
Accepted

Test #25:

score: 8
Accepted
time: 820ms
memory: 96780kb

input:

300000 300000 5
629 447 2259 86 1828 1091 1344 2291 159549 1641 2079 227 2606 82 1557 1459 159826 2194 746 2599 1979 2439 2669 2199 2623 969 902 158016 275 1552 1174 1841 831 2127 267 159933 1340 159184 1389 172 2330 563 1986 1265 1199 1747 158872 1355 94 1915 2407 1771 151 796 1083 1624 2023 2189 4...

output:

5635
6408
6420
59
5606
1971
5869
6120
2701
3851
4341
4652
5350
5995
4514
5829
5097
3907
4409
5517
5609
1153
3429
5038
6505
4737
5241
5517
5577
5045
6263
1099
5688
6439
6263
5294
2144
3760
5934
6581
509
5478
6276
4914
4173
1790
3911
6528
5967
6314
6612
4917
4383
5751
6014
6599
4305
6894
1712
4800
579...

result:

ok 300000 numbers

Test #26:

score: 0
Accepted
time: 830ms
memory: 99196kb

input:

300000 300000 12
161 248 932 984 1509 2098 1935 1374 118418 1136 1610 1056 997 1357 1879 953 1500 932 1685 2165 120655 118195 183 75 1935 1645 237 681 415 814 1155 1976 120 1032 1004 1817 1105 837 2192 525 119315 178 1397 1816 1581 119138 120709 826 1999 268 922 1354 1335 1907 101 119483 116 2174 91...

output:

1302
1402
50
1437
162
754
1513
479
981
647
792
598
1209
1049
50
1412
849
132
1029
294
804
1520
1155
1029
151
1339
924
1630
1362
1714
901
973
304
663
1473
632
1217
1221
1382
1329
278
123
1288
488
1213
1294
1330
536
909
992
1166
871
702
701
713
665
621
1264
1033
507
254
1008
1216
1498
887
1223
1190
26...

result:

ok 300000 numbers

Test #27:

score: 0
Accepted
time: 1113ms
memory: 101224kb

input:

300000 300000 913
39 985 406 634 753 1026 380 1095 36 460 840 725 114 820 83 715 162 271 1087 1021 72 567 622 612 694 306 915 488 69 429 649 782 954 204 1045 560 175 745 1022 621 452 914 507 529 736 1096 592 1038 851 12 393 768 872 665 522 731 381 1085 184 1032 407 328 933 1013 202 312 281 17 841 88...

output:

1
1
39
33
2
13
40
17
2
64
41
2
35
31
39
27
43
5
1
13
31
35
1
30
40
1
2
27
26
5
17
31
31
1
1
41
40
27
31
31
46
1
41
41
2
5
1
31
40
27
17
1
41
1
46
40
17
5
43
1
1
5
1
1
35
31
31
17
1
46
31
6
42
6
1
27
41
41
2
6
40
1
34
39
34
41
64
1
40
1
35
1
27
35
27
31
1
1
40
1
21
40
31
1
30
17
31
1
35
21
2
40
41
39...

result:

ok 300000 numbers

Subtask #11:

score: 4
Accepted

Test #28:

score: 4
Accepted
time: 1023ms
memory: 123092kb

input:

300000 300000 5
258453 2 159342 6 4 5 17931 8 9 161038 11 14 15 16 136403 13 224782 21 22 118484 19 25 23 215708 28 2995 29 27 49288 32 33 30 224227 234280 37 35 39 128732 66005 40 110386 44 48020 43 45 50 51 47 48 223892 55 52 53 35958 250021 58 108355 60 57 240112 51602 62 66 292618 65 236914 69 7...

output:

14320
4150
13774
14884
14577
1969
12529
12799
7247
2639
10663
14120
11225
14801
8687
1215
13398
3028
15017
14709
5840
3816
11774
14234
12930
11184
12985
11011
10341
11966
8886
13194
14589
12575
14819
14952
10137
4690
14667
7667
12106
1480
4288
11431
6861
15052
12932
13603
4072
14767
1653
14253
6759
...

result:

ok 300000 numbers

Test #29:

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

input:

300000 300000 14
9 10 5 8 3 6 11 7 4 295545 15 132914 13 14 17 12 143751 18 23 29 21 28 27 187583 20 26 25 31 22 24 30 36 37 38 39 552 33 34 41 47 40 46 43 296950 49 48 45 42 276580 55 57 51 53 62 52 54 60 50 59 58 61 47115 67 69 65 37906 64 68 81 78 73 157912 71 76 79 72 82 80 70 74 77 92 86 87 94 ...

output:

4772
4685
3029
43
5154
5071
3435
3269
4867
5053
5201
2618
3259
2418
3998
3693
1188
3975
4981
4872
2710
3266
1019
4268
5227
563
4429
2336
4238
1708
2223
5192
4904
3791
5143
5157
5089
4142
4643
3013
1967
5069
1309
442
4447
4370
2363
4854
4822
4339
4945
5222
1593
4806
3947
2617
4104
4739
1633
426
4521
...

result:

ok 300000 numbers

Test #30:

score: 0
Accepted
time: 889ms
memory: 127516kb

input:

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

output:

954
5
956
959
962
801
952
949
843
969
559
961
167
362
862
531
526
930
537
691
394
956
303
766
882
241
522
265
284
195
239
855
928
885
808
240
347
283
972
196
41
899
133
78
107
96
524
39
962
757
936
233
887
836
553
508
945
874
741
826
104
545
911
231
504
952
957
117
848
909
173
771
658
734
270
856
87...

result:

ok 300000 numbers

Test #31:

score: 0
Accepted
time: 925ms
memory: 128048kb

input:

300000 300000 246
57 140868 19 42 32 34 9 58 47 5 11 28 59 16 18 60 31 56 24 72 20 43 71 6 17 8 15 44 53 21 14 51 13 27 49 45 3 64 68 10 61 4 50 73 69 25 74 52 66 29 46 41 63 22 55 12 7 70 62 67 65 2 38 35 48 23 36 33 39 40 30 54 26 170 115 85 138 161 102 80 182 143 88 171 173 267 124 241 279 92 218...

output:

292
239
54
290
108
201
245
283
9
248
13
249
142
260
74
295
247
253
186
121
6
2
41
198
275
67
21
253
6
277
242
257
187
88
281
122
40
207
198
56
56
209
18
282
107
248
172
272
293
258
283
119
234
241
47
272
16
138
230
200
286
257
267
92
50
174
157
149
294
230
242
285
150
49
8
125
287
252
131
303
196
30...

result:

ok 300000 numbers

Test #32:

score: 0
Accepted
time: 1102ms
memory: 128264kb

input:

300000 300000 5189
1543 1762 4137 149 837 3686 3560 4947 1374 2059 3475 2996 519 4309 295 350 552 4216 299 2078 1776 5033 1463 3160 601 1552 4528 1591 1076 1489 5080 117 3805 1514 467 4282 4676 1010 2269 4480 4921 3544 3988 222 3017 2363 4492 720 1408 5075 4674 255 1353 1598 628 3956 4915 4671 4396 ...

output:

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

result:

ok 300000 numbers

Subtask #12:

score: 8
Accepted

Dependency #8:

100%
Accepted

Test #33:

score: 8
Accepted
time: 219ms
memory: 65160kb

input:

100000 200000 2
9 8 7 7 14 95519 95518 95518 23 23 25 16 95520 25 95520 18 95517 18 24171 14 9 95519 8 95517 717 2416 3320 3271 2217 2034 3573 2197 73 1695 3185 2521 2049 3247 802 470 2335 3259 1627 3188 585 731 1699 1238 662 3264 62279 1075 1664 128 3423 724 2378 3279 1863 2369 3183 1713 1023 3562 ...

output:

11691
5679
17564
8045
16858
13929
4012
3605
15055
3590
13753
14754
20784
6850
4359
6640
15561
16897
12208
19640
15772
2734
19046
8135
15724
19225
20126
3209
18438
19172
8212
18179
4535
10158
6197
4773
17167
15600
8334
10816
19745
14144
2834
17878
5347
19026
19300
5140
1527
10885
7656
5766
13005
1261...

result:

ok 200000 numbers

Test #34:

score: 0
Accepted
time: 255ms
memory: 66144kb

input:

100000 200000 6
51 91345 38 50 91263 76 81 91267 42 76 74 61 117 54 109 91291 91248 59 50 98 58 91245 91335 75 81 91328 102 27 91326 59 72 76 98 47 70 91325 91305 91279 91273 3 91311 97 106 85 91273 91308 85 91341 91342 91290 107 81 91321 91333 91350 68 91252 91251 91313 91291 101 49 59 82 71 9 9133...

output:

1070
439
723
599
559
730
1030
1482
1012
1059
805
1763
1079
1271
866
1765
1764
1292
1397
1400
1104
883
457
1686
606
1208
947
514
1687
723
306
444
811
251
1364
683
1066
1076
1099
1062
598
1038
1067
1208
1034
762
940
374
214
63
724
1465
1683
687
1136
1689
1239
1116
1019
1759
1894
610
1449
759
799
416
8...

result:

ok 200000 numbers

Test #35:

score: 0
Accepted
time: 268ms
memory: 73644kb

input:

100000 200000 21
38 821 256 2166 1759 611 1227 2761 1837 2741 902 2172 2428 2246 2080 686 2576 2414 1026 1366 2163 1490 2734 2120 40083 2813 765 40304 931 1514 2170 26 1305 381 1635 2992 693 3112 1016 2648 2016 1008 2437 2114 1739 39718 972 699 40248 2402 2050 1841 1782 2327 298 40166 2057 40588 162...

output:

273
294
225
284
397
62
253
275
292
285
341
350
195
183
392
84
235
301
229
328
134
318
261
182
237
79
305
152
298
216
210
256
392
251
246
189
118
328
189
239
79
325
233
155
390
284
245
83
38
252
243
279
112
75
312
57
152
292
412
228
267
314
303
196
229
336
181
138
271
103
281
322
288
294
397
344
75
1...

result:

ok 200000 numbers

Test #36:

score: 0
Accepted
time: 295ms
memory: 75728kb

input:

100000 200000 213
1159 1216 876 1075 1420 2048 831 1776 1282 150 562 1933 1182 17119 1627 826 748 1242 1814 1390 2040 1801 1018 1769 16206 96 642 1915 1772 776 900 234 10 348 1082 1030 1005 2002 1853 1389 369 1162 1561 1713 1967 2000 1490 412 761 1036 123 161 427 1418 75 709 1502 1664 411 686 1480 2...

output:

8
42
37
48
39
20
30
39
66
57
31
45
9
57
23
22
47
26
44
37
53
33
30
13
51
46
41
14
61
54
45
45
44
14
46
60
43
42
31
14
52
18
28
14
42
25
21
35
41
51
42
38
36
28
29
52
50
20
63
12
24
49
56
46
24
29
42
24
43
46
29
22
55
36
42
52
50
23
38
51
31
46
28
48
27
14
31
60
41
5
23
50
47
36
34
11
17
49
42
57
26
...

result:

ok 200000 numbers

Subtask #13:

score: 8
Accepted

Dependency #12:

100%
Accepted

Test #37:

score: 8
Accepted
time: 446ms
memory: 83208kb

input:

200000 400000 2
199739 199741 199744 199742 199742 199741 199739 199744 507 137654 137562 137624 1547 2628 2639 137604 572 2330 973 216 353 1924 1007 137625 2923 254 2061 689 137670 1241 925 765 137860 2613 138 1042 1850 137896 796 2907 1128 659 138009 1417 2204 511 418 137608 157898 137649 603 1223...

output:

31016
4487
6621
12637
32791
28499
19990
38914
2238
16303
37074
6172
9856
39049
1350
33325
6997
39112
21189
37628
6462
24859
793
2168
6564
18381
14277
2191
22743
14910
7663
21739
38810
38148
32615
36758
9929
6320
33110
4216
38692
24437
15391
23948
31216
2771
31903
35959
18895
15963
10783
37943
5441
1...

result:

ok 400000 numbers

Test #38:

score: 0
Accepted
time: 546ms
memory: 87228kb

input:

200000 400000 6
55999 537 56078 368 7 465 171 514 35 391 430 180 391 480 407 379 171 359 437 221 138 461 199 153 194 252 213 33 88 135 98 81 2 31 56211 348 305 392 81 392 257 276 512 529 56 74 549 236 149 529 454 424 329 544 325 231 534 62 10 233 167 254 219 411 174 508 56238 120 155 56528 142 56225...

output:

2537
1878
2765
2542
3267
2890
3187
1084
3524
966
3057
1780
2985
1873
2992
3306
3154
3236
2465
3474
3049
1790
1085
2636
2496
3544
3385
1948
3170
3243
1029
1691
2357
2546
1808
3268
2118
3514
2349
3506
3176
1628
3372
2186
3191
1153
2634
2735
2483
1594
3681
3365
2917
1104
1998
3484
2481
2971
2162
3226
2...

result:

ok 400000 numbers

Test #39:

score: 0
Accepted
time: 572ms
memory: 90956kb

input:

200000 400000 21
7982 449 499 3066 2718 458 3293 7498 4024 339 5055 8275 3687 2643 436 4597 6605 7291 1149 2925 4378 529 6834 1470 6939 7005 472 7714 7583 308 4438 7413 7343 1743 3021 8415 4859 7781 1302 4881 790 6406 7959 1158 5385 5092 2060 8246 4278 4544 5178 2580 7306 4457 5153 4284 437 5198 758...

output:

782
486
764
273
625
814
850
312
986
689
502
718
380
98
905
718
327
655
97
79
388
786
829
603
715
188
376
442
613
619
548
467
593
655
695
336
794
884
465
620
451
757
432
111
320
467
343
383
510
557
101
563
320
638
441
665
376
657
493
681
478
547
473
128
235
502
442
271
431
274
128
196
804
537
956
757...

result:

ok 400000 numbers

Test #40:

score: 0
Accepted
time: 634ms
memory: 94172kb

input:

200000 400000 213
780 401 942 1329 1289 566 1010 206 1115 1140 529 945 163 1086 649 282 420 1192 1091 113 233 474 915 132 480 582 880 15 925 1332 584 749 27 516 1363 142 271 704 1280 348 508 1439 1341 1184 120 466 6459 1458 1502 1101 931 124 1112 860 1462 312 781 1190 1321 23 590 138 998 281 812 56 ...

output:

69
94
52
120
76
98
105
49
95
102
108
29
78
41
88
91
80
65
37
65
108
52
50
97
78
77
118
33
119
99
90
114
76
72
74
102
112
112
60
40
21
118
67
38
110
52
67
21
93
108
15
98
18
90
94
100
105
111
86
80
116
67
37
82
18
106
54
119
96
40
90
112
66
103
60
7
110
30
95
16
22
81
95
123
114
112
72
86
65
101
93
9...

result:

ok 400000 numbers

Subtask #14:

score: 8
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

100%
Accepted

Dependency #6:

100%
Accepted

Dependency #7:

100%
Accepted

Dependency #8:

100%
Accepted

Dependency #9:

100%
Accepted

Dependency #10:

100%
Accepted

Dependency #11:

100%
Accepted

Dependency #12:

100%
Accepted

Dependency #13:

100%
Accepted

Test #41:

score: 8
Accepted
time: 722ms
memory: 97484kb

input:

300000 600000 2
367 299776 285 299639 299594 299538 299665 147 299753 2901 2874 288708 299556 2568 2664 299718 2432 299681 1448 1324 299633 734 2798 299735 97 2665 1454 530 2951 115 299776 2192 160 299447 299497 2786 299751 399 1450 2110 299421 299673 1059 1445 2159 299675 1142 299747 511 2053 2927 ...

output:

19636
15738
12310
61485
65469
55165
18579
23608
42012
18491
43781
26512
30522
19623
50864
38617
2107
5989
30129
16056
16508
19602
4421
22181
19704
33675
2108
2062
57651
34808
40290
53833
19242
34608
2165
48688
14099
55940
45916
2096
40109
7069
2101
9804
51721
64860
1562
61461
10212
56998
43729
26398...

result:

ok 600000 numbers

Test #42:

score: 0
Accepted
time: 879ms
memory: 102604kb

input:

300000 600000 6
19 385 231 219 168 332 161 56 48 89 332 220 326 351 203444 203438 172 203230 297 388 189 19 236 38 398 6 259 388 360 228 314 391 250 122 138 315 203235 174 24 71 203308 4 45 15 11 133 159 170 198 368 290 17 147 285 369 98 40 66 354 12 406 93 87 403 44 60 383 322 292 124 165 367 25 90...

output:

4885
2015
3162
2981
2814
1563
2857
2335
2981
4331
3991
4105
3323
3364
3171
5061
2022
2101
4471
2492
5815
2477
4612
1624
5030
957
4272
3960
2129
5440
4593
4061
2630
3622
2714
2997
790
2901
3464
4248
4960
2078
5012
5370
5009
1176
2958
3068
4591
762
2698
4101
2867
1134
4582
5992
4596
2687
4122
2007
221...

result:

ok 600000 numbers

Test #43:

score: 0
Accepted
time: 906ms
memory: 104852kb

input:

300000 600000 21
60 188 124 161 160 140 3 181 23 20 167 179 151 136 110 80 2 73 131 182 119 102 299966 66 112 178 75 105 13 21 299990 299976 70 15 46 84 183 109 4 123 19 51 183 159 133 141 129 73 157 120 54 47 33 44 164 123 148 53 132 190 30 28 157 30 70 140 91 6 168 123 124 155 7 154 132 128 117 18...

output:

940
706
626
212
691
386
1012
774
913
865
851
341
878
1076
1007
866
655
761
223
837
938
911
217
932
867
214
899
705
592
918
1012
398
396
636
939
680
404
929
979
910
1005
843
939
908
732
933
452
82
1194
705
972
51
1156
297
800
627
360
590
916
584
477
873
596
906
684
888
1007
393
869
221
884
381
892
35...

result:

ok 600000 numbers

Test #44:

score: 0
Accepted
time: 1046ms
memory: 108292kb

input:

300000 600000 213
645 67 556 372 522 391 863 911 177 195 191 779 2 483 114 301 888 583 922 98 704 20 486 227 529 341 525 363 938 391 560 830 253 417 15 93 600 786 26 713 566 356 599 266 347 706 134 693 29 300 13 436 906 794 106 531 200 687 930 960 284 101441 454 21 817 219 425 100407 740 702 961 12 ...

output:

136
85
173
124
108
147
101
147
126
173
119
150
143
82
74
22
176
174
148
90
39
165
147
144
86
75
68
173
85
107
133
98
33
85
139
131
125
138
27
174
25
141
71
145
136
154
126
120
127
166
142
102
108
116
125
69
176
44
107
154
78
101
118
25
174
153
89
119
170
130
134
160
106
31
79
16
128
83
140
124
71
96...

result:

ok 600000 numbers

Test #45:

score: 0
Accepted
time: 715ms
memory: 98588kb

input:

300000 600000 2
167540 183756 260391 180393 253969 191302 198142 235959 247443 202698 206574 152266 192076 255511 156657 234350 173854 150857 186900 228773 225331 248823 214568 247857 220761 266283 167331 182795 164534 173760 242859 185660 249917 180106 202034 242089 226454 254782 194214 212461 2493...

output:

25817
18175
20047
38706
54915
26331
30437
18453
5115
4841
6293
59321
18396
6810
40581
32559
25258
18945
36317
21490
10041
47294
43119
24885
18375
43330
3290
18777
49909
55571
56966
68723
14062
37591
40968
23779
1538
67195
69736
31450
53919
39104
29620
18419
19434
28226
51753
19117
56854
24029
28058
...

result:

ok 600000 numbers

Test #46:

score: 0
Accepted
time: 868ms
memory: 102600kb

input:

300000 600000 6
5195 2094 3304 3062 192714 4329 5629 5770 6417 7496 1103 8793 193280 4628 3580 188333 190693 185663 190562 193400 1300 4401 908 5902 6971 8535 8179 5800 1434 7553 184892 2929 4308 4567 550 5851 5848 9397 185087 181304 7438 182428 181336 1958 1830 1543 5769 9099 2480 4797 8395 8004 52...

output:

5261
4236
6157
2215
3561
5239
5131
5876
6065
3177
5384
3863
856
4613
5054
4447
4452
3520
2463
5924
1610
3805
6013
3048
2698
4821
5293
5351
3997
2427
2809
3522
1708
5733
5599
2171
3704
2645
5612
6214
4220
5018
6096
3219
1580
4295
1540
688
1736
636
4077
3052
4322
6391
4482
5983
4186
3669
4456
1818
130...

result:

ok 600000 numbers

Test #47:

score: 0
Accepted
time: 920ms
memory: 104880kb

input:

300000 600000 21
440 5371 2775 5789 6080 6338 5630 413 742 4139 181 3609 7266 4458 202 248262 120 6419 248133 3139 7217 6027 717 3791 4110 403 2983 2930 5812 513 488 4195 6156 4288 2372 248058 1393 3412 948 1910 6635 7707 6687 5095 306 7301 5910 3245 3253 1079 3107 7031 6009 6588 6419 248132 1928 21...

output:

936
567
993
837
771
819
643
586
615
735
1118
189
876
611
754
758
220
770
250
370
257
1127
162
756
405
548
874
547
942
408
1011
978
891
1125
807
1008
766
593
314
798
537
658
758
833
735
397
535
1130
555
488
505
598
130
510
940
676
707
923
955
1053
338
1169
897
380
358
532
972
807
806
291
544
535
534
...

result:

ok 600000 numbers

Test #48:

score: 0
Accepted
time: 1064ms
memory: 108288kb

input:

300000 600000 213
1960 789 738 1351 646 838 11 1803 822 652 548 100 182 95 1159 1988 530 1797 1160 1224 1579 747 66 944 1530 866 989 1190 267 1010 2038 1207 625 1420 316 1146 290 750 210 1635 1630 1578 181 328 1076 1753 1857 6 213 767 280 1816 526 554 1125 1275 1056 680 215 736 1970 1792 266 1837 15...

output:

139
123
49
88
16
173
111
89
47
127
110
90
150
139
154
88
77
115
156
152
137
158
183
161
41
87
162
64
101
140
129
26
149
143
136
74
34
87
173
178
138
128
137
151
183
40
177
127
156
171
172
164
60
113
169
119
153
12
157
135
137
125
22
156
96
129
153
131
166
55
173
126
132
87
156
124
41
203
115
150
141...

result:

ok 600000 numbers