CT54348

The Taller Ahead Beneath Rootwater

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The paymaster Theo has been asked to approve the repair estimates. 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: 1212 245468512 -392800802 8243514 342406675 -133467954 761055378 370635289 -645399017 827108078 882902127 827769911 911183326 -910079515 63549206 -36915677 269566473 445403927 -701386483 -924897751 -921971216 979834183 -178825200 905231458 -221963649 -668657258 -989520865 992984286 225738784 -109467544 499423500 537617148 71590968 -986951564 -171921604 -721325363 -851585403 41586172 -756476588 894562218 147549826 604866377 -282357326 -740968434 -283669981 902898262 664826096 321063123 659767592 -848454988 -859970203 -765409988 7406754 821770589 768332880 -36507773 -499190995 920253867 -858724403 -582171336 -483722339 828267636 -405202160 -628380250 829610767 -449926444 919065723 -521126659 261776263 10387036 978681766 806801053 -516965856 -581578462 -18483333 63129255 -919823048 -248127169…
Output: 342406675 8243514 342406675 761055378 761055378 827108078 827108078 827108078 882902127 911183326 911183326 979834183 63549206 269566473 269566473 445403927 979834183 979834183 -921971216 979834183 992984286 905231458 992984286 992984286 992984286 992984286 993126034 499423500 499423500 537617148 894562218 894562218 -171921604 41586172 41586172 41586172 894562218 894562218 902898262 604866377 902898262 902898262 -283669981 902898262 920253867 821770589 659767592 821770589 -765409988 -765409988 7406754 821770589 920253867 920253867 920253867 920253867 978681766 -582171336 -483722339 828267636 829610767 829610767 829610767 919065723 919065723 978681766 261776263 978681766 978681766 993126034 849002158 -18483333 -18483333 63129255 665169272 -248127169 665169272 -405434345 665169272 665169272 …

Example 2:

Input: 2756 -81451110 457926556 -289020568 -88815230 -575744076 -837861146 -385349167 -679692523 -102162492 -305956942 924801763 -739841077 221487287 -421158395 813048799 669570689 -601513048 831802102 -148529844 -409684091 929484121 887167951 -451165887 330600184 -570682882 720902552 212797778 -237603744 485074067 809856639 460980491 932633133 359061903 670555235 -953596643 901028152 53250093 -491840404 -295724015 820067420 -322557929 -854222394 413806736 80909744 -894017486 -502774553 -232537492 645291022 -709389844 -69828438 -244238098 148268656 -441309043 -851186865 597099848 -976271216 475882963 -974420078 647236679 478906559 -51872404 -659006216 -595440255 885783800 221951672 467639028 -953878887 61239165 -606297500 -286514560 -304009845 -461221774 247057167 493749272 -120285532 527814156 1…
Output: 457926556 924801763 -88815230 924801763 -385349167 -385349167 -102162492 -102162492 924801763 924801763 929484121 221487287 813048799 813048799 831802102 831802102 831802102 929484121 929484121 929484121 932633133 932633133 330600184 720902552 720902552 809856639 485074067 485074067 809856639 932633133 932633133 941627371 670555235 901028152 901028152 941627371 820067420 -295724015 820067420 885783800 413806736 413806736 645291022 645291022 -502774553 -232537492 645291022 647236679 -69828438 148268656 148268656 597099848 597099848 597099848 647236679 475882963 647236679 647236679 885783800 885783800 885783800 -595440255 885783800 941627371 467639028 493749272 61239165 247057167 -286514560 247057167 247057167 247057167 493749272 527814156 527814156 759647804 80496363 -324070084 -324070084 8…

Example 3:

Input: 3928 -923456399 -831354950 475534996 -243458131 774070620 -634981390 -59404771 190195592 208218124 673590898 -729806599 -133914064 -735027542 703600108 -358694728 -718622755 358177708 994038995 -757112111 397133886 232135337 -93144714 800816443 -882854124 644420608 -400229537 -785852091 343386850 -684328428 -968520997 615184685 -448367183 579179711 -17987428 557951510 871540630 -69370838 292681435 -381460089 -871377808 70406990 -600701106 628509902 -133007551 965421444 917089532 -694245207 613289285 960800906 -582449824 -367828224 -538322403 -779972863 -866288008 670623053 58451028 -165644121 200729938 28352034 -690907883 155627930 925867940 523817304 -528205974 140973897 738830471 429618250 -873568269 -713912318 -933817986 -110277475 -889181825 -317845813 625813529 253338036 -780401188 -7…
Output: -831354950 475534996 774070620 774070620 994038995 -59404771 190195592 208218124 673590898 703600108 -133914064 703600108 703600108 994038995 358177708 358177708 994038995 999858799 397133886 800816443 800816443 800816443 871540630 644420608 871540630 343386850 343386850 615184685 615184685 615184685 871540630 579179711 871540630 557951510 871540630 965421444 292681435 628509902 70406990 70406990 628509902 628509902 965421444 965421444 968688557 960800906 613289285 960800906 968688557 -367828224 670623053 670623053 670623053 670623053 925867940 200729938 200729938 925867940 155627930 155627930 925867940 968688557 738830471 140973897 738830471 747646644 625813529 -713912318 -110277475 -110277475 625813529 -317845813 625813529 747646644 747646644 747646644 747646644 864454953 663278454 66327…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Taller Ahead Beneath Rootwater - MEDIUM Coding Problem | CodeTikki