CT56144

The Mossy Taller Ahead

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Librarian runs the archive at the opal reefs of Shimmerdeep. Today the books show a list of marks, and the numbers must be worked out before sundown. 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: 1636 -245926148 -858527209 327682134 206160586 -990656941 -340854294 -549931485 492730413 534226711 -765703274 635861391 -308532630 -303071358 493731520 589254774 -606661055 18688068 678399297 -766631726 -929374917 542668188 492336692 165115532 -493952307 -72978553 -192734937 -504401675 337491710 910908685 -848147895 -889167412 -438100466 660348398 -396566634 753490436 -813391546 -501934477 694005895 477030272 -642967683 -549160639 -413248527 -706525061 476332104 734096525 43894374 638464201 750415254 149599331 597459380 88793713 875719233 655671025 444692129 -456401586 530674568 287340415 327052847 -129497798 -78278973 -891667793 -567934230 -174004034 -650874705 -108961328 961785621 -339378040 -834881504 -817353820 214887783 51193741 197621437 814442931 -967668205 726167629 -131300860 991…
Output: 327682134 327682134 492730413 492730413 -340854294 492730413 492730413 534226711 635861391 635861391 678399297 -303071358 493731520 589254774 678399297 18688068 678399297 910908685 542668188 542668188 910908685 910908685 337491710 -72978553 337491710 337491710 337491710 910908685 961785621 -438100466 -438100466 660348398 753490436 753490436 875719233 -501934477 694005895 734096525 734096525 -549160639 -413248527 476332104 476332104 734096525 750415254 638464201 750415254 875719233 597459380 875719233 875719233 961785621 961785621 530674568 530674568 961785621 327052847 961785621 -78278973 961785621 -567934230 -174004034 -108961328 -108961328 961785621 991753068 214887783 -817353820 214887783 814442931 197621437 814442931 991753068 726167629 991753068 991753068 999142493 36888167 987569179 …

Example 2:

Input: 3367 530027890 -492769025 426439248 396651327 -81770618 776581613 282968475 677324269 -154900215 -666462952 -965656642 591414452 -517819530 -46598234 -228987946 611973098 814199232 396938440 534585699 -242229321 -553582967 698657352 386764244 696135983 -112711094 423326056 156627354 246069500 468469501 797537751 -257963940 674282351 223381374 296209339 716077694 -705571502 -833256808 60152190 -640346573 -826230328 -160916015 197174540 426466674 833097218 -69081395 688207569 -605687481 411679656 197463257 355374299 -749633203 387101838 868252217 230910044 572033587 345279521 431178663 -635700866 -455480034 -759130273 -258859281 -644464877 -710377021 822513048 -930717185 -497092979 851344140 108170166 -16665920 997842915 144513969 230187370 -936846240 926702142 -381300183 -640213346 -7627271…
Output: 776581613 426439248 776581613 776581613 776581613 814199232 677324269 814199232 591414452 591414452 591414452 611973098 -46598234 611973098 611973098 814199232 833097218 534585699 698657352 698657352 698657352 797537751 696135983 797537751 423326056 468469501 246069500 468469501 797537751 833097218 674282351 716077694 296209339 716077694 833097218 60152190 60152190 197174540 -160916015 -160916015 197174540 426466674 833097218 868252217 688207569 868252217 411679656 868252217 355374299 387101838 387101838 868252217 997842915 572033587 822513048 431178663 822513048 -455480034 -258859281 -258859281 822513048 822513048 822513048 851344140 -497092979 851344140 997842915 997842915 997842915 997964817 230187370 926702142 926702142 944544622 944544622 944544622 944544622 969124594 -88533712 -88533…

Example 3:

Input: 145 289541794 -529152983 -973961627 270885085 877133120 629566902 680933770 -581718648 -504573474 -526719056 649731019 -7586449 168800541 -122313711 -627476828 -173959636 -190516825 258666315 938224809 -32371712 117297368 438260965 -924295864 -858877074 50850733 421673056 -776943410 -22873459 -85879033 -929851848 886057440 -427483803 -606316258 -720961135 -62745277 -694714623 -65343378 -764078375 -6836264 148801806 -152340437 79253515 743779196 -716020162 -273407525 131989838 -139859659 202979434 857095815 -445522111 -815018816 -115399975 380469247 -957769819 313313920 -190933271 -138600631 397285970 582014149 -53667726 376731335 -910073018 16520693 496612806 537097923 -243482057 868675219 -633659660 -987406218 442711600 -611482000 -582849059 27213218 -520921031 -970271503 -711311809 -3282…
Output: 877133120 270885085 270885085 877133120 938224809 680933770 938224809 -504573474 649731019 649731019 938224809 168800541 258666315 258666315 -173959636 258666315 258666315 938224809 944683861 117297368 438260965 886057440 -858877074 50850733 421673056 886057440 -22873459 886057440 886057440 886057440 887514439 -62745277 -62745277 -62745277 -6836264 -65343378 -6836264 -6836264 148801806 743779196 79253515 743779196 857095815 -273407525 131989838 202979434 202979434 857095815 868675219 -115399975 -115399975 380469247 397285970 313313920 397285970 -138600631 397285970 582014149 868675219 376731335 496612806 16520693 496612806 537097923 868675219 868675219 887514439 442711600 442711600 837844662 -582849059 27213218 837844662 -328258319 -711311809 -328258319 837844662 -595627984 837844662 85991…

Constraints:

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

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