CT50726

Jatin's Crimson registers

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Jatin found an old ledger of registers in the signal tower attic at the poppy fields of Scarlet Plain. 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: 2249 -921050581 420941603 -194661418 -125170785 919115624 272654506 646016012 -752662592 -346702926 -437181496 -338424287 643996251 -927032619 586589362 443293246 444559895 844623834 -40829399 673286142 806157374 895234767 -830900950 615324419 67054401 -231615261 -5523946 633600292 -464432360 247318588 47506478 955203004 737740046 706721437 -918645348 -939870653 3951406 858667562 829384598 535786794 -519986821 -323870432 37693621 296747598 -883023592 -551625019 -589762370 136203304 -714458397 -814003782 -408255631 405600385 -397750718 -619480105 989207289 411712145 276330141 541213629 -122342914 247940845 -160109386 104997578 524549104 -188764224 777886993 247254826 -460132448 963694593 -742406096 -750073715 56194691 409271924 314674032 508078056 -162065975 490248803 -50592177 777508695 44…
Output: 420941603 919115624 -125170785 919115624 955203004 646016012 844623834 -346702926 -338424287 -338424287 643996251 844623834 586589362 844623834 444559895 844623834 895234767 673286142 806157374 895234767 955203004 615324419 633600292 633600292 -5523946 633600292 955203004 247318588 955203004 955203004 989207289 858667562 858667562 3951406 3951406 858667562 989207289 989207289 989207289 -323870432 37693621 296747598 405600385 -551625019 136203304 136203304 405600385 -408255631 -408255631 405600385 989207289 989207289 989207289 998546411 541213629 541213629 777886993 247940845 524549104 104997578 524549104 777886993 777886993 963694593 963694593 963694593 966832826 56194691 56194691 409271924 508078056 508078056 777508695 490248803 777508695 777508695 932873481 661964257 -203803529 -20380352…

Example 2:

Input: 686 -531987534 31613199 344996785 145610174 224523591 182892458 -954643911 -346409269 -312028723 693893351 -187215101 653112827 -623667358 151998808 864567199 507291255 -968111275 -21363129 427525056 162542861 -469595026 497403096 -321193831 423771383 -539165280 -653551299 53572633 882524490 -116170762 -170048301 -759396998 415992441 753977701 117043010 622218346 300076937 -968245496 -71330772 268024817 68895550 177388885 704779144 -547637031 235526123 -759331267 346322332 -782125167 -718521799 554757830 696728341 997048770 819020154 -360554425 -671822510 837906619 345655581 -505212942 215686616 928788914 890305837 -375498520 719394715 -750078962 180428853 -61762904 13347316 -438048085 55403772 374866091 -578096719 723024804 -89034296 52076590 -752991871 799368561 -76856259 116514614 -3279…
Output: 31613199 344996785 693893351 224523591 693893351 693893351 -346409269 -312028723 693893351 864567199 653112827 864567199 151998808 864567199 882524490 882524490 -21363129 427525056 497403096 497403096 497403096 882524490 423771383 882524490 53572633 53572633 882524490 997048770 415992441 415992441 415992441 753977701 997048770 622218346 704779144 704779144 -71330772 268024817 704779144 177388885 704779144 997048770 235526123 346322332 346322332 554757830 -718521799 554757830 696728341 997048770 -1 837906619 837906619 837906619 928788914 928788914 215686616 928788914 964163079 905871634 719394715 723024804 180428853 374866091 13347316 55403772 55403772 374866091 723024804 723024804 799368561 52076590 799368561 799368561 905871634 116514614 269193730 269193730 269193730 -336345008 -336345008…

Example 3:

Input: 38 489839805 873108247 -731393107 -908923409 867804706 -674527508 110530606 984996733 -804655987 -303254350 868392802 305075985 462853086 845808332 -384891481 430542616 -788525677 672051561 -822034191 306741254 551870575 -792610730 -842524939 495871814 224752205 -69545302 324975008 -736862338 -630615417 -491951065 248896879 -689821210 562774803 -850092009 663361266 702808916 400873703 653894908
Output: 873108247 984996733 867804706 867804706 984996733 110530606 984996733 -1 -303254350 868392802 -1 462853086 845808332 -1 430542616 672051561 672051561 702808916 306741254 551870575 562774803 495871814 495871814 562774803 324975008 324975008 562774803 -630615417 -491951065 248896879 562774803 562774803 663361266 663361266 702808916 -1 653894908 -1

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Jatin's Crimson registers - MEDIUM Coding Problem | CodeTikki