CT35658

Gautam's registers Taller Ahead

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

At the fjord village of Deepwater, Gautam records each registers 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: 333 -773746991 334158786 110418258 236555834 407012928 259975050 -949357483 421142467 -114952277 637382940 21768628 -723783790 -725200532 378921354 -787293333 -190531667 764712128 488751735 -639973710 870070943 958807474 -757951546 495821490 -484367839 -636262862 406633371 -585549124 -766843150 651570255 666337868 775850561 776579500 -567667411 -486565233 -160916604 -911825570 978863523 239407119 -931171834 462545885 162983889 -821350926 243618608 -539297362 -375077384 432867374 -153751909 -268433577 931961941 -223554134 -84402431 -152280620 -139832101 478378105 -59920757 113286574 -510982706 595330133 596611734 -71549303 -807109898 897245563 -566495199 -220100183 970748727 -498017035 -780460861 -287689382 298277404 496712329 -571258422 -603841112 678881962 -266204005 883726678 -61146798 -…
Output: 334158786 407012928 236555834 407012928 421142467 421142467 421142467 637382940 637382940 764712128 378921354 378921354 378921354 764712128 -190531667 764712128 870070943 870070943 870070943 958807474 978863523 495821490 651570255 406633371 406633371 651570255 651570255 651570255 666337868 775850561 776579500 978863523 -486565233 -160916604 978863523 978863523 997505253 462545885 462545885 931961941 243618608 243618608 432867374 -375077384 432867374 931961941 931961941 931961941 970748727 -84402431 478378105 -139832101 478378105 595330133 113286574 595330133 595330133 596611734 897245563 897245563 897245563 970748727 -220100183 970748727 973633017 -287689382 -287689382 298277404 496712329 678881962 678881962 678881962 883726678 883726678 954961338 14408710 14408710 594286603 -264207471 594…

Example 2:

Input: 2214 -879968963 -819899909 -993694047 -801837935 -718727942 -596577217 241713589 -525100868 -911813783 981279955 360519591 347148687 834845038 416197314 180346831 -736737677 -14883945 -624161669 930664548 481445781 -775003189 588569174 475313971 -994970536 442761772 473154038 515710131 -440811488 988303274 475462198 -785723994 -172893690 475111198 964897845 272853175 926279437 -1750866 -425973169 618567393 -546501905 -865569912 667027892 -981008446 -273403456 -65215301 504354611 459743513 -710935389 -361717988 -874969893 164745976 -468952802 13569453 -726701549 -867529102 -560751838 567833647 -365427609 -369014448 -942318312 976445053 628937028 626773416 45231850 -857990640 -529298356 278698063 -806870576 -38231465 848185994 584409015 394996761 -252396581 139963599 -197449693 303199687 -43…
Output: -819899909 -801837935 -801837935 -718727942 -596577217 241713589 981279955 981279955 981279955 988303274 834845038 834845038 930664548 930664548 930664548 -14883945 930664548 930664548 988303274 588569174 588569174 988303274 515710131 442761772 473154038 515710131 988303274 988303274 992004555 964897845 -172893690 475111198 964897845 976445053 926279437 976445053 618567393 618567393 667027892 667027892 667027892 976445053 -273403456 -65215301 504354611 567833647 567833647 -361717988 164745976 164745976 567833647 13569453 567833647 -560751838 -560751838 567833647 976445053 976445053 976445053 976445053 992004555 848185994 848185994 278698063 -529298356 278698063 848185994 -38231465 848185994 931808340 810559552 810559552 139963599 303199687 303199687 810559552 -256640772 -256640772 -2566407…

Example 3:

Input: 185 -671918409 111574006 -291828442 845209636 -726294010 -728118001 -556310722 493192225 394598270 -673182742 -61003076 811551510 -212583733 916749666 -858476536 -497596858 -577994390 408891097 162198081 -864640197 260604711 -736143505 -648367702 648017891 853845150 667438506 -782847731 -958342378 -144662389 659479240 197454803 -920964595 -470499575 682839705 -249576341 340995664 13506715 -778675927 297947653 535131665 -851474313 764088882 -493008726 -869467264 -314674684 757011384 -399206829 -849807166 -327229470 -216610377 262318213 -490342988 -56662565 -177157399 -137682411 831947286 848555344 262478082 -903325636 661133562 293175470 756885013 619126496 110593288 -953607285 569772951 760901568 858543596 769122454 -128558644 263800972 -420230731 -858803830 905699027 -280167658 -283776242…
Output: 111574006 845209636 845209636 916749666 -556310722 -556310722 493192225 811551510 811551510 -61003076 811551510 916749666 916749666 933199982 -497596858 408891097 408891097 648017891 260604711 260604711 648017891 -648367702 648017891 853845150 858543596 682839705 -144662389 -144662389 659479240 682839705 682839705 -470499575 682839705 764088882 340995664 535131665 297947653 297947653 535131665 764088882 764088882 831947286 -314674684 -314674684 757011384 831947286 -327229470 -327229470 -216610377 262318213 831947286 -56662565 831947286 -137682411 831947286 848555344 858543596 661133562 661133562 756885013 756885013 760901568 760901568 569772951 569772951 760901568 858543596 905699027 905699027 263800972 905699027 905699027 905699027 933199982 486472462 486472462 611790268 -9269870 32747514…

Constraints:

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

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