CT31693

Farmer's Insertion Slot Ledger

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

In the thorn maze of Bramblecourt, Farmer the chronicler keeps careful count of the shelves. Verify the safety inspections, every figure matters. Task: The array is sorted non-decreasing. Print the 1-based position where x would be inserted to keep the order (before equal values). Input format: First line: n and x. Second line: n sorted integers. Output format: Print the insertion position (1..n+1). Constraints: 1 <= n <= 10469; 0 <= a[i],x <= 1000.

Example 1:

Input: 941 607 2 2 3 3 4 4 4 4 6 7 8 10 10 10 10 11 13 13 17 18 19 20 22 23 24 28 30 30 30 31 33 35 36 37 38 41 41 44 45 45 47 48 49 50 50 50 56 58 60 61 61 61 62 63 64 66 68 68 68 68 70 71 73 73 76 77 77 82 82 83 84 84 85 85 86 87 87 89 91 92 93 94 95 98 99 99 101 101 102 102 104 105 106 107 109 110 110 116 117 117 118 118 118 118 120 120 121 122 122 127 129 129 131 132 133 135 135 136 136 138 140 144 144 145 145 148 150 153 153 160 164 165 166 166 167 167 167 167 168 169 170 171 173 173 175 176 177 178 178 179 180 182 186 187 189 189 190 190 190 193 193 196 197 198 199 205 206 206 208 209 210 213 215 216 216 218 218 218 219 220 220 221 221 221 222 223 223 224 224 225 225 225 226 227 229 230 231 231 232 232 233 235 236 236 238 240 241 241 241 242 242 242 243 243 243 246 246 248 248 248 248 250 2…
Output: 545

Example 2:

Input: 5690 348 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 2 2 2 2 2 3 3 3 3 4 5 5 6 6 6 6 6 6 7 7 7 7 7 7 8 8 8 8 8 8 8 8 8 9 9 10 10 10 11 11 11 11 12 12 12 12 12 13 13 13 13 13 13 13 14 14 14 14 14 14 14 15 15 15 15 16 16 16 17 17 17 18 18 18 18 18 18 18 19 19 19 19 19 19 19 19 19 20 20 20 20 21 21 21 21 22 22 22 22 22 23 23 23 23 24 24 25 25 25 25 25 25 25 25 25 26 26 26 26 26 26 26 26 27 27 27 27 28 28 28 28 28 28 28 28 28 28 28 28 29 29 29 29 29 29 30 30 30 30 30 30 30 31 31 31 31 32 32 32 33 33 33 34 34 34 34 34 35 35 35 35 35 35 35 36 36 36 36 36 37 37 37 37 38 38 38 38 38 38 38 38 38 39 39 40 40 40 40 40 40 40 40 40 40 41 41 41 41 41 41 41 42 43 43 43 43 43 43 43 44 44 44 45 45 45 45 45 46 46 46 46 46 46 46 46 46 46 47 47 47 47 47 48 48 48 48 48 48 48 49 50 50 50 50 50 51 51 51 51 51 51 51 51 51 51…
Output: 1984

Example 3:

Input: 185 200 8 8 12 24 27 47 49 59 61 63 68 71 73 73 78 88 92 96 101 108 109 126 130 133 133 136 144 154 157 157 183 207 213 215 221 222 223 227 238 238 240 257 257 273 279 279 281 290 291 305 314 321 325 327 328 341 372 383 388 388 392 398 401 405 408 417 421 422 422 432 441 441 442 451 454 456 458 465 469 472 478 480 485 489 492 495 495 495 496 498 503 505 506 507 517 519 521 521 522 523 525 527 529 529 540 561 579 582 592 594 612 632 646 655 659 664 665 665 674 697 704 704 705 718 718 726 727 727 728 732 740 755 757 758 760 764 774 780 787 792 800 802 803 806 809 812 816 835 840 844 862 862 867 869 876 879 883 888 895 896 902 906 907 914 916 919 927 927 930 932 933 935 937 937 944 960 967 977 980 981 984 991 993 994 998
Output: 32

Constraints:

1 <= n <= 10469; 0 <= a[i],x <= 1000.

Loading...
Test Cases:No test cases
No test cases available.