CT46540

Scribe's Ledger of registers

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Scribe found an old ledger of registers in the observatory attic at the ferry landing of Crosswater. The margin notes pose a precise question. 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: 545 -633520182 918134154 -15846801 -390147181 755080050 -824690121 -408911832 506354272 -818299329 286874451 248402728 298319531 25662350 -957497811 107501962 973733435 -155947920 -615295577 -960428925 -797591754 666207705 909977521 204197027 658426530 -9402021 218204240 390555699 -983224295 612338083 -565786709 -189209673 623769322 -744499387 -490939548 -695728405 830445357 -550967874 -671270469 -71764127 -692240207 508212676 -73640368 524464942 -965694896 829356939 103322290 -182865805 -436482530 266703471 -17656428 -636418297 775920486 -566675266 -316446068 800713797 511428396 169289752 -481258327 -244034286 -804639660 -105973456 820550360 573066990 -489866413 -896748930 -547908654 534631813 -303246276 -438133141 844780172 999900577 79120533 938919152 -146659897 -204344268 585037341 -56…
Output: 918134154 973733435 755080050 755080050 973733435 -408911832 506354272 973733435 286874451 298319531 298319531 973733435 107501962 107501962 973733435 999900577 666207705 666207705 -797591754 666207705 909977521 999900577 658426530 830445357 218204240 390555699 612338083 612338083 623769322 -189209673 623769322 830445357 -490939548 830445357 830445357 844780172 -71764127 -71764127 508212676 508212676 524464942 524464942 829356939 829356939 844780172 266703471 266703471 266703471 775920486 775920486 775920486 800713797 -316446068 800713797 820550360 820550360 820550360 -244034286 -105973456 -105973456 820550360 844780172 844780172 534631813 -547908654 534631813 844780172 844780172 844780172 999900577 -1 938919152 977427591 585037341 585037341 815363470 -47732979 -47732979 815363470 -8214348…

Example 2:

Input: 3145 335119977 -673204581 440257972 -917686271 811002201 -658447256 192270750 -991230828 110127067 733016093 -798560276 -12599649 521277992 442703251 -40925766 788789541 507552509 814052072 659016935 -68797462 753106969 747573189 -696977451 291231858 420116677 299114030 -40281058 957237755 577646957 -639448989 807706279 -174537248 237273199 115254389 565376175 -77192258 -158533143 -801814638 174847276 -327414776 -827643309 78871549 -3144846 -784621339 888681071 -15560963 -928997070 357033137 469089254 889511727 77413260 -61165989 -182555026 -361455430 247660894 891243127 998080888 786794560 237750872 -219822146 -836734303 99070229 428110587 200030447 -190739590 -476681707 715697892 131018705 -134325829 677263135 -843695805 323321136 390169856 -993173092 -353147583 368134562 171981243 -9282…
Output: 440257972 440257972 811002201 811002201 814052072 192270750 733016093 110127067 733016093 788789541 -12599649 521277992 788789541 788789541 788789541 814052072 814052072 957237755 753106969 753106969 957237755 957237755 291231858 420116677 957237755 957237755 957237755 998080888 807706279 807706279 888681071 237273199 565376175 565376175 888681071 174847276 174847276 174847276 888681071 78871549 78871549 888681071 888681071 888681071 889511727 357033137 357033137 469089254 889511727 891243127 247660894 247660894 247660894 247660894 891243127 998080888 998942577 990497731 428110587 99070229 99070229 428110587 715697892 715697892 715697892 715697892 990497731 677263135 677263135 990497731 323321136 390169856 990497731 -353147583 368134562 990497731 990497731 990497731 998942577 974775926 470…

Example 3:

Input: 122 44870288 -927828958 395594157 -831862357 -804871071 -969686733 720049063 845160205 633418713 250452395 -604015348 336508896 -575623210 660889316 -306008868 521523168 10615711 586685833 -489617940 452212418 255630117 436017424 225487688 697242453 -223519737 873354827 -765422062 525927109 372963962 -905033655 -933531876 506012551 -329053210 341393870 150743612 -319504436 58688046 322659506 446781520 25550122 -701115740 86256910 207503296 -745765787 -833732812 399493645 -869654093 -772542051 946049744 156735861 -321604632 -582029934 13439538 964906207 591346298 -958524105 899909670 300052714 -989925548 -227150919 -868433943 611727071 556024845 -539504585 -641110449 923010021 711850488 854551927 -162710489 -568069720 -261436176 -617254020 389470576 -657747783 -441620395 -408026468 84705788…
Output: 395594157 395594157 720049063 -804871071 720049063 720049063 845160205 873354827 660889316 336508896 336508896 660889316 660889316 697242453 521523168 586685833 586685833 697242453 452212418 697242453 436017424 697242453 697242453 873354827 873354827 946049744 525927109 946049744 506012551 506012551 506012551 946049744 341393870 446781520 322659506 58688046 322659506 446781520 946049744 86256910 86256910 207503296 399493645 399493645 399493645 946049744 -772542051 946049744 964906207 964906207 13439538 13439538 964906207 -1 899909670 899909670 923010021 611727071 -227150919 611727071 611727071 923010021 923010021 923010021 923010021 937773756 854551927 937773756 389470576 -261436176 389470576 389470576 847057884 -441620395 -408026468 847057884 937773756 41630568 296024511 606458226 6064582…

Constraints:

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

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