CT28131

The Insertion Slot Beneath Redrock

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

In the canyon post of Redrock, Lysander the scribe keeps careful count of the crates. plan the beacon maintenance rota, every figure matters. 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 <= 530; -1000000000 <= a[i],x <= 1000000000.

Example 1:

Input: 173 982806072 -947728482 -941968486 -934505847 -917291049 -870665798 -869982236 -869051627 -863919656 -855246437 -848231611 -847881771 -830038358 -816780948 -816041816 -795725448 -782980911 -762484492 -745998817 -738318067 -735754181 -717385825 -712342529 -707998608 -696830431 -676339400 -634104746 -625299311 -607542112 -606868157 -592892990 -589735660 -578155411 -562752349 -562298514 -544644144 -540447651 -533000083 -524368000 -511926206 -502756390 -490254800 -487324013 -432512884 -428854285 -427475971 -426279815 -406312191 -398072965 -389907888 -388091278 -387327108 -365121600 -360813817 -355005554 -351063448 -349444391 -348854795 -340507182 -337875620 -329600476 -325493113 -314330275 -310389488 -301808366 -291388416 -285612332 -261256459 -244687323 -238402534 -236281903 -231616898 -218832389 -207884061 -196982863 -190218243 -187330747 -169045647 -157669682 -151871116 -141389945 -136202055 -130641886 -124234127 -113416953 -55804831 -37686654 -33974290 18474969 28580531 34842684 40852873 56212677 69499984 71622401 71872469 72667029 83575847 88707988 90854833 94107203 95613594 110548237 121339251 154669182 157546461 160312315 168415072 183288328 206905536 211662877 217053016 223799088 224722013 225274298 235614140 238429542 242561684 271926195 272577105 283150445 287060691 293867807 310891250 313143129 342533456 350194621 364310703 376905451 381343176 415701755 454408066 487555204 503984028 508687478 534028124 537072249 546910724 553955468 556811669 575978390 613090569 625891856 628134234 642267317 643771919 667725580 688224174 706943919 714952220 738445537 752070567 761765984 769110051 779318969 781047260 800102361 821139620 826834915 832597619 865691377 889627168 897598450 903898627 909546158 916660211 927387083 951049416 960591095 963051434 963511657 965755198 984454389 988845028
Output: 172

Example 2:

Input: 76 119349772 -991300261 -949973454 -946577190 -913486940 -842162244 -832994920 -826490688 -791231522 -739426091 -738298091 -724408816 -706528321 -637267159 -556803235 -539708589 -515199283 -509655215 -504311974 -494899956 -357116449 -311020056 -305495930 -305099166 -293392180 -284748944 -256630289 -201419992 -170246416 -165988179 -148804665 -146929079 -101500573 -99277996 -6947499 4051227 4658248 26896179 30161160 39844874 54177056 56752470 65614093 104381771 115540901 115894771 144824898 158402151 196829549 258143233 265324666 269671399 323481184 345764990 360208024 367989022 428042621 460204822 460652445 495361921 511967421 607918074 626821269 697995555 700432882 722577535 728195527 729231379 763918929 776138182 828732630 867970070 922852572 934932083 953540748 956798503 998771790
Output: 46

Example 3:

Input: 294 -120266110 -991080768 -985235072 -980564399 -973846013 -967346193 -962070331 -960486682 -949632994 -924984417 -911922627 -910887874 -901890494 -889810756 -886466125 -870948453 -856969233 -856387332 -855094989 -848432070 -847005586 -843350768 -840762110 -835574924 -831274511 -831140582 -827748667 -810369213 -805843249 -805517483 -803665935 -787604604 -783210725 -777355618 -755600115 -741067960 -729598202 -726302394 -713413111 -711023480 -696742661 -694842621 -689032999 -687493981 -679086210 -678136573 -677813856 -664020979 -654181009 -647289697 -641498608 -628325315 -626426454 -622841753 -622393841 -620863486 -610153547 -608360479 -607116883 -604750583 -602685429 -594663335 -594464817 -594175079 -585181160 -557346628 -551649969 -542746912 -537607031 -535735122 -526844359 -524115243 -521580010 -520502438 -517368907 -506615958 -496129156 -492966168 -487203925 -485399485 -473991728 -473331784 -472767079 -467879388 -461061052 -455486114 -450971260 -449442226 -448961321 -447065467 -437928904 -429355804 -426759260 -425787325 -412820514 -411992819 -411910154 -410644882 -406750423 -389941018 -383757313 -356265680 -348620080 -336322891 -324833892 -319141902 -312324707 -310421608 -300592193 -299005517 -291726162 -288169506 -280897186 -277813025 -253512598 -253129621 -250960730 -249683705 -246586438 -239854513 -238987176 -235507043 -218260876 -210645919 -181039766 -178863111 -174673702 -171028218 -161474420 -160417159 -155834345 -148614826 -112783451 -110584012 -108217956 -103819466 -99718378 -95917490 -95496484 -84910270 -45185338 -43633439 -23527349 -22868886 -16595246 -1103101 -38877 1156379 3581960 9488461 11715691 27507978 29561624 47139042 53990948 61151778 72692789 88958238 112663435 113069142 121892949 140121635 148699853 170740241 180472148 182880234 188063220 188594767 198620794 208041173 216728434 221285886 223122990 223813200 225596332 227430749 254187215 256874143 261048163 264231212 266201810 268303665 269831453 270522700 277828289 292462073 310691496 320973083 321195700 327972888 328792288 332974989 340320031 348255061 350763433 355405083 359185105 364264746 381134519 383542027 403675381 414491641 424740929 435086299 439174712 442094641 444350726 446501289 446949077 455449682 465299623 471231648 475804202 478658480 485479085 490843840 494760659 496089011 505395551 517083259 518632478 522289474 524910929 528391436 530938869 538485601 541317338 541788831 541791276 549724309 591256139 614862767 614944596 633787970 636824511 637525771 650066947 651163452 656995409 659574331 672079230 672429219 674605832 687924530 696325906 704866904 712949629 719616396 723030689 725690729 726761099 727077484 753693029 754590396 754875018 757645270 770782724 777939489 780480658 780931621 790847086 799506120 801401127 803126717 808258958 818625228 826954833 829440807 852461756 854163748 854246052 855241357 855265585 869936755 879072323 879857056 880298948 884359485 884710803 896932286 899728816 910271474 916302261 931920557 937867466 949875187 950538798 970017188 979721398 984959127 985724441 990452334 991593268 995444700 998471425
Output: 132

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Insertion Slot Beneath Redrock - EASY Coding Problem | CodeTikki