CT29019

Last shelves of Quade

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Quade runs the studio at the windmill fields of Gusthaven. Today the books show a list of shelves, and the numbers must be worked out before sundown. 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 <= 680; -1000000000 <= a[i],x <= 1000000000.

Example 1:

Input: 417 -85728631 -997549801 -996998907 -975288580 -975213629 -973512574 -968840853 -968720456 -960496986 -960459329 -955028899 -954227840 -952429088 -942678116 -937620789 -931931326 -930797494 -929399962 -925878621 -925066873 -920156079 -919275360 -917199155 -915077142 -910506338 -908899315 -908783829 -907968185 -906084526 -899980772 -898043624 -895195964 -857713807 -852086270 -836548275 -831470742 -821452473 -818833745 -816723431 -813097771 -798804586 -797204396 -789132262 -777536904 -775499474 -772510901 -772049737 -771292197 -769037293 -762029837 -755715194 -752313422 -747074116 -743996710 -736075147 -731876816 -731392796 -721477576 -721354185 -716041197 -715913827 -709025444 -698455889 -691504046 -686932886 -680166318 -676933540 -674213401 -661313945 -661186477 -652404184 -633584747 -6254…
Output: 196

Example 2:

Input: 272 293193122 -971703379 -969486782 -967780523 -965339670 -963705691 -960064966 -958651228 -957859413 -951533766 -928910531 -915954289 -913541981 -912822926 -899516784 -890828884 -886892553 -882357732 -867474776 -864297917 -861288646 -851373001 -837465260 -835431095 -824036868 -823057841 -797696925 -787379776 -783930867 -773473285 -764996885 -762781238 -756846490 -753736565 -740156050 -738883373 -736973660 -734429721 -733769576 -729374717 -728922186 -728019741 -718731543 -716588460 -703615102 -698531941 -691337776 -687004040 -680249132 -674593380 -658942243 -658687300 -654408808 -651381215 -648203230 -639899828 -634755529 -623402349 -617073872 -616274205 -613895925 -613632760 -603594669 -603277014 -590180816 -576318180 -571081017 -569064191 -559087926 -550771617 -529397175 -525750988 -5253…
Output: 177

Example 3:

Input: 60 -360573748 -961957812 -943102441 -938791527 -889689616 -820193124 -727600591 -690441570 -630897646 -604857300 -583820820 -570529581 -540136779 -529596802 -478535670 -461609574 -421641985 -413754847 -409846364 -364566223 -360573748 -336041048 -335625974 -180117306 -147416429 -105231588 -89934898 -80363946 -65971531 -51765371 -29038103 -21126387 25995500 61704248 63772302 70003226 91412647 125015876 133168227 152953448 200149581 209340048 229259102 254703616 273327122 366390806 388213191 388640783 516282696 529423255 534340111 548199624 562894488 564233969 799048392 848227992 908505218 966241874 974892763 990268056 996618703
Output: 20

Constraints:

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

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