CT50240

Cressida's Golden marks

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Caravans arrive at the mining town of Ironvein with crates of marks, and Cressida the tallyman must account for every last one. 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: 1984 97528290 -815963908 -934193835 -831928325 818680788 955290388 -19882636 71607148 820675112 985918105 -308616803 594894649 -142847759 -202690016 23028366 973238311 -128642796 -534309024 524691290 -14114362 154234709 -57103644 -376831550 -322034272 -743628886 319544904 211396062 -633398864 -281461701 -410618939 33165401 -498631901 -450973198 341688807 572536823 749976839 -983388089 -283149205 90563244 17500252 -916712841 594517894 -421917001 -994491263 120697944 -270293168 -367611863 243243414 -434498982 -210984568 -880103386 898007185 -973374931 -9794304 595733193 36670690 -790328198 211898510 -848535687 707438824 -953688339 989031755 131862101 -819779878 -445257444 -257608432 803035086 -418320554 927649238 671510759 -592999883 -60532966 -799810695 -211857003 807049047 690451360 -56673…
Output: 818680788 818680788 -831928325 818680788 955290388 985918105 71607148 820675112 985918105 989031755 594894649 973238311 23028366 23028366 973238311 989031755 524691290 524691290 572536823 154234709 319544904 319544904 -322034272 319544904 319544904 341688807 341688807 -281461701 33165401 33165401 341688807 -450973198 341688807 572536823 749976839 898007185 -283149205 90563244 594517894 594517894 594517894 898007185 120697944 120697944 243243414 243243414 243243414 898007185 -210984568 898007185 898007185 989031755 -9794304 595733193 707438824 211898510 211898510 707438824 707438824 989031755 989031755 998964411 803035086 -445257444 -257608432 803035086 927649238 927649238 998964411 807049047 -60532966 807049047 -211857003 807049047 998964411 998964411 -113554095 637335304 637335304 9989644…

Example 2:

Input: 927 -634724534 -726110427 -463570423 -193168208 -325642994 -459889916 381016218 687398406 984180090 -969721233 -97733874 -721171998 -759337718 -474042251 362659598 702003689 191844413 -444823291 625773191 172452616 -366924382 -287901126 146856804 -37861167 -403647991 -79368057 -550081119 895457129 -148432546 489045640 344970062 336683777 -277775002 152266982 876743937 -575968178 663104616 786247445 904010447 -986201581 363043613 -985342865 975439032 41487686 -523484645 -719342779 -859827800 771552907 -997563304 -701119539 301805124 41512106 -251833125 713816218 -264085686 -235901797 451661548 246084748 288368185 743222028 -509563900 885559984 598086223 933939240 -320497404 -544505869 -105668302 -580940512 992369624 -78105947 660251630 284157404 -732431182 -843193490 -767207199 -966492143 -…
Output: -463570423 -463570423 -193168208 381016218 381016218 381016218 687398406 984180090 992369624 -97733874 362659598 -474042251 -474042251 362659598 702003689 895457129 625773191 625773191 895457129 895457129 -287901126 146856804 895457129 895457129 -79368057 895457129 895457129 904010447 489045640 876743937 876743937 876743937 152266982 876743937 904010447 663104616 786247445 904010447 975439032 363043613 975439032 975439032 992369624 771552907 771552907 771552907 771552907 885559984 -701119539 301805124 713816218 713816218 713816218 743222028 -235901797 451661548 743222028 288368185 743222028 885559984 885559984 933939240 933939240 992369624 -105668302 -105668302 992369624 992369624 998267943 660251630 665979108 665979108 -589238128 -767207199 -589238128 -589238128 -336092987 665979108 89311…

Example 3:

Input: 2634 187739051 531367157 892454967 -297137741 -258647951 -667356565 962503336 373470951 196193014 954686555 -946868265 420321869 -297739182 325499170 -963638182 -753131333 -65796455 67261028 -110118317 -465084817 -367303309 870210287 -280027425 617023876 -981926713 -651642973 -517859171 171537866 -830796606 -866384624 174985831 -90165205 -590623294 448318156 509827827 -90078430 122753948 -130804339 335949828 -588465149 479954725 -968035963 78607197 624163072 -650286393 123311744 956927190 451252858 7127144 512830424 844683728 364407930 702580955 -102020103 -843377638 905875639 183298544 -765427432 -190486976 -706575632 591450310 -542271757 648253338 -776513649 736174382 -154343373 995100483 -537528864 -875413727 -442567083 963561271 950602196 120347486 -460708803 520363793 266861036 -95599…
Output: 531367157 892454967 962503336 -258647951 962503336 962503336 995100483 954686555 954686555 956927190 420321869 870210287 325499170 870210287 -753131333 -65796455 67261028 870210287 870210287 -367303309 870210287 956927190 617023876 624163072 -651642973 -517859171 171537866 174985831 174985831 174985831 448318156 448318156 448318156 509827827 624163072 122753948 335949828 335949828 479954725 479954725 624163072 78607197 624163072 956927190 123311744 956927190 995100483 512830424 512830424 844683728 905875639 702580955 905875639 905875639 905875639 995100483 591450310 -190486976 591450310 591450310 648253338 648253338 736174382 736174382 995100483 995100483 996084091 -442567083 -442567083 963561271 989734204 989734204 520363793 520363793 645930744 645930744 645930744 946858230 611778848 6117…

Constraints:

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

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