CT35648

Baker's ledgers Reckoning

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Legend says the vault under the mangrove channels of Rootwater opens only for a perfect tally of ledgers. Baker means to find out. 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: 3345 -31341159 -869065429 918823065 -17604199 420147475 -352155107 919919532 65306740 197545331 765155937 -491888430 344957763 929826423 -51276353 815563703 455286678 864678061 849040173 53552425 -365297423 -184333502 743493448 139992968 -368484676 183980362 -151723347 -842134930 -100960950 132935989 414261492 570632693 -362267157 -419731650 -526576256 161087276 -682855213 114887743 464152060 -606194185 -823972451 -78519544 -221793220 378058634 -894359392 595435652 486538002 -876264684 -174303751 666432758 532952751 -546703008 -686239091 617669002 597143944 888361654 -696483075 73817008 118915400 -872908962 -167448556 704630284 -714439504 376610837 179518433 -228393778 939581001 -740965398 -842024198 257701890 128058328 -317015270 -687105428 896771553 389024597 498075942 -815816851 -606044…
Output: 918823065 918823065 919919532 420147475 919919532 919919532 929826423 197545331 765155937 929826423 344957763 929826423 939581001 815563703 864678061 864678061 888361654 888361654 743493448 -184333502 743493448 888361654 183980362 183980362 414261492 -100960950 -100960950 132935989 414261492 570632693 595435652 161087276 161087276 161087276 464152060 114887743 464152060 595435652 -78519544 -78519544 378058634 378058634 595435652 595435652 666432758 666432758 -174303751 666432758 888361654 617669002 617669002 617669002 888361654 888361654 939581001 73817008 118915400 704630284 -167448556 704630284 939581001 376610837 939581001 939581001 939581001 949254400 257701890 257701890 896771553 896771553 896771553 896771553 949254400 498075942 736542705 -606044851 491593971 736542705 736542705 73654…

Example 2:

Input: 248 124384731 -608480963 632491194 -758243899 -73436555 -72549038 -966069132 961904255 509657318 -354049491 -472685657 601001658 412519065 -294445004 -964138689 -165550538 -616834911 738951568 594934387 -171472789 982991174 -483928229 -253979528 336741444 38008718 832786220 -543309503 676940054 42914157 -797087598 -701758020 -557735886 -696519058 -33477837 -210006623 -429016747 75130541 -923942888 975449496 -466347988 -914567444 195998162 407938723 39353926 -53741275 30722405 784722815 377833536 -275639557 3472864 -421596284 779019451 -213815678 -625975835 741162220 886074445 107730348 925573527 -16165751 -143371507 -63713566 749506736 993423363 -789101795 -964500981 -888497467 430579652 412931167 272770314 694846950 -61214022 -83264330 -236613692 -85955760 588179440 -818061512 -354587235 …
Output: 632491194 632491194 961904255 -73436555 -72549038 961904255 961904255 982991174 601001658 601001658 601001658 738951568 738951568 -165550538 -165550538 738951568 738951568 982991174 982991174 982991174 993423363 -253979528 336741444 832786220 832786220 975449496 676940054 975449496 75130541 -701758020 -557735886 -33477837 -33477837 75130541 75130541 75130541 975449496 975449496 993423363 195998162 195998162 407938723 784722815 784722815 30722405 784722815 886074445 779019451 3472864 779019451 779019451 886074445 741162220 741162220 886074445 925573527 925573527 993423363 749506736 -63713566 749506736 993423363 -1 430579652 -888497467 430579652 694846950 694846950 694846950 942836487 588179440 588179440 -85955760 588179440 942836487 -354587235 -108553873 125984315 125984315 942836487 961590…

Example 3:

Input: 1063 -801272403 806678019 -856242260 -859604725 -694462693 -36331174 781430667 -716928678 935052964 888168623 -610601120 -369891509 -737365059 550790099 -829130392 852383663 -54717812 -706467303 175649670 458252993 640416561 843889534 -697177754 666305260 -607336437 -846624198 -162187757 374041561 -891303517 -723402236 -387720209 -299618567 642871375 -371163988 -216500260 777485162 -22676860 154092366 820237851 -92984758 100835028 338718337 -9976987 833564981 796262746 -671002801 806832581 361071015 115228952 956649699 -845319991 -400832827 81546105 358862205 107245508 -260259614 603720159 129471055 293354886 -683554461 -740992460 17202637 -341055908 480038855 819442697 15321224 -812603260 -227861231 -69558686 -120885243 -80183204 345782018 -954495683 251745236 -643530592 764903736 5650601…
Output: 806678019 935052964 -694462693 -694462693 -36331174 781430667 935052964 935052964 956649699 956649699 -369891509 550790099 550790099 852383663 852383663 956649699 175649670 175649670 458252993 640416561 843889534 956649699 666305260 777485162 -162187757 -162187757 374041561 642871375 -723402236 -387720209 -299618567 642871375 777485162 -216500260 777485162 820237851 154092366 820237851 833564981 100835028 338718337 833564981 833564981 956649699 806832581 806832581 956649699 956649699 956649699 987567184 -400832827 81546105 358862205 603720159 603720159 603720159 819442697 293354886 480038855 17202637 17202637 480038855 480038855 819442697 891795525 345782018 -227861231 -69558686 345782018 -80183204 345782018 764903736 251745236 764903736 764903736 891795525 891795525 891795525 987567184 98…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Baker's ledgers Reckoning - MEDIUM Coding Problem | CodeTikki