CT28928

The Shelf Position of Rainhaven

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

In the monsoon port of Rainhaven, Ishaan the reckoner keeps careful count of the weights. Verify the ledger before the auditors arrive, every figure matters. 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 <= 369; -1000000000 <= a[i],x <= 1000.

Example 1:

Input: 333 -302350208 -996894684 -992211035 -990267491 -984769858 -984186580 -983837384 -981988717 -976485900 -976191204 -974870378 -968908811 -967910500 -966631215 -966249162 -962583714 -957286894 -957119907 -952515120 -949758576 -945127455 -942676114 -941808139 -940280956 -938101671 -935285531 -935150117 -933490680 -930153519 -927622555 -927173582 -922640561 -921251861 -918425894 -918353280 -909073519 -900424826 -899404245 -899124567 -898898337 -898775236 -898305675 -897541635 -896020354 -891459573 -890592109 -890256365 -887993902 -886073335 -884797654 -884128382 -882101525 -881483930 -869386171 -862947834 -858723094 -858436273 -857221732 -845928216 -842732608 -840941256 -838155492 -836587195 -833798571 -825029376 -819436061 -817694790 -816465148 -814952577 -806421049 -804971795 -803737906 -801…
Output: -1

Example 2:

Input: 201 -640737433 -995469222 -994794775 -993967440 -992263949 -991302682 -989018278 -987702021 -981591598 -973576293 -962308172 -959929243 -956616513 -942504120 -938336998 -931591280 -930478539 -920130673 -916209058 -911224801 -908745043 -906385897 -892824604 -890816538 -884911683 -875081845 -868547080 -868339697 -866638974 -854815510 -852302760 -849891852 -848208706 -834709406 -834558001 -829259583 -828217036 -819827588 -816626155 -816417963 -810805744 -809076330 -800210761 -796055972 -791273357 -778266563 -777712128 -774731869 -756850453 -755979066 -754282705 -753374012 -750766392 -745326858 -737537003 -735346235 -733948771 -731302701 -730037280 -728254417 -727844658 -726200960 -724636879 -714966515 -712187210 -692416823 -686542483 -680442091 -678271887 -676073514 -676044381 -670574080 -652…
Output: -1

Example 3:

Input: 10 -766580603 -766580603 -749268058 -525302260 -315207469 -260720024 -236749619 -218109966 -119249462 -92798827 -68931046
Output: 1

Constraints:

1 <= n <= 369; -1000000000 <= a[i],x <= 1000.

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