CT55772

The ledgers at Caravanrest

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The customs officer Ranger has been asked to balance the workshop's books. On the desk lies a long table of ledgers 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: 417 -478533295 -619772826 58438664 326913463 -401300154 841727580 -417152060 708490232 585524718 493552352 -902581775 -682395898 -356274861 380740742 -219297868 510858662 -785696535 393525176 429051758 968919322 -277953595 883806583 -458210527 -81021395 -971030043 -723487671 219185528 784177858 874377919 -862298973 -37862705 974215833 -893224862 727908368 -736245792 -301770276 371546363 284359291 956239149 22089453 -684137486 -256651163 -645304290 -959456146 -519021248 -741503140 667092711 -18483597 19714259 -232403823 -810001174 120961262 819327744 792285438 -15596505 219292114 944974894 -161616494 555690361 -649000431 -626987917 625543231 -708160053 -717506968 623566566 -495951619 660078963 -956071283 740715406 807081585 -292346998 -910966934 781057608 988073607 423697062 -769875491 -260…
Output: 58438664 58438664 326913463 841727580 841727580 968919322 708490232 968919322 968919322 510858662 -682395898 -356274861 380740742 510858662 510858662 968919322 393525176 429051758 968919322 974215833 883806583 974215833 -81021395 219185528 -723487671 219185528 784177858 874377919 974215833 -37862705 974215833 988073607 727908368 956239149 -301770276 371546363 956239149 956239149 988073607 667092711 -256651163 667092711 -519021248 -519021248 667092711 667092711 819327744 19714259 120961262 120961262 120961262 819327744 944974894 944974894 219292114 944974894 988073607 555690361 625543231 -626987917 625543231 660078963 623566566 623566566 660078963 660078963 740715406 740715406 807081585 988073607 781057608 781057608 988073607 999756695 563063468 -260963918 563063468 -329265674 563063468 582…

Example 2:

Input: 115 870227482 890565798 722229096 -641065844 -259418379 288387388 -445767464 -480772931 -832115872 898818772 -157694321 -640818594 -568541842 98441906 -216820573 428422900 770932377 -636280910 -18597951 -426296751 -630759224 344262158 -293253237 959315396 605008099 -623617664 21948117 306681649 398757313 -328461312 -559655555 -841752224 353356076 -782110680 -605747457 -949738296 -564529401 -998421915 -671659672 821512604 -690205984 -353633691 635160614 596112999 -10767092 -442262433 -485287974 -21155861 99541177 18658179 -489970221 429049612 -143039924 299397457 -505186523 -695877703 430218588 -848110474 -111089961 -223774752 395774602 19252920 261754229 99077061 -662350099 -198380642 300203575 523684583 774241832 -927506451 824145506 477261643 -845069451 102499932 -162796669 -975900900 -9…
Output: 890565798 898818772 898818772 -259418379 288387388 898818772 898818772 898818772 898818772 959315396 98441906 -568541842 98441906 428422900 428422900 770932377 959315396 -18597951 344262158 344262158 344262158 959315396 959315396 984285040 821512604 21948117 306681649 398757313 821512604 353356076 353356076 353356076 821512604 -605747457 -564529401 -564529401 821512604 -671659672 821512604 824145506 -353633691 635160614 774241832 774241832 99541177 -21155861 -21155861 99541177 429049612 429049612 429049612 430218588 299397457 430218588 430218588 430218588 523684583 -111089961 395774602 395774602 523684583 261754229 300203575 300203575 -198380642 300203575 523684583 774241832 824145506 824145506 872305231 872305231 102499932 872305231 872305231 -915455435 -760190167 -760190167 -535109686 87…

Example 3:

Input: 1709 -77362881 857473178 967687166 886836218 634457309 884387226 128761834 -427957811 61477669 -548771053 -390196241 -183614756 977175493 -829875898 -770601752 457403055 822796622 -291362313 -935965133 968908477 -120253809 541628686 -374372239 393538620 -509763423 -749221986 961925957 912739187 174363566 -524296047 123959086 -623228961 552034519 -49948194 229153558 487242742 -765071930 -382720999 747961137 -605600477 900175243 -176032926 -263785218 -874930365 13885867 -907254916 -360581307 52252800 477052687 547512863 -609026244 -25811322 750742768 -149273387 838961455 449957249 860328290 -782106688 58704116 948371845 453031235 -491892072 -672705859 -242849823 -164731413 814588464 219137054 211904807 307108353 668713760 876779345 609271269 -534874375 -54998366 -637784665 -414572418 -746706…
Output: 857473178 967687166 977175493 977175493 884387226 977175493 977175493 61477669 977175493 -390196241 -183614756 977175493 980795887 -770601752 457403055 822796622 968908477 968908477 968908477 971608718 541628686 961925957 393538620 961925957 961925957 961925957 965884244 948371845 552034519 123959086 552034519 552034519 747961137 229153558 487242742 747961137 -382720999 747961137 900175243 900175243 948371845 13885867 13885867 13885867 52252800 -360581307 52252800 477052687 547512863 750742768 -25811322 750742768 838961455 838961455 860328290 860328290 948371845 58704116 948371845 965884244 814588464 -242849823 -242849823 -164731413 814588464 876779345 307108353 307108353 668713760 876779345 924830746 762195641 -54998366 762195641 -414572418 762195641 -663373618 762195641 924830746 6591754…

Constraints:

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

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