CT47895

Last marks of Neel

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Neel the scribe watches over the temple city of Sunspire's stores of marks. 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: 2272 -6349967 158804943 -500908588 8577329 270278394 460757160 -108979122 914108627 -939832509 -686546643 647402172 -653798675 -634282562 144367217 618176078 762311445 938332063 782973335 -369998923 -707912457 271748607 -635727211 237131393 57858475 -525826818 709537452 -734134842 -783225091 -74345182 477209912 -876764595 606262862 -145907769 -791569076 -117310754 433459785 89559098 -97144866 -548430362 -883046508 451264737 -911130658 -1823779 -969054774 -132325057 823768970 -384663324 -789255993 489267268 876073449 907788549 339548971 965206948 -240067678 -851231814 -145672784 -227825961 652566374 -878891676 860225335 -351923145 951056698 -386919672 -63550431 81803521 -427792654 -239593326 32640482 532596671 -860023383 -847373455 786806538 193284056 957515897 -636265913 -677904645 3813673…
Output: 158804943 270278394 8577329 270278394 460757160 914108627 914108627 938332063 -686546643 647402172 762311445 -634282562 144367217 618176078 762311445 938332063 965206948 823768970 271748607 271748607 709537452 237131393 709537452 709537452 709537452 823768970 -74345182 -74345182 477209912 606262862 606262862 823768970 -117310754 -117310754 433459785 451264737 451264737 451264737 451264737 451264737 823768970 -1823779 823768970 -132325057 823768970 876073449 489267268 489267268 876073449 907788549 965206948 965206948 965985936 -145672784 -145672784 652566374 652566374 860225335 860225335 951056698 951056698 957515897 -63550431 81803521 532596671 -239593326 32640482 532596671 786806538 -847373455 786806538 957515897 957515897 965985936 381367311 381367311 500552671 -74447899 84517942 5005526…

Example 2:

Input: 832 397423024 881090999 658645021 857208044 464235271 -775141338 99437001 872444104 256096233 445162026 -560523174 -196403790 -129991441 -798594557 -707920929 -31579608 615600632 -192812871 550254527 -418649897 -443587286 677032589 217885028 464391454 826150560 923049856 -355057719 964933768 -168683820 -361806321 -42788615 -160267361 587974197 -110413389 -573428859 546049275 -799247155 -314364810 -992630307 672852315 -56777884 188604320 534899933 434593651 268761043 484937708 -327223135 -965213837 -613189762 170315881 -12393158 329743698 24422997 -284475794 634310956 -126563086 803329488 510942045 524720780 -220540905 139207322 -211733898 404174072 -612706076 194973846 512445428 886429888 -797184391 -731977856 346044456 -499929118 -97937038 784744919 687143611 993484926 448302010 -98903800…
Output: 881090999 923049856 857208044 872444104 872444104 99437001 872444104 923049856 445162026 615600632 -196403790 -129991441 -31579608 -707920929 -31579608 615600632 677032589 550254527 677032589 677032589 677032589 826150560 464391454 826150560 923049856 964933768 964933768 993484926 -42788615 -42788615 587974197 587974197 672852315 546049275 546049275 672852315 -314364810 672852315 672852315 803329488 188604320 534899933 634310956 484937708 484937708 634310956 170315881 -613189762 170315881 329743698 329743698 634310956 634310956 634310956 803329488 803329488 886429888 524720780 886429888 139207322 404174072 404174072 512445428 194973846 512445428 886429888 993484926 -731977856 346044456 784744919 -97937038 784744919 993484926 993484926 997803030 710856250 -446704583 196882076 710856250 9429…

Example 3:

Input: 3944 -239040274 906275434 -402424267 394215803 111999151 -702822861 889377140 235909541 -161395162 961523456 -142815236 -236123488 -957360266 -844943876 -160400707 -146077655 861355270 -584498094 489143263 874928452 -172595038 578547215 745584791 -176268902 734361802 703746620 235659479 -375145199 -272849314 -554927393 -223551825 398462757 -100152976 -230017156 447258406 246979748 -450724338 -252541095 -828235282 747032993 580484428 849418145 -885017295 -70024446 -498188247 919571570 -449556057 -639935186 661587629 -695619858 232496446 -148478451 127846317 204627286 -856430577 514479108 945339096 376263469 255348709 73094786 -438747174 -416653969 220719055 -423012456 451088008 -677234198 -484575559 -14369056 607183068 871398292 -346428131 522017410 -396756809 697521755 -293836763 616888905…
Output: 906275434 961523456 394215803 889377140 889377140 889377140 961523456 961523456 961523456 985920811 861355270 -160400707 -844943876 -160400707 -146077655 861355270 874928452 489143263 874928452 919571570 578547215 745584791 747032993 734361802 747032993 747032993 398462757 -272849314 -223551825 -223551825 398462757 447258406 447258406 447258406 747032993 747032993 -252541095 747032993 747032993 849418145 849418145 919571570 -70024446 919571570 919571570 945339096 661587629 661587629 945339096 232496446 514479108 127846317 204627286 514479108 514479108 945339096 985920811 451088008 451088008 220719055 -416653969 220719055 451088008 451088008 607183068 -484575559 -14369056 607183068 871398292 985920811 522017410 697521755 697521755 744344048 616888905 744344048 744344048 744344048 744344048 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Last marks of Neel - MEDIUM Coding Problem | CodeTikki