CT40380

The Mossy Taller Ahead

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

At the orchid house of Bloomglass, Tailor records each marks in a worn leather ledger. The guild wants answers, not guesses. 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: 1333 832286406 -40595433 560642277 70800569 -719682041 694977299 -175064127 -530871885 -569401105 -917926469 416092475 -672552005 -833565866 -119957794 8967071 -680655814 82338780 -691319984 285624887 -301555997 714293637 49794404 845158550 859824825 332642546 -369736140 -432101631 -742639376 -173895851 960280819 461904329 750235945 -137571386 456528426 -6672879 744260092 -417386907 -564001493 -730291952 -667052101 584647268 109905130 -714061189 -580597322 -214372000 473981386 864486657 467036121 654717095 638346562 -807909997 416169871 -808078305 161764476 382366017 -427951009 -687647968 531075562 -571772298 -891897681 -1818149 172427781 668219989 718028102 711493192 172391856 -465953063 -758166602 277276586 528421313 456954755 -472173965 -81803206 -243286788 -323748886 -959516717 -588114…
Output: 845158550 560642277 694977299 694977299 694977299 714293637 416092475 416092475 416092475 416092475 714293637 -119957794 -119957794 8967071 82338780 82338780 285624887 285624887 714293637 714293637 845158550 845158550 859824825 960280819 960280819 -173895851 -173895851 -173895851 960280819 998197762 750235945 864486657 456528426 744260092 744260092 864486657 584647268 584647268 -667052101 584647268 864486657 473981386 -580597322 -214372000 473981386 864486657 998197762 654717095 668219989 668219989 416169871 531075562 161764476 382366017 531075562 531075562 531075562 668219989 -1818149 -1818149 172427781 668219989 718028102 998197762 998197762 277276586 277276586 277276586 528421313 998197762 998197762 -81803206 367611211 367611211 367611211 -588114116 367611211 998197762 998197762 9996724…

Example 2:

Input: 3464 405630264 -480209324 831326802 770974385 -219883043 -965756853 -998706103 -535305561 418673105 -545647122 -151108020 -480262863 -778543381 389299507 269894833 113570566 -837316597 158529155 744060048 437552227 -919768510 19352338 -981204224 -677918648 500251569 369817943 -222953405 500085209 -253565129 482016231 -644145047 949301809 465089425 -156943481 -692875179 287060382 292178066 -802256149 833598337 838863515 760277581 -598798918 518891258 -129117034 -826259872 379124744 924664610 -538285310 571387307 121361339 481416820 -315715479 -145199859 212659225 842253850 -2530734 -195904745 -288616289 267199387 241129605 -782241407 -103675747 637507752 -989664863 51817557 -500993363 450975560 575882388 68072568 -218018983 762797470 -526747911 -247572051 -639653741 831920612 -538828625 758…
Output: 831326802 831326802 949301809 949301809 418673105 -535305561 -535305561 418673105 744060048 -151108020 389299507 389299507 389299507 744060048 744060048 158529155 158529155 744060048 949301809 500251569 19352338 500251569 -677918648 500251569 949301809 500085209 500085209 949301809 482016231 949301809 949301809 995136208 833598337 287060382 287060382 292178066 833598337 833598337 838863515 924664610 924664610 518891258 924664610 379124744 379124744 924664610 995136208 571387307 842253850 481416820 842253850 -145199859 212659225 842253850 995136208 267199387 267199387 267199387 637507752 637507752 -103675747 637507752 762797470 51817557 450975560 450975560 575882388 762797470 762797470 762797470 831920612 -247572051 831920612 831920612 995136208 758863982 995136208 996723569 462724434 82624…

Example 3:

Input: 1075 -782094727 609370922 669490926 137245488 904516980 -327850057 -824266099 46726958 842884530 -418429892 -904960253 622605327 -765309774 736974566 -161987587 -348574824 790128575 335376254 -137978936 -436886613 127527465 -379024050 485087670 -855819613 -634279226 520934103 424118671 -760232624 974545046 -323073874 466110157 630139446 748216239 931911151 753855654 -157113327 564910949 866254443 -782518180 -765047364 901813614 813152278 592465706 168643955 341285860 -844213816 -194024849 321698914 -325187564 722221190 -566127317 84735416 -19055387 974465319 383448239 -504997138 -463208309 -260463516 275526622 338777265 -165323959 468637561 -890561823 -622200391 -361040686 403293927 -237158008 199885167 819479917 -428300056 238416012 -374533928 -722726478 678664094 -677184630 516970041 683…
Output: 609370922 669490926 904516980 904516980 974545046 46726958 46726958 842884530 974545046 622605327 622605327 736974566 736974566 790128575 790128575 790128575 974545046 485087670 127527465 127527465 485087670 485087670 520934103 -634279226 520934103 974545046 974545046 974545046 986929654 466110157 630139446 748216239 931911151 974465319 866254443 564910949 866254443 901813614 -765047364 901813614 974465319 974465319 722221190 341285860 722221190 -194024849 321698914 722221190 722221190 974465319 84735416 974465319 974465319 986929654 468637561 -463208309 -260463516 275526622 338777265 468637561 468637561 819479917 -622200391 -361040686 403293927 819479917 199885167 819479917 880649547 238416012 678664094 678664094 678664094 683049102 516970041 683049102 880649547 497745181 880649547 880649…

Constraints:

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

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