QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#489673#139. Jakarta Skyscraperswangxiu100 ✓532ms10932kbC++141.1kb2024-07-24 22:41:112024-07-24 22:41:13

詳細信息

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 2ms
memory: 9216kb

input:

1 2
0 1
0 1

output:

0

result:

ok single line: '0'

Test #2:

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

input:

6 3
0 4
0 4
1 3

output:

0

result:

ok single line: '0'

Test #3:

score: 10
Accepted
time: 1ms
memory: 9216kb

input:

7 3
3 9
5 8
0 8

output:

-1

result:

ok single line: '-1'

Test #4:

score: 10
Accepted
time: 1ms
memory: 9292kb

input:

10 3
0 1
2 3
3 9

output:

2

result:

ok single line: '2'

Test #5:

score: 10
Accepted
time: 1ms
memory: 9004kb

input:

10 3
0 2
5 1
8 3

output:

5

result:

ok single line: '5'

Test #6:

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

input:

10 3
0 1
9 1
1 1

output:

9

result:

ok single line: '9'

Subtask #2:

score: 12
Accepted

Dependency #1:

100%
Accepted

Test #7:

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

input:

37 19
20 1
21 56
1 47
27 7
24 30
29 93
3 61
10 47
1 14
18 69
27 49
13 72
4 84
23 35
31 87
2 32
1 97
15 21
26 22

output:

1

result:

ok single line: '1'

Test #8:

score: 12
Accepted
time: 1ms
memory: 9052kb

input:

59 48
36 5
14 8
5 13
17 24
15 58
20 39
44 5
53 41
12 51
22 44
51 34
3 9
4 8
57 44
43 39
12 35
19 28
3 38
8 6
50 33
53 17
37 1
54 46
25 5
38 38
4 14
5 41
12 16
13 12
37 5
17 23
38 31
22 12
18 10
48 1
5 52
19 52
55 21
56 7
44 29
32 51
56 12
6 33
4 53
30 58
18 29
20 55
9 17

output:

9

result:

ok single line: '9'

Test #9:

score: 12
Accepted
time: 1ms
memory: 9296kb

input:

100 403
22 25
49 8
56 85
50 32
82 54
26 12
83 45
78 53
6 97
4 64
74 56
29 22
91 98
99 84
77 52
14 68
31 89
8 82
23 41
79 20
68 59
52 94
21 33
64 25
40 41
82 79
91 30
37 76
45 35
85 34
63 60
94 70
34 88
62 70
9 85
97 73
31 27
48 89
58 50
9 57
10 41
96 62
22 82
60 70
7 50
86 27
41 2
74 79
34 70
62 19
...

output:

3

result:

ok single line: '3'

Test #10:

score: 12
Accepted
time: 2ms
memory: 9272kb

input:

100 2000
42 40
54 31
95 26
14 71
21 33
33 43
80 22
29 51
14 97
8 10
21 90
92 15
79 46
57 11
1 69
87 3
23 11
4 95
10 31
76 14
13 48
22 59
14 94
72 59
25 45
20 37
97 73
13 5
62 96
69 80
58 44
23 77
98 85
86 53
38 60
98 42
54 37
36 37
55 89
25 26
41 100
60 73
48 69
78 22
91 31
60 60
37 79
76 29
90 88
5...

output:

1

result:

ok single line: '1'

Test #11:

score: 12
Accepted
time: 1ms
memory: 9236kb

input:

100 2000
0 2
91 1
98 3
5 5
85 7
1 11
67 13
67 17
67 19
67 23
67 29
9 31
9 37
9 41
91 43
91 47
91 53
91 59
91 61
91 67
91 71
91 73
91 79
91 83
91 89
91 97
91 1
91 1
91 1
91 1
91 1
91 1
91 1
91 1
91 1
91 1
91 1
91 1
91 1
91 1
91 1
91 1
91 1
91 1
91 1
91 1
91 1
91 1
91 1
91 1
91 1
91 1
91 1
91 1
91 1
9...

output:

118

result:

ok single line: '118'

Test #12:

score: 12
Accepted
time: 2ms
memory: 9304kb

input:

100 2000
0 1
99 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
67 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98 1
98...

output:

99

result:

ok single line: '99'

Test #13:

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

input:

100 2000
0 1
59 1
5 56
39 42
10 48
7 34
14 39
52 62
28 41
25 62
7 58
31 63
44 45
21 61
14 36
2 51
20 46
19 61
35 62
6 16
30 46
22 33
0 12
10 33
8 59
47 62
5 59
49 52
3 63
17 33
4 53
17 35
36 41
32 39
1 59
40 53
22 34
11 30
48 54
13 35
27 33
44 62
36 58
52 59
29 62
19 36
16 20
13 45
30 42
12 34
6 60
...

output:

59

result:

ok single line: '59'

Test #14:

score: 12
Accepted
time: 2ms
memory: 9108kb

input:

100 2000
0 1
99 1
2 60
1 59
0 14
10 22
30 31
45 58
47 62
34 43
58 60
26 35
2 61
41 53
53 58
1 64
9 46
11 27
2 23
7 64
17 47
16 25
3 50
15 41
2 27
33 34
11 28
2 49
26 47
0 62
44 63
24 34
60 63
61 63
0 26
1 50
42 57
44 45
1 24
8 25
36 63
27 56
53 59
28 32
2 12
42 44
32 37
30 46
3 31
7 11
19 41
4 18
12...

output:

2

result:

ok single line: '2'

Subtask #3:

score: 14
Accepted

Dependency #2:

100%
Accepted

Test #15:

score: 14
Accepted
time: 2ms
memory: 8972kb

input:

200 1522
113 197
195 179
101 45
39 93
58 96
99 70
26 30
14 118
47 38
52 38
122 14
36 100
51 121
175 5
128 65
85 126
42 10
165 136
169 30
148 53
37 133
116 158
48 29
118 20
18 81
112 7
199 59
127 178
168 16
23 79
7 103
172 94
142 90
110 52
124 45
70 51
165 85
167 102
93 99
129 41
98 169
29 55
144 172...

output:

4

result:

ok single line: '4'

Test #16:

score: 14
Accepted
time: 0ms
memory: 9304kb

input:

2000 2000
1998 2
1 1
0 3
1999 1
612 939
784 1712
1777 1065
1617 1270
1758 572
1476 1617
572 1606
286 1583
1108 566
367 511
1755 998
766 1701
1088 1905
1133 963
1230 1559
1513 686
1564 1874
52 506
1676 960
1047 1274
1934 504
1345 1512
422 1181
1044 1258
991 977
1579 776
1965 1112
1291 971
453 1982
12...

output:

42

result:

ok single line: '42'

Test #17:

score: 14
Accepted
time: 2ms
memory: 9304kb

input:

2000 2000
0 2
1999 1
1998 3
3 5
1993 5
1993 7
1993 7
5 9
1985 9
1985 11
1985 11
49 13
1999 13
1999 15
1999 15
79 17
1915 17
11 19
1987 19
1987 21
1987 21
55 23
1757 23
1757 25
1957 25
7 27
1681 27
1681 29
1855 29
637 31
1691 31
17 33
1997 33
1997 35
1997 35
37 37
1961 37
1961 39
1961 39
245 41
1885 ...

output:

2892

result:

ok single line: '2892'

Test #18:

score: 14
Accepted
time: 2ms
memory: 9108kb

input:

2000 2000
0 2
1607 1
1998 3
3 5
1993 7
5 11
1985 13
35 17
1939 19
1 23
1841 29
101 31
1961 37
37 41
1759 43
125 47
1817 53
121 59
1891 61
427 67
695 71
127 73
1879 79
931 83
1927 89
325 97
1877 101
59 103
265 107
265 109
1355 113
1129 127
1637 131
65 137
1709 139
41 149
935 151
29 157
1285 163
959 1...

output:

3340

result:

ok single line: '3340'

Test #19:

score: 14
Accepted
time: 0ms
memory: 9144kb

input:

2000 2000
461 538
0 1
307 346
833 1999
436 564
1395 1999
242 253
414 529
1281 1999
575 1999
1164 1999
260 295
280 288
276 290
633 1999
1921 92
1639 426
668 1999
1933 81
344 349
1775 227
743 1999
1764 255
1416 1999
5 9
1826 203
1721 288
813 1999
1214 1999
315 337
839 1999
1326 1999
1352 1999
1258 199...

output:

17769

result:

ok single line: '17769'

Test #20:

score: 14
Accepted
time: 0ms
memory: 9432kb

input:

2000 746
0 1
1888 1
10 32
26 35
3 10
19 37
21 33
36 38
32 40
3 31
26 31
19 29
17 33
9 18
0 35
3 25
21 30
6 30
0 14
6 13
4 15
0 26
2 39
18 24
11 34
13 21
20 34
6 39
3 19
19 36
12 27
27 39
7 25
5 12
15 22
10 28
2 20
20 37
11 26
17 19
31 34
5 35
13 16
0 33
16 25
10 19
24 27
9 30
14 29
23 35
1 24
26 30
...

output:

1888

result:

ok single line: '1888'

Test #21:

score: 14
Accepted
time: 2ms
memory: 9088kb

input:

2000 182
0 1
1928 1
18 25
23 26
6 27
19 27
14 21
6 24
17 22
0 27
5 22
13 26
6 21
21 27
2 21
14 26
4 25
2 27
1 24
26 27
19 24
9 24
18 27
12 23
1 27
1 25
20 25
14 27
10 25
20 26
6 20
10 24
7 27
11 20
19 20
12 27
18 21
15 24
16 20
17 23
0 25
15 27
6 25
9 22
15 20
18 20
10 26
6 22
3 24
16 22
2 20
15 22
...

output:

1928

result:

ok single line: '1928'

Test #22:

score: 14
Accepted
time: 0ms
memory: 9104kb

input:

2000 586
0 1
1446 1
20 44
14 40
11 32
8 42
27 34
27 30
28 45
22 38
3 35
5 45
28 42
17 30
13 33
21 30
19 39
36 44
30 38
29 32
16 37
20 33
10 42
33 43
21 41
27 32
36 40
18 38
14 41
32 35
42 43
1 31
7 44
28 30
23 40
18 30
6 34
33 44
40 45
21 45
5 42
11 44
27 38
20 43
25 32
27 36
40 43
44 45
37 41
14 38...

output:

1446

result:

ok single line: '1446'

Test #23:

score: 14
Accepted
time: 0ms
memory: 9352kb

input:

2000 486
0 1
1669 1
30 45
41 48
4 44
25 50
36 43
11 40
44 50
5 41
32 45
37 46
39 41
3 46
18 42
34 49
3 42
8 44
31 49
36 50
35 50
22 47
20 42
17 45
39 40
31 41
40 41
39 48
15 47
2 49
25 46
23 46
42 49
40 48
10 44
2 45
2 50
26 40
10 42
42 43
22 46
45 48
1 50
29 42
12 41
26 41
6 41
4 46
25 49
28 43
14 ...

output:

1669

result:

ok single line: '1669'

Test #24:

score: 14
Accepted
time: 3ms
memory: 9140kb

input:

2000 2000
0 1
1679 1
8 29
21 42
2 56
5 35
2 38
3 44
15 21
18 39
3 64
38 63
45 55
13 53
48 53
50 51
27 63
23 56
6 47
14 60
44 53
36 41
33 34
46 57
7 63
15 43
17 32
10 47
27 36
32 57
24 62
29 57
7 64
7 10
3 37
10 61
2 58
10 15
1 61
37 55
47 49
50 63
4 10
19 56
0 43
34 40
10 21
21 59
38 55
4 63
34 49
2...

output:

1679

result:

ok single line: '1679'

Test #25:

score: 14
Accepted
time: 3ms
memory: 9436kb

input:

2000 2000
0 1
1999 1
27 62
18 63
50 59
40 49
9 30
15 22
10 64
4 28
4 53
4 15
15 40
22 37
2 21
16 30
34 54
33 57
0 55
42 55
25 63
22 47
22 50
10 47
17 59
44 45
36 37
0 56
13 52
19 44
2 9
33 53
31 38
21 32
14 59
18 37
50 58
12 28
3 45
42 49
17 60
43 62
9 57
29 49
17 29
15 45
4 55
38 57
13 36
9 46
1 6
...

output:

32

result:

ok single line: '32'

Test #26:

score: 14
Accepted
time: 2ms
memory: 9328kb

input:

742 1742
629 8
197 315
463 116
563 50
539 228
544 95
496 127
556 66
76 192
578 100
453 161
87 419
487 1
192 382
111 185
104 92
73 73
352 109
416 4
132 218
545 265
493 302
80 382
295 140
282 384
171 29
622 395
645 208
225 176
206 88
138 364
249 110
34 115
553 141
266 340
80 51
96 206
417 329
741 269
...

output:

4

result:

ok single line: '4'

Test #27:

score: 14
Accepted
time: 2ms
memory: 9032kb

input:

1747 1894
1401 934
1659 215
950 454
40 250
457 1018
611 1195
1557 495
787 120
1573 1554
1620 1046
1388 1097
623 1735
1493 875
1659 87
482 1666
1544 990
126 112
1507 774
1128 1158
1710 928
142 294
1076 1853
242 1872
377 986
689 582
1685 1235
1206 938
287 608
1736 404
1094 368
138 1627
40 1070
1398 50...

output:

-1

result:

ok single line: '-1'

Test #28:

score: 14
Accepted
time: 1ms
memory: 9088kb

input:

2000 737
743 395
795 416
1023 1227
60 803
408 308
1168 428
823 1016
477 434
929 417
1223 784
715 1862
1872 649
203 1874
517 1748
586 1404
835 1231
1883 1466
899 1625
1247 1795
1456 1569
1416 1728
1201 1723
1333 848
1669 1427
1081 143
1956 1925
1900 1955
1845 456
697 1434
949 1803
288 1902
1841 1474
...

output:

-1

result:

ok single line: '-1'

Test #29:

score: 14
Accepted
time: 4ms
memory: 9384kb

input:

2000 2000
0 1
1999 1
1100 1
1402 1
1120 1
1720 1
1362 1
1718 1
84 1
161 1
1449 1
737 1
813 1
647 1
1815 1
207 1
312 1
1922 1
1231 1
1445 1
1291 1
52 1
1028 1
950 1
227 1
490 1
1869 1
791 1
1085 1
640 1
1857 1
408 1
936 1
1952 1
1540 1
1673 1
1283 1
903 1
467 1
1071 1
1884 1
1547 1
852 1
1316 1
424 1...

output:

1999

result:

ok single line: '1999'

Test #30:

score: 14
Accepted
time: 2ms
memory: 9268kb

input:

465 1659
102 726
376 145
119 1954
255 459
405 1780
1 1755
298 1588
424 348
422 1571
386 1520
184 623
137 1566
340 1057
152 1365
176 177
323 440
397 643
121 1885
262 1236
223 413
82 1861
377 1671
382 883
250 1664
144 465
122 709
311 431
401 941
79 1533
271 243
132 1431
241 1563
62 437
325 1889
201 18...

output:

-1

result:

ok single line: '-1'

Test #31:

score: 14
Accepted
time: 1ms
memory: 9016kb

input:

449 801
227 1422
431 1937
163 1920
322 1179
91 540
287 803
250 918
303 130
240 500
90 225
16 1
139 1297
343 1621
198 787
192 651
341 279
127 558
187 1041
185 549
219 744
342 1208
169 1364
1 480
112 1858
28 805
115 1571
106 150
380 1923
25 1296
196 1792
396 1909
382 824
417 15
414 731
131 1686
230 10...

output:

-1

result:

ok single line: '-1'

Test #32:

score: 14
Accepted
time: 1ms
memory: 9268kb

input:

1623 911
1046 1831
1119 1899
882 1446
84 615
25 1443
883 140
257 1211
797 1672
1470 1056
1451 1121
1588 401
937 1322
377 1097
384 1959
1038 1969
907 1483
851 357
174 23
822 1267
1509 931
870 75
1194 149
1402 459
1143 1188
900 682
1280 1855
68 995
867 1763
466 239
1060 406
769 1900
528 1558
243 867
9...

output:

-1

result:

ok single line: '-1'

Test #33:

score: 14
Accepted
time: 0ms
memory: 9008kb

input:

1842 1600
670 360
1728 121
1022 1888
409 1618
1442 141
521 628
115 1245
1267 705
523 238
1349 415
1626 38
834 874
1375 246
755 1867
1798 1479
887 395
1457 1770
1193 1373
1030 1113
1719 384
842 1186
344 1920
1351 937
1646 942
777 1479
1632 192
551 1965
148 1675
1197 824
391 1093
1216 681
49 1629
915 ...

output:

35

result:

ok single line: '35'

Subtask #4:

score: 21
Accepted

Dependency #3:

100%
Accepted

Test #34:

score: 21
Accepted
time: 2ms
memory: 9360kb

input:

1345 27521
838 1311
847 689
179 425
418 932
1219 1803
103 1546
12 1553
1181 1482
252 1815
615 1335
824 289
912 1673
154 438
94 375
802 1587
433 1404
503 98
402 973
1260 635
809 1960
24 529
832 176
441 1827
1080 1952
745 359
1324 274
288 1096
814 1545
394 775
1258 1055
589 401
1011 586
89 1767
759 17...

output:

3

result:

ok single line: '3'

Test #35:

score: 21
Accepted
time: 35ms
memory: 9256kb

input:

2000 30000
0 1
1999 1
1998 1
1998 1
1028 1
1998 1
1998 1
1998 1
1998 1
1998 1
1998 1
1998 1
1998 1
1998 1
1998 1
1998 1
1998 1
1998 1
1998 1
1998 1
1998 1
1998 1
1998 1
1998 1
1998 1
1998 1
1998 1
1998 1
1785 1
1998 1
1998 1
1998 1
1004 1
1998 1
1998 1
1998 1
1998 1
1998 1
1976 1
1998 1
1998 1
1998 ...

output:

1999

result:

ok single line: '1999'

Test #36:

score: 21
Accepted
time: 6ms
memory: 9592kb

input:

2000 30000
0 1
1679 1
47 62
75 116
70 196
91 106
117 218
8 29
12 55
34 222
52 178
40 50
28 98
26 131
55 200
125 208
26 48
40 241
54 150
211 222
111 184
40 238
2 173
48 144
26 67
17 28
8 148
52 148
185 196
79 108
88 117
36 127
144 193
132 165
87 203
77 193
25 233
50 230
88 170
98 149
45 146
133 194
4...

output:

1679

result:

ok single line: '1679'

Test #37:

score: 21
Accepted
time: 5ms
memory: 9400kb

input:

2000 30000
0 1
1999 1
213 229
84 230
19 117
146 203
203 234
36 213
111 216
107 110
67 230
89 96
84 133
33 65
13 242
10 232
62 95
154 176
127 186
182 184
12 13
57 137
184 230
84 91
135 187
170 212
130 143
60 150
85 113
64 199
46 125
39 213
82 120
26 77
41 67
13 72
103 179
88 202
110 230
9 144
169 225...

output:

9

result:

ok single line: '9'

Test #38:

score: 21
Accepted
time: 4ms
memory: 9360kb

input:

1036 26882
526 46
386 1332
183 1351
353 76
105 340
598 811
830 209
572 1392
633 1758
314 1914
730 1829
752 117
846 97
948 1903
589 55
684 1978
461 569
372 243
78 1803
436 1616
613 1385
48 19
182 808
140 669
249 162
695 557
857 1427
764 726
492 1241
56 283
145 1329
333 615
731 522
177 1783
1021 1338
...

output:

3

result:

ok single line: '3'

Test #39:

score: 21
Accepted
time: 4ms
memory: 9296kb

input:

1938 19374
1588 470
1091 326
1240 648
840 498
964 159
197 838
1260 451
833 456
1000 449
21 893
1245 914
1755 35
1057 580
1633 728
336 66
728 409
1802 41
459 773
1856 702
1051 12
1617 96
1166 803
903 156
1676 444
1088 898
264 555
594 109
729 625
1075 411
1877 473
1097 720
230 356
1806 603
637 340
173...

output:

3

result:

ok single line: '3'

Test #40:

score: 21
Accepted
time: 5ms
memory: 9584kb

input:

1997 29997
1550 882
1655 827
1335 97
1413 118
649 755
256 505
505 1228
473 834
19 1442
568 1357
884 309
582 1809
1410 474
588 256
1011 867
420 96
320 1359
1716 1535
1544 102
1191 1331
1217 556
908 46
444 455
718 511
1754 99
414 1246
1133 819
987 1911
1248 600
350 414
647 75
1127 1955
1144 251
552 93...

output:

4

result:

ok single line: '4'

Test #41:

score: 21
Accepted
time: 5ms
memory: 9356kb

input:

2000 30000
316 244
229 1111
186 1248
887 1306
1635 815
1431 1085
142 1902
234 380
589 785
577 1264
1527 535
1707 31
1022 1498
540 94
736 1881
821 1112
247 1597
1120 890
292 1508
69 248
597 843
1450 656
1390 203
214 1219
1066 197
316 379
1091 186
1490 908
656 1037
644 772
1494 1783
686 483
844 1443
1...

output:

3

result:

ok single line: '3'

Test #42:

score: 21
Accepted
time: 5ms
memory: 9360kb

input:

2000 30000
1998 2
1 1
0 3
1999 1
493 364
1735 475
535 174
1091 405
1588 1223
1783 248
690 454
363 540
814 138
1294 1501
1609 166
1603 498
1990 626
1535 811
1624 134
1350 1202
1806 1714
1582 1749
1563 1186
1319 597
1400 1590
1143 814
380 770
1475 551
359 1281
748 1823
139 1847
1604 1457
1541 1053
135...

output:

3

result:

ok single line: '3'

Test #43:

score: 21
Accepted
time: 5ms
memory: 9408kb

input:

1999 30000
1997 2
1 1
0 3
1998 1
1539 694
564 1180
257 1279
594 441
549 1765
1111 642
1289 886
254 1229
412 533
62 1710
574 1183
588 1892
1368 62
926 1541
226 158
294 1161
994 941
129 899
1839 522
498 444
1725 1096
1686 301
1304 1700
1385 367
1393 1134
1376 1944
1456 197
960 1037
1690 1184
1782 1182...

output:

3

result:

ok single line: '3'

Test #44:

score: 21
Accepted
time: 4ms
memory: 9420kb

input:

2000 30000
0 2
1999 1
1998 3
3 5
1993 5
1993 7
1993 7
5 9
1985 9
1985 11
1985 11
49 13
1999 13
1999 15
1999 15
79 17
1915 17
11 19
1987 19
1987 21
1987 21
55 23
1757 23
1757 25
1957 25
7 27
1681 27
1681 29
1855 29
637 31
1691 31
17 33
1997 33
1997 35
1997 35
37 37
1961 37
1961 39
1961 39
245 41
1885...

output:

2892

result:

ok single line: '2892'

Test #45:

score: 21
Accepted
time: 2ms
memory: 9136kb

input:

2000 30000
0 2
1607 1
1998 3
3 5
1993 7
5 11
1985 13
35 17
1939 19
1 23
1841 29
101 31
1961 37
37 41
1759 43
125 47
1817 53
121 59
1891 61
427 67
695 71
127 73
1879 79
931 83
1927 89
325 97
1877 101
59 103
265 107
265 109
1355 113
1129 127
1637 131
65 137
1709 139
41 149
935 151
29 157
1285 163
959 ...

output:

3340

result:

ok single line: '3340'

Subtask #5:

score: 43
Accepted

Dependency #4:

100%
Accepted

Test #46:

score: 43
Accepted
time: 3ms
memory: 9616kb

input:

12345 24321
11829 2257
2931 428
1065 506
11674 320
4070 1339
11412 810
10176 413
8329 1771
2775 532
2152 1970
7115 2143
3016 830
8231 1343
3165 924
3122 1458
8180 1641
3712 92
3398 440
1979 830
3718 2271
11355 2233
2337 122
10576 893
7463 123
6367 820
1220 1814
11577 993
6599 1352
8089 1871
9813 335...

output:

7

result:

ok single line: '7'

Test #47:

score: 43
Accepted
time: 532ms
memory: 10060kb

input:

30000 30000
0 1
29999 1
25731 1
29123 1
3075 1
8459 1
21393 1
12080 1
26159 1
6963 1
721 1
20222 1
1087 1
2227 1
23601 1
14373 1
19590 1
29916 1
16320 1
25517 1
22659 1
8788 1
3293 1
19131 1
16801 1
4501 1
5324 1
282 1
14439 1
22176 1
13072 1
9017 1
16666 1
19743 1
1828 1
8478 1
3123 1
13442 1
3029 ...

output:

29999

result:

ok single line: '29999'

Test #48:

score: 43
Accepted
time: 3ms
memory: 9244kb

input:

30000 2471
1 2
0 29997
9516 11
11616 31
15376 47
23359 19
6802 47
14899 31
14911 13
4004 31
13888 19
779 3
5571 29
5133 31
14911 31
11811 59
2773 11
22836 11
143 11
1430 7
6825 47
21244 5
8075 17
12240 13
28132 41
4141 37
9102 59
11918 29
5829 41
14063 17
26945 59
13275 47
6721 17
11526 17
18683 11
...

output:

47

result:

ok single line: '47'

Test #49:

score: 43
Accepted
time: 527ms
memory: 9320kb

input:

30000 30000
0 2
29999 1
29998 3
1 9
1 9
1 15
1 15
1 21
1 21
1 27
1 27
1 33
1 33
1 39
1 39
1 45
1 45
1 51
1 51
1 57
1 57
1 63
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
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:

54996

result:

ok single line: '54996'

Test #50:

score: 43
Accepted
time: 6ms
memory: 9532kb

input:

30000 30000
0 2
29999 1
29998 3
1 5
29991 5
29991 7
29991 7
3 9
29973 9
29973 11
29973 11
9 13
29987 13
29987 15
29987 15
47 17
29967 17
29967 19
29967 19
23 21
29969 21
29969 23
29969 23
69 25
29769 25
29769 27
29985 27
15 29
29943 29
29943 31
29943 31
245 33
29945 33
179 35
29999 35
29999 37
29999...

output:

56832

result:

ok single line: '56832'

Test #51:

score: 43
Accepted
time: 3ms
memory: 9252kb

input:

30000 30000
0 2
29999 1
29998 3
1 5
29991 5
29991 7
29991 7
3 9
29973 9
29973 11
29973 11
9 13
29987 13
29987 15
29987 15
47 17
29967 17
29967 19
29967 19
23 21
29969 21
29969 23
29969 23
69 25
29769 25
29769 27
29985 27
15 29
29943 29
29943 31
29943 31
245 33
29945 33
179 35
29999 35
29999 37
29999...

output:

56832

result:

ok single line: '56832'

Test #52:

score: 43
Accepted
time: 3ms
memory: 9252kb

input:

30000 30000
0 2
24989 1
29998 3
1 5
29991 7
3 11
29967 13
15 17
29969 19
63 23
29825 29
303 31
29939 37
413 41
29933 43
5 47
29897 53
323 59
29705 61
425 67
28967 71
567 73
29913 79
209 83
29757 89
387 97
29099 101
617 103
27603 107
1709 109
29177 113
23 127
28217 131
183 137
29775 139
29 149
29829 ...

output:

45814

result:

ok single line: '45814'

Test #53:

score: 43
Accepted
time: 3ms
memory: 10228kb

input:

30000 30000
6605 8395
0 1
29055 969
2347 2514
21396 29999
26177 4363
21519 29999
5604 6263
18074 29999
19666 29999
8689 29999
4964 5018
16074 29999
24682 6171
13617 29999
19753 29999
15422 29999
6614 8386
24400 6266
28422 1580
8983 29999
21365 29999
16873 29999
11628 29999
11206 29999
2956 3010
1925...

output:

417046

result:

ok single line: '417046'

Test #54:

score: 43
Accepted
time: 526ms
memory: 10064kb

input:

30000 30000
0 1
29999 1
29997 2
3 1
4 1
5 1
6 1
7 1
8 1
9 1
10 1
11 1
12 1
13 1
14 1
15 1
16 1
17 1
18 1
19 1
20 1
21 1
22 1
23 1
24 1
25 1
26 1
27 1
28 1
29 1
30 1
31 1
32 1
33 1
34 1
35 1
36 1
37 1
38 1
39 1
40 1
41 1
42 1
43 1
44 1
45 1
46 1
47 1
48 1
49 1
50 1
51 1
52 1
53 1
54 1
55 1
56 1
57 1
...

output:

29998

result:

ok single line: '29998'

Test #55:

score: 43
Accepted
time: 22ms
memory: 9852kb

input:

30000 30000
0 1
24012 1
280 515
196 341
258 349
122 330
168 289
487 497
218 348
250 582
82 379
9 273
49 366
73 502
37 421
204 440
258 423
123 230
197 573
143 368
173 593
248 482
258 390
149 559
206 489
199 336
390 506
292 455
264 416
389 491
330 346
263 534
247 565
53 215
486 526
494 537
257 287
476...

output:

24012

result:

ok single line: '24012'

Test #56:

score: 43
Accepted
time: 19ms
memory: 10932kb

input:

30000 30000
0 1
17722 1
50 261
193 403
252 395
166 368
5 444
236 327
369 370
242 266
39 259
268 359
69 382
159 271
172 275
162 417
44 389
201 343
289 431
56 295
342 392
224 310
305 367
350 411
47 418
83 352
200 315
420 437
138 379
174 217
365 402
62 406
231 351
421 438
127 441
4 378
53 219
257 361
4...

output:

17722

result:

ok single line: '17722'

Test #57:

score: 43
Accepted
time: 0ms
memory: 9644kb

input:

23221 22370
10253 9226
20937 18122
1001 23170
3307 8715
23035 5417
10029 11660
15840 22300
9031 8708
20565 4436
21360 7187
14623 7747
16073 13103
12538 13206
9072 10651
4438 10729
4439 3468
461 7484
6021 6992
15963 2134
8252 16897
16585 14434
10613 17709
6252 5918
14367 1503
2770 135
1972 4876
7065 ...

output:

25

result:

ok single line: '25'

Test #58:

score: 43
Accepted
time: 28ms
memory: 10840kb

input:

30000 30000
0 1
29991 1
62 326
115 305
35 177
14 160
263 304
74 111
35 217
150 241
27 302
181 305
97 108
78 165
189 326
277 304
108 132
67 282
179 300
142 214
250 322
94 158
120 285
18 347
86 237
117 268
91 179
188 222
85 173
208 287
306 334
214 252
102 281
8 244
147 253
197 198
126 271
111 199
273 ...

output:

29991

result:

ok single line: '29991'

Test #59:

score: 43
Accepted
time: 39ms
memory: 10856kb

input:

30000 30000
0 1
27719 1
122 176
39 194
1 112
85 102
46 225
78 152
60 245
6 174
9 210
120 208
8 169
29 127
88 207
140 157
35 50
53 72
58 153
140 219
101 116
94 162
68 163
130 134
115 143
96 100
159 233
69 246
126 244
25 155
6 220
42 88
64 220
16 209
69 100
87 186
113 235
37 187
128 206
31 155
206 215...

output:

27719

result:

ok single line: '27719'

Test #60:

score: 43
Accepted
time: 25ms
memory: 10836kb

input:

30000 30000
0 1
29999 1
30 107
239 243
86 88
48 227
15 199
44 107
73 186
56 63
162 189
80 180
40 61
138 242
57 204
108 232
117 145
71 175
33 101
115 207
1 124
39 245
0 4
87 177
161 225
47 132
44 69
11 154
37 176
12 158
123 208
18 75
15 54
43 203
154 227
85 232
70 71
18 199
68 214
84 245
19 90
206 22...

output:

123

result:

ok single line: '123'

Test #61:

score: 43
Accepted
time: 0ms
memory: 9644kb

input:

22399 29399
5808 29654
8026 11299
7070 19610
16503 7758
19113 16982
17457 6126
17976 27551
18084 10028
3140 19775
17358 1113
3213 10504
2807 18078
5573 9284
6328 3285
8089 3221
12912 13156
5354 7480
21768 7437
16758 29446
9513 3568
15961 24387
16255 13971
17597 20408
3954 3981
18130 23920
12376 89
1...

output:

20

result:

ok single line: '20'

Test #62:

score: 43
Accepted
time: 4ms
memory: 9616kb

input:

15108 22344
11828 17001
4298 21462
13616 3967
11764 28505
12987 5809
11656 9555
9250 17608
1362 6220
8552 15292
12129 29474
6733 26950
8804 15882
4711 10929
1373 13718
8455 4300
1729 18446
14089 22260
7037 17321
8075 9473
11269 13790
10252 26612
14467 7576
2805 11935
6902 5525
3903 12019
9753 25808
...

output:

-1

result:

ok single line: '-1'

Test #63:

score: 43
Accepted
time: 4ms
memory: 9968kb

input:

30000 30000
28015 3113
15640 9063
6654 23019
5274 260
7 11225
4116 27873
6878 24762
14746 12757
11797 22554
16455 17817
10584 12034
24264 1161
28122 27402
29676 24186
3205 28108
1555 2286
16500 22409
16409 25853
15787 12508
26802 1662
6166 17567
4367 6536
10846 26636
19537 8625
13393 29374
1411 2550...

output:

19

result:

ok single line: '19'

Test #64:

score: 43
Accepted
time: 10ms
memory: 9816kb

input:

30000 30000
29998 2
1 1
0 3
29999 1
19696 855
9857 13617
22860 6865
8152 22387
11047 1270
26970 26185
3674 17305
11460 23944
6079 9005
2863 17046
28013 6737
20923 23140
2114 24557
22268 1920
6876 15823
25450 18613
17665 875
11668 24999
19817 15990
24136 15894
21137 22158
12515 8256
7003 24082
28913 ...

output:

20

result:

ok single line: '20'

Test #65:

score: 43
Accepted
time: 7ms
memory: 9716kb

input:

30000 30000
29998 2
1 1
0 3
29999 1
18494 27896
429 28607
18654 27073
8106 25831
23215 27558
14726 29792
27498 26844
1997 26270
26002 25986
19781 28489
16994 27840
18993 26587
26933 27444
1067 26095
5578 27832
1077 26111
27665 25163
23167 26318
11833 25761
8763 26911
23398 25239
25229 29579
8796 264...

output:

23685

result:

ok single line: '23685'

Test #66:

score: 43
Accepted
time: 3ms
memory: 9180kb

input:

29999 2
110 2
17 2

output:

-1

result:

ok single line: '-1'

Test #67:

score: 43
Accepted
time: 3ms
memory: 9184kb

input:

30000 4
29998 2
1 1
0 3
29999 1

output:

-1

result:

ok single line: '-1'

Extra Test:

score: 0
Extra Test Passed