CT30969

Jatin Counts the vials

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Caravans arrive at the copper works of Verdigris with crates of vials, and Jatin the archivist must account for every last one. 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 <= 5744; -1000000 <= a[i],x <= 1000000.

Example 1:

Input: 5501 856110 -999396 -999365 -999188 -999059 -998601 -998468 -998461 -997968 -997894 -997591 -997338 -996568 -996510 -996375 -996325 -996091 -995496 -994482 -994145 -993734 -993722 -993673 -993635 -993307 -991867 -991579 -991306 -990909 -990875 -990725 -990699 -990663 -990272 -990156 -989756 -988654 -988336 -988185 -987684 -987471 -987185 -986559 -985291 -985133 -984906 -984243 -984203 -983927 -983182 -982365 -982291 -982203 -981301 -980785 -980232 -979916 -979896 -979819 -979626 -979334 -979105 -978997 -978800 -978647 -977480 -977264 -977250 -977167 -976780 -976475 -975814 -974602 -974594 -974508 -974223 -973570 -973342 -973207 -973099 -972937 -972833 -971991 -971880 -971756 -971483 -970967 -970587 -970505 -970492 -969305 -969292 -968847 -968655 -967200 -967158 -967065 -966353 -966052 -965…
Output: 5119

Example 2:

Input: 5474 808003 -999751 -998762 -998756 -998590 -998110 -998103 -997670 -997497 -997356 -997187 -996836 -996750 -996702 -996492 -995971 -995206 -995182 -994956 -994915 -994894 -994867 -994178 -994089 -993631 -992725 -992096 -991809 -991808 -991515 -991138 -990924 -990442 -990413 -990013 -989844 -989548 -988157 -987945 -987912 -987883 -987877 -986716 -986609 -986287 -985455 -984978 -983715 -983361 -982768 -982688 -982606 -982471 -982380 -981883 -981687 -980646 -980588 -979817 -979708 -979123 -978541 -978021 -976896 -976766 -975446 -975353 -975316 -974901 -974659 -974504 -974413 -974344 -974166 -973681 -973125 -972980 -972614 -971386 -971191 -971169 -970613 -969998 -969828 -969388 -968810 -968712 -968642 -968393 -968364 -968176 -967996 -967035 -966784 -965746 -965409 -965356 -965136 -964719 -964…
Output: 4927

Example 3:

Input: 4574 932667 -999348 -999341 -998897 -997793 -997612 -995763 -994312 -993214 -992766 -992519 -991286 -990537 -988052 -987804 -987579 -987518 -987356 -987058 -986132 -986090 -985752 -985331 -984314 -983377 -983077 -982793 -982539 -981837 -981540 -981454 -981205 -980069 -979669 -979251 -978796 -977154 -977046 -976938 -976220 -975561 -975493 -975352 -975242 -975034 -974660 -974473 -974354 -974287 -972944 -972625 -971739 -971497 -971133 -970799 -969965 -969729 -969696 -968814 -968686 -968214 -967897 -966547 -965415 -964909 -964724 -964428 -964351 -964161 -964001 -963889 -963858 -963712 -963609 -963424 -963348 -963214 -963137 -963014 -962701 -962290 -962223 -961933 -961685 -961653 -961590 -961181 -959993 -959782 -959779 -959693 -958876 -958446 -958394 -958349 -958123 -957348 -956972 -955786 -954…
Output: 4417

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.