CT37111

The Pearl marks of Tarun

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

It is audit day at the anvil district of Hammerfall. Tarun spreads the marks records across the table and picks up a sharp pencil. 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: 2294 245638840 851367277 237171553 -201756593 -106135423 979196995 -162622788 952970534 -942287245 326956191 329179566 -578493611 -454532547 632317036 -984689394 991824347 630259859 -723438041 36677197 -663208315 271163565 -951047874 376740719 -850078857 -438332973 535378923 642394582 -272273734 -867640217 -276774574 -155811370 99586578 -913291729 182922306 -218158017 488096723 434698414 61291876 638735289 637375016 16229601 -252641899 -698462687 226051050 988891782 -860945144 576346471 630454229 85467963 451678502 183946088 622539186 217504161 511011863 -119111985 699883599 -371212022 -553550308 988266009 45692509 460659874 452838212 262098177 804230615 -686301619 -618132606 869845163 -602265547 -748814598 -303444505 291985907 -692472783 -493312874 -630431894 -134537941 500623312 87337185…
Output: 851367277 979196995 979196995 -106135423 979196995 991824347 952970534 991824347 326956191 329179566 632317036 -454532547 632317036 991824347 991824347 994076823 642394582 36677197 271163565 271163565 376740719 376740719 535378923 -438332973 535378923 642394582 988891782 -155811370 -276774574 -155811370 99586578 182922306 182922306 488096723 488096723 638735289 638735289 638735289 988891782 988891782 226051050 226051050 226051050 988891782 989204798 576346471 630454229 699883599 451678502 622539186 622539186 699883599 511011863 699883599 699883599 988266009 988266009 988266009 989204798 460659874 804230615 804230615 804230615 869845163 -618132606 869845163 873371854 -303444505 -303444505 291985907 500623312 -493312874 -134537941 -134537941 500623312 873371854 981325608 827289516 981325608 …

Example 2:

Input: 3934 -26415622 349038609 649258806 -883714003 765189895 -155686183 626233246 -863210519 519579211 -100931442 576168655 -501808989 -69946280 -457120584 -570402560 241418792 -313374707 98340763 -149472672 161088795 -496650048 -602120317 513642139 268815375 538339194 279223121 -282752880 185999415 -301220782 437747690 -990925253 622435800 -132235785 -620143101 366391786 -914230116 903370875 434596191 -715893635 383268014 254982838 729883757 380609014 960553237 -732047035 906959016 979223994 -466474177 -366712028 -476099550 -148282711 -141660754 -288562945 264527060 -322191366 -818125648 -576542410 816850603 236336348 -660388060 -748959625 138463209 828879454 980670922 -268456515 -577424273 -437061964 -830333480 -531824782 -766874758 -791281236 -181907003 872219322 911945226 926184327 92769710…
Output: 349038609 649258806 765189895 765189895 903370875 626233246 903370875 519579211 576168655 576168655 622435800 -69946280 241418792 241418792 241418792 513642139 98340763 161088795 161088795 513642139 513642139 513642139 538339194 538339194 622435800 437747690 185999415 437747690 437747690 622435800 622435800 903370875 366391786 366391786 903370875 903370875 960553237 729883757 383268014 729883757 729883757 960553237 960553237 979223994 906959016 979223994 980670922 -366712028 -148282711 -148282711 -141660754 264527060 264527060 816850603 816850603 -576542410 816850603 828879454 828879454 138463209 138463209 828879454 980670922 997539132 -181907003 -437061964 -181907003 -531824782 -181907003 -181907003 -181907003 872219322 911945226 926184327 927697106 974101872 777941709 974101872 68480886 …

Example 3:

Input: 2311 -62392704 -4628398 -360937353 -571399787 116552968 555111843 -557868541 -889939124 -372068766 -866191169 240940354 -72902339 748292110 59949616 -3145731 -84367989 861978435 559263616 913163809 853079098 545816314 758581755 -755346445 -513791873 -597948226 -406416036 844811257 402549396 -739213841 249947093 356079123 -492149403 205065088 -887328815 -95321659 -49416515 -745488231 -351276791 709704690 46854682 -393483980 -127186862 572045858 279479292 238260978 361295455 740777774 -907919283 130252054 131607849 145169800 306014032 -499537174 -852226365 -465580189 -996438315 39825204 -348986389 -770396035 -100894276 -475288223 -15334958 726366988 218324487 -605519009 -183839712 842553373 620315421 -945467317 -283577507 -530318282 722630957 291583682 634984662 177251759 -564652602 63426020…
Output: -4628398 116552968 116552968 116552968 555111843 748292110 -372068766 -372068766 240940354 240940354 748292110 748292110 861978435 861978435 861978435 861978435 913163809 913163809 998139495 888214136 758581755 844811257 -513791873 -406416036 -406416036 844811257 888214136 709704690 249947093 356079123 709704690 205065088 709704690 -95321659 -49416515 709704690 -351276791 709704690 740777774 572045858 -127186862 572045858 740777774 361295455 361295455 740777774 842553373 130252054 131607849 145169800 306014032 726366988 -465580189 -465580189 39825204 39825204 726366988 -100894276 -100894276 -15334958 -15334958 726366988 842553373 842553373 -183839712 842553373 888214136 722630957 -283577507 722630957 722630957 888214136 634984662 888214136 634260200 634260200 888214136 998139495 998139495 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Pearl marks of Tarun - MEDIUM Coding Problem | CodeTikki