CT26884

Secret vials Shelf Position

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

In the windmill fields of Gusthaven, Vesper the paymaster keeps careful count of the vials. rank apprentices for the new term, 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 <= 837; -1000000000 <= a[i],x <= 1000.

Example 1:

Input: 540 -50031699 -998698782 -997013895 -995917272 -994473209 -993545034 -993274508 -990069249 -988981659 -981301482 -977732155 -977513817 -977207767 -976899419 -975953495 -975686646 -975599279 -971614010 -971463259 -971120715 -964309443 -961861498 -958785816 -955224900 -954864935 -954814654 -953242577 -952295977 -952031470 -951833713 -951802039 -948949528 -943285036 -941879709 -941473973 -939424859 -937200971 -934426806 -933689051 -933326192 -933198611 -932866584 -930063549 -929749461 -927118928 -926061797 -925390102 -922228966 -919170500 -919090243 -917096510 -913702376 -910810005 -908756415 -908027209 -906822224 -906253256 -904835386 -903540404 -902376068 -901721389 -900882246 -897556810 -897174036 -895440939 -884831934 -884520174 -882587762 -882265498 -881156796 -875036318 -873277411 -8709…
Output: 513

Example 2:

Input: 399 -231999169 -997339690 -995457272 -994697100 -988105835 -983436140 -980283275 -976219559 -972723671 -972039709 -965463031 -964633492 -963685743 -958219685 -952556011 -949648301 -947663131 -947647655 -947392049 -945582944 -944039893 -941191031 -934898629 -930990872 -929650987 -925664095 -918645526 -915496006 -914848992 -914608716 -910444563 -909226361 -908193169 -906907645 -905988455 -904954681 -903791870 -903174327 -902584279 -896032636 -894974075 -894758470 -893381103 -888131335 -886688588 -885605294 -885289142 -883648145 -883630179 -882236391 -881345501 -875179130 -875103429 -873986323 -872402753 -872072083 -871782478 -871036566 -870279827 -868878835 -867828483 -864559776 -858304171 -855621574 -851367951 -850121210 -847935041 -845979234 -845151723 -840817302 -839970958 -839572498 -836…
Output: 316

Example 3:

Input: 452 -8598580 -998675005 -998282196 -995514561 -994819999 -994443949 -991076656 -988541743 -987233129 -986662758 -981469943 -977836846 -974375247 -973626732 -972175930 -969934921 -969541986 -965749570 -963732980 -961230455 -960665639 -955661218 -955262957 -954320697 -952864040 -952417063 -949588543 -947194242 -943949346 -943036721 -941814773 -939764073 -934962912 -933380491 -926397376 -924618991 -920365072 -916049719 -915099688 -909735985 -906328753 -903629934 -896675666 -895329441 -894511344 -893613698 -892528713 -890775967 -889573798 -886958305 -886688924 -886091787 -884891998 -883930217 -883315088 -877505771 -876033941 -874554562 -869373329 -867816212 -864182298 -863792004 -863491443 -861267844 -860479872 -860099260 -858774949 -853048718 -849317678 -844838012 -838946190 -836455583 -83597…
Output: 448

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Secret vials Shelf Position - EASY Coding Problem | CodeTikki