CT33613

Bram Counts the shelves

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The council of the fox den of Rustwood pays by the answer, and Bram intends to earn it. First: the full register of shelves. Task: The array is sorted in non-decreasing order. Print the 1-based index of the first occurrence of x, or -1 if x is absent. Input format: First line: n and x. Second line: n sorted integers. Output format: Print the 1-based index or -1. Constraints: 1 <= n <= 13798; 0 <= a[i],x <= 1000.

Example 1:

Input: 1251 526 0 4 4 6 7 8 8 9 9 10 10 12 13 13 14 14 15 15 16 16 17 18 20 20 21 21 22 23 23 23 26 26 26 27 28 28 28 29 30 31 31 32 34 36 36 38 38 39 41 42 42 43 43 43 44 44 45 46 46 46 47 47 47 48 49 50 50 51 53 53 53 54 55 55 55 55 56 57 59 59 59 62 62 63 65 65 67 68 69 70 70 71 71 73 75 75 76 77 78 79 82 82 84 85 85 85 86 87 87 88 90 91 91 93 94 96 97 97 97 98 98 99 100 101 101 101 101 102 102 102 102 105 105 105 106 107 108 108 108 108 109 110 111 111 111 112 112 113 114 114 118 118 118 118 120 121 121 123 123 125 125 125 127 127 128 129 129 129 130 131 133 133 134 134 134 135 137 139 143 144 145 145 145 146 146 150 150 150 152 152 152 153 154 154 154 155 156 156 157 157 157 158 159 160 163 163 163 165 166 166 167 167 168 168 168 168 169 170 170 171 171 171 172 172 172 173 173 173 173 174 17…
Output: 678

Example 2:

Input: 720 885 0 0 1 6 9 10 11 13 14 14 15 15 15 17 17 18 19 20 20 21 25 25 25 26 28 28 29 29 32 32 34 34 35 35 37 40 43 44 45 46 47 48 48 50 52 53 55 55 57 58 61 65 66 67 70 70 71 73 74 74 78 80 80 80 81 81 81 81 82 82 85 86 86 87 87 91 93 94 98 98 99 99 101 102 103 105 109 113 113 115 116 118 119 120 122 123 123 125 126 127 128 130 131 132 132 133 134 134 136 137 138 138 139 142 142 142 143 146 147 148 148 148 150 151 156 156 157 157 157 158 158 159 160 163 164 165 165 170 171 175 177 177 177 177 179 179 180 180 181 181 182 183 185 185 186 187 190 191 191 193 193 196 196 198 200 202 203 203 203 204 206 206 207 209 209 214 218 219 221 221 222 222 224 224 224 224 227 228 229 230 230 230 232 234 236 237 237 240 240 240 241 241 241 244 248 249 251 252 253 254 254 255 255 256 258 260 262 262 263 265…
Output: 627

Example 3:

Input: 224 549 16 17 17 19 21 22 23 27 32 32 41 60 64 67 68 83 87 89 101 108 108 121 126 126 135 136 136 139 142 144 145 156 157 169 169 171 172 173 176 179 180 182 185 187 188 191 192 193 203 204 204 226 233 251 255 258 258 263 263 266 268 275 277 279 279 287 288 289 294 294 295 300 301 304 310 311 312 312 314 319 319 319 325 326 327 328 332 332 335 336 339 344 345 347 350 354 358 359 364 368 374 380 381 392 394 396 400 402 402 414 415 424 425 425 426 447 449 455 465 467 470 476 477 481 494 496 497 499 508 520 522 523 525 526 544 545 545 546 546 549 551 555 555 561 568 576 583 583 588 590 597 609 613 614 615 625 627 634 635 649 656 661 664 675 683 692 692 703 711 713 715 717 718 720 722 742 744 746 751 755 758 762 763 763 765 767 769 771 785 786 788 789 793 794 801 806 819 827 831 838 847 847 84…
Output: 140

Constraints:

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

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