CT40591

The Twilight Taller Ahead

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the dune sea of Caravanrest as Vigo unrolls the day's manifest of marks. The tally will decide the next shipment. 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: 1479 -225061376 250557277 560131890 -84428905 611808691 713461519 649651393 -863085210 344912717 596538340 363955630 -82615091 911280809 -20255649 -930952605 -519026752 -167996778 234355884 418728878 -157811726 -793926332 307669807 594211334 -870850647 -171517844 -911101581 11919214 63513230 -573190645 -118378950 -703898186 -82445294 -790313027 -475254530 -726647950 920238344 -868089512 -862027961 -679716603 -224620879 -462380942 519446093 726438321 967243151 -438034650 884445694 -523491599 -988885247 -787113301 33426110 -328216081 927356362 419377701 -759800211 914790055 -179584665 -771557968 288745723 -244254535 -165739820 420011878 732975046 -289747313 750054826 -702550345 -980446405 -419484082 875268539 550187339 -596566340 -366283006 -965332906 -628602694 332251647 -242569983 24026454…
Output: 250557277 560131890 611808691 611808691 713461519 911280809 911280809 344912717 596538340 911280809 911280809 911280809 920238344 234355884 -519026752 -167996778 234355884 418728878 594211334 307669807 307669807 594211334 920238344 -171517844 11919214 11919214 63513230 920238344 -118378950 -82445294 -82445294 920238344 -475254530 920238344 920238344 967243151 -862027961 -679716603 -224620879 519446093 519446093 726438321 967243151 967560032 884445694 927356362 33426110 -787113301 33426110 927356362 927356362 933213591 914790055 914790055 933213591 288745723 288745723 420011878 -165739820 420011878 732975046 750054826 750054826 875268539 -419484082 -419484082 875268539 885343594 885343594 -366283006 332251647 -628602694 332251647 460143902 240264542 460143902 -127854550 -675937887 -12785455…

Example 2:

Input: 446 758066204 179607769 533671685 -769580852 777359617 32384185 -531011722 -991734864 -906825156 626492734 738444142 121452614 -253177992 -971812781 -740279700 453309962 793649842 -441229846 207332564 509530975 1876882 -254035173 -151432551 534342813 -189254714 373874173 428792748 -372801778 -351046184 181151415 -435298395 215521055 -111289820 790122627 -395428406 102800630 110723466 48951277 -412954941 339502538 424326435 -675845549 -424986516 768466060 -221247042 -889252566 294087427 -582594428 6015985 881643460 -497927436 654385442 -880926409 -935811745 325734550 -854595343 843266024 373960371 -587247396 349638557 -384741363 792102878 -799864061 -279504632 924127040 13309626 690967803 -257853964 -629312185 771530255 -650670154 320756470 -891413786 532307548 -546385450 63037003 -56373349…
Output: 777359617 533671685 777359617 777359617 793649842 626492734 626492734 -906825156 626492734 738444142 793649842 453309962 453309962 -740279700 453309962 793649842 881643460 207332564 509530975 534342813 534342813 -151432551 534342813 790122627 373874173 428792748 790122627 -351046184 181151415 215521055 215521055 790122627 790122627 881643460 102800630 110723466 339502538 339502538 339502538 424326435 768466060 -424986516 768466060 881643460 294087427 294087427 881643460 6015985 881643460 924127040 654385442 843266024 325734550 325734550 843266024 843266024 924127040 792102878 349638557 792102878 792102878 924127040 -279504632 924127040 943275469 690967803 771530255 771530255 771530255 943275469 320756470 532307548 532307548 591719378 63037003 591719378 -256705763 591719378 943275469 943275…

Example 3:

Input: 3020 374574480 383654345 799593067 -147854542 9013109 -240830985 -945411333 889616153 -484548642 -385128335 859685706 161752577 -339943852 527675226 148328400 289865389 366370557 -835092663 73259643 -215906888 232564278 669855267 -679439851 -238411973 -221057017 -737064565 -355289671 530974814 730268318 -760135233 -56130541 -798768574 717812302 -586820051 513142924 642071316 914985072 9908766 -626178492 -152367018 -9340229 -323305012 -56789662 447980493 875980810 -889723478 5982723 -104171429 -907279083 -497799985 -464938042 57404759 817835498 656899173 -736715652 527418076 -551980219 -570681162 -77460000 -15419539 -886054010 -629809750 -963886732 487710837 572865057 -534064908 173259154 884636308 268886529 108247388 351817015 -843809178 467652118 398474188 89666027 32231434 -53449747 -204…
Output: 383654345 799593067 889616153 9013109 889616153 889616153 889616153 914985072 -385128335 859685706 914985072 527675226 527675226 669855267 289865389 366370557 669855267 73259643 232564278 232564278 669855267 730268318 -238411973 -221057017 530974814 -355289671 530974814 730268318 914985072 -56130541 717812302 717812302 914985072 513142924 642071316 914985072 985064144 447980493 -152367018 -9340229 447980493 -56789662 447980493 875980810 884636308 5982723 57404759 57404759 -497799985 -464938042 57404759 817835498 884636308 884636308 527418076 572865057 -77460000 -77460000 -15419539 487710837 -629809750 487710837 487710837 572865057 884636308 173259154 884636308 985064144 351817015 351817015 467652118 467652118 668677857 668677857 668677857 72277229 72277229 72277229 668677857 668677857 9850…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Twilight Taller Ahead - MEDIUM Coding Problem | CodeTikki