CT22837

The ledgers at Brimstone

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Deep in the sulphur springs of Brimstone, Dora studies rows of ledgers entries. One clean number will settle the guild's oldest argument. 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 <= 816; -1000000000 <= a[i],x <= 1000000.

Example 1:

Input: 526 -648285068 -999450752 -998585460 -997968585 -997579245 -997478456 -996674917 -994421456 -994178790 -993874143 -991843961 -991298294 -988663230 -988336491 -984118406 -978031643 -977464187 -973315522 -972372820 -970449066 -967341286 -967191086 -963578447 -962954177 -962404071 -962059661 -960183609 -959753392 -958291396 -957144915 -956583622 -953297548 -952911760 -952408085 -949381118 -947540691 -936213683 -934926956 -932217363 -931393188 -931180168 -930423646 -926357930 -926264133 -925876623 -922560477 -920430461 -919637301 -919587580 -913939278 -906491589 -905952060 -903490553 -903341533 -903160547 -901865878 -901093683 -896372182 -895468282 -894300197 -891854805 -891786301 -890574400 -890306533 -887386180 -887385332 -885986028 -879893787 -877820271 -876856630 -876349671 -875422409 -871…
Output: 176

Example 2:

Input: 556 -607897931 -998688919 -998645920 -997887930 -996990968 -996407649 -993819269 -992907224 -991007281 -987067868 -986295809 -985460990 -984823370 -981203157 -979299912 -979080607 -977713122 -975249111 -974943640 -974552533 -974162261 -973907994 -973856066 -972037174 -971558725 -971315411 -970712231 -968126704 -964708644 -961457161 -956481108 -955260007 -955216317 -955073943 -953359024 -951541554 -951304560 -948394835 -945991895 -945250091 -937640677 -935633761 -934023232 -932998460 -931282710 -931242714 -931207864 -928944561 -927951477 -924824270 -923973496 -923688958 -922877690 -922319165 -921385597 -920508096 -919899011 -919679995 -917473019 -914850927 -913038214 -911777597 -911327464 -910462178 -909499538 -907205951 -906709055 -906257604 -904923857 -904368261 -903767798 -901892005 -900…
Output: 245

Example 3:

Input: 571 -672712303 -990952261 -990305124 -988906430 -980786555 -980689885 -979812114 -978773832 -978732877 -975764358 -973535673 -972582818 -971720062 -970636063 -967364324 -965735736 -965333171 -964991492 -964686004 -963727903 -962748016 -962569721 -962142740 -962073428 -961778138 -959877759 -959224619 -958310412 -956737098 -955118657 -953888516 -953494474 -949970213 -949011465 -948262864 -947139128 -946460368 -944834299 -944276715 -942839767 -940156342 -939920275 -938972544 -938757077 -937541923 -934451930 -931923067 -929255472 -929228454 -928177149 -926818933 -925399109 -919443331 -919111132 -919045483 -918108319 -909957452 -909274812 -907147023 -905145103 -901244631 -899908745 -893640618 -892447107 -891584675 -890339067 -888992481 -886220399 -885814115 -884487292 -883690131 -882794567 -882…
Output: -1

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The ledgers at Brimstone - EASY Coding Problem | CodeTikki