CT31194

Botanist Counts the ledgers

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Morning light hits the ivy courts of Vineward as Botanist unrolls the day's manifest of ledgers. The tally will decide the next shipment. Task: The array is sorted non-decreasing. Print the 1-based position where x would be inserted to keep the order (before equal values). Input format: First line: n and x. Second line: n sorted integers. Output format: Print the insertion position (1..n+1). Constraints: 1 <= n <= 5337; -1000000 <= a[i],x <= 1000000.

Example 1:

Input: 1250 824137 -998270 -997481 -996186 -994463 -989527 -987683 -985562 -984615 -984447 -982815 -982291 -981415 -975446 -974092 -972825 -972477 -971746 -971127 -970906 -970778 -970450 -966027 -965513 -964656 -964445 -963455 -959794 -959674 -959131 -957702 -955800 -955333 -954551 -953868 -953618 -951211 -950625 -949724 -949014 -948565 -945681 -945585 -941865 -940630 -938304 -936211 -936044 -935189 -934496 -933206 -931842 -927132 -925765 -918749 -913178 -908482 -907604 -902655 -899925 -899467 -897120 -889393 -886233 -883464 -883323 -882712 -882054 -881258 -880734 -878786 -878769 -877028 -876212 -874578 -873904 -873531 -871536 -870475 -870247 -867869 -867121 -865766 -865578 -864740 -862716 -858179 -856433 -853601 -853351 -849191 -848631 -848150 -846926 -842095 -838641 -836427 -836053 -835821 -835…
Output: 1130

Example 2:

Input: 4189 835830 -1000000 -999322 -999036 -998828 -998448 -998242 -998196 -998016 -997996 -997989 -997430 -996530 -996216 -994132 -992757 -992542 -992408 -992187 -991606 -991288 -990927 -990812 -990648 -990274 -989792 -989664 -989143 -988138 -987447 -987158 -987090 -986928 -986683 -986357 -985621 -985326 -985257 -985139 -984382 -983160 -982966 -982559 -982127 -982033 -981895 -980997 -980566 -979463 -978827 -978653 -978518 -977793 -977510 -977381 -977371 -976346 -975990 -975863 -975208 -974289 -973555 -971902 -971816 -971636 -970898 -970820 -969600 -969248 -967360 -967270 -966132 -965403 -965110 -964196 -962793 -962681 -961915 -960433 -960372 -959796 -959080 -958584 -958352 -956944 -956675 -956427 -956372 -955592 -954950 -954305 -953768 -952451 -952337 -951555 -950995 -950796 -949704 -949625 -94…
Output: 3822

Example 3:

Input: 4277 11954 -999778 -999457 -999062 -998946 -998603 -996959 -996854 -996368 -996111 -995657 -994725 -994446 -993924 -993464 -992996 -992913 -991979 -991567 -991254 -990700 -990435 -989390 -987403 -986913 -986260 -986004 -985013 -985011 -984684 -984585 -984450 -984169 -983102 -982975 -982870 -980117 -980043 -979888 -979460 -979326 -979121 -978973 -978221 -978046 -977766 -977634 -977487 -977380 -976882 -976852 -976657 -976627 -975830 -975695 -974779 -974255 -974061 -973731 -973626 -973277 -972948 -972651 -972430 -972107 -971991 -971770 -971634 -970404 -970338 -969832 -969227 -969172 -968629 -967646 -967381 -967381 -966690 -966418 -966336 -966192 -965401 -964864 -964682 -964360 -964295 -964284 -963998 -963834 -963313 -961777 -961113 -960612 -960177 -959769 -959435 -957125 -956510 -956417 -9558…
Output: 2210

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Botanist Counts the ledgers - MEDIUM Coding Problem | CodeTikki