CT36273

Harish's ledgers Reckoning

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Every season at the pine barrens of Needlepoint, someone must balance the workshop's books. This year the task falls to Harish, armed only with the ledgers register. 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: 3135 824979040 531863393 29782276 -58378475 -894090733 714961737 -140764521 976455277 -631266160 -40930451 -568497858 -698504845 75414578 -983872977 -988330265 280087323 -891789875 -580665625 -529364305 175367699 18855981 -630003833 -765657733 96171287 495058896 135390911 -509350756 115178980 -598877747 -147430901 438377408 -804453693 -897961042 -114768246 -904260075 -794065247 -470708687 257753710 81530160 -330279352 322768208 610872776 678492689 -760324700 419943389 122696217 41640221 936732667 -635974392 280972063 -285950605 464418599 -964290455 288930727 312529583 -156192287 -174875519 186780396 -733182987 646905863 618505945 57266927 -328695574 668054231 -162897142 -2728131 717596021 -356149473 756439052 521996967 -535346027 -930690420 -762769173 936652449 13170485 972278485 242627276…
Output: 976455277 714961737 714961737 714961737 714961737 976455277 976455277 996081827 -40930451 75414578 75414578 75414578 280087323 280087323 280087323 495058896 -580665625 -529364305 175367699 495058896 96171287 96171287 96171287 495058896 610872776 438377408 115178980 438377408 -147430901 438377408 610872776 -114768246 -114768246 257753710 -794065247 -470708687 257753710 322768208 322768208 322768208 610872776 678492689 936732667 419943389 936732667 936732667 936732667 972278485 280972063 464418599 464418599 646905863 288930727 312529583 646905863 186780396 186780396 646905863 646905863 668054231 668054231 668054231 668054231 717596021 -2728131 717596021 756439052 756439052 936652449 936652449 936652449 -762769173 936652449 972278485 972278485 996081827 922037173 922037173 922037173 996081827…

Example 2:

Input: 1921 -94868271 -661239719 -475190218 -395026743 623372592 181783569 -339283928 -854582386 -706041572 -412430760 656180694 -899421506 22950878 99022528 -994327505 48447641 -592572507 -908254597 396820775 401204391 439757936 744139377 -840857520 345036706 587555046 29428829 -44386273 105158316 -804747077 -211075759 -621733361 -179964945 -776483014 477385348 -450454345 -153602700 -626379772 -773258160 -713789480 -626130344 -152368322 134623508 -939884260 920469628 941995787 -377840895 642723513 537544301 580600019 -942416030 713977447 71050218 131259426 466219099 96486828 -874426089 -145546664 240985326 240451998 510424664 601242154 245111192 -531126022 -502133302 431155585 800246608 -3461434 882034761 278027694 327218399 -971382845 608474482 167613841 760209141 837315523 20149778 -425494416 …
Output: 623372592 -475190218 -395026743 623372592 656180694 656180694 656180694 -706041572 -412430760 656180694 744139377 22950878 99022528 396820775 48447641 396820775 396820775 396820775 401204391 439757936 744139377 920469628 345036706 587555046 920469628 105158316 105158316 477385348 -211075759 -179964945 -179964945 477385348 477385348 920469628 -153602700 -152368322 -626130344 -713789480 -626130344 -152368322 134623508 920469628 920469628 941995787 998798703 642723513 713977447 580600019 713977447 713977447 800246608 131259426 466219099 510424664 240985326 -145546664 240985326 510424664 510424664 601242154 800246608 431155585 -502133302 431155585 800246608 882034761 882034761 998798703 327218399 608474482 608474482 760209141 760209141 837315523 998798703 998798703 998798703 -727911303 9987987…

Example 3:

Input: 1702 428775467 513754366 494275429 310771200 -448419108 -776851183 861090959 -590704160 -79289271 -772940864 598480809 -286726346 313867347 -671280443 -648974964 131603658 -359589876 -79937702 947638869 963201726 -492078457 -125657005 -11434269 -873154045 798065440 -163052644 11767350 -131283392 655637504 -445023665 -777783743 -164941152 -715497427 -157974521 -834864205 380730985 351179460 -79953016 -892079197 -277040712 832402393 955770550 749760314 -66499690 -445503451 19654416 -13702503 -290284049 -442264192 900887233 -947729095 -511363418 994201287 192620978 -330068551 -973542551 857873853 750953467 711451531 233966681 -887879273 668535361 273053522 346896062 -700266447 217826363 29093877 73077850 -271104753 -310304985 369016965 133570548 -911539324 -604810624 938734000 -773694539 -513…
Output: 513754366 861090959 861090959 861090959 861090959 861090959 947638869 -79289271 598480809 598480809 947638869 313867347 947638869 -648974964 131603658 947638869 -79937702 947638869 963201726 994201287 -125657005 -11434269 798065440 798065440 832402393 11767350 655637504 655637504 832402393 -164941152 -164941152 -157974521 -157974521 380730985 380730985 832402393 832402393 832402393 -277040712 832402393 955770550 994201287 900887233 19654416 19654416 900887233 900887233 900887233 900887233 994201287 -511363418 994201287 998005024 857873853 857873853 857873853 938734000 938734000 938734000 668535361 668535361 938734000 346896062 369016965 217826363 369016965 73077850 369016965 369016965 369016965 938734000 938734000 -604810624 938734000 946900192 -513413592 323653855 946900192 946900192 9469…

Constraints:

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

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