QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#103317#365. Railway TripDaiRuiChen007100 ✓178ms20100kbC++171.1kb2023-05-05 08:23:282023-05-05 08:23:30

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-05 08:23:30]
  • 评测
  • 测评结果:100
  • 用时:178ms
  • 内存:20100kb
  • [2023-05-05 08:23:28]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e5+1;
int a[MAXN],stk[MAXN],top,L[MAXN][20],R[MAXN][20];
signed main() {
	int n,k,q;
	scanf("%d%d%d",&n,&k,&q);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	top=0;
	for(int i=1;i<=n;++i) {
		while(top&&a[stk[top]]<a[i]) --top;
		L[i][0]=top?stk[top]:i,stk[++top]=i;
	}
	top=0;
	for(int i=n;i>=1;--i) {
		while(top&&a[stk[top]]<a[i]) --top;
		R[i][0]=top?stk[top]:i,stk[++top]=i;
	}
	for(int k=1;k<20;++k) {
		for(int i=1;i<=n;++i) {
			L[i][k]=min(L[L[i][k-1]][k-1],L[R[i][k-1]][k-1]);
			R[i][k]=max(R[L[i][k-1]][k-1],R[R[i][k-1]][k-1]);
		}
	}
	while(q--) {
		int u,v;
		scanf("%d%d",&u,&v);
		if(u>v) swap(u,v);
		int l=u,r=u,ans=0;
		for(int k=19;k>=0;--k) {
			if(max(R[l][k],R[r][k])<v) {
				ans+=1<<k;
				int a=l,b=r;
				l=min(L[a][k],L[b][k]),r=max(R[a][k],R[b][k]);
			}
		}
		u=r,l=v,r=v;
		for(int k=19;k>=0;--k) {
			if(min(L[l][k],L[r][k])>u) {
				ans+=1<<k;
				int a=l,b=r;
				l=min(L[a][k],L[b][k]),r=max(R[a][k],R[b][k]);
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

詳細信息

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 2ms
memory: 3568kb

input:

100 100 50
100
86
39
28
49
22
79
14
83
100
15
26
37
51
53
18
74
15
96
72
47
80
10
46
62
88
20
36
46
29
40
28
37
88
91
41
24
63
14
92
24
31
99
61
62
96
94
51
51
21
72
97
59
96
97
94
66
88
32
96
58
26
53
1
100
31
85
30
42
69
40
62
54
94
49
62
13
20
82
74
20
44
54
69
65
34
78
64
48
69
19
35
8
92
100
87...

output:

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

result:

ok 50 lines

Test #2:

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

input:

100 100 50
100
85
82
7
50
49
51
45
30
3
29
99
71
93
5
68
70
52
12
44
1
35
99
80
76
34
23
28
62
91
80
77
59
57
30
15
23
13
16
21
58
23
38
49
44
73
7
47
24
53
97
83
14
71
16
75
61
24
17
96
51
41
74
53
25
2
42
36
73
57
53
45
10
12
11
79
68
2
78
44
47
67
21
99
25
68
60
71
23
92
9
2
97
37
43
64
32
28
7
1...

output:

2
0
5
4
2
4
2
4
3
5
4
3
3
6
4
4
3
3
3
4
2
3
3
3
4
5
5
2
3
3
5
4
3
4
2
2
3
5
3
6
2
5
4
2
2
4
4
3
4
7

result:

ok 50 lines

Test #3:

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

input:

100 100 50
100
56
83
81
2
73
24
77
19
11
79
100
36
32
62
4
41
50
51
62
68
6
11
36
28
21
61
82
72
86
35
93
94
87
50
14
77
83
14
49
95
32
5
20
59
55
77
31
52
70
23
81
4
10
34
100
4
67
60
1
23
26
65
1
30
96
43
49
70
81
18
82
97
80
62
28
93
38
91
39
67
6
17
78
60
60
55
97
45
58
44
80
24
91
14
5
35
93
25...

output:

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

result:

ok 50 lines

Test #4:

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

input:

100 100 50
100
50
72
67
84
3
28
84
40
70
52
28
37
16
66
92
47
27
30
49
33
7
69
22
33
85
1
98
4
97
89
27
99
21
33
76
89
26
74
10
80
23
70
10
63
1
78
38
28
30
95
11
17
99
10
52
5
30
38
95
4
71
50
2
40
28
17
21
10
13
23
98
92
84
8
3
37
38
71
78
57
87
22
79
59
26
13
50
33
87
9
6
78
85
19
68
79
9
62
100
...

output:

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

result:

ok 50 lines

Test #5:

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

input:

100 100 50
100
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
100
91 65
31 33
13 98
45 91
54 50
94 66
78 5
28 13
100 4
15 63
55 2
72 49
97 18
57 59
40 ...

output:

25
1
14
45
3
27
26
14
3
47
46
22
20
1
6
1
22
27
15
39
25
36
35
24
14
12
35
32
48
5
9
2
26
4
27
17
36
35
10
15
38
7
16
2
48
3
31
32
48
6

result:

ok 50 lines

Test #6:

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

input:

100 100 50
100
99
99
99
97
97
97
95
95
95
93
93
93
91
91
91
89
89
89
87
87
87
85
85
85
83
83
83
81
81
81
79
79
79
77
77
77
75
75
75
73
73
73
71
71
71
69
69
69
67
67
67
68
68
70
70
70
72
72
72
74
74
74
76
76
76
78
78
78
80
80
80
82
82
82
84
84
84
86
86
86
88
88
88
90
90
90
92
92
92
94
94
94
96
96
96
...

output:

9
6
23
6
1
21
5
18
5
15
2
3
16
3
15
26
2
3
12
1
1
0
20
27
26
3
3
3
30
22
30
1
1
0
26
11
13
13
16
21
2
12
7
22
7
13
2
9
8
15

result:

ok 50 lines

Test #7:

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

input:

100 100 50
100
99
99
99
97
97
97
95
95
95
93
93
93
91
91
91
89
89
89
87
87
87
85
85
85
83
83
83
81
81
81
79
79
79
77
77
77
75
75
75
73
73
73
71
71
71
69
69
69
67
67
67
68
68
70
70
70
72
72
72
74
74
74
76
76
76
78
78
78
80
80
80
82
82
82
84
84
84
86
86
86
88
88
88
90
90
90
92
92
92
94
94
94
96
96
96
...

output:

9
20
22
8
30
3
22
11
2
8
10
5
1
26
10
20
19
21
1
6
17
2
6
9
13
9
20
25
24
1
25
19
4
14
15
23
10
19
19
3
2
3
9
24
9
10
17
10
7
14

result:

ok 50 lines

Test #8:

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

input:

100 30 50
30
29
29
29
27
27
27
25
25
25
23
23
23
21
21
21
19
19
19
17
17
17
15
15
15
13
13
13
11
11
11
9
9
9
7
7
7
5
5
5
3
3
3
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
4
4
4
6
6
6
8
8
8
10
10
10
12
12
12
14
14
14
16
16
16
18
18
18
20
20
20
22
22
22
24
24
24
26
26
26
28
28
28
30
29 60
12 67
26 10
71 29
70 5...

output:

9
15
10
3
14
21
20
17
4
8
18
0
2
6
16
3
11
12
7
14
2
8
17
3
13
7
3
3
7
21
6
6
10
2
9
11
5
0
18
9
20
14
2
2
7
26
3
3
9
13

result:

ok 50 lines

Test #9:

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

input:

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

output:

0
2
0
1
1
1
0
1
1
2
1
2
1
1
1
2
2
1
1
1
1
1
1
0
1
2
1
1
1
1
1
2
0
1
2
0
1
0
1
0
1
1
1
1
0
0
1
0
0
1

result:

ok 50 lines

Subtask #2:

score: 15
Accepted

Dependency #1:

100%
Accepted

Test #10:

score: 15
Accepted
time: 2ms
memory: 3928kb

input:

1000 1000 50
1000
922
228
50
969
778
800
874
487
278
681
989
234
951
889
87
926
534
311
876
955
989
810
841
423
580
204
360
127
808
441
249
754
777
831
192
797
272
163
832
471
669
837
129
774
425
435
315
515
626
725
883
415
932
9
891
34
146
288
321
980
972
776
449
458
188
75
412
81
523
705
137
564
7...

output:

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

result:

ok 50 lines

Test #11:

score: 0
Accepted
time: 27ms
memory: 19644kb

input:

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

output:

1359
1428
6356
1112
1488
1359
2215
713
4226
3135
1169
3371
2015
4999
274
3670
6146
666
1474
7777
4789
3933
3816
6070
4619
3537
9444
303
305
4196
5588
2949
2371
2426
4223
6478
5818
2204
4708
3962
4045
5028
576
7645
21
6384
1164
2279
1975
2912

result:

ok 50 lines

Test #12:

score: 0
Accepted
time: 23ms
memory: 19580kb

input:

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

output:

1266
721
574
2414
1804
2566
3123
2680
421
2509
2114
741
4862
144
321
2708
673
797
1103
8
474
754
798
3825
2887
3700
92
1263
836
162
889
410
1494
386
607
47
930
2160
2285
1414
1946
2546
217
2180
1348
1509
1934
1281
1155
269

result:

ok 50 lines

Test #13:

score: 0
Accepted
time: 24ms
memory: 19628kb

input:

100000 50 50
50
11
46
27
40
21
34
12
28
6
1
31
6
48
35
29
37
28
16
47
47
25
37
7
38
35
33
12
14
16
28
40
48
38
36
41
26
23
13
5
45
22
29
40
28
38
6
2
27
10
46
20
19
47
42
38
23
26
50
22
17
19
28
15
21
41
26
44
37
41
34
28
6
45
50
1
4
29
1
20
12
3
47
5
30
27
31
27
14
14
19
11
26
36
22
40
39
3
35
48
1...

output:

418
263
271
1079
65
35
1084
1365
1821
816
913
0
1716
948
1815
268
657
727
388
140
1122
1417
434
304
591
1462
534
26
6
1319
1013
653
51
403
1123
337
1298
681
291
922
1429
136
1267
404
172
639
1098
126
365
589

result:

ok 50 lines

Test #14:

score: 0
Accepted
time: 24ms
memory: 19564kb

input:

100000 100 50
100
56
93
96
24
53
1
36
62
6
78
9
80
45
58
9
73
66
88
84
70
23
72
45
51
30
39
34
58
29
58
86
42
60
22
85
31
5
97
84
43
29
9
39
59
99
22
19
64
37
73
38
3
56
100
7
70
7
63
85
3
37
89
3
37
86
15
38
77
8
69
93
84
88
6
42
2
97
83
52
50
30
87
100
6
35
6
57
29
85
43
5
44
53
70
70
37
28
1
79
5...

output:

75
421
426
64
188
480
375
230
205
110
514
521
202
438
41
90
550
600
278
41
555
306
227
374
314
251
329
106
349
326
237
168
85
733
493
732
287
292
420
48
82
185
268
586
138
18
58
563
132
880

result:

ok 50 lines

Test #15:

score: 0
Accepted
time: 25ms
memory: 19592kb

input:

100000 1000 50
1000
344
191
778
485
819
164
138
378
874
442
986
928
4
40
283
48
414
694
741
809
739
868
462
128
210
421
486
411
962
568
354
717
373
451
749
487
579
555
274
770
315
57
683
726
11
736
143
664
294
315
983
546
685
879
613
938
593
129
670
460
68
262
667
670
970
750
621
245
664
849
897
921...

output:

26
39
13
25
20
12
45
49
23
14
14
17
35
45
27
61
33
64
17
26
46
19
16
53
56
28
66
44
13
27
69
82
49
39
16
67
18
28
20
23
27
21
31
48
33
44
19
57
57
84

result:

ok 50 lines

Test #16:

score: 0
Accepted
time: 31ms
memory: 19532kb

input:

100000 100000 50
100000
56580
49884
11827
17239
65717
9804
79174
23154
24944
14239
25479
99414
34931
73537
80958
49760
64994
26812
21303
26338
69277
40768
58666
18101
14466
43220
86838
28869
93571
6030
83932
63479
7787
90481
41114
83812
43297
333
42187
89338
74969
29378
9198
54116
92280
44472
67702
...

output:

11
18
14
11
8
12
13
10
14
12
14
10
9
17
6
7
15
7
10
11
7
17
13
18
11
12
14
10
14
12
11
10
17
17
15
11
12
15
13
12
13
14
13
20
13
12
8
19
21
15

result:

ok 50 lines

Test #17:

score: 0
Accepted
time: 34ms
memory: 19916kb

input:

100000 98765 50
98765
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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:

8543
47309
23958
26174
49100
4352
16877
15157
4073
4915
27708
29524
37655
35894
27397
39765
13061
47027
34482
47152
22163
8303
34266
7734
48073
28964
44848
9697
33881
34902
49642
16645
37421
12636
45492
18481
10058
26951
24249
4493
16977
32341
34921
27407
6885
29650
38665
26423
20992
4006

result:

ok 50 lines

Test #18:

score: 0
Accepted
time: 39ms
memory: 19792kb

input:

100000 100000 50
100000
99999
99999
99999
99997
99997
99997
99995
99995
99995
99993
99993
99993
99991
99991
99991
99989
99989
99989
99987
99987
99987
99985
99985
99985
99983
99983
99983
99981
99981
99981
99979
99979
99979
99977
99977
99977
99975
99975
99975
99973
99973
99973
99971
99971
99971
99969
...

output:

8011
17947
19968
6041
2560
5984
12778
5061
6067
875
33330
1137
28701
506
9660
9077
4698
29794
3944
15977
624
15732
29615
569
12988
10918
6867
22754
9635
15808
8037
12778
28287
5842
16734
11588
22433
8009
25516
266
2178
10474
8818
19731
5938
5977
17163
13752
14967
22906

result:

ok 50 lines

Test #19:

score: 0
Accepted
time: 29ms
memory: 19888kb

input:

99987 20000 50
20000
19999
19999
19999
19997
19997
19997
19995
19995
19995
19993
19993
19993
19991
19991
19991
19989
19989
19989
19987
19987
19987
19985
19985
19985
19983
19983
19983
19981
19981
19981
19979
19979
19979
19977
19977
19977
19975
19975
19975
19973
19973
19973
19971
19971
19971
19969
199...

output:

4252
10848
8908
12418
11319
14639
23531
32898
33082
19996
4328
29974
15741
7631
15055
27561
33768
10747
8569
12964
26763
11238
1568
12149
16704
9780
853
117
12290
7524
16324
7480
9529
2496
6232
16327
18091
16754
16387
2168
29018
3881
4970
13707
3938
25233
4644
1343
5144
8130

result:

ok 50 lines

Test #20:

score: 0
Accepted
time: 23ms
memory: 19780kb

input:

100000 100000 50
100000
99999
99999
99999
99999
74745
62562
99999
98122
99999
99999
56828
99997
58955
99997
54699
67218
99997
50790
99997
58134
99995
99995
99995
99995
99995
99995
99995
55529
99993
99993
99993
99993
99993
99993
99991
99991
99991
99989
90797
99989
99989
99989
99989
99989
86368
99989
...

output:

6420
3248
359
6904
464
499
2049
2980
7120
6633
7065
7436
1723
1694
8588
11366
2553
4371
4307
1923
2788
47
3379
7678
10918
2206
10990
5473
9297
6117
13683
2404
3665
9394
4125
6942
10577
894
3737
476
9154
64
4418
7686
9593
14621
10711
673
6886
270

result:

ok 50 lines

Test #21:

score: 0
Accepted
time: 29ms
memory: 19756kb

input:

100000 40000 50
40000
39999
39999
37766
39999
39999
39999
39999
39999
39999
39999
39997
36045
25615
39997
39997
39997
39997
39997
39042
29937
39995
39995
39993
39993
39993
39993
39993
39991
39991
39991
39991
39991
39991
39991
39989
39989
39989
39989
39989
39989
39989
30300
39989
24555
39987
39987
39...

output:

286
6753
6738
2684
450
4653
5387
7493
10039
2298
1824
6432
1323
523
2223
9704
4024
679
5343
9918
5841
1311
2024
9345
79
2760
704
5619
4334
2451
8862
5294
3571
6549
5939
9021
8996
2324
5371
1439
13503
3135
3548
5563
1577
4287
3656
1016
7549
3580

result:

ok 50 lines

Test #22:

score: 0
Accepted
time: 25ms
memory: 19872kb

input:

100000 20000 50
20000
19999
19999
11771
15039
19999
15800
13126
19997
19997
14925
19997
19997
19997
19997
15396
19997
19997
19382
19995
19995
19995
19995
19995
19995
17939
19995
19993
19993
19993
19993
19993
15292
19993
19993
16823
19991
15117
15824
19991
19991
19742
12374
19989
19987
19987
19987
19...

output:

10506
9972
7125
12749
3527
3907
9799
3269
9484
4446
6302
686
6645
6572
1234
14344
11329
9423
844
802
4003
10005
6738
1394
811
9437
3159
158
2377
1985
768
13808
2263
7257
1102
12069
6736
2108
13371
244
6867
51
2972
502
788
4258
1730
5267
7201
9111

result:

ok 50 lines

Test #23:

score: 0
Accepted
time: 27ms
memory: 19936kb

input:

100000 100000 50
100000
99999
99999
59766
99999
99999
99999
70484
95515
99999
99997
76492
99997
99997
99997
99995
99995
99995
76093
99995
99995
99995
99995
99993
68766
99993
83484
99991
99991
99991
99991
99991
99989
99989
99989
95161
87092
99987
99987
99987
99985
99985
99985
99983
99983
99983
99983
...

output:

9534
1930
6161
63
1724
6602
738
41
1408
4626
346
6821
8185
2142
4602
7672
9
7478
9590
2859
11237
10321
3463
979
110
7685
11565
5902
1736
9594
6814
617
2656
7156
6637
2297
6397
1400
4732
9567
899
2911
7977
3854
3819
11422
2886
10876
71
2617

result:

ok 50 lines

Test #24:

score: 0
Accepted
time: 34ms
memory: 19724kb

input:

100000 40000 50
40000
27735
39999
39999
39999
30089
39997
27533
39997
39545
39997
39997
24354
39997
39997
27224
39995
39995
39995
39995
39993
39993
39993
39993
34655
25979
39991
39991
39991
39989
32792
39989
36957
39989
39987
39987
26138
39987
29470
39987
33306
39987
34758
39985
39985
39985
39985
39...

output:

2514
7015
10860
5932
13900
2163
1428
2507
10389
2343
4686
7003
3289
8271
1376
4061
809
7390
3003
7079
5581
12266
747
5123
3280
4452
1407
9561
3094
4738
8026
1539
4911
3536
2790
8421
775
3573
10234
2875
5141
9477
1754
9083
10285
10589
2100
10535
1105
3392

result:

ok 50 lines

Test #25:

score: 0
Accepted
time: 29ms
memory: 19780kb

input:

100000 20000 50
20000
11142
19999
19999
19997
19997
19997
17756
19995
19995
19995
12835
18839
10465
19995
13346
19995
19993
19993
19993
19993
19993
19993
15061
13380
19991
16895
19991
15093
12347
19991
19989
19989
19989
19696
19989
19989
19989
19987
19987
19987
14062
19987
19987
19533
19985
18678
19...

output:

5625
7813
1921
1346
5823
2760
481
12722
3312
1069
1873
4450
3293
1785
10
12760
8129
6284
582
213
2417
8790
400
2159
2813
3450
10101
1990
190
1230
5868
4487
9615
1468
4713
9995
11318
6062
4657
2159
10995
3946
3077
11956
10209
7994
2029
11532
6120
6191

result:

ok 50 lines

Test #26:

score: 0
Accepted
time: 25ms
memory: 19592kb

input:

100000 100000 50
100000
99991
99989
99990
99992
99993
99991
99992
99990
99991
99994
99991
99992
99989
99990
99991
99993
99991
99989
99990
99992
99991
99990
99995
99987
99988
99985
99986
99985
99983
99984
99987
99989
99990
99988
99989
99991
99989
99990
99992
99988
99989
99987
99985
99986
99988
99990
...

output:

14
10
12
15
15
11
16
15
13
14
11
15
13
19
14
14
17
14
14
13
11
16
13
13
15
17
13
8
14
15
10
11
14
7
17
12
10
10
4
10
10
11
10
15
10
11
11
12
15
13

result:

ok 50 lines

Test #27:

score: 0
Accepted
time: 22ms
memory: 19792kb

input:

100000 100000 50
100000
99990
99991
99989
99988
99990
99989
99988
99992
99989
99990
99991
99993
99987
99986
99988
99989
99986
99987
99985
99986
99988
99984
99985
99986
99987
99986
99990
99987
99986
99985
99984
99988
99986
99987
99989
99986
99987
99988
99986
99985
99987
99985
99986
99991
99990
99992
...

output:

15
11
19
12
8
13
13
14
17
14
10
14
11
12
11
11
13
12
12
17
11
14
11
15
10
12
12
9
10
6
13
11
7
9
20
12
14
15
14
13
13
10
14
11
14
14
4
13
11
6

result:

ok 50 lines

Test #28:

score: 0
Accepted
time: 22ms
memory: 19592kb

input:

100000 100000 50
100000
2
50010
4
5
6
7
8
9
10
11
3861
13
41123
15
16
17
18
19
20
21
22
23
24
25
26
27
28
3182
30
31
32
33
34
35
36
37
38
94545
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
59849
63
64
87129
66
67
68
52693
5951
71
72
73
74
75
76
77
78
79
80
84907
82
83
84
85
86
8...

output:

11
10
13
9
10
12
12
10
11
10
13
12
12
11
11
14
11
9
10
7
11
11
13
4
9
11
15
6
12
12
9
10
15
9
9
7
12
11
12
11
5
13
12
7
8
10
5
13
13
12

result:

ok 50 lines

Subtask #3:

score: 25
Accepted

Dependency #1:

100%
Accepted

Test #29:

score: 25
Accepted
time: 85ms
memory: 19600kb

input:

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

output:

1523
3536
1392
500
2340
3799
2904
1305
798
2809
4932
4547
1588
5967
1415
3375
1397
148
4560
4615
1360
4354
201
2264
2746
342
1017
4193
4580
41
218
2929
3825
298
3506
792
2629
3260
1577
485
4991
906
1284
782
1568
5972
2103
2405
672
148
3125
145
768
1091
1110
963
876
2521
2573
802
79
4786
851
2633
248...

result:

ok 100000 lines

Test #30:

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

input:

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

output:

5202
7890
500
3331
3860
2993
241
5842
3343
6693
7658
851
1307
6437
504
3219
1147
647
445
5998
5688
367
1119
1629
5556
3779
968
816
1652
5394
3521
2127
69
1108
3342
7869
1661
1868
5933
1024
2372
84
2816
115
6718
608
4730
674
338
4692
3685
7
1935
959
5213
1771
1243
6773
2623
127
5873
2244
8528
492
435...

result:

ok 100000 lines

Test #31:

score: 0
Accepted
time: 87ms
memory: 19796kb

input:

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

output:

980
1118
3019
1916
470
1698
1307
1859
3499
42
808
4840
2720
1202
1092
2835
3441
3427
5645
2789
272
2239
717
1040
902
25
462
3737
1047
3614
3966
4478
21
3859
2076
2848
422
1839
288
538
3564
1111
3681
2078
3770
4146
1641
1952
949
1157
2357
1344
434
1789
2308
1389
943
267
5130
640
4279
1873
127
516
370...

result:

ok 100000 lines

Test #32:

score: 0
Accepted
time: 95ms
memory: 19744kb

input:

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

output:

1617
499
332
771
2995
1684
1150
612
839
2047
3648
4615
2909
96
2760
383
258
1982
3173
3980
2092
278
2547
2883
742
3782
2116
252
2483
2823
551
39
5373
305
1667
5658
639
366
3739
535
582
1360
2128
2137
1221
2163
179
1363
2710
395
3251
1162
1462
300
3507
988
2199
4579
174
3296
2537
368
2388
1323
3330
2...

result:

ok 100000 lines

Test #33:

score: 0
Accepted
time: 93ms
memory: 19620kb

input:

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

output:

5252
347
72
2818
2826
312
3012
3378
3207
2343
4717
2036
1606
1717
3050
652
949
1399
438
1406
1115
219
697
1520
333
4176
4015
2122
2897
2667
3077
590
2348
2169
829
1201
1651
611
4998
4506
2982
4351
3422
63
3866
359
4531
514
152
2628
2667
1208
3309
5524
226
1068
884
431
2439
2611
2879
2431
137
3707
18...

result:

ok 100000 lines

Test #34:

score: 0
Accepted
time: 87ms
memory: 19784kb

input:

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

output:

1052
2787
2662
169
727
10
1907
2086
2742
3249
1040
453
1898
1135
3636
3038
1305
3369
766
1830
180
2562
3754
254
1078
2749
594
886
945
4159
1607
3486
794
4002
203
832
494
3177
824
745
219
967
1178
1936
2491
1037
170
1093
2544
2606
2083
3231
4141
931
699
183
2215
1396
411
222
652
510
1941
1525
85
4693...

result:

ok 100000 lines

Test #35:

score: 0
Accepted
time: 92ms
memory: 19552kb

input:

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

output:

2769
2447
213
1998
1469
3241
1098
723
1196
331
1501
2355
282
1930
536
112
165
89
2399
1319
1568
2788
1486
640
4259
894
1096
2168
1060
1061
1090
3026
2230
3112
2289
475
742
2573
2121
550
75
91
1995
2272
1368
3990
2651
2167
1394
1215
1891
1454
1653
484
2707
3079
3049
503
833
3923
47
1001
1647
12
4521
...

result:

ok 100000 lines

Test #36:

score: 0
Accepted
time: 97ms
memory: 19772kb

input:

100000 2 100000
2
1
2
1
2
2
2
2
2
2
1
1
2
1
1
1
1
2
2
2
1
1
2
2
2
1
2
1
1
2
1
2
1
1
1
2
2
2
2
1
2
1
1
1
1
2
2
2
2
1
1
2
2
2
1
1
2
1
2
2
1
1
2
1
1
2
1
2
1
2
1
1
1
2
1
2
2
1
1
1
1
2
1
2
1
1
1
2
1
2
1
1
2
1
2
2
1
1
2
2
1
1
2
1
2
2
1
1
2
2
2
1
1
2
2
1
1
1
2
2
2
2
1
2
2
2
2
2
2
2
1
1
2
1
1
2
2
1
1
1
2
1
...

output:

17035
17972
12306
25967
4119
33822
35097
37733
1440
21132
36870
2924
30877
2872
2152
10974
9944
44604
4034
23875
30926
21393
9749
16041
24525
1349
9307
21149
16025
18941
12918
4112
1880
26873
3859
24814
17259
41389
27718
16629
292
3416
22582
35224
2599
38836
11791
11907
33712
3892
21552
11471
287
33...

result:

ok 100000 lines

Test #37:

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

input:

100000 15 100000
15
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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:

18404
1616
37729
34035
37827
34488
27434
9009
19065
2263
11128
40223
7618
22643
32429
48053
26485
42253
18194
47015
19272
38168
2726
3332
47453
43534
44086
44128
3243
4885
10372
26949
41050
4287
46039
12000
44170
22857
17215
32299
14234
46716
24176
16212
27545
46481
21219
29076
9806
35679
36776
1163...

result:

ok 100000 lines

Test #38:

score: 0
Accepted
time: 121ms
memory: 20024kb

input:

100000 20 100000
20
19
19
19
17
17
17
15
15
15
13
13
13
11
11
11
9
9
9
7
7
7
5
5
5
3
3
3
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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:

40263
15863
17525
13009
24269
24841
5560
13585
45771
5888
43029
11364
40499
41772
3039
21676
18738
20940
44822
9994
47386
32246
30546
44187
41818
43044
20071
11971
9062
33881
28563
6810
30563
25174
34386
981
37251
43823
46840
14901
25114
44071
44731
18895
29722
40287
47870
16597
33779
49068
4292
469...

result:

ok 100000 lines

Test #39:

score: 0
Accepted
time: 125ms
memory: 20004kb

input:

100000 20 100000
20
13
19
19
19
19
19
17
17
17
17
17
9
17
17
15
15
10
13
15
15
15
15
9
7
13
13
13
13
13
13
9
9
11
11
11
11
11
5
9
9
9
6
9
9
6
8
7
6
7
7
5
4
5
3
3
3
3
3
3
3
3
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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:

19920
19433
5312
20479
25520
36389
8741
42093
33209
42875
13175
42462
20800
26497
1713
23993
1310
37895
7524
38357
23775
28996
2193
14701
21425
26038
21332
22408
3580
18452
33696
16837
6608
17422
3326
15138
24645
30473
17544
36096
21243
27054
46017
42948
27682
3120
36526
22133
6558
28991
3770
31011
...

result:

ok 100000 lines

Test #40:

score: 0
Accepted
time: 121ms
memory: 20000kb

input:

100000 20 100000
20
14
16
19
19
17
17
17
17
17
17
17
15
15
8
15
15
13
13
9
13
13
13
11
11
11
11
11
11
11
9
9
9
9
9
8
9
9
9
8
7
7
6
5
5
5
5
5
5
5
5
5
4
3
3
3
3
3
3
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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:

12072
10232
41913
35695
3431
18634
39475
46936
42172
27399
49469
37991
20694
23999
4337
18014
9212
14404
104
17491
3315
48796
9800
27979
7460
27558
18996
48589
22002
1718
30243
13926
28262
34592
49027
6464
28439
47901
21373
31067
48488
28577
7709
33697
7177
38470
46257
48068
17455
20467
2626
8413
34...

result:

ok 100000 lines

Test #41:

score: 0
Accepted
time: 117ms
memory: 20100kb

input:

100000 20 100000
20
19
19
17
19
19
19
19
17
17
17
9
11
10
15
15
14
15
15
15
13
10
13
13
13
13
11
11
9
11
9
8
8
9
9
9
7
7
5
7
7
7
7
7
7
5
5
5
5
3
3
3
3
3
3
3
3
3
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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:

14384
47456
8467
17706
48932
8412
19008
3505
8306
22557
30336
48112
35727
6792
43403
20339
32747
28270
40645
5375
47280
14479
22028
13332
8263
31652
23903
26666
8799
38497
10184
10250
33075
26373
48431
37543
30625
39770
9222
19972
1709
31018
18537
45200
9002
19127
42177
19371
34906
24853
15123
47369...

result:

ok 100000 lines

Test #42:

score: 0
Accepted
time: 115ms
memory: 19636kb

input:

100000 20 100000
20
12
19
19
19
17
15
13
6
11
11
11
9
6
9
7
5
5
5
3
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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:

6303
3663
7708
10343
11809
9852
14873
4775
6784
6245
2512
5158
3000
13153
9272
1905
9370
8395
2874
3527
2803
6256
8317
12296
4555
7698
7935
8771
5703
3166
2448
5844
10081
9749
1454
9549
4123
11036
6515
10930
3475
13311
3783
6542
6433
6158
4616
5108
9572
4869
4852
2245
10275
1656
5391
7787
2593
5900
...

result:

ok 100000 lines

Test #43:

score: 0
Accepted
time: 103ms
memory: 19592kb

input:

100000 20 100000
20
19
19
19
12
15
17
15
9
13
13
13
11
7
7
6
9
7
7
7
4
5
5
5
3
3
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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:

238
453
309
1129
1103
523
1490
792
279
791
765
233
970
337
537
945
541
1761
1272
1130
905
1150
676
1026
1089
741
277
162
881
1229
891
230
957
129
1356
1841
463
2376
632
1180
205
1026
968
796
497
242
269
315
1157
1849
518
421
217
306
504
1428
583
425
3185
811
110
2195
1459
1564
535
1721
855
1000
389
...

result:

ok 100000 lines

Test #44:

score: 0
Accepted
time: 99ms
memory: 19776kb

input:

100000 20 100000
20
19
19
17
17
9
17
15
15
15
13
13
10
13
10
11
9
9
9
9
4
5
5
3
3
3
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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:

217
188
203
442
588
220
509
273
296
368
484
462
89
284
182
457
115
427
642
188
424
192
217
655
218
278
748
345
933
109
224
423
72
913
315
542
235
348
544
497
421
610
777
313
446
616
764
85
146
181
180
35
175
569
252
169
858
605
410
473
533
206
699
307
578
477
263
168
284
555
844
491
641
189
168
294
...

result:

ok 100000 lines

Subtask #4:

score: 55
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Test #45:

score: 55
Accepted
time: 84ms
memory: 19552kb

input:

100000 100000 100000
100000
48819
41147
26617
87569
89354
47401
80757
50790
38804
46276
89458
93533
49516
88206
79688
93827
69968
90375
36636
58322
70859
89161
36565
1523
17088
90348
56548
92351
39826
61258
80879
59375
63439
69274
20493
93449
40982
26144
13622
8860
21646
63496
43603
15272
80472
4077...

output:

13
17
9
15
18
10
10
12
15
14
10
15
9
17
14
15
15
12
13
13
12
12
12
18
10
11
12
8
10
20
18
6
10
12
14
13
16
13
17
15
13
15
13
12
13
11
10
16
11
19
12
14
12
10
13
8
8
14
11
13
14
8
19
12
9
14
10
11
18
9
14
12
14
16
11
9
16
12
11
10
9
10
11
13
15
12
12
8
7
8
17
14
19
10
11
14
16
13
16
13
17
12
18
12
14...

result:

ok 100000 lines

Test #46:

score: 0
Accepted
time: 78ms
memory: 19604kb

input:

100000 100000 100000
100000
55892
82204
85169
71561
40017
41744
48887
20467
24902
30353
73209
17527
62642
33205
84259
57159
35200
82847
9450
65610
41640
23241
41536
73987
10162
76170
1505
77672
82095
82749
3223
2280
47142
25062
60859
38784
31771
64828
90562
49960
11972
57606
46973
23179
64305
40183
...

output:

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

result:

ok 100000 lines

Test #47:

score: 0
Accepted
time: 71ms
memory: 19768kb

input:

100000 10000 100000
10000
485
1268
4453
4917
7158
907
7987
6599
126
3056
3685
8151
5071
8662
4790
8300
1582
7968
9026
6736
165
7390
6133
8850
2719
4749
2504
9453
6816
7868
8490
3943
9549
30
9552
3381
1167
4690
9462
4725
8275
8005
3834
7811
4396
9375
7759
9285
7633
9783
2912
1659
1147
4092
1968
9375
...

output:

16
21
10
13
9
14
15
17
18
27
15
7
9
18
8
17
12
21
17
9
18
16
9
16
18
19
11
13
11
9
14
10
11
13
11
18
13
17
8
25
15
15
18
11
15
20
15
13
14
10
18
9
11
23
17
16
19
11
14
18
8
21
17
15
9
10
17
17
15
24
14
15
18
19
22
15
9
13
11
16
24
14
22
13
18
12
23
20
15
17
11
19
19
8
19
9
18
15
18
16
20
18
11
11
13...

result:

ok 100000 lines

Test #48:

score: 0
Accepted
time: 73ms
memory: 19572kb

input:

100000 30000 100000
30000
26623
14503
22444
27965
10180
27523
19219
26465
9959
897
19602
12963
983
8226
27237
19763
11273
26854
13488
19386
4547
10727
1413
22024
7086
25214
29205
14631
2904
28853
7935
19960
4952
22241
12206
7304
13150
13449
3364
1493
9715
22980
28895
11543
10721
5019
25063
20029
150...

output:

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

result:

ok 100000 lines

Test #49:

score: 0
Accepted
time: 136ms
memory: 19956kb

input:

100000 100000 100000
100000
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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:

36681
31380
19681
36330
21173
49228
17863
18601
20992
30887
47399
27391
18167
24530
38469
45571
45459
39341
32043
47829
9779
2490
41322
49688
11420
6916
18331
19384
34596
4208
20834
41707
22749
11823
23352
38034
47689
34305
37408
38837
16530
44577
21095
20005
6758
26974
6605
6442
25106
46919
19794
3...

result:

ok 100000 lines

Test #50:

score: 0
Accepted
time: 112ms
memory: 19916kb

input:

100000 100000 100000
100000
99999
99999
99999
99997
99997
99997
99995
99995
99995
99993
99993
99993
99991
99991
99991
99989
99989
99989
99987
99987
99987
99985
99985
99985
99983
99983
99983
99981
99981
99981
99979
99979
99979
99977
99977
99977
99975
99975
99975
99973
99973
99973
99971
99971
99971
99...

output:

20761
12856
14146
21402
13771
7139
14624
14087
18592
7969
23815
25806
10557
10271
4591
3938
585
2162
19544
15631
19229
20605
25409
1068
1186
13491
14342
15869
17261
7295
21276
2189
9840
566
3375
215
19773
22773
7094
1713
4188
2720
23089
20536
13674
8221
11518
17410
23725
22835
7688
1746
13469
3138
2...

result:

ok 100000 lines

Test #51:

score: 0
Accepted
time: 98ms
memory: 19768kb

input:

100000 50000 100000
50000
49999
49999
49999
49997
49997
49997
49995
49995
49995
49993
49993
49993
49991
49991
49991
49989
49989
49989
49987
49987
49987
49985
49985
49985
49983
49983
49983
49981
49981
49981
49979
49979
49979
49977
49977
49977
49975
49975
49975
49973
49973
49973
49971
49971
49971
4996...

output:

1743
12106
16734
22118
1825
16353
16123
6417
10310
16234
12771
22221
1577
22605
21087
19449
2938
18092
26421
23550
25977
20428
1281
5175
14867
12105
17973
24737
761
20709
10814
12951
32095
25850
8199
19110
2815
7920
4752
9451
2278
12069
24520
14392
26182
10178
17428
21781
21760
5700
7997
1142
7979
1...

result:

ok 100000 lines

Test #52:

score: 0
Accepted
time: 131ms
memory: 20056kb

input:

100000 20000 100000
20000
19999
19999
19999
19997
19997
19997
19995
19995
19995
19993
19993
19993
19991
19991
19991
19989
19989
19989
19987
19987
19987
19985
19985
19985
19983
19983
19983
19981
19981
19981
19979
19979
19979
19977
19977
19977
19975
19975
19975
19973
19973
19973
19971
19971
19971
1996...

output:

16141
8521
26853
15024
4685
21334
28555
24867
2358
21041
25929
16752
21003
14427
8421
2806
35581
12611
2574
33726
22580
34502
1218
32984
17583
3735
7212
15720
7357
14397
9613
12549
10345
20882
8784
10799
32715
17546
7561
15400
20530
28547
16603
12709
28844
14907
15607
1071
478
33098
34842
37413
2577...

result:

ok 100000 lines

Test #53:

score: 0
Accepted
time: 106ms
memory: 19744kb

input:

100000 100000 100000
100000
99999
99999
99999
73500
99999
59775
99999
99999
99999
99997
99997
99997
99997
99995
99995
99995
99993
99993
91823
86196
99993
99993
99991
99991
99991
99991
83717
99991
99991
50447
99991
99991
98917
60404
99989
99987
99987
99987
92229
99987
75638
99985
99985
99985
99985
99...

output:

13173
2293
1993
802
1904
6000
1097
10595
4333
1912
2283
10275
1063
9665
11391
5389
966
7165
6431
8161
7117
7618
3105
5387
4108
10352
9082
4862
4245
759
2757
2079
10431
1356
1991
7659
6321
8993
6142
8161
1434
1116
9573
10444
3844
10156
4768
12431
1770
8349
6899
2774
6838
961
816
5638
5881
7191
11542
...

result:

ok 100000 lines

Test #54:

score: 0
Accepted
time: 111ms
memory: 19780kb

input:

100000 50000 100000
50000
49999
49999
49999
49999
49999
49997
31191
49997
39722
49997
49995
49995
49995
49993
44823
49993
49993
43765
49993
49993
49993
49993
49993
49621
49991
49991
49991
49991
42536
49989
49989
44792
49987
49987
28561
49987
26131
49987
49987
49987
49987
37497
49985
49985
41057
4998...

output:

1472
3627
9595
6529
28
9237
12546
4355
311
2550
47
2209
5100
978
12078
9834
8313
4003
5716
2265
283
10038
9096
6319
11481
4379
2628
473
3750
4121
5974
4150
1443
3237
333
7447
9245
6499
12658
7337
576
7199
5962
12464
3641
342
851
4563
33
5314
6620
168
11648
5369
2112
10261
504
3786
5451
3116
8858
261...

result:

ok 100000 lines

Test #55:

score: 0
Accepted
time: 104ms
memory: 19916kb

input:

100000 20000 100000
20000
17912
19999
19999
19997
19997
19997
19997
19997
19997
19995
19995
17706
10803
19995
19995
19995
19993
19993
19993
17212
19991
19991
19991
14690
19991
17484
19991
19991
19991
19991
11700
16054
19989
17490
19989
19989
19989
19987
19987
19987
19987
19987
10313
19502
19987
1572...

output:

3616
1092
840
7772
7809
3287
7361
3620
8316
5009
2455
8089
10500
2266
4855
5097
11728
768
9211
529
49
7648
1671
1363
7794
4229
12581
9054
2146
6401
1509
5875
4355
1758
2286
7493
6623
1164
5674
11620
2568
5137
231
3930
13283
3193
8132
2210
1442
3048
2352
10823
3748
2066
4064
2947
3583
3042
2740
9801
...

result:

ok 100000 lines

Test #56:

score: 0
Accepted
time: 103ms
memory: 19680kb

input:

100000 100000 100000
100000
99999
99999
99999
99999
99997
90184
99997
55173
53925
84584
99997
99997
99997
91345
85549
99995
99993
99993
99993
99993
99993
99993
72767
72749
79838
99993
99991
99991
99991
99991
99991
70388
99989
99989
95075
99989
99989
99989
99989
99989
99989
99987
99987
88512
99987
99...

output:

2821
1604
2481
6711
999
549
1069
8933
6298
4339
441
4351
3198
1219
7513
144
6638
12158
6779
2231
3390
5578
7167
4411
2262
745
2579
720
11126
1847
1329
12040
2611
713
7038
3034
1218
4776
3234
429
1830
2704
6254
2124
1111
2371
8163
4713
10414
10980
5904
4393
5113
7946
925
2451
3867
265
6997
6135
2359
...

result:

ok 100000 lines

Test #57:

score: 0
Accepted
time: 101ms
memory: 19684kb

input:

100000 50000 100000
50000
49999
49999
46894
49999
49999
44959
49997
49997
33539
39390
49997
49997
42179
49997
49995
49995
49995
41431
49995
49995
49993
49993
43152
49993
31809
49993
49993
49993
38994
49991
43049
49991
49991
49991
49991
27901
49144
49989
49989
49989
49989
49989
49989
49989
34218
4998...

output:

3653
2035
8655
5837
3084
2492
6549
2738
841
7796
1910
12621
3996
5552
1387
1704
9000
9337
9761
6783
2446
1780
7446
1463
1944
5226
1944
13694
6408
2405
4108
4423
7358
695
2643
6857
4715
4580
4595
2613
194
237
12873
6256
606
14379
10405
9056
3485
7080
2784
2146
3211
4549
6092
804
9530
3793
3823
4508
1...

result:

ok 100000 lines

Test #58:

score: 0
Accepted
time: 102ms
memory: 19740kb

input:

100000 100000 100000
100000
99999
99997
99997
96011
99995
61602
55897
99991
53446
99989
99989
99989
99987
62657
99987
64804
99983
99983
99983
99981
99981
99979
99979
99979
99977
99977
96037
99975
99973
99973
99971
99971
99969
99969
99967
99967
56710
99965
99965
79213
68280
99961
99961
99961
99959
99...

output:

21102
16584
7926
2669
7174
21479
2055
6668
10969
9483
20804
5438
7192
16753
14196
11908
7628
3883
27
17258
14056
13119
3639
13365
7388
6346
1501
2468
3715
613
4707
2694
18120
1111
4336
2408
7048
418
8457
3905
2726
3339
749
9482
4777
7593
19007
2134
8747
9478
19813
1940
26931
13908
27668
14918
1048
2...

result:

ok 100000 lines

Test #59:

score: 0
Accepted
time: 114ms
memory: 19940kb

input:

100000 100000 100000
100000
99999
99997
99997
99995
62489
99993
99993
94216
86852
99987
99987
99985
85645
99983
99981
99981
99979
99979
99977
99977
99975
99975
87047
99971
67984
99969
99969
99967
99967
81307
99963
99963
99961
99961
99959
99957
56774
99955
99953
99953
99951
54551
99947
99947
99945
99...

output:

9692
16746
4185
26171
16069
1592
13235
14005
2609
5257
3842
6009
19982
16377
10137
6334
9961
26625
3532
19255
10863
13609
1741
4670
6673
21999
59
24302
16734
13887
5166
5821
6939
9071
21331
846
9898
6177
21103
3302
7916
5666
2220
12030
25095
7443
10145
3172
15195
8044
5524
16167
5576
10301
4693
4486...

result:

ok 100000 lines

Test #60:

score: 0
Accepted
time: 121ms
memory: 19720kb

input:

100000 100000 100000
100000
99999
99997
99995
99993
99991
99989
96398
99985
99983
99981
52517
61354
99975
92414
74143
74767
78704
99965
61281
99961
99959
99957
99955
99953
68353
63994
99947
99945
99943
99941
99939
91322
99935
81487
99931
99929
99927
99925
99923
99921
58272
99917
99915
99913
99911
99...

output:

2341
2238
4716
12832
11152
5127
6215
6900
13119
16604
1651
1519
25147
16734
9533
11902
7689
7272
21554
15280
5901
4100
821
582
20802
4274
1997
498
13944
19576
1038
17125
756
7996
15045
11122
6718
3174
1266
23961
16502
13848
7756
7889
21538
8526
24346
4045
16753
5088
576
9334
1688
27392
3281
3024
964...

result:

ok 100000 lines

Test #61:

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

input:

100000 100000 100000
100000
99999
77058
99999
99999
99997
99997
77402
99993
99993
99993
99993
99991
99991
96900
93775
99989
89642
99989
79356
99987
52430
99985
99985
99985
65382
99983
97345
95471
99983
99981
99979
99979
99979
54112
99977
99975
99973
99973
66155
93130
99971
78608
99969
99969
99969
99...

output:

5150
6055
5025
10274
4024
947
4112
15784
6648
7792
981
11563
9067
9556
16487
596
7427
9986
8353
16273
4827
4238
13327
5473
4125
238
10528
9743
8095
9485
9021
15122
5537
4372
15301
15071
9755
6197
1827
8352
10598
9994
3261
11755
13828
339
6162
4884
7139
10283
12940
3630
1359
4400
1831
14769
858
3947
...

result:

ok 100000 lines

Test #62:

score: 0
Accepted
time: 128ms
memory: 19676kb

input:

100000 100000 100000
100000
99999
75554
78962
99999
99997
84652
72785
99997
99995
99995
89071
99993
99993
99993
99991
70871
99989
99987
99985
88072
99983
99983
99981
99981
99981
99979
99979
51112
99977
95986
88945
99973
99973
99973
95106
99969
99969
77329
99967
99965
58081
65039
99963
58003
99963
99...

output:

1824
12039
12713
11620
256
11438
2386
11105
4695
12233
5339
3560
16740
3988
5155
10988
3134
12260
11320
11457
6830
14862
18053
8537
587
1412
3324
6293
505
6711
10722
20171
7998
11288
1363
13395
888
11581
15579
1285
12087
9540
10610
3929
1955
4662
2081
7506
7430
14676
1511
3589
17210
4295
15134
409
1...

result:

ok 100000 lines

Test #63:

score: 0
Accepted
time: 178ms
memory: 19660kb

input:

100000 100000 100000
100000
99999
99999
66373
99999
87334
99997
99997
86916
99995
99993
99991
99991
99991
99991
55033
99989
99989
80253
99987
99987
99987
99985
99985
63998
89127
99983
99981
99981
99981
72656
99979
99979
99979
99979
99977
99977
99977
99975
99975
99973
99968
99971
67884
99969
99969
99...

output:

3392
11644
3564
7273
9181
11695
9447
8801
10623
8907
831
15120
5555
11457
19470
893
3924
5876
10449
1153
9963
6538
12319
6861
1497
1661
4579
5199
1956
8213
6882
4768
5240
136
5995
5195
6242
8812
14976
2675
5953
4807
11217
10209
2282
1407
2801
9208
9995
655
11935
7118
16057
2959
9269
6116
8282
11633
...

result:

ok 100000 lines

Test #64:

score: 0
Accepted
time: 107ms
memory: 19776kb

input:

100000 100000 100000
100000
71577
99997
99995
99995
92835
99514
99993
99993
99991
99991
99989
69759
99987
99987
96832
73225
99985
99983
99981
68927
99979
99979
56547
99977
99977
89483
99977
99975
99975
53978
51842
99973
99971
99969
89032
99967
99967
99967
99967
99965
99965
99965
99965
71518
99963
99...

output:

941
369
928
146
640
95
171
859
400
450
576
337
652
671
342
365
527
747
257
262
765
923
580
76
1312
574
234
661
80
839
598
344
297
550
369
477
270
290
571
94
414
710
1039
264
1241
643
432
458
329
493
413
224
441
1350
326
345
219
1385
420
192
959
445
1140
273
587
263
648
180
319
415
240
505
305
507
37...

result:

ok 100000 lines

Test #65:

score: 0
Accepted
time: 81ms
memory: 19720kb

input:

100000 100000 100000
100000
99990
99987
99988
99989
99985
99984
99986
99987
99986
99988
99987
99986
99984
99985
99991
99983
99984
99983
99985
99984
99983
99981
99982
99981
99980
99986
99987
99984
99985
99984
99982
99983
99981
99982
99981
99986
99988
99989
99986
99987
99983
99984
99985
99986
99985
99...

output:

6
10
10
12
12
14
12
12
18
12
15
10
11
9
16
10
8
10
16
10
9
11
14
9
9
12
7
13
15
11
9
7
16
10
11
11
9
10
9
12
10
13
19
10
9
8
14
10
13
14
15
16
9
14
11
16
13
10
12
13
3
12
9
9
13
9
12
13
15
10
14
10
10
11
11
9
10
12
11
11
9
18
12
12
11
15
6
8
17
11
11
12
15
17
13
9
14
10
11
10
13
11
14
20
11
11
12
16...

result:

ok 100000 lines

Test #66:

score: 0
Accepted
time: 67ms
memory: 19536kb

input:

100000 100000 100000
100000
99991
99992
99991
99993
99994
99991
99990
99992
99989
99990
99989
99991
99986
99983
99982
99984
99983
99982
99985
99983
99984
99982
99983
99987
99985
99984
99986
99985
99984
99988
99987
99989
99987
99986
99985
99988
99990
99989
99988
99986
99985
99987
99993
99988
99989
99...

output:

11
14
16
12
9
14
11
14
12
13
13
14
15
11
14
14
14
9
9
10
10
11
9
11
9
14
17
9
13
9
15
15
15
13
10
9
13
15
16
15
12
13
12
11
13
13
10
10
15
16
12
15
15
13
17
12
18
12
13
10
13
10
11
15
17
12
13
14
16
12
12
9
15
10
16
13
14
11
12
12
11
15
17
12
12
15
12
9
11
11
16
10
11
14
13
16
4
18
12
12
10
12
8
10
...

result:

ok 100000 lines

Test #67:

score: 0
Accepted
time: 76ms
memory: 19772kb

input:

100000 100000 100000
100000
2
3
4
5
6
59144
8
9
4493
11
12
13
14
15
16
17
18
19
20
47240
22
57327
33185
25
76221
27
28
29
30
31
32
33
34
35
89595
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
46409
53
54
55
56
57
58
53199
60
22215
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
49061
53437
81
7191...

output:

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

result:

ok 100000 lines

Extra Test:

score: 0
Extra Test Passed