CT43526

The marks at Saffronia

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the spice bazaar of Saffronia as Squire unrolls the day's manifest of marks. The tally will decide the next shipment. 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: 1498 941247611 -295600106 891623835 -688364742 -125518318 -235537973 -89051400 -114991463 -21509961 -705537043 -206945087 -636293732 -245674851 -799383393 105816480 -671890523 -887520117 -304112487 -439962694 605355209 -590575882 -682472755 923061612 213956816 626838953 50838791 739398241 317705606 -863918071 -243994231 88885467 -575147236 566002444 -505909253 408939764 -46221013 288614561 -296694341 -886946147 799450391 298222487 488993211 -493114449 -853269768 516143940 -534940346 -887631079 908376921 -49502963 125839896 25836146 889968353 900692037 -648527188 -933867261 527548432 684046118 -833353906 143767991 -580144839 721266456 -788487279 920525908 -707272887 793677610 -688035131 365933396 230423506 -172079227 841610886 380197605 77488347 -44901874 390734222 949670918 -607115445 8074…
Output: 949670918 891623835 923061612 -125518318 -89051400 -89051400 -21509961 -21509961 105816480 -206945087 105816480 -245674851 105816480 105816480 605355209 -304112487 -304112487 605355209 605355209 923061612 923061612 923061612 949670918 626838953 739398241 739398241 799450391 566002444 -243994231 88885467 566002444 566002444 799450391 408939764 799450391 288614561 799450391 799450391 799450391 908376921 488993211 516143940 516143940 516143940 908376921 908376921 908376921 920525908 125839896 889968353 889968353 900692037 920525908 527548432 527548432 684046118 721266456 143767991 721266456 721266456 920525908 920525908 949670918 793677610 841610886 365933396 841610886 841610886 841610886 949670918 390734222 390734222 390734222 949670918 975642764 807499516 926870363 121295093 926870363 97564…

Example 2:

Input: 2929 -645785452 577763311 -583518710 842188838 -941256361 920511654 484210890 291365612 -602946008 879156386 -586239542 331014627 -840922116 846404383 -672744762 255308027 729113523 203645253 528367549 -967382074 -743332478 -947864749 888321149 18732237 -859479807 -898737580 565913358 105519332 837680141 -202652110 -426776732 -871344285 102828787 166186544 -601692532 543236745 648128653 -977305773 -841047764 365937388 731197244 -615426456 534660065 671736633 182161904 -163179066 319059469 -439788235 947111497 924205321 160605776 241588991 906035893 -588851195 947431158 340548058 -4701364 373515669 -365097496 -907054288 693708179 77919173 -318091464 -577242169 -138663003 -37964362 541091264 -548150880 173547243 -122440545 92656091 -998160293 -2476502 -906805264 -481395993 915901272 90022790…
Output: 577763311 842188838 842188838 920511654 920511654 947111497 879156386 879156386 879156386 888321149 331014627 846404383 846404383 888321149 255308027 729113523 888321149 528367549 888321149 -743332478 888321149 888321149 947111497 565913358 565913358 565913358 837680141 837680141 947111497 102828787 102828787 102828787 166186544 543236745 543236745 648128653 731197244 -841047764 365937388 731197244 947111497 534660065 671736633 947111497 319059469 319059469 947111497 947111497 947431158 947431158 241588991 906035893 947431158 947431158 988081294 373515669 373515669 693708179 693708179 693708179 915901272 541091264 -138663003 -138663003 -37964362 541091264 915901272 173547243 915901272 92656091 915901272 -2476502 915901272 -481395993 915901272 924643496 924643496 733260076 733260076 7332600…

Example 3:

Input: 755 -477869274 731680971 25970781 274407836 784013825 -262905172 206845373 -320564201 -124927450 -417313928 770001757 338475769 -469965259 951616244 -647873669 57330177 -830370925 673027088 589163555 756727974 788818790 710488099 -21171585 201555550 -691794758 -781603535 -633071864 -822987596 -791481110 806725489 -713077660 -38026779 -605607097 80492510 775591940 615983719 -79190082 849143925 54583970 845892577 -970856723 764279864 439773524 225232949 -102696831 102847152 200866223 536420676 -23385927 376036687 783199941 37653671 377146565 -555855422 389056285 27609825 175785575 -431136261 -606605907 524897562 639657565 -803580751 -480038241 790483539 516958028 -546258119 29821702 551982496 -68195737 114464926 -464209121 68661981 106976340 -623336904 -199542100 935936783 662516810 -8963236…
Output: 731680971 784013825 274407836 784013825 951616244 206845373 770001757 -124927450 770001757 770001757 951616244 951616244 951616244 962070243 57330177 673027088 673027088 756727974 756727974 788818790 806725489 806725489 201555550 806725489 -633071864 -633071864 806725489 -791481110 806725489 849143925 -38026779 80492510 80492510 775591940 849143925 849143925 849143925 935936783 845892577 935936783 764279864 783199941 536420676 536420676 102847152 200866223 536420676 783199941 376036687 783199941 790483539 377146565 389056285 389056285 524897562 175785575 524897562 524897562 524897562 639657565 790483539 -480038241 790483539 935936783 551982496 29821702 551982496 935936783 114464926 935936783 68661981 106976340 935936783 -199542100 935936783 962070243 857089199 22180236 275135229 857089199 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The marks at Saffronia - MEDIUM Coding Problem | CodeTikki