CT40855

Painted marks Taller Ahead

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

In the basalt cliffs of Obsidian Shore, Silas the auditor keeps careful count of the marks. Certify the cargo before shipping, every figure matters. 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: 3743 938946708 -526823903 -800203764 -553206119 93357888 728054733 -810878267 -992625867 886647793 362914238 -242963111 -822986911 -733799931 -53940927 383726275 -92543965 922083954 914017896 977222582 -6403451 785822011 822512962 453705740 -430905779 -815623974 546298800 -552706912 -4203994 601400502 -852915305 -389699241 -976223084 -447471570 180195996 53067159 -979123606 108842769 -371882031 724193939 923980658 -983951402 899273195 -78455075 295882657 799473394 -572905995 895566817 649160241 -828006921 358146689 -800092944 -777278588 625369063 -346379574 -293228868 -241358814 -623755670 145190888 -656494949 -783587101 39868588 -482136538 88106656 195293323 -70717965 600867625 741388411 -315322059 484445154 -513263484 -609990643 -234770558 -501529265 -36191744 -507666719 -859981242 -2917…
Output: 977222582 93357888 -553206119 93357888 728054733 886647793 886647793 886647793 922083954 383726275 -53940927 -733799931 -53940927 383726275 922083954 922083954 977222582 977222582 979627652 785822011 822512962 923980658 546298800 546298800 546298800 601400502 -4203994 601400502 724193939 -389699241 180195996 -447471570 180195996 724193939 108842769 108842769 724193939 724193939 923980658 961465294 899273195 961465294 295882657 799473394 895566817 895566817 961465294 741388411 358146689 625369063 -777278588 625369063 741388411 -293228868 -241358814 145190888 145190888 195293323 39868588 39868588 88106656 88106656 195293323 600867625 600867625 741388411 805933280 484445154 614242052 -234770558 -234770558 -36191744 -36191744 202758311 -291714132 -291714132 202758311 370616257 614242052 614242…

Example 2:

Input: 243 -404499943 58606494 104730390 -934687191 219922660 210807813 559698290 -368273987 -428960919 -543731971 -472376394 -568232860 -617484864 118844 132644008 877338357 414090298 310355080 934419384 202591714 -1251873 880077810 -912572129 312448522 498721698 65927375 203238655 -853006836 719671144 81140851 -444060594 -177390 468813882 -21766302 946636498 12501703 167617121 814875653 -997336872 -10046820 613670325 999973672 -767846900 612010938 -453691578 -153456011 -312648284 976895117 172731219 611361376 -524897624 -77636155 -469571058 286471242 635310727 -350484800 -956540734 176451442 15937716 -681783394 -957486980 -967668705 -492441618 141700396 -488409177 895529146 398737585 -689159231 589853184 999983177 820459739 -971458247 -562595112 -65234462 -736289025 -427950369 -977333657 775790…
Output: 58606494 104730390 219922660 219922660 559698290 559698290 877338357 118844 118844 -472376394 118844 118844 118844 132644008 877338357 934419384 934419384 934419384 946636498 880077810 880077810 946636498 312448522 498721698 719671144 203238655 719671144 719671144 946636498 468813882 -177390 468813882 946636498 946636498 999973672 167617121 814875653 999973672 -10046820 613670325 999973672 999983177 612010938 976895117 -153456011 976895117 976895117 999983177 611361376 635310727 -77636155 286471242 286471242 635310727 895529146 176451442 176451442 895529146 141700396 -492441618 -492441618 -492441618 141700396 895529146 895529146 999983177 589853184 589853184 999983177 -1 956497507 -562595112 -65234462 775790825 -427950369 775790825 775790825 956497507 426421227 426421227 611835557 28450464…

Example 3:

Input: 2251 -602351475 -180811582 -949756405 359456047 881663293 498342171 -874999222 -642988168 -781083396 872879944 541412025 773975244 -299854911 -936776655 -990632198 49915224 -601294472 882808870 483090829 588530062 590629611 -783742747 -949172033 -804337312 349221422 -264565993 -330127742 321784205 -752639908 973021858 83858562 -625177244 -415688087 269644027 -290942903 -510117454 640336331 258828066 -816492319 297605677 -795153238 -562005114 -438742905 403878318 683580039 -703320778 381127983 -17831492 125307782 -701616409 -836020839 264446687 -45520382 -300529918 197579574 -390540739 -4889099 -353661268 -569737917 609437546 -658328703 -29814443 405367891 627743398 -344601937 663825016 172128821 -294918224 -801715682 -193679541 860692627 414738548 -938316175 -232397061 137930010 929492866 …
Output: -180811582 359456047 359456047 881663293 882808870 872879944 -642988168 872879944 872879944 882808870 773975244 882808870 49915224 49915224 49915224 882808870 882808870 973021858 588530062 590629611 973021858 349221422 -804337312 349221422 973021858 321784205 321784205 973021858 973021858 992091048 269644027 -415688087 269644027 640336331 640336331 640336331 683580039 297605677 297605677 403878318 -562005114 -438742905 403878318 683580039 860692627 381127983 609437546 125307782 264446687 264446687 264446687 609437546 197579574 197579574 609437546 -4889099 609437546 609437546 609437546 627743398 -29814443 405367891 627743398 663825016 663825016 860692627 860692627 -193679541 -193679541 860692627 929492866 929492866 -232397061 137930010 929492866 951066795 238904107 460700128 460700128 46070…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Painted marks Taller Ahead - MEDIUM Coding Problem | CodeTikki