CT25500

Jatin's Ledger of vials

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Caravans arrive at the zephyr cliffs of Galeholm with crates of vials, and Jatin the measurer 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 <= 743; -1000000000 <= a[i],x <= 1000000000.

Example 1:

Input: 115 -269232764 -962231947 -930794812 -919291033 -906358134 -887159903 -873899725 -870298310 -845341458 -793136245 -792039421 -757145518 -716945154 -710404129 -710010608 -698871567 -697484879 -651813005 -619158011 -563265090 -561838148 -551328849 -538924095 -511415072 -497642360 -496012966 -473881421 -455348573 -426228597 -401475866 -401165916 -400430374 -395497979 -394021960 -377557713 -363480533 -353673412 -349026711 -342610874 -314497313 -312603633 -310506080 -302483056 -301471612 -265175937 -191385720 -142226604 -131410310 -111715185 -104701468 -76044526 -42453637 -20214785 -12052469 -10493398 16156794 20322249 21760805 35444586 64025479 68999045 93413563 111651189 116879801 138880905 159411504 159869128 172695508 174094514 198719453 266730856 279402394 282659165 288525707 291172237 328…
Output: 44

Example 2:

Input: 12 351684977 -831431521 -673281966 -572842289 -360444115 -148252396 -65468376 295732083 403889310 415707162 553419993 597679307 632046316
Output: 8

Example 3:

Input: 645 565695389 -998669636 -998206048 -992556085 -991501673 -986155139 -973375894 -972803162 -970715450 -967634571 -966771721 -965697327 -965427559 -964628319 -964393183 -962745823 -959676444 -956413711 -954109364 -953434596 -952695751 -950841904 -949710997 -948673822 -947477124 -947002295 -944017940 -942445687 -938572318 -938571060 -937183887 -930229464 -929626575 -923450351 -920803079 -919007744 -917616954 -917414489 -914615236 -914109498 -906572646 -905819040 -905771426 -905409845 -904518402 -903758281 -902576080 -899987964 -890674912 -889158025 -889078507 -884947141 -879650536 -878790910 -876023570 -875263751 -867584114 -866450689 -863094771 -858358523 -853579851 -852911732 -850319612 -844057476 -843795633 -843597608 -839797582 -839736857 -832293543 -830032350 -824377185 -818872340 -8123…
Output: 506

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Jatin's Ledger of vials - EASY Coding Problem | CodeTikki