CT39181

The Lantern Tor Taller Ahead

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The scribe Boris has been asked to fulfill a tricky customer order. On the desk lies a long table of registers readings. 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: 1967 284385323 -787984460 707561116 -138506080 -922857204 587755993 602034913 280926944 609178125 -974086411 -82081794 961200999 377148393 -117923334 -304269627 -630149248 -314299888 669263145 -568881338 960799519 885798343 659760371 370200725 351440839 -76720735 759466539 335222075 714129736 613743055 206674076 -269577033 127112380 984532002 -927208942 986576662 -276472069 -86005221 -266888805 148484412 701900129 -909431794 -400246596 -263668311 407806210 108505758 -374660760 -63236443 316228776 281605170 -534560279 -660299199 -247310893 54430775 -568991329 -681653963 -253050663 758433414 -501307025 -736679681 496673446 -421840502 229329000 255777717 -394439697 -104031389 -181843821 -163159231 830671920 519197883 969433150 572949087 -137713717 46696268 902827242 -2649976 636837616 -170917…
Output: 707561116 707561116 961200999 587755993 587755993 602034913 609178125 609178125 961200999 -82081794 961200999 984532002 669263145 669263145 669263145 -314299888 669263145 960799519 960799519 984532002 984532002 759466539 759466539 759466539 759466539 984532002 714129736 984532002 984532002 984532002 127112380 984532002 986576662 986576662 991060527 -86005221 148484412 148484412 701900129 758433414 -400246596 -263668311 407806210 758433414 316228776 -63236443 316228776 758433414 758433414 -247310893 -247310893 54430775 758433414 -253050663 -253050663 758433414 830671920 496673446 496673446 830671920 229329000 255777717 830671920 -104031389 830671920 -163159231 830671920 969433150 969433150 991060527 902827242 46696268 902827242 911660802 636837616 770478097 148866736 437454377 437454377 496…

Example 2:

Input: 2455 931017578 975971251 779373362 616243694 -92700183 -593185660 -978091878 -115645642 -733208333 -957369730 921791062 -216164558 151603794 -406197402 3742650 -492306876 -922389626 155400303 -212773713 -817120562 588217271 600866682 -370848886 -279611218 46038878 845657934 -139625050 905416932 -50485233 143313768 638853547 -965170285 -619422711 122614197 -883116759 189548195 -335126892 -610530007 795238543 -463871756 -199150319 231620458 617965791 500074686 183623500 -467327246 636604750 22589428 410821689 -543149813 309118318 456870564 27167086 -982846991 142603077 -281047472 794550363 -815187156 201595083 -753144103 273812080 -938051058 -877910811 -295697069 -261322988 678937843 -362823044 -914546615 599867467 222170954 -44222868 902151460 65664694 18182332 -630391695 -663018856 1231797…
Output: 975971251 996911474 921791062 921791062 921791062 -115645642 -115645642 921791062 921791062 921791062 942826350 151603794 155400303 3742650 155400303 155400303 155400303 588217271 588217271 588217271 600866682 845657934 -279611218 46038878 845657934 905416932 905416932 942826350 143313768 638853547 795238543 -619422711 122614197 189548195 189548195 795238543 795238543 795238543 902151460 -199150319 231620458 617965791 636604750 636604750 636604750 636604750 794550363 410821689 456870564 309118318 456870564 794550363 142603077 142603077 794550363 794550363 902151460 201595083 273812080 273812080 678937843 -877910811 -295697069 -261322988 678937843 902151460 599867467 599867467 902151460 902151460 902151460 942826350 123179735 123179735 123179735 123179735 158686200 444898387 147443718 44489…

Example 3:

Input: 1852 604598819 -128659013 580788941 -865511848 -705403022 -26169014 626801696 -657563133 -821029940 594473800 223189308 -954261706 -218668249 -66606221 -525130967 624901071 -329804686 812375936 -578558344 598253181 -215599930 276093846 -519734962 -777432540 509893280 -630512128 -639375517 853479275 686041134 991186400 797545246 883441370 145817432 775966903 914980990 497072583 -358845132 -230728019 746994898 779572787 -371364327 649593939 -975286939 -699221 100062986 -219381193 -437990353 313418352 539848548 -473363115 -419424050 -184239173 -924101862 77750926 -13338605 888047975 440845213 89571910 438136740 181168676 959770133 574498453 -744034633 -227557523 97442741 874545181 -771973494 462798633 -353866199 -176774733 -631155938 947635222 341286384 651751281 -365746537 -116098454 -956623…
Output: 626801696 580788941 626801696 -705403022 -26169014 626801696 812375936 594473800 594473800 624901071 624901071 -218668249 -66606221 624901071 624901071 812375936 812375936 853479275 598253181 853479275 276093846 509893280 509893280 509893280 853479275 853479275 853479275 991186400 991186400 997655123 883441370 914980990 775966903 914980990 959770133 746994898 -230728019 746994898 779572787 888047975 649593939 888047975 -699221 100062986 313418352 313418352 313418352 539848548 888047975 -419424050 -184239173 77750926 77750926 888047975 888047975 959770133 959770133 438136740 959770133 959770133 979166286 874545181 -227557523 97442741 874545181 947635222 462798633 947635222 -176774733 947635222 947635222 949258985 651751281 751234415 -116098454 349712950 349712950 639383943 751234415 -762932…

Constraints:

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

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