CT32230

The vials at Thornveld

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Legend says the vault under the acacia flats of Thornveld opens only for a perfect tally of vials. Ulmar means to find out. 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 <= 6301; -1000000 <= a[i],x <= 1000000.

Example 1:

Input: 4339 -867444 -999601 -999482 -999425 -997943 -997256 -996485 -995265 -995062 -994943 -994854 -994823 -994586 -994360 -994168 -992976 -992944 -992397 -992135 -991770 -991383 -990759 -990224 -989802 -988335 -988162 -988028 -987915 -987908 -986740 -986294 -985902 -985775 -984645 -984428 -984319 -983849 -983833 -983630 -983135 -982692 -982281 -981668 -980722 -980611 -980447 -980013 -979936 -979381 -978887 -978202 -977853 -977722 -977463 -976940 -976275 -976239 -976022 -975665 -975524 -974815 -974689 -973461 -972609 -972141 -972088 -971294 -970559 -970110 -970104 -969706 -969274 -968106 -967821 -967695 -967326 -966721 -965431 -965193 -965062 -964854 -964854 -964728 -963927 -963718 -963507 -963464 -963146 -962548 -962429 -961431 -961381 -960319 -960115 -959802 -959440 -959322 -959158 -958217 -95…
Output: 302

Example 2:

Input: 105 721525 -989453 -964408 -962891 -948843 -946980 -942706 -923388 -899555 -897988 -865248 -861162 -811099 -796461 -771472 -765547 -746361 -741651 -730574 -669982 -665649 -640974 -600124 -596630 -584070 -542172 -481801 -438876 -404057 -388107 -379123 -368116 -356049 -346933 -346559 -345393 -316328 -304806 -279969 -276352 -240747 -240547 -235000 -215191 -188377 -186425 -162977 -148540 -143346 -90930 -84656 -56278 -39723 -33430 -23068 -3200 57218 85334 95063 95765 103392 116013 130173 153267 178387 190047 251776 272292 308259 358253 390631 392115 396178 453254 460667 468420 468987 505523 514171 538864 541127 597222 597272 630210 678837 696112 698782 721525 759203 773119 779668 785152 787026 822202 824692 840244 858872 869948 887986 913198 924092 924310 929956 948408 957007 959130
Output: 87

Example 3:

Input: 1976 -991116 -999874 -999117 -998794 -998608 -998282 -997236 -995599 -995150 -994788 -993947 -993598 -993489 -992159 -991697 -991209 -989839 -989639 -989434 -988952 -986516 -986463 -985988 -985145 -983263 -982674 -981895 -981049 -980856 -979870 -978687 -978165 -977693 -976136 -976096 -974972 -971934 -970383 -969905 -967769 -965222 -963941 -963589 -958167 -957695 -956935 -954929 -954100 -953229 -952443 -952150 -951511 -949224 -949093 -946951 -944960 -944895 -944008 -940989 -940086 -938889 -937504 -937214 -936951 -934633 -934616 -934556 -933482 -931804 -931778 -930925 -929207 -926228 -924843 -923200 -921097 -920392 -919441 -918305 -918215 -916033 -909155 -908227 -906799 -905054 -905034 -903736 -902503 -901670 -901614 -900916 -900330 -899889 -897815 -894823 -893921 -893432 -889420 -888214 -88…
Output: -1

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The vials at Thornveld - MEDIUM Coding Problem | CodeTikki