CT37620

Fletcher's Ledger of beacons

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Caravans arrive at the tundra station of Whitesnow with crates of beacons, and Fletcher the log keeper 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: 948 -606596366 -988173607 690300153 -909746274 -922455346 589813986 -160628988 156119295 374215869 -312295125 666014867 786025400 -802084113 -286639226 152720933 -141554577 681327973 171985769 -208314008 19788554 134626773 639203206 -825169009 377284069 870124927 470722287 965123485 -365666992 839203321 107982330 816456039 732139436 -840249541 -706989588 913218698 -511734397 -321781060 -562263880 398421500 -408041276 723139876 -783573333 -648460925 -731341962 -66307949 -405012523 -887911840 -554584414 -86245245 579943785 741653804 -321501412 4131040 -245702046 54773140 -126177534 -155211919 -263529131 -803843962 -276455824 713428480 971326111 556808471 495711054 987741089 558344024 -704690519 -618568065 -113826339 -495947563 719597693 385057615 -706884216 -466718234 685859098 430094499 -58…
Output: 690300153 690300153 786025400 589813986 589813986 666014867 156119295 374215869 666014867 666014867 786025400 870124927 -286639226 152720933 681327973 681327973 870124927 639203206 19788554 134626773 639203206 870124927 377284069 870124927 965123485 965123485 971326111 839203321 913218698 816456039 913218698 913218698 -706989588 913218698 971326111 -321781060 398421500 398421500 723139876 723139876 741653804 -648460925 -66307949 -66307949 579943785 -86245245 -554584414 -86245245 579943785 741653804 971326111 4131040 54773140 54773140 713428480 713428480 713428480 713428480 -276455824 713428480 971326111 987741089 987741089 987741089 989034421 719597693 -618568065 -113826339 719597693 719597693 894589286 685859098 -466718234 685859098 894589286 645404483 645404483 676971334 -60056289 558310…

Example 2:

Input: 3932 324722859 403612957 -749616886 126242923 697032981 864672578 762891178 -727341029 505003362 -284770075 -599327146 -645084167 -211912071 -761928013 426003299 -956831016 -316065100 -831449001 -532410141 -113507037 994454656 51737596 -834178537 -721657708 -924355173 132991695 417903468 688400847 658791121 -626365737 904186802 -109558798 315279780 160055263 839931005 -681825848 -128858305 660682926 -70099462 -513823599 -636993462 -26710600 518781936 -140369699 514375848 -384832068 541077481 -430990911 487342441 994641598 -955013758 75130100 606185838 -914090711 980596740 971164544 305938448 212260662 753004680 -822938432 849678810 -632252887 -742331544 679425486 240837458 621189089 -627717107 -247464362 718236958 -108296363 580632667 -796285211 402065604 693603412 93364378 48915961 -82727…
Output: 403612957 697032981 126242923 697032981 864672578 994454656 994454656 505003362 994454656 -211912071 -211912071 -211912071 426003299 426003299 994454656 -316065100 -113507037 -532410141 -113507037 994454656 994641598 132991695 -721657708 132991695 132991695 417903468 688400847 904186802 904186802 904186802 994641598 315279780 839931005 839931005 994641598 -128858305 660682926 994641598 -26710600 -26710600 -26710600 518781936 541077481 514375848 541077481 541077481 994641598 487342441 994641598 999508837 75130100 606185838 980596740 980596740 999508837 975717981 753004680 753004680 849678810 849678810 862568267 679425486 679425486 718236958 621189089 718236958 -247464362 718236958 862568267 580632667 693603412 402065604 693603412 862568267 624646193 624646193 624646193 862568267 862568267 9…

Example 3:

Input: 636 -452794026 -207426750 839869323 -225867803 6487313 677354375 -941232973 -530029732 -740900700 465378703 -416226126 309131337 422383485 124895956 819621405 373148578 116919849 431466261 975963391 511856632 -578650625 -210402951 -667128463 -894286491 871697597 774421286 -252272994 294229197 -912075783 95842524 195064634 -51295235 54072634 -421404131 -324763866 -510347416 373923716 -424431244 893560120 888705600 -40716788 -201077377 -638251988 -316352222 -851145407 -81198970 103602719 230909162 -960064540 -771856016 -21459480 462951129 -631253818 -327873712 865915412 -266250099 -416597901 83166422 199963025 739981571 -674452604 417128773 366315915 -972065244 763549459 -136472576 -366399448 528988375 6099641 324228334 -398049933 -812461428 600463292 681022843 -679598014 110111885 418049286…
Output: -207426750 839869323 975963391 6487313 677354375 819621405 -530029732 465378703 465378703 819621405 309131337 422383485 819621405 819621405 975963391 431466261 431466261 975963391 976363876 871697597 -210402951 871697597 871697597 871697597 893560120 893560120 294229197 373923716 95842524 195064634 373923716 54072634 373923716 -324763866 373923716 373923716 893560120 893560120 929584034 929584034 103602719 -81198970 -316352222 -81198970 -81198970 103602719 230909162 462951129 -771856016 -21459480 462951129 865915412 -327873712 865915412 929584034 83166422 83166422 199963025 739981571 763549459 417128773 763549459 763549459 763549459 929584034 528988375 528988375 600463292 324228334 600463292 600463292 600463292 681022843 929584034 110111885 418049286 638018509 638018509 929584034 153877157…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Fletcher's Ledger of beacons - MEDIUM Coding Problem | CodeTikki