CT23867

Freya Counts the crates

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

The council of the tannery row of Leatherwick pays by the answer, and Freya intends to earn it. First: the full register of crates. 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 <= 297; 0 <= a[i],x <= 1000.

Example 1:

Input: 117 566 18 56 71 80 98 100 100 116 117 123 125 127 127 133 138 152 158 159 168 176 182 183 197 203 208 213 219 228 230 237 240 265 271 296 317 324 338 349 353 373 395 399 403 409 417 428 444 454 458 463 465 471 474 480 490 507 513 519 522 542 555 563 564 566 568 582 587 595 600 600 603 610 610 614 625 663 670 681 691 700 705 713 718 723 731 733 744 762 782 782 789 790 795 799 800 801 801 814 816 832 842 844 854 857 857 874 898 907 908 913 915 954 965 972 983 993 997
Output: 64

Example 2:

Input: 284 399 12 18 28 30 31 32 35 40 42 42 45 51 51 55 55 57 57 60 66 67 73 74 85 96 97 98 100 101 102 102 104 105 119 120 121 138 141 145 155 157 163 163 165 166 169 173 173 174 174 176 182 183 187 188 192 198 202 203 203 208 211 212 215 215 217 223 223 224 224 226 227 228 233 234 234 234 255 257 262 267 270 270 272 272 273 275 276 280 282 284 285 289 297 298 299 302 306 307 315 316 317 320 325 338 341 354 366 373 376 377 383 395 399 401 403 404 406 408 413 416 418 421 421 426 434 435 439 441 450 451 451 462 470 472 473 481 485 491 493 493 494 494 495 502 505 507 512 520 524 525 525 526 536 536 537 538 540 542 549 557 559 562 579 583 585 587 589 590 590 592 593 595 596 596 599 600 601 609 617 627 630 631 632 634 641 649 650 651 651 652 653 657 661 668 674 676 677 683 685 685 687 691 693 698 70…
Output: 113

Example 3:

Input: 115 389 5 9 29 42 48 52 54 55 69 71 79 79 84 91 97 99 111 114 143 151 157 160 163 163 167 179 186 194 196 201 221 228 231 248 257 265 267 285 297 313 318 321 323 331 338 344 348 357 367 369 381 389 400 422 430 438 441 448 453 463 464 467 486 491 495 515 515 520 534 588 592 594 600 610 615 617 618 619 639 645 661 673 685 685 691 697 704 725 731 735 754 785 815 827 841 852 870 876 876 877 881 894 907 927 929 932 933 937 953 956 974 975 981 990 993
Output: 52

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Freya Counts the crates - EASY Coding Problem | CodeTikki