CT24767

The Shelf Position of the Amber weights

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

It is audit day at the ferry landing of Crosswater. Odin spreads the weights records across the table and picks up a sharp pencil. 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 <= 962; -1000000000 <= a[i],x <= 1000000.

Example 1:

Input: 629 -785663767 -999264694 -995297887 -993965557 -990640123 -989897082 -988646161 -983729498 -981639798 -979482942 -975501141 -975227742 -974905202 -973986096 -971303801 -968320208 -964295234 -964052514 -963512364 -963443767 -961214676 -960950497 -960335617 -959612002 -959435308 -958768271 -957101752 -956140292 -955359016 -953702828 -952989501 -950130496 -948704311 -948626623 -946004289 -943223975 -942379839 -941052142 -940068910 -938630291 -937376096 -935684047 -933637818 -932098595 -929094240 -929072589 -928626648 -924665986 -920825020 -919392444 -918568841 -918417501 -914041241 -912373338 -910463000 -910372789 -909618252 -909454074 -907323544 -906358429 -906150792 -905447844 -904945570 -903004900 -901679503 -901342691 -901047200 -899289993 -897805129 -897143573 -897083566 -893951004 -893…
Output: -1

Example 2:

Input: 770 -416482713 -999869784 -999386291 -998679954 -995839903 -995562811 -992970675 -990802925 -990456161 -990373668 -989204015 -987348268 -987262217 -983596350 -983398647 -983023371 -979984026 -979071461 -978854567 -977716779 -976309886 -975652677 -974865189 -974611467 -973815358 -971336649 -970336508 -969571819 -968872652 -966741123 -966691687 -966151450 -965179846 -963297894 -961537790 -961435505 -959425779 -956686547 -955991970 -952666497 -952071179 -952065589 -951644658 -950341088 -948560951 -947990445 -945429871 -944648806 -944301211 -942862037 -938922977 -938631142 -938037415 -937709881 -936358116 -936067832 -935447604 -933431862 -931748793 -931458323 -929548675 -927499064 -926373062 -925383261 -925063856 -923680623 -922385574 -920357239 -919925131 -914364618 -913959622 -910943543 -910…
Output: 465

Example 3:

Input: 917 -510123540 -999957978 -998562464 -998411151 -997329801 -996572130 -996147382 -995351936 -994417831 -994336938 -994015801 -993458413 -993294085 -991918515 -991748953 -989818495 -989705822 -988416661 -986868788 -985989253 -985393355 -984203851 -980369758 -979744922 -977675889 -977162535 -973385561 -973273961 -971073987 -968099918 -967563215 -966308915 -964165743 -962573694 -958596263 -956372260 -954750400 -954367643 -951552289 -950555806 -949165730 -947432439 -943263702 -943123452 -941506750 -941125684 -940765434 -939700567 -939378156 -939322502 -937960497 -937389512 -936906435 -936497917 -935308507 -934813753 -934645253 -933663095 -932872244 -931002440 -930327592 -929112886 -928338645 -926806653 -926086050 -924597818 -922404039 -922199229 -921641592 -921418389 -920573724 -919832805 -919…
Output: 463

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Shelf Position of the Amber weights - EASY Coding Problem | CodeTikki