QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#344589#8279. Segment TreehouzhiyuanWA 278ms122652kbC++143.8kb2024-03-04 20:10:352024-03-04 20:10:35

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2 1
1
0 2

output:

5

result:

ok 1 number(s): "5"

Test #2:

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

input:

2 1
1
1 2

output:

5

result:

ok 1 number(s): "5"

Test #3:

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

input:

5 2
2 1 4 3
1 3
2 5

output:

193

result:

ok 1 number(s): "193"

Test #4:

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

input:

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

output:

70848

result:

ok 1 number(s): "70848"

Test #5:

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

input:

2 2
1
0 1
0 2

output:

4

result:

ok 1 number(s): "4"

Test #6:

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

input:

3 3
1 2
0 1
0 2
0 3

output:

14

result:

ok 1 number(s): "14"

Test #7:

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

input:

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

output:

48

result:

ok 1 number(s): "48"

Test #8:

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

input:

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

output:

164

result:

ok 1 number(s): "164"

Test #9:

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

input:

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

output:

544

result:

ok 1 number(s): "544"

Test #10:

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

input:

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

output:

1856

result:

ok 1 number(s): "1856"

Test #11:

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

input:

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

output:

6528

result:

ok 1 number(s): "6528"

Test #12:

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

input:

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

output:

21520

result:

ok 1 number(s): "21520"

Test #13:

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

input:

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

output:

71296

result:

ok 1 number(s): "71296"

Test #14:

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

input:

2 3
1
0 1
0 2
1 2

output:

4

result:

ok 1 number(s): "4"

Test #15:

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

input:

3 6
1 2
0 1
0 2
0 3
1 2
1 3
2 3

output:

14

result:

ok 1 number(s): "14"

Test #16:

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

input:

4 10
1 2 3
0 1
0 2
0 3
0 4
1 2
1 3
1 4
2 3
2 4
3 4

output:

48

result:

ok 1 number(s): "48"

Test #17:

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

input:

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

output:

164

result:

ok 1 number(s): "164"

Test #18:

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

input:

6 21
5 3 1 2 4
0 1
0 2
0 3
0 4
0 5
0 6
1 2
1 3
1 4
1 5
1 6
2 3
2 4
2 5
2 6
3 4
3 5
3 6
4 5
4 6
5 6

output:

544

result:

ok 1 number(s): "544"

Test #19:

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

input:

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

output:

1912

result:

ok 1 number(s): "1912"

Test #20:

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

input:

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

output:

6304

result:

ok 1 number(s): "6304"

Test #21:

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

input:

9 45
6 2 1 4 3 5 7 8
0 1
0 2
0 3
0 4
0 5
0 6
0 7
0 8
0 9
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
2 3
2 4
2 5
2 6
2 7
2 8
2 9
3 4
3 5
3 6
3 7
3 8
3 9
4 5
4 6
4 7
4 8
4 9
5 6
5 7
5 8
5 9
6 7
6 8
6 9
7 8
7 9
8 9

output:

20736

result:

ok 1 number(s): "20736"

Test #22:

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

input:

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

output:

70784

result:

ok 1 number(s): "70784"

Test #23:

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

input:

2 1
1
0 2

output:

5

result:

ok 1 number(s): "5"

Test #24:

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

input:

3 1
2 1
2 3

output:

21

result:

ok 1 number(s): "21"

Test #25:

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

input:

4 1
2 1 3
0 1

output:

85

result:

ok 1 number(s): "85"

Test #26:

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

input:

5 1
4 1 3 2
0 5

output:

341

result:

ok 1 number(s): "341"

Test #27:

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

input:

6 1
5 1 2 3 4
0 2

output:

1260

result:

ok 1 number(s): "1260"

Test #28:

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

input:

7 1
2 1 6 4 3 5
3 4

output:

5545

result:

ok 1 number(s): "5545"

Test #29:

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

input:

8 1
5 4 2 1 3 6 7
4 7

output:

14745

result:

ok 1 number(s): "14745"

Test #30:

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

input:

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

output:

101031

result:

ok 1 number(s): "101031"

Test #31:

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

input:

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

output:

373889

result:

ok 1 number(s): "373889"

Test #32:

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

input:

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

output:

261049

result:

ok 1 number(s): "261049"

Test #33:

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

input:

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

output:

122329

result:

ok 1 number(s): "122329"

Test #34:

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

input:

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

output:

175630

result:

ok 1 number(s): "175630"

Test #35:

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

input:

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

output:

176820

result:

ok 1 number(s): "176820"

Test #36:

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

input:

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

output:

123102

result:

ok 1 number(s): "123102"

Test #37:

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

input:

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

output:

107712

result:

ok 1 number(s): "107712"

Test #38:

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

input:

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

output:

70272

result:

ok 1 number(s): "70272"

Test #39:

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

input:

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

output:

82208

result:

ok 1 number(s): "82208"

Test #40:

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

input:

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

output:

89920

result:

ok 1 number(s): "89920"

Test #41:

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

input:

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

output:

71168

result:

ok 1 number(s): "71168"

Test #42:

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

input:

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

output:

70336

result:

ok 1 number(s): "70336"

Test #43:

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

input:

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

output:

73856

result:

ok 1 number(s): "73856"

Test #44:

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

input:

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

output:

73024

result:

ok 1 number(s): "73024"

Test #45:

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

input:

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

output:

552106926

result:

ok 1 number(s): "552106926"

Test #46:

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

input:

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

output:

413773825

result:

ok 1 number(s): "413773825"

Test #47:

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

input:

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

output:

62575440

result:

ok 1 number(s): "62575440"

Test #48:

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

input:

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

output:

409347680

result:

ok 1 number(s): "409347680"

Test #49:

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

input:

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

output:

390437573

result:

ok 1 number(s): "390437573"

Test #50:

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

input:

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

output:

819705181

result:

ok 1 number(s): "819705181"

Test #51:

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

input:

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

output:

750766504

result:

ok 1 number(s): "750766504"

Test #52:

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

input:

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

output:

331243901

result:

ok 1 number(s): "331243901"

Test #53:

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

input:

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

output:

614246259

result:

ok 1 number(s): "614246259"

Test #54:

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

input:

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

output:

663163875

result:

ok 1 number(s): "663163875"

Test #55:

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

input:

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

output:

62035584

result:

ok 1 number(s): "62035584"

Test #56:

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

input:

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

output:

388044595

result:

ok 1 number(s): "388044595"

Test #57:

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

input:

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

output:

292284846

result:

ok 1 number(s): "292284846"

Test #58:

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

input:

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

output:

118898834

result:

ok 1 number(s): "118898834"

Test #59:

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

input:

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

output:

567391097

result:

ok 1 number(s): "567391097"

Test #60:

score: 0
Accepted
time: 10ms
memory: 4132kb

input:

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

output:

882819037

result:

ok 1 number(s): "882819037"

Test #61:

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

input:

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

output:

384573809

result:

ok 1 number(s): "384573809"

Test #62:

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

input:

500 500
497 1 6 5 2 3 4 7 495 492 10 8 9 12 11 491 16 15 14 13 19 18 17 20 25 21 23 22 24 487 484 479 27 26 29 28 31 30 477 475 35 34 32 33 473 37 36 40 39 38 45 44 41 42 43 47 46 469 51 49 48 50 468 55 54 52 53 59 56 57 58 466 463 462 458 454 60 63 62 61 65 64 450 449 445 67 66 68 440 72 69 70 71 4...

output:

175047909

result:

ok 1 number(s): "175047909"

Test #63:

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

input:

500 3000
497 493 5 3 2 1 4 490 485 10 6 9 8 7 15 11 12 14 13 484 16 482 20 19 18 17 479 477 475 471 469 21 466 24 22 23 465 26 25 462 30 29 28 27 458 34 32 31 33 456 35 453 449 444 40 37 36 38 39 443 45 42 41 43 44 438 434 432 48 47 46 49 50 430 426 424 55 52 51 54 53 419 57 56 58 417 414 412 62 60 ...

output:

208249623

result:

ok 1 number(s): "208249623"

Test #64:

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

input:

500 500
4 1 2 3 499 496 492 6 5 488 485 8 7 483 481 10 9 15 13 12 11 14 20 18 17 16 19 478 477 21 475 25 23 22 24 26 30 29 27 28 34 32 31 33 38 35 37 36 470 42 41 40 39 469 46 45 43 44 464 459 457 456 453 51 50 49 47 48 449 56 53 52 55 54 57 59 58 60 61 448 443 441 64 63 62 440 68 67 65 66 73 71 70 ...

output:

57890760

result:

ok 1 number(s): "57890760"

Test #65:

score: 0
Accepted
time: 3ms
memory: 4928kb

input:

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

output:

927919648

result:

ok 1 number(s): "927919648"

Test #66:

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

input:

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

output:

965999797

result:

ok 1 number(s): "965999797"

Test #67:

score: 0
Accepted
time: 6ms
memory: 5548kb

input:

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

output:

462834466

result:

ok 1 number(s): "462834466"

Test #68:

score: 0
Accepted
time: 21ms
memory: 5876kb

input:

5000 200000
3441 3112 1065 678 466 324 8 1 7 5 4 2 3 6 169 36 35 9 17 13 12 10 11 16 14 15 30 25 23 18 20 19 21 22 24 26 27 29 28 32 31 33 34 65 61 50 49 45 37 42 41 40 38 39 43 44 46 48 47 52 51 54 53 60 58 57 56 55 59 63 62 64 108 97 72 70 69 66 68 67 71 75 73 74 92 80 78 76 77 79 90 83 82 81 86 8...

output:

944502858

result:

ok 1 number(s): "944502858"

Test #69:

score: 0
Accepted
time: 6ms
memory: 5728kb

input:

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

output:

992123431

result:

ok 1 number(s): "992123431"

Test #70:

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

input:

5000 1000
4996 4991 5 3 1 2 4 4988 6 10 9 7 8 14 12 11 13 18 15 16 17 23 22 20 19 21 4984 25 24 4980 29 27 26 28 4979 32 30 31 4974 33 4973 34 37 35 36 4968 4967 4964 41 38 39 40 4961 43 42 45 44 47 46 4959 4955 49 48 4954 50 4950 52 51 57 54 53 55 56 60 58 59 63 62 61 64 4945 4944 65 4939 69 66 68 ...

output:

942332279

result:

ok 1 number(s): "942332279"

Test #71:

score: 0
Accepted
time: 5ms
memory: 5248kb

input:

5000 5000
4997 4995 4994 4991 4 1 2 3 4989 4984 4982 4981 4979 8 7 5 6 11 9 10 16 12 13 14 15 4975 4970 19 17 18 4966 4964 20 22 21 4959 4954 23 24 4949 26 25 30 28 27 29 4948 31 34 32 33 38 37 36 35 42 39 40 41 44 43 48 47 45 46 4947 53 50 49 52 51 58 54 55 56 57 4946 4942 61 59 60 4941 4936 4932 6...

output:

458864653

result:

ok 1 number(s): "458864653"

Test #72:

score: 0
Accepted
time: 18ms
memory: 5452kb

input:

5000 200000
4997 4 1 2 3 6 5 4995 4991 10 8 7 9 4989 4986 12 11 4981 4976 4974 13 4972 14 4971 17 15 16 4970 19 18 4968 20 4965 4962 22 21 4959 25 24 23 4954 27 26 31 30 28 29 4949 33 32 4945 4944 34 38 35 37 36 40 39 4939 4936 43 42 41 4933 45 44 49 48 47 46 50 4930 54 52 51 53 55 4927 4925 59 58 5...

output:

248680221

result:

ok 1 number(s): "248680221"

Test #73:

score: 0
Accepted
time: 5ms
memory: 5464kb

input:

5000 5000
4998 4 1 2 3 8 6 5 7 4994 4993 4992 4989 4985 4983 4982 9 13 11 10 12 14 18 15 16 17 23 22 19 21 20 25 24 4978 4976 4974 4973 26 30 29 28 27 31 32 4972 4969 4968 33 4967 4962 38 35 34 36 37 43 39 40 41 42 44 4959 48 47 45 46 53 51 50 49 52 4956 4951 55 54 4950 59 58 57 56 4948 4943 62 60 6...

output:

284890525

result:

ok 1 number(s): "284890525"

Test #74:

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

input:

2 1
1
0 2

output:

5

result:

ok 1 number(s): "5"

Test #75:

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

input:

3 1
2 1
2 3

output:

21

result:

ok 1 number(s): "21"

Test #76:

score: 0
Accepted
time: 46ms
memory: 36656kb

input:

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

output:

54900200

result:

ok 1 number(s): "54900200"

Test #77:

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

input:

199999 1
39981 30792 15067 5153 4932 1167 698 157 7 2 1 4 3 6 5 141 37 23 17 8 14 12 10 9 11 13 15 16 20 18 19 22 21 24 35 26 25 29 27 28 33 32 30 31 34 36 109 74 71 51 39 38 48 42 41 40 44 43 45 46 47 49 50 59 57 53 52 55 54 56 58 69 61 60 63 62 64 67 65 66 68 70 72 73 93 92 79 75 78 77 76 85 83 81...

output:

426286730

result:

ok 1 number(s): "426286730"

Test #78:

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

input:

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

output:

107301064

result:

ok 1 number(s): "107301064"

Test #79:

score: 0
Accepted
time: 83ms
memory: 74564kb

input:

199999 1
2 1 4 3 199995 199994 199990 5 199988 6 199983 199980 199975 11 8 7 10 9 199970 199968 13 12 199967 17 14 16 15 22 20 18 19 21 199963 199961 27 24 23 26 25 199957 29 28 30 199955 199954 199952 199949 31 199946 199942 199941 199937 199936 33 32 37 36 35 34 199931 42 38 40 39 41 199927 199924...

output:

924406167

result:

ok 1 number(s): "924406167"

Test #80:

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

input:

200000 1
4 1 3 2 199995 7 6 5 199993 199991 199988 199985 9 8 199981 199977 10 15 14 13 11 12 199973 199972 199970 199969 199967 199965 20 16 17 18 19 199962 23 22 21 25 24 199957 29 26 28 27 32 30 31 35 33 34 199953 199950 199946 199941 199938 40 39 37 36 38 199936 199933 199931 44 42 41 43 45 46 1...

output:

527773965

result:

ok 1 number(s): "527773965"

Test #81:

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

input:

3 2
2 1
0 1
1 3

output:

15

result:

ok 1 number(s): "15"

Test #82:

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

input:

3 3
1 2
1 2
1 3
2 3

output:

18

result:

ok 1 number(s): "18"

Test #83:

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

input:

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

output:

14

result:

ok 1 number(s): "14"

Test #84:

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

input:

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

output:

14

result:

ok 1 number(s): "14"

Test #85:

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

input:

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

output:

48

result:

ok 1 number(s): "48"

Test #86:

score: 0
Accepted
time: 91ms
memory: 69580kb

input:

200000 2
124275 43227 4823 1132 356 148 114 13 1 9 8 5 2 3 4 6 7 10 11 12 44 20 17 15 14 16 19 18 28 25 21 23 22 24 26 27 41 40 29 34 30 33 31 32 35 37 36 38 39 43 42 106 61 48 45 47 46 51 50 49 53 52 60 58 54 55 56 57 59 100 91 66 64 62 63 65 84 71 69 68 67 70 81 77 75 72 73 74 76 80 78 79 82 83 89...

output:

182581647

result:

ok 1 number(s): "182581647"

Test #87:

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

input:

200000 3
55475 15157 4293 2033 1645 1050 649 526 402 266 109 26 8 6 1 5 2 4 3 7 22 12 9 10 11 14 13 20 19 16 15 18 17 21 25 23 24 81 36 27 33 31 28 29 30 32 34 35 45 37 41 40 38 39 44 42 43 68 50 49 47 46 48 59 54 52 51 53 58 56 55 57 65 61 60 64 63 62 67 66 75 71 69 70 73 72 74 76 78 77 79 80 100 8...

output:

43886574

result:

ok 1 number(s): "43886574"

Test #88:

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

input:

200000 4
175445 72142 54296 37617 24691 23785 12914 4994 4152 4 2 1 3 2035 409 177 136 39 21 13 8 6 5 7 11 9 10 12 16 15 14 18 17 20 19 36 23 22 27 24 25 26 30 28 29 33 32 31 34 35 37 38 131 83 80 44 40 42 41 43 53 45 51 48 46 47 49 50 52 54 77 76 66 56 55 60 57 58 59 61 62 63 64 65 71 69 67 68 70 7...

output:

498767188

result:

ok 1 number(s): "498767188"

Test #89:

score: 0
Accepted
time: 84ms
memory: 69676kb

input:

200000 5
106645 97838 57664 23376 20725 10759 1247 516 172 101 65 1 57 45 21 7 4 2 3 6 5 16 15 11 8 10 9 14 13 12 19 17 18 20 39 34 33 29 24 22 23 28 27 26 25 32 31 30 35 36 37 38 40 41 44 42 43 52 50 46 49 48 47 51 54 53 55 56 62 58 59 61 60 63 64 100 94 75 70 67 66 68 69 72 71 73 74 86 82 77 76 81...

output:

613008198

result:

ok 1 number(s): "613008198"

Test #90:

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

input:

200000 2
2 1 7 6 5 3 4 199998 12 9 8 10 11 199993 13 199990 199985 199980 17 15 14 16 19 18 20 24 22 21 23 27 26 25 28 199978 33 29 31 30 32 36 35 34 199973 39 38 37 199969 43 40 41 42 44 199968 47 45 46 52 51 50 48 49 55 53 54 58 57 56 59 60 65 64 62 61 63 67 66 199965 199963 72 68 70 69 71 76 74 7...

output:

449030945

result:

ok 1 number(s): "449030945"

Test #91:

score: 0
Accepted
time: 89ms
memory: 74428kb

input:

200000 3
2 1 199995 199993 3 199989 7 4 6 5 9 8 12 11 10 15 13 14 199985 199983 199980 19 17 16 18 199978 22 21 20 199976 199973 26 23 25 24 28 27 33 29 32 30 31 199971 199968 199963 36 34 35 199962 199959 41 37 39 38 40 42 199957 199955 199950 199949 44 43 199945 47 45 46 51 50 48 49 199941 52 1999...

output:

300585770

result:

ok 1 number(s): "300585770"

Test #92:

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

input:

200000 4
1 199996 6 4 3 2 5 8 7 11 10 9 199995 12 13 17 14 16 15 199991 19 18 199987 21 20 22 24 23 199983 199978 29 27 26 25 28 199975 199974 199970 199969 33 32 30 31 38 34 36 35 37 40 39 199966 45 42 41 44 43 48 47 46 53 49 52 50 51 54 199965 57 56 55 58 199960 60 59 199957 65 64 63 61 62 67 66 7...

output:

772992430

result:

ok 1 number(s): "772992430"

Test #93:

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

input:

200000 5
1 199995 6 5 3 2 4 199993 199989 11 9 8 7 10 199988 13 12 199986 199985 199984 14 15 199983 199979 199974 16 199969 18 17 199965 199961 199959 22 20 19 21 26 23 24 25 199955 199951 27 199950 28 199945 199940 30 29 35 33 32 31 34 39 37 36 38 199936 41 40 199931 42 199930 44 43 47 45 46 50 49...

output:

713625740

result:

ok 1 number(s): "713625740"

Test #94:

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

input:

2 2
1
0 1
0 2

output:

4

result:

ok 1 number(s): "4"

Test #95:

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

input:

3 3
1 2
0 1
0 2
0 3

output:

14

result:

ok 1 number(s): "14"

Test #96:

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

input:

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

output:

48

result:

ok 1 number(s): "48"

Test #97:

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

input:

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

output:

71296

result:

ok 1 number(s): "71296"

Test #98:

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

input:

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

output:

614246259

result:

ok 1 number(s): "614246259"

Test #99:

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

input:

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

output:

490260340

result:

ok 1 number(s): "490260340"

Test #100:

score: 0
Accepted
time: 12ms
memory: 8396kb

input:

10000 10000
4195 1722 1337 767 660 561 320 27 8 4 1 2 3 7 5 6 15 11 10 9 12 14 13 18 16 17 19 26 24 21 20 23 22 25 164 62 52 36 29 28 34 30 31 32 33 35 45 37 42 40 38 39 41 44 43 46 50 48 47 49 51 61 53 54 60 58 55 56 57 59 109 70 64 63 69 65 68 67 66 99 73 72 71 75 74 87 85 79 78 76 77 84 80 83 82 ...

output:

875958203

result:

ok 1 number(s): "875958203"

Test #101:

score: 0
Accepted
time: 130ms
memory: 60800kb

input:

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

output:

646402656

result:

ok 1 number(s): "646402656"

Test #102:

score: 0
Accepted
time: 275ms
memory: 122652kb

input:

199999 199999
43677 26620 24009 1060 922 441 387 12 5 3 2 1 4 10 7 6 8 9 11 201 20 14 13 17 15 16 18 19 130 29 22 21 28 23 27 26 25 24 54 46 37 33 31 30 32 36 35 34 41 38 40 39 43 42 44 45 53 50 49 47 48 51 52 55 121 78 70 66 65 64 63 60 57 56 59 58 61 62 67 68 69 75 73 71 72 74 76 77 87 84 80 79 83...

output:

459959065

result:

ok 1 number(s): "459959065"

Test #103:

score: 0
Accepted
time: 278ms
memory: 120884kb

input:

200000 200000
23147 4701 1478 883 200 73 53 52 44 42 26 5 1 4 3 2 17 12 9 8 7 6 11 10 16 13 14 15 25 21 18 19 20 22 23 24 32 27 30 28 29 31 34 33 36 35 38 37 40 39 41 43 48 45 46 47 51 50 49 65 59 56 54 55 57 58 62 61 60 63 64 68 67 66 69 70 71 72 148 76 74 75 135 131 97 78 77 83 81 79 80 82 92 86 8...

output:

121976102

result:

ok 1 number(s): "121976102"

Test #104:

score: 0
Accepted
time: 174ms
memory: 87988kb

input:

199998 199998
5 3 2 1 4 199997 199994 199989 9 6 7 8 11 10 199984 199983 199982 16 15 13 12 14 199977 199972 199967 19 17 18 199966 20 199963 199961 22 21 27 23 25 24 26 199960 30 28 29 199959 199954 32 31 33 35 34 37 36 199953 199952 38 199950 199946 199944 199939 199938 43 40 39 42 41 47 44 45 46 ...

output:

303906212

result:

ok 1 number(s): "303906212"

Test #105:

score: 0
Accepted
time: 179ms
memory: 88016kb

input:

199999 199999
5 1 2 4 3 199995 6 199993 8 7 199988 199986 199982 11 9 10 199980 199977 199972 199967 15 13 12 14 199964 16 20 17 18 19 21 199963 199962 199959 25 24 22 23 26 199958 199957 28 27 30 29 32 31 36 35 33 34 38 37 39 42 41 40 199954 199953 47 44 43 45 46 48 51 49 50 199950 55 54 53 52 1999...

output:

891471459

result:

ok 1 number(s): "891471459"

Test #106:

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

input:

200000 200000
199998 199995 199994 199993 5 1 2 3 4 199989 7 6 199985 199980 199976 199975 199973 199972 199970 199968 10 9 8 13 12 11 199967 199962 199961 199956 199954 199950 199949 16 14 15 199947 18 17 22 20 19 21 199943 26 23 24 25 199941 199936 199932 199928 28 27 199924 199922 199921 29 19992...

output:

228098903

result:

ok 1 number(s): "228098903"

Test #107:

score: -100
Wrong Answer
time: 19ms
memory: 11300kb

input:

13327 13327
13326 6663 6185 3092 1546 773 386 193 96 48 24 12 6 3 1 2 4 5 9 7 8 10 11 18 15 13 14 16 17 21 19 20 22 23 36 30 27 25 26 28 29 33 31 32 34 35 42 39 37 38 40 41 45 43 44 46 47 72 60 54 51 49 50 52 53 57 55 56 58 59 66 63 61 62 64 65 69 67 68 70 71 84 78 75 73 74 76 77 81 79 80 82 83 90 8...

output:

428260639

result:

wrong answer 1st numbers differ - expected: '903762303', found: '428260639'