CT25131

The Shelf Position of Alabast

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

The harbor bell rings at the ivory gates of Alabast; Pia weighs the day's vials manifests and starts the calculations. 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 <= 753; -1000000000 <= a[i],x <= 1000000.

Example 1:

Input: 683 -90885460 -999748889 -998614657 -996297016 -993694565 -993408732 -992325186 -988499311 -986058131 -986032486 -983426199 -983399543 -982512384 -980278769 -978997245 -978542877 -976818429 -973503046 -971128019 -968746621 -968119459 -967819416 -965997744 -965392339 -962438095 -960768111 -958303327 -955341188 -954647278 -951522561 -948860591 -946762595 -944635608 -942381931 -941018701 -939013939 -938440081 -934348345 -933225144 -932783916 -929982628 -927781173 -926841917 -926428540 -924873770 -924666979 -924112651 -924060871 -923789129 -922615500 -922350746 -916059264 -915560649 -914001684 -912457796 -911065056 -909199800 -905924881 -905485797 -903785272 -900793779 -900578113 -897548806 -897172664 -896473007 -896104944 -895696650 -893240037 -892972867 -890943586 -890877722 -889819536 -8897…
Output: -1

Example 2:

Input: 643 -158749757 -999245292 -998444835 -998139539 -997548668 -991434781 -991206575 -987837826 -987130074 -983554842 -982168782 -979948871 -979721805 -978575231 -975755142 -975568606 -975186700 -974360601 -971631549 -970110477 -969060341 -966261650 -966182518 -965399198 -965068263 -962977849 -962583960 -959965855 -958861374 -956360344 -955812494 -955363908 -953979121 -952570166 -952569074 -952478203 -950875765 -947784476 -947550344 -946631820 -946165847 -941511379 -940240075 -936651576 -936068866 -935992169 -935399872 -928888568 -928834145 -928206875 -927605419 -927554371 -925977865 -923333298 -919909092 -919424738 -918485666 -916745549 -915794831 -914722038 -913387160 -913108509 -911065717 -910202591 -909313516 -909302296 -908333694 -907917271 -905796649 -905733313 -904706328 -891708154 -891…
Output: 521

Example 3:

Input: 545 -394108579 -997435694 -988492999 -985640429 -981632235 -980677972 -980396738 -979741293 -979355067 -979022134 -975922934 -969903686 -969716414 -968806846 -968112065 -968018470 -967146690 -966156505 -962767527 -962510873 -962306351 -962051199 -949914946 -949380975 -947711463 -947371342 -947218666 -946373193 -941146950 -941110287 -940643407 -939750834 -939718675 -937614400 -935261908 -934177647 -932177273 -925448270 -924890955 -923379945 -920950940 -920854655 -918084196 -917084123 -916643374 -914526234 -913359235 -911609696 -909317215 -907832062 -904608151 -899326038 -895824639 -891913377 -891895741 -891382934 -890220548 -888975958 -888830356 -886110337 -885899163 -882513014 -881319411 -877916676 -875073682 -873458324 -872662761 -872021152 -870643013 -870609769 -870107134 -862858982 -860…
Output: -1

Constraints:

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

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