CT40126

Zane's Ledger of ledgers

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Zane the store warden watches over the sulphur springs of Brimstone's stores of ledgers. 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: 1846 700182521 218083542 606906126 -686162448 273916521 793124001 -907858832 223714883 490980948 -410315625 -121222302 -982545877 -300787967 -730137061 -249184093 75785748 -411804858 -434215583 -105491419 -934709804 -153425204 -520150219 291174184 -472253503 991889409 260269770 266320250 713247991 -407525715 -907584725 -537366226 -377114879 -366096292 105670868 576932144 -227543491 586534558 -992868452 -916675147 -453366591 -326828547 623216589 643058372 -234236550 965476841 323535480 847460935 92542413 -28997700 288769123 473544052 -756203375 -804673930 -60731939 790315760 -489351531 688218997 -686836927 -517033725 -613459426 -789218909 289088895 -559908571 -315073773 25300158 -716107310 -303264275 311290980 -558876168 684586567 435709713 -317991040 568286292 -729439727 -892188941 3894746…
Output: 793124001 606906126 793124001 273916521 793124001 991889409 223714883 490980948 991889409 -121222302 75785748 -300787967 -249184093 -249184093 75785748 291174184 -105491419 -105491419 291174184 -153425204 291174184 291174184 991889409 991889409 995524016 266320250 713247991 965476841 -377114879 -537366226 -377114879 -366096292 105670868 576932144 586534558 586534558 623216589 -916675147 -453366591 -326828547 623216589 643058372 965476841 965476841 973777745 847460935 973777745 288769123 288769123 473544052 790315760 -60731939 -60731939 790315760 837260884 688218997 837260884 -517033725 289088895 289088895 289088895 311290980 -315073773 25300158 311290980 -303264275 311290980 684586567 684586567 837260884 568286292 568286292 669372598 389474635 389474635 669372598 837260884 491281940 837260…

Example 2:

Input: 2953 7093221 -79932076 -207971976 266967175 804319261 586642781 254668359 -672765891 352950278 901901630 203055395 28438537 -382093114 511606867 -826312699 636331795 -332356169 -529566928 -493421382 221868945 558309811 857652719 -561562221 885064594 -882583619 -168989375 808618328 380124112 498599363 80087875 -520322311 -635061277 125081938 -274014330 -156819498 500505205 -293574550 -830770021 706622329 -677915453 372619800 274114854 -104997857 -52530152 274313165 698048970 -934619765 607865796 37945543 80265137 -320646254 682681094 -346079788 851917954 808042372 -459944757 857650325 -262267126 996188557 929669584 -284201775 -721375230 -537587360 10063009 413326091 -153312991 -513364416 671128039 -71156918 -180269814 -553340230 584734042 147765505 377859172 -129757290 84774112 325442091 -4…
Output: 266967175 266967175 266967175 804319261 901901630 901901630 352950278 352950278 901901630 996188557 511606867 511606867 511606867 636331795 636331795 857652719 221868945 -493421382 221868945 558309811 857652719 885064594 885064594 996188557 -168989375 808618328 851917954 498599363 500505205 125081938 125081938 125081938 500505205 -156819498 500505205 706622329 706622329 706622329 851917954 372619800 698048970 274313165 -52530152 274313165 698048970 851917954 607865796 682681094 80265137 682681094 682681094 851917954 851917954 857650325 857650325 857650325 996188557 996188557 998269873 953616760 10063009 -537587360 10063009 413326091 671128039 671128039 671128039 953616760 584734042 584734042 584734042 953616760 377859172 953616760 84774112 325442091 953616760 953616760 -717634830 953616760…

Example 3:

Input: 3622 -371377083 297698032 -503536530 -361288590 -182511033 -811509460 815617172 809401008 -483499662 524664885 -727321651 -196116153 -772690692 -134379325 -706293392 -50325135 451445949 861765694 280051494 105251244 -332184737 986086241 -224368079 -748282818 -148812238 489748598 858162471 73872400 -531639560 272419463 67490633 -876928395 923647800 892479106 538138638 752324045 66186520 541715107 226731154 904450355 -712952882 277580939 352357790 198547641 -1800328 716857951 -999994888 90195426 959337216 841329666 -454113025 -659792171 280189940 641716090 781793142 458227994 735806582 789556183 -932742507 997470136 600554540 -14503396 579758420 908489258 -165515347 64885072 864975325 -645852142 -44087163 357484515 -44844814 -482285112 -772531768 -847846620 546347137 -758493908 405050442 -63…
Output: 297698032 815617172 -361288590 -182511033 815617172 815617172 861765694 861765694 524664885 861765694 -196116153 -134379325 -134379325 -50325135 -50325135 451445949 861765694 986086241 986086241 986086241 986086241 997470136 -148812238 -148812238 489748598 858162471 923647800 272419463 272419463 923647800 923647800 923647800 959337216 904450355 752324045 904450355 541715107 904450355 904450355 959337216 277580939 352357790 716857951 716857951 716857951 959337216 90195426 959337216 997470136 997470136 280189940 280189940 641716090 781793142 789556183 735806582 789556183 997470136 997470136 998595199 908489258 579758420 908489258 969703269 64885072 864975325 969703269 -44087163 357484515 546347137 546347137 546347137 546347137 546347137 756852743 405050442 756852743 33528747 333687511 333687…

Constraints:

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

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