CT22725

Tailor's Smoky Ledger

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Legend says the vault under the peat bogs of Mossgrieve opens only for a perfect tally of shelves. Tailor means to find out. 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 <= 809; -1000000 <= a[i],x <= 1000000.

Example 1:

Input: 669 -375306 -996495 -996459 -994141 -993583 -988759 -986232 -984157 -982003 -981247 -978169 -974375 -972127 -956789 -952475 -946213 -944405 -944381 -944234 -942974 -940981 -938911 -930599 -930086 -929131 -927905 -925347 -924811 -922429 -915862 -904813 -904374 -902294 -901013 -900299 -892713 -887628 -887320 -885133 -879353 -873174 -873050 -869040 -866575 -860018 -859593 -859052 -858134 -857846 -856268 -845710 -845553 -842985 -836628 -834594 -833758 -833519 -823867 -806822 -805785 -801190 -799430 -796972 -791718 -791717 -789479 -788696 -788637 -784848 -779264 -775648 -774638 -773616 -770484 -745846 -738641 -737836 -733492 -732539 -729218 -721129 -719374 -715758 -714977 -713610 -712792 -706996 -703089 -701112 -701006 -697473 -691929 -690814 -687513 -685889 -684213 -684022 -674714 -673613 -671…
Output: 211

Example 2:

Input: 15 514777 -902400 -710316 -569797 -556735 -495103 -460691 -334671 -307805 -226710 -14039 5051 339013 405648 514777 745896
Output: 14

Example 3:

Input: 125 -38309 -996296 -958965 -955832 -954753 -948816 -946885 -943123 -903581 -882313 -873872 -840316 -805804 -785066 -783039 -775782 -760725 -757434 -750597 -728812 -718597 -696703 -664192 -651479 -645187 -644383 -635147 -628636 -626344 -614387 -610859 -575193 -554732 -537850 -534225 -529419 -517720 -487062 -479240 -467949 -448338 -417979 -407802 -399915 -370059 -360573 -340810 -338152 -309418 -288527 -257366 -238095 -215565 -198228 -195438 -181426 -168618 -166695 -137619 -136168 -123752 -86881 -81491 -77192 -66409 -38495 -38309 -29755 -14261 -8263 42381 47810 54967 92016 127724 150368 159996 162315 167816 179105 181256 183227 190848 232414 235859 279584 290666 332069 332338 349452 372739 378454 381565 416547 421098 439688 440909 455228 462313 483461 515050 526353 556615 563569 571742 576529…
Output: 66

Constraints:

1 <= n <= 809; -1000000 <= a[i],x <= 1000000.

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