CT48048

Xavi's Ledger of beacons

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Xavi the bookkeeper watches over the saffron fields of Marigold Row's stores of beacons. A careful computation stands between order and chaos. 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: 2451 -152321831 953007084 -603139309 412057042 840581305 -235495783 701620403 449594077 -316570955 606317058 -807239835 130139374 77190535 -267258669 -707453459 464907790 -999615601 -104064538 -440293936 850628100 384820073 972744149 -484795567 886404081 -308677721 443625258 -669606392 -419780534 -923915694 60170539 356043968 -123373584 802263706 -134809830 568824752 677365594 -841811628 490142712 -946877617 -437825485 268427031 137089627 -448302980 -342221413 796825662 -975378609 -45976702 757366054 484846775 -431425524 48431429 -450603897 662295230 -581846401 -117636360 -799147611 -604298379 -975450727 -803926001 351324842 698969247 890936368 -261934753 827103876 184782559 -945598270 539455380 513805163 -958762926 611454501 750301756 -752425267 183935645 539713946 676557034 338588000 -34…
Output: 953007084 972744149 412057042 840581305 850628100 701620403 850628100 606317058 606317058 850628100 130139374 464907790 464907790 464907790 464907790 850628100 -104064538 850628100 850628100 972744149 972744149 995665954 886404081 890936368 443625258 802263706 -419780534 60170539 60170539 356043968 802263706 802263706 890936368 568824752 677365594 796825662 490142712 796825662 -437825485 268427031 796825662 796825662 -342221413 796825662 890936368 -45976702 757366054 890936368 662295230 48431429 662295230 662295230 698969247 -117636360 351324842 -604298379 351324842 -803926001 351324842 698969247 890936368 921343208 827103876 921343208 539455380 539455380 611454501 611454501 611454501 750301756 783115524 183935645 539713946 676557034 704057392 660629645 660629645 660629645 660629645 704057…

Example 2:

Input: 2188 704259960 -696419103 -373533690 24108652 -662344793 -361115361 976932647 -521640095 639891382 -306254257 352166779 294095739 858194182 -751747125 824426463 -55984241 85082884 15450724 485901227 955015102 -448286731 -842650365 23031018 548123381 -842020345 850756838 -315033483 -855367126 -880188450 -935500026 579821581 -929251342 -78127461 -656693560 102027190 -902276296 -691866744 301107761 949734930 686502278 -26050823 290175908 453918660 638178631 -298649572 -837921136 983727663 -712336281 980024630 -454965027 848260773 966305476 97612556 862106448 18855966 333934545 -644599640 -173763206 171451095 -733659351 591502475 -64737266 -623376261 -595371255 432691400 -829180238 -798499259 720199951 927130738 -538820560 65433644 327865767 -217576037 523114668 651569802 76481047 -529629954 1…
Output: 976932647 -373533690 24108652 976932647 -361115361 976932647 983727663 639891382 858194182 352166779 858194182 858194182 955015102 824426463 955015102 85082884 485901227 485901227 955015102 983727663 23031018 23031018 548123381 850756838 850756838 949734930 579821581 579821581 579821581 579821581 949734930 -78127461 102027190 102027190 301107761 -691866744 301107761 949734930 983727663 983727663 290175908 453918660 638178631 983727663 983727663 983727663 995725078 980024630 995725078 848260773 966305476 969729413 862106448 927130738 333934545 591502475 -173763206 171451095 591502475 591502475 720199951 432691400 -595371255 432691400 720199951 -798499259 720199951 927130738 969729413 65433644 327865767 523114668 523114668 651569802 969729413 161747935 161747935 969729413 -901010 969729413 9…

Example 3:

Input: 1572 11307175 486142366 -737099545 -363771171 824027309 989882133 880099010 147049146 -791062798 -950514566 302334293 -101188441 -32091018 698113595 851127379 -428769847 -516362671 666744316 -442818657 -928578487 32796782 138240405 -736465378 -11752484 -649818197 -96149584 115857271 -672193256 -637365593 452855316 -404248863 509080790 739640300 761455463 470453419 890110496 -739904958 532021810 -862792829 -274977669 130725321 -392113547 -556444446 -646617804 -582044844 -495934937 36723269 210016858 878388758 907564442 422882563 275904495 666157516 -476069078 -942334425 717787401 -672155977 528420895 -404564277 655897934 -99404293 -359617283 -902685913 873273017 473735209 348246671 -671974961 159130158 565270218 407467555 317804173 864019380 -175603754 -387856668 26755138 -586823721 1030284…
Output: 486142366 824027309 -363771171 824027309 989882133 990426101 890110496 302334293 302334293 302334293 698113595 -32091018 698113595 851127379 890110496 666744316 666744316 739640300 32796782 32796782 138240405 452855316 -11752484 115857271 -96149584 115857271 452855316 -637365593 452855316 509080790 509080790 739640300 761455463 890110496 890110496 907564442 532021810 878388758 -274977669 130725321 210016858 36723269 -495934937 -582044844 -495934937 36723269 210016858 878388758 907564442 929110505 666157516 666157516 717787401 717787401 717787401 873273017 528420895 655897934 655897934 873273017 873273017 873273017 873273017 929110505 565270218 565270218 159130158 565270218 864019380 864019380 864019380 929110505 26755138 26755138 103028415 103028415 443939181 783301899 929110505 717802610 …

Constraints:

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

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