QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#590635#33. Cat in a treeNova_NightWind0311100 ✓56ms24296kbC++20803b2024-09-26 09:14:302024-09-26 09:14:31

详细

Subtask #1:

score: 11
Accepted

Test #1:

score: 11
Accepted
time: 1ms
memory: 5984kb

input:

10 2
0
0
2
2
0
3
4
7
2

output:

6

result:

ok single line: '6'

Test #2:

score: 11
Accepted
time: 1ms
memory: 5844kb

input:

10 3
0
0
2
1
4
4
3
1
7

output:

4

result:

ok single line: '4'

Test #3:

score: 11
Accepted
time: 1ms
memory: 5860kb

input:

12 1
0
0
1
3
1
0
2
1
3
2
2

output:

12

result:

ok single line: '12'

Test #4:

score: 11
Accepted
time: 0ms
memory: 5932kb

input:

12 4
0
0
1
2
0
0
4
7
7
9
10

output:

3

result:

ok single line: '3'

Test #5:

score: 11
Accepted
time: 1ms
memory: 5940kb

input:

14 2
0
1
2
3
0
1
5
1
4
0
3
11
9

output:

8

result:

ok single line: '8'

Test #6:

score: 11
Accepted
time: 1ms
memory: 5884kb

input:

14 4
0
0
2
3
4
2
6
3
6
9
3
3
2

output:

3

result:

ok single line: '3'

Test #7:

score: 11
Accepted
time: 1ms
memory: 3816kb

input:

16 2
0
0
0
1
2
3
2
6
6
0
4
11
0
12
2

output:

11

result:

ok single line: '11'

Test #8:

score: 11
Accepted
time: 1ms
memory: 3804kb

input:

16 3
0
0
0
3
2
2
0
2
8
4
6
11
8
3
5

output:

6

result:

ok single line: '6'

Test #9:

score: 11
Accepted
time: 0ms
memory: 5880kb

input:

18 1
0
0
2
2
2
1
0
3
1
4
2
2
12
0
6
10
13

output:

18

result:

ok single line: '18'

Test #10:

score: 11
Accepted
time: 0ms
memory: 5940kb

input:

18 5
0
0
2
1
0
2
6
5
8
5
0
8
5
4
12
7
10

output:

4

result:

ok single line: '4'

Test #11:

score: 11
Accepted
time: 1ms
memory: 3932kb

input:

18 1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

output:

18

result:

ok single line: '18'

Test #12:

score: 11
Accepted
time: 0ms
memory: 5956kb

input:

18 2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

output:

17

result:

ok single line: '17'

Test #13:

score: 11
Accepted
time: 0ms
memory: 5848kb

input:

17 1
0
1
1
0
0
1
2
0
1
0
2
1
2
2
2
2

output:

17

result:

ok single line: '17'

Test #14:

score: 11
Accepted
time: 1ms
memory: 5860kb

input:

17 2
0
1
0
1
1
0
2
1
2
1
1
0
1
2
0
0

output:

14

result:

ok single line: '14'

Test #15:

score: 11
Accepted
time: 1ms
memory: 5936kb

input:

18 5
0
0
1
1
0
1
2
2
2
1
0
0
1
0
1
1
0

output:

1

result:

ok single line: '1'

Test #16:

score: 11
Accepted
time: 1ms
memory: 3844kb

input:

18 1
0
1
2
0
1
0
4
0
2
3
0
3
2
1
3
4
2

output:

18

result:

ok single line: '18'

Test #17:

score: 11
Accepted
time: 1ms
memory: 5984kb

input:

18 2
0
0
0
1
2
2
3
3
1
3
4
1
1
4
2
4
0

output:

13

result:

ok single line: '13'

Test #18:

score: 11
Accepted
time: 0ms
memory: 5884kb

input:

18 3
0
1
1
3
1
4
2
1
0
2
0
0
1
1
3
0
3

output:

5

result:

ok single line: '5'

Test #19:

score: 11
Accepted
time: 0ms
memory: 5804kb

input:

18 6
0
0
2
3
4
3
3
1
6
1
2
0
2
0
5
2
4

output:

2

result:

ok single line: '2'

Test #20:

score: 11
Accepted
time: 1ms
memory: 3908kb

input:

18 7
0
1
0
3
2
0
6
3
4
4
3
2
6
3
6
0
0

output:

1

result:

ok single line: '1'

Subtask #2:

score: 40
Accepted

Dependency #1:

100%
Accepted

Test #21:

score: 40
Accepted
time: 2ms
memory: 6040kb

input:

1500 1000
0
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
97
98
99
...

output:

2

result:

ok single line: '2'

Test #22:

score: 40
Accepted
time: 0ms
memory: 3832kb

input:

500 1
0
1
1
1
1
5
5
2
4
4
10
0
0
11
12
6
13
5
17
2
13
12
19
12
8
7
18
5
9
10
15
1
25
21
7
32
29
14
22
12
34
13
1
10
0
20
4
6
44
38
19
12
9
17
20
51
5
3
23
46
39
25
7
42
37
55
13
14
30
46
9
71
47
55
61
43
39
1
76
0
49
8
80
51
51
71
55
44
79
25
80
24
68
15
41
88
72
76
72
38
83
94
88
69
17
9
49
75
64
3...

output:

500

result:

ok single line: '500'

Test #23:

score: 40
Accepted
time: 1ms
memory: 3836kb

input:

500 5
0
1
2
0
3
5
0
2
0
3
10
1
3
5
13
8
8
16
16
4
17
5
1
17
6
1
17
9
20
0
27
27
1
14
24
30
17
5
37
37
9
33
7
20
39
24
29
20
33
19
32
26
13
33
31
21
31
11
20
50
35
34
16
47
17
5
48
55
60
66
57
43
10
68
69
69
34
75
27
41
3
56
8
32
41
85
55
70
5
57
48
61
41
78
19
12
85
73
62
18
79
95
47
39
61
67
88
18
...

output:

89

result:

ok single line: '89'

Test #24:

score: 40
Accepted
time: 1ms
memory: 5880kb

input:

500 10
0
1
1
0
1
0
6
6
8
1
4
0
10
0
13
8
11
16
18
1
17
7
21
22
1
22
9
26
1
4
1
21
5
18
6
7
35
4
31
5
38
36
31
37
25
17
8
28
36
12
26
20
9
11
20
42
38
17
29
42
29
38
28
39
46
39
3
46
22
16
34
25
14
3
21
73
62
77
78
29
43
3
25
48
3
47
17
54
3
43
47
43
42
62
12
44
38
29
75
62
37
96
91
47
97
104
15
84
4...

output:

23

result:

ok single line: '23'

Test #25:

score: 40
Accepted
time: 1ms
memory: 5904kb

input:

1000 1
0
0
0
2
0
4
3
4
4
2
9
4
1
12
2
12
7
12
13
1
12
20
17
5
8
3
7
0
11
18
28
2
29
26
34
24
5
24
22
38
30
0
30
19
17
9
45
32
14
47
42
29
47
5
2
1
44
23
16
48
3
51
28
44
16
24
31
8
49
0
6
12
39
6
13
2
74
77
0
25
78
67
43
83
32
22
69
38
57
32
62
23
12
22
53
85
88
91
3
4
42
96
93
20
59
44
59
102
95
86...

output:

1000

result:

ok single line: '1000'

Test #26:

score: 40
Accepted
time: 1ms
memory: 4000kb

input:

1000 5
0
0
1
1
2
3
0
2
0
1
6
3
10
13
14
1
12
0
2
0
0
16
0
14
13
11
1
4
2
15
21
10
24
4
0
18
16
29
24
2
38
40
17
31
17
30
8
18
12
49
16
47
31
52
53
10
41
28
39
57
20
49
43
1
46
27
59
38
7
37
24
38
36
13
59
34
25
31
63
36
4
32
72
9
17
4
80
87
63
20
68
43
42
64
80
8
88
2
24
68
6
41
34
68
63
66
92
32
93...

output:

191

result:

ok single line: '191'

Test #27:

score: 40
Accepted
time: 1ms
memory: 4000kb

input:

1000 10
0
0
1
2
2
2
4
2
3
9
10
5
7
3
4
6
7
2
8
16
9
5
4
3
17
17
23
10
11
26
15
30
20
32
27
12
5
29
10
15
22
9
40
19
30
1
23
33
16
5
0
5
18
18
5
48
5
50
27
39
35
60
54
11
29
25
43
13
62
29
48
39
13
49
44
66
52
65
54
29
66
15
32
35
76
7
53
40
57
7
7
77
82
83
43
31
28
85
69
1
9
72
32
29
53
57
5
94
57
6...

output:

44

result:

ok single line: '44'

Test #28:

score: 40
Accepted
time: 1ms
memory: 5928kb

input:

1500 12
0
1
2
0
4
2
0
4
6
2
3
10
4
2
12
2
10
1
5
7
7
10
3
10
0
20
1
15
24
25
0
10
30
13
0
14
24
20
7
37
25
6
20
34
37
0
27
28
25
26
28
8
2
25
50
19
19
55
33
26
53
1
53
23
20
23
27
36
17
63
22
39
10
22
26
68
62
26
1
56
11
1
51
12
19
84
42
59
65
73
9
61
63
65
27
44
34
85
31
79
98
72
60
57
92
10
53
45
...

output:

41

result:

ok single line: '41'

Test #29:

score: 40
Accepted
time: 0ms
memory: 5944kb

input:

1500 5
0
0
2
2
3
0
5
0
0
6
2
8
0
12
8
0
2
5
4
4
4
0
0
10
16
4
26
27
10
17
23
21
5
24
27
6
22
28
2
38
24
11
38
25
19
20
22
35
21
7
6
42
21
19
30
30
56
10
23
31
5
35
49
25
2
28
31
56
43
65
55
62
15
45
10
70
30
56
67
28
35
56
4
25
42
34
41
76
12
81
66
66
8
57
47
80
75
14
68
97
12
58
10
75
86
64
101
104...

output:

293

result:

ok single line: '293'

Test #30:

score: 40
Accepted
time: 1ms
memory: 3848kb

input:

1500 15
0
1
2
3
0
0
5
1
8
0
10
1
1
0
4
6
4
2
5
18
1
8
3
8
3
1
20
22
23
28
25
31
3
28
27
8
36
25
3
30
8
29
41
21
41
34
46
37
24
6
33
15
44
44
18
14
37
55
43
59
10
3
40
27
55
44
40
3
22
53
18
11
17
35
1
41
53
41
22
40
29
35
21
26
37
23
38
74
33
84
2
63
82
53
45
24
43
75
1
66
80
52
63
31
63
46
71
65
48...

output:

19

result:

ok single line: '19'

Test #31:

score: 40
Accepted
time: 1ms
memory: 3996kb

input:

1500 40
0
1
0
0
1
1
0
7
2
5
1
9
11
9
12
3
14
8
10
11
3
5
16
5
9
20
18
21
17
8
30
13
28
9
9
30
9
2
9
6
25
28
8
33
43
19
37
41
14
10
44
38
8
53
47
1
46
32
14
24
23
51
14
46
32
32
66
60
49
53
45
35
47
24
72
52
56
22
77
65
23
3
61
33
36
48
12
79
21
46
74
9
24
23
25
36
2
63
95
49
45
68
18
51
16
1
29
48
1...

output:

1

result:

ok single line: '1'

Test #32:

score: 40
Accepted
time: 1ms
memory: 6024kb

input:

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

output:

13

result:

ok single line: '13'

Test #33:

score: 40
Accepted
time: 1ms
memory: 6068kb

input:

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

output:

1

result:

ok single line: '1'

Test #34:

score: 40
Accepted
time: 1ms
memory: 4000kb

input:

1400 10
0
1
1
1
3
3
1
0
7
1
5
3
8
0
6
11
6
13
4
5
5
17
4
6
13
21
3
24
19
21
21
13
0
29
5
2
29
23
15
4
14
24
33
15
44
4
5
13
7
10
46
24
25
15
48
43
16
0
57
35
43
35
33
50
20
46
21
4
6
1
1
42
8
44
8
17
30
70
40
0
8
3
80
10
14
26
66
2
45
1
46
73
0
8
89
25
4
60
51
26
61
50
85
29
38
17
84
88
30
44
1
64
1...

output:

5

result:

ok single line: '5'

Test #35:

score: 40
Accepted
time: 1ms
memory: 3972kb

input:

1400 12
0
0
0
1
0
1
3
2
1
1
4
7
5
0
7
9
13
8
2
18
5
2
14
18
11
12
5
0
9
27
5
1
9
21
4
10
21
25
15
26
23
8
36
15
37
0
1
38
27
49
26
9
20
45
6
48
36
24
34
16
34
11
36
57
28
21
11
53
32
53
44
22
17
24
52
28
9
36
64
71
20
74
23
15
45
0
31
87
43
22
88
21
67
31
12
18
73
67
30
8
7
74
60
85
18
94
16
20
15
6...

output:

5

result:

ok single line: '5'

Test #36:

score: 40
Accepted
time: 0ms
memory: 5976kb

input:

1500 10
0
1
0
2
3
4
5
5
6
1
10
4
6
11
12
7
11
6
7
1
19
14
20
12
21
12
6
1
18
9
16
16
25
19
18
21
22
4
18
24
25
7
14
8
31
12
29
46
40
5
43
4
7
52
12
17
11
42
43
32
9
48
24
17
24
63
8
10
48
1
9
33
28
25
64
20
71
49
69
5
26
1
73
19
42
78
24
84
9
21
39
65
80
12
80
57
50
36
68
92
97
57
46
7
88
72
21
50
5...

output:

7

result:

ok single line: '7'

Test #37:

score: 40
Accepted
time: 0ms
memory: 6004kb

input:

1500 4
0
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
97
98
79
93
...

output:

50

result:

ok single line: '50'

Test #38:

score: 40
Accepted
time: 1ms
memory: 4020kb

input:

1500 50
0
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
97
98
99
10...

output:

7

result:

ok single line: '7'

Test #39:

score: 40
Accepted
time: 1ms
memory: 5896kb

input:

1500 70
0
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
97
98
99
10...

output:

8

result:

ok single line: '8'

Test #40:

score: 40
Accepted
time: 1ms
memory: 5964kb

input:

1500 5
0
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
97
98
99
100...

output:

301

result:

ok single line: '301'

Subtask #3:

score: 49
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Test #41:

score: 49
Accepted
time: 35ms
memory: 15780kb

input:

190001 5
0
1
2
0
4
5
0
7
8
0
10
11
0
13
14
0
16
17
0
19
20
0
22
23
0
25
26
0
28
29
0
31
32
0
34
35
0
37
38
0
40
41
0
43
44
0
46
47
0
49
50
0
52
53
0
55
56
0
58
59
0
61
62
0
64
65
0
67
68
0
70
71
0
73
74
0
76
77
0
79
80
0
82
83
0
85
86
0
88
89
0
91
92
0
94
95
0
97
98
0
100
101
0
103
104
0
106
107
0
1...

output:

50462

result:

ok single line: '50462'

Test #42:

score: 49
Accepted
time: 19ms
memory: 11808kb

input:

100000 1
0
1
0
2
2
5
6
5
5
2
8
4
7
3
2
4
3
1
13
17
3
18
11
23
20
9
3
18
26
15
2
11
19
27
5
0
19
9
31
17
2
7
12
2
1
5
40
6
4
33
16
30
8
40
2
26
4
23
0
32
39
32
43
11
52
8
61
15
0
62
16
56
11
34
21
14
64
23
11
71
33
78
60
76
65
19
45
9
38
79
74
45
39
49
55
17
64
53
90
78
70
4
8
13
73
26
4
98
63
70
105...

output:

100000

result:

ok single line: '100000'

Test #43:

score: 49
Accepted
time: 25ms
memory: 10180kb

input:

100000 20
0
1
1
0
2
5
6
3
5
5
2
3
5
13
0
2
8
16
8
5
16
12
4
22
2
7
26
23
26
28
12
17
23
21
4
17
1
31
14
4
24
21
28
33
33
24
35
27
15
33
42
32
32
7
46
39
20
44
52
0
13
5
54
11
43
0
45
43
25
2
44
66
50
20
18
34
28
75
28
21
24
23
10
62
23
79
53
81
71
77
29
43
42
83
86
13
24
87
10
67
60
77
54
74
74
52
8...

output:

454

result:

ok single line: '454'

Test #44:

score: 49
Accepted
time: 20ms
memory: 11556kb

input:

100000 50
0
1
1
2
0
3
5
3
7
9
5
6
4
6
8
7
15
3
10
1
17
15
14
22
2
4
19
9
5
12
2
4
20
18
8
8
35
15
26
13
19
35
30
34
20
42
27
0
26
39
41
43
51
3
39
24
38
56
48
32
59
50
56
33
1
65
61
14
19
61
40
6
50
47
59
54
48
69
29
40
61
76
11
37
16
46
53
23
53
40
63
4
12
50
44
55
89
10
85
9
72
95
81
85
18
85
36
6...

output:

1

result:

ok single line: '1'

Test #45:

score: 49
Accepted
time: 23ms
memory: 11884kb

input:

100000 100
0
1
0
3
1
2
2
7
6
9
7
11
3
12
14
1
2
2
2
14
5
7
15
21
18
0
18
6
18
16
1
7
4
26
34
29
31
37
36
11
38
18
7
29
37
45
4
40
37
4
0
14
9
2
25
36
36
45
40
56
34
41
61
37
32
52
59
65
40
19
67
41
41
43
14
72
49
73
69
67
59
32
50
16
35
44
4
2
25
0
49
4
85
68
57
43
78
96
36
93
23
9
24
47
92
55
54
56...

output:

1

result:

ok single line: '1'

Test #46:

score: 49
Accepted
time: 56ms
memory: 16596kb

input:

200000 2
0
0
0
0
3
4
1
0
0
9
7
7
1
11
3
9
4
12
18
7
14
13
22
9
18
0
6
15
17
19
8
31
5
30
1
23
1
10
38
33
32
2
27
38
8
21
29
33
8
27
28
15
9
1
29
25
32
45
55
26
15
50
17
38
3
22
38
7
64
39
10
67
37
8
44
15
45
40
53
11
16
44
9
51
30
44
8
35
85
42
53
58
36
67
25
78
75
9
42
52
54
50
101
97
10
25
26
62
7...

output:

119331

result:

ok single line: '119331'

Test #47:

score: 49
Accepted
time: 56ms
memory: 16540kb

input:

200000 40
0
1
2
2
0
2
0
1
2
3
2
9
11
3
11
15
14
12
16
8
11
6
0
19
11
16
14
8
21
18
12
3
14
31
23
19
9
19
13
23
32
29
42
16
27
7
26
7
37
38
44
33
8
33
54
43
34
3
16
16
13
14
11
38
46
19
66
30
19
31
33
71
41
41
32
42
8
74
4
79
79
34
35
52
74
68
11
4
1
4
5
42
28
24
1
11
93
4
0
68
61
51
35
83
5
14
102
5...

output:

14

result:

ok single line: '14'

Test #48:

score: 49
Accepted
time: 49ms
memory: 16520kb

input:

200000 80
0
1
0
0
0
2
6
5
6
3
9
4
7
8
14
2
0
17
2
16
2
4
13
8
23
8
3
11
24
27
21
18
6
26
14
27
2
25
13
39
8
1
36
15
25
19
21
14
30
17
46
32
45
19
1
25
30
24
50
48
52
38
51
56
26
3
8
58
17
68
48
61
54
6
28
48
41
51
14
33
34
25
30
35
20
68
26
30
4
86
87
26
8
80
62
85
54
81
48
59
45
11
77
82
5
28
78
84...

output:

1

result:

ok single line: '1'

Test #49:

score: 49
Accepted
time: 55ms
memory: 16608kb

input:

200000 200
0
1
1
3
2
0
4
6
6
5
6
5
6
6
11
6
9
3
13
5
17
5
4
21
5
2
7
0
3
10
27
21
10
24
33
25
19
13
25
17
0
5
31
10
23
43
34
18
25
44
42
39
28
4
23
7
10
17
23
0
42
48
18
35
22
5
44
53
35
16
40
71
38
72
74
68
57
19
33
51
72
45
26
27
72
11
29
42
36
48
50
49
35
83
66
26
58
65
55
25
49
62
6
89
36
97
61
...

output:

1

result:

ok single line: '1'

Test #50:

score: 49
Accepted
time: 16ms
memory: 12352kb

input:

100000 3
0
1
1
0
0
0
1
0
5
4
6
3
3
4
11
5
10
15
16
4
5
16
18
20
11
15
8
25
5
14
21
2
4
30
2
20
27
22
23
31
7
8
24
27
32
8
31
5
35
7
32
1
4
40
9
28
47
11
5
56
36
1
43
32
63
55
33
30
60
35
55
40
23
14
30
18
2
34
36
23
65
20
31
82
47
63
54
52
6
62
84
28
6
56
11
21
17
16
61
47
27
51
27
34
14
37
42
89
14...

output:

1000

result:

ok single line: '1000'

Test #51:

score: 49
Accepted
time: 11ms
memory: 10676kb

input:

100000 10
0
1
2
1
2
1
4
4
8
7
3
9
8
9
4
3
16
3
0
9
7
12
14
23
8
15
20
20
7
27
22
28
2
17
25
34
28
26
3
0
39
39
5
34
34
31
26
45
45
43
1
9
51
44
20
46
30
19
40
51
3
6
49
62
49
46
51
61
22
41
20
40
71
27
17
69
51
5
6
72
79
22
41
76
13
14
35
40
41
78
71
51
91
54
24
82
2
61
44
16
96
25
47
62
99
72
52
85...

output:

79

result:

ok single line: '79'

Test #52:

score: 49
Accepted
time: 12ms
memory: 12608kb

input:

100000 15
0
0
0
0
1
1
6
1
1
3
9
6
0
9
10
1
14
1
4
8
13
3
17
3
2
2
12
15
28
0
21
4
11
14
16
6
23
12
16
1
10
8
22
7
43
15
38
40
33
35
31
0
37
41
3
55
13
20
31
27
18
40
17
49
61
35
64
35
0
14
19
16
29
44
15
5
29
20
9
13
0
46
27
46
69
22
80
56
7
20
80
82
35
85
16
66
70
45
21
68
14
16
20
95
92
23
46
90
9...

output:

23

result:

ok single line: '23'

Test #53:

score: 49
Accepted
time: 20ms
memory: 17484kb

input:

200000 4
0
0
2
0
1
5
5
5
6
2
3
5
11
9
2
0
2
8
4
11
5
6
12
8
15
11
11
1
2
6
7
29
12
4
1
17
24
23
14
2
29
16
9
20
42
4
40
47
38
37
23
10
0
28
9
55
51
45
56
32
31
31
12
39
43
35
47
16
44
7
51
34
30
7
10
1
59
65
59
34
32
7
74
82
60
43
25
80
10
73
41
59
81
34
81
80
62
92
51
84
70
97
81
94
53
30
36
3
27
4...

output:

600

result:

ok single line: '600'

Test #54:

score: 49
Accepted
time: 19ms
memory: 17428kb

input:

200000 12
0
1
0
2
1
3
5
1
4
1
4
5
3
9
2
7
15
13
14
3
19
21
2
11
12
1
3
4
15
27
0
28
10
25
30
13
21
28
26
17
0
17
35
10
17
37
14
15
39
24
33
36
32
27
31
1
45
0
0
6
21
3
3
19
37
18
41
48
8
6
40
66
29
8
72
47
21
46
1
38
14
46
64
57
5
44
48
86
56
42
83
51
89
25
15
65
83
66
98
85
40
56
26
74
101
38
69
52...

output:

48

result:

ok single line: '48'

Test #55:

score: 49
Accepted
time: 28ms
memory: 17348kb

input:

200000 17
0
1
1
0
1
5
5
1
7
9
0
4
6
3
6
6
7
12
10
0
7
19
3
9
3
18
9
16
16
1
5
21
14
21
9
2
24
18
11
20
37
5
34
13
10
3
11
31
13
37
32
26
22
14
51
8
56
35
46
58
57
28
26
26
18
65
37
62
16
45
38
10
18
28
0
21
59
25
18
25
42
7
23
17
63
16
60
45
77
57
81
54
31
28
89
78
91
77
21
89
42
36
38
7
94
70
4
34
...

output:

12

result:

ok single line: '12'

Test #56:

score: 49
Accepted
time: 1ms
memory: 6132kb

input:

2400 4
0
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
97
98
99
100...

output:

435

result:

ok single line: '435'

Test #57:

score: 49
Accepted
time: 0ms
memory: 6808kb

input:

21200 2000
0
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
97
98
99...

output:

11

result:

ok single line: '11'

Test #58:

score: 49
Accepted
time: 10ms
memory: 18776kb

input:

100000 10000
0
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
97
98
...

output:

9

result:

ok single line: '9'

Test #59:

score: 49
Accepted
time: 54ms
memory: 24296kb

input:

199999 10000
0
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
97
98
...

output:

11

result:

ok single line: '11'

Test #60:

score: 49
Accepted
time: 28ms
memory: 16128kb

input:

195001 7
0
1
2
3
0
5
6
7
0
9
10
11
0
13
14
15
0
17
18
19
0
21
22
23
0
25
26
27
0
29
30
31
0
33
34
35
0
37
38
39
0
41
42
43
0
45
46
47
0
49
50
51
0
53
54
55
0
57
58
59
0
61
62
63
0
65
66
67
0
69
70
71
0
73
74
75
0
77
78
79
0
81
82
83
0
85
86
87
0
89
90
91
0
93
94
95
0
97
98
99
0
101
102
103
0
105
106...

output:

40021

result:

ok single line: '40021'

Test #61:

score: 49
Accepted
time: 41ms
memory: 15668kb

input:

190001 200
0
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
97
98
99...

output:

1000

result:

ok single line: '1000'