CT54433

Zephyr's Ledger of ledgers

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Caravans arrive at the island market of Coralcove with crates of ledgers, and Zephyr the reckoner must account for every last one. Task: For each element print the value of the nearest element to its right that is strictly greater, or -1. Input format: First line: n. Second line: n integers. Output format: Print n answers space-separated. Constraints: 1 <= n <= 4000; -10^9 <= a[i] <= 10^9.

Example 1:

Input: 271 -530898272 180214851 -49356676 -723296309 74568883 -695886799 175965149 775834565 965339433 -363162327 112879015 908040338 -281718956 -584432189 -486392319 544913072 -255803838 635435178 -115771118 -786307393 222757183 -297809023 183952294 -305645943 271124090 -243688202 401286630 993571352 828909323 549031999 -467384495 84682122 -796036663 906971272 196562060 359599028 253661985 -378533232 -201952379 711617535 -185501010 -777937310 787101497 -982615965 723007089 674152331 189702728 519418513 -971251758 -619039663 319041151 801316409 792493053 -330901745 -291821093 24779942 -344269936 12441737 629065852 -868919956 -517486312 796066264 -929458063 600186 -6574601 79124774 -927985760 -821209464 182327786 252602834 -494333199 560463802 936555394 -274377990 -692671510 -883005495 -410662635 …
Output: 180214851 775834565 74568883 74568883 175965149 175965149 775834565 965339433 993571352 112879015 908040338 993571352 544913072 -486392319 544913072 635435178 635435178 993571352 222757183 222757183 271124090 183952294 271124090 271124090 401286630 401286630 993571352 999219912 906971272 906971272 84682122 906971272 906971272 936555394 359599028 711617535 711617535 -201952379 711617535 787101497 787101497 787101497 801316409 723007089 801316409 801316409 519418513 801316409 -619039663 319041151 801316409 936555394 796066264 -291821093 24779942 629065852 12441737 629065852 796066264 -517486312 796066264 936555394 600186 79124774 79124774 182327786 -821209464 182327786 252602834 560463802 560463802 936555394 990815556 -163841908 -410662635 -410662635 -163841908 198281665 198281665 300092252 …

Example 2:

Input: 2205 -726003356 835968288 -71671494 -720069415 43890216 -625215586 65269993 -433498832 -379637289 673415403 -287517952 660030785 341895729 607793044 -551477952 211439698 -361243514 243965492 -920253443 515522178 -318773586 -888779656 160896027 -790523757 760684370 546990466 -975320427 -980911102 776830262 954707145 -462768616 -331844400 -332710384 878333371 -972484741 -614315555 693234555 533661813 -610151013 554268579 -166083214 159111310 -182753700 -279276004 -220876888 -626808630 984854826 42324943 -545132987 -615753597 345971137 -311465086 -742523125 368642390 -897953627 568659931 896981103 -59640907 576776226 859840588 -545798429 318688258 -829032565 -791916286 468443869 329287105 163672631 -540273999 364371165 816539262 88019929 761252264 -406086928 -67181977 -547926662 -886184109 79…
Output: 835968288 954707145 43890216 43890216 65269993 65269993 673415403 -379637289 673415403 760684370 660030785 760684370 607793044 760684370 211439698 243965492 243965492 515522178 515522178 760684370 160896027 160896027 760684370 760684370 776830262 776830262 776830262 776830262 954707145 984854826 -331844400 878333371 878333371 984854826 -614315555 693234555 984854826 554268579 554268579 984854826 159111310 984854826 984854826 -220876888 984854826 984854826 990062775 345971137 345971137 345971137 368642390 368642390 368642390 568659931 568659931 896981103 905074065 576776226 859840588 896115927 318688258 468443869 -791916286 468443869 816539262 364371165 364371165 364371165 816539262 896115927 761252264 795828160 -67181977 795828160 795828160 795828160 896115927 569462406 896115927 -68405356…

Example 3:

Input: 3102 -674033534 -545861880 186060299 488879281 666914577 526661313 -87299791 893108445 357201048 414811840 -73680369 -410274738 -183002199 -111136141 795513766 -997344406 332454727 -801823773 88690772 -85448568 50493843 -90230065 -203835456 -274301332 -810500478 -764924327 -152981835 -547182737 -325526094 -884040048 924847654 607462154 -457583822 121179979 -657215140 391523754 -118345129 101007098 -571127420 432334030 646177765 -516777373 160381745 -389430234 -36630639 610184810 42030690 -756087777 -136365707 221353045 -950965940 906529890 -163410802 -792760827 -936131510 604306306 554938060 -803230591 11058457 228335532 2510454 914664820 540804068 724896815 -579237360 -878612674 652339969 -621322682 -895149559 -385517473 672457536 109588107 -212382542 -930054979 -237162109 361634666 -1581…
Output: -545861880 186060299 488879281 666914577 893108445 893108445 893108445 924847654 414811840 795513766 795513766 -183002199 -111136141 795513766 924847654 332454727 924847654 88690772 924847654 50493843 924847654 924847654 -152981835 -152981835 -764924327 -152981835 924847654 -325526094 924847654 924847654 972377776 646177765 121179979 391523754 391523754 432334030 101007098 432334030 432334030 646177765 906529890 160381745 610184810 -36630639 610184810 906529890 221353045 -136365707 221353045 906529890 906529890 914664820 604306306 604306306 604306306 914664820 914664820 11058457 228335532 914664820 914664820 972377776 724896815 972377776 652339969 652339969 672457536 -385517473 -385517473 672457536 699352498 361634666 361634666 -237162109 361634666 699352498 358344823 699352498 972377776 9…

Constraints:

1 <= n <= 4000; -10^9 <= a[i] <= 10^9.

Loading...
Test Cases:No test cases
No test cases available.
Zephyr's Ledger of ledgers - MEDIUM Coding Problem | CodeTikki