CT37801

The Wild ledgers of Sailor

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Sailor found an old ledger of ledgers in the foundry attic at the ink district of Scriptoria. The margin notes pose a precise question. 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: 1876 -463794577 541319988 143305912 -919471956 539387580 -555952193 953302454 66883966 961276347 -396126782 -533824686 415452138 2928243 952306593 -99218238 -566273907 -619840306 -740448273 205527451 -289780110 683363689 365683629 -96166220 -858245454 -290725451 318965104 -432949007 -995112956 643173797 -623930712 -508173537 93149657 -891531121 381879570 329087950 241696033 939555849 29462364 123173413 272620983 -146002001 -428981551 446092517 -467968612 -256383752 -76485787 657581430 -281041564 158057399 -139078771 198400153 732298474 -459875483 -819020014 789896387 287976797 -475974455 353253001 -993781764 -149909850 -303728575 -693041726 -88208202 507058526 -245470363 -563706063 796735941 950287847 -69990374 340113592 -213917646 -311576913 823018475 -577956893 -30395693 277723524 -96948…
Output: 541319988 953302454 539387580 539387580 953302454 953302454 961276347 961276347 997449481 415452138 415452138 952306593 952306593 997449481 205527451 205527451 205527451 205527451 683363689 683363689 939555849 643173797 318965104 -290725451 318965104 643173797 643173797 643173797 939555849 -508173537 93149657 381879570 381879570 939555849 939555849 939555849 950287847 123173413 272620983 446092517 446092517 446092517 657581430 -256383752 -76485787 657581430 732298474 158057399 198400153 198400153 732298474 789896387 789896387 789896387 796735941 353253001 353253001 507058526 -149909850 -88208202 -88208202 -88208202 507058526 796735941 796735941 796735941 950287847 997449481 340113592 823018475 823018475 823018475 882513700 -30395693 277723524 518285621 518285621 882513700 882513700 8825137…

Example 2:

Input: 3412 255581472 -797428282 756146720 -500174107 230581507 -822059164 -206045064 629869744 382417097 910755153 404847131 -720418013 -90817092 805059238 -229219909 43761149 863551318 863984487 -858379547 -127524564 -992120030 -630411044 667296186 -117331291 -341266053 -443393121 783393897 715759069 -701233254 -166220256 -241605767 -708198628 -307156565 219040570 -954075778 134988604 -280000139 -54376340 -511089643 -702370418 812969302 -493882144 695251923 -703231612 -573914885 -532575761 -29565828 122088804 -415192468 -534976263 -649490615 788649353 394444809 -744956719 -899004247 518856293 -165084355 199650595 -431869941 -539490948 565714492 738386567 -333477498 -698364182 918093637 -419815472 802196949 -688327707 730468085 -259177661 675791004 974304965 431719376 -632948107 383478234 944467…
Output: 756146720 756146720 910755153 230581507 629869744 -206045064 629869744 910755153 910755153 918093637 805059238 -90817092 805059238 863551318 43761149 863551318 863984487 918093637 -127524564 667296186 -630411044 667296186 783393897 783393897 783393897 783393897 812969302 812969302 -166220256 219040570 219040570 -307156565 219040570 812969302 134988604 812969302 -54376340 812969302 812969302 812969302 918093637 695251923 788649353 -573914885 -532575761 -29565828 122088804 788649353 788649353 788649353 788649353 918093637 518856293 518856293 518856293 565714492 199650595 565714492 565714492 565714492 738386567 918093637 918093637 918093637 974304965 802196949 974304965 730468085 974304965 675791004 974304965 996919129 944467143 383478234 944467143 996919129 996919129 998560866 945308632 1375…

Example 3:

Input: 3356 -72448956 193504817 943537234 96829381 895590614 -510128917 316881237 324627740 -749561251 -133197742 991793437 638562449 -675072251 826619709 711769728 427671494 -556151109 -930271015 -491193477 -912169406 536442074 -525608814 -297950525 301971626 557798624 -298816760 332277854 247961324 -331263675 532002788 -95201854 -147744089 -280944234 150208745 -504635814 988920200 -973331069 340408601 -397948372 -636235885 332694013 943059385 -555777054 873304533 -102760547 914680966 137315719 -33446009 -153331156 465912106 -862157173 396793288 -884201301 -85680328 557693978 -687922874 651380449 -933520912 391204280 -884000673 801142231 543387954 888912126 -609971146 -275933289 -364742379 499193280 -916567503 194809474 -574889451 455320370 263782886 624359468 630343737 -979798860 -364127799 701…
Output: 193504817 943537234 991793437 895590614 991793437 316881237 324627740 991793437 -133197742 991793437 999861846 826619709 826619709 988920200 988920200 536442074 -491193477 -491193477 536442074 536442074 557798624 -297950525 301971626 557798624 988920200 332277854 532002788 532002788 532002788 988920200 150208745 150208745 150208745 988920200 988920200 999861846 340408601 943059385 332694013 332694013 943059385 947979688 873304533 914680966 914680966 947979688 465912106 465912106 465912106 557693978 396793288 557693978 -85680328 557693978 651380449 651380449 801142231 391204280 801142231 801142231 888912126 888912126 890088687 -275933289 499193280 499193280 624359468 194809474 455320370 455320370 624359468 624359468 630343737 701919728 -364127799 701919728 888671132 575144770 575144770 8886…

Constraints:

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

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