CT54740

The Taller Ahead of the Caramel beacons

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Deep in the pearl fisheries of Nacre Bay, Lila studies rows of beacons entries. One clean number will settle the guild's oldest argument. 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: 923 -855974089 -457455726 42753158 -351451286 96342097 -307241129 343311049 405982719 767711713 -787249576 626720724 -125345971 -830969024 -983759310 361909118 -575415209 463897716 663204924 -623605764 -398225814 58929812 63368839 -183397505 -20284392 -278509003 354544309 -817055019 639268883 -924013944 -324753985 -782234613 329411266 346824515 -997442925 -392646036 571516077 845800458 -131266405 946711254 459168852 955671077 -353479379 288482632 -661518686 -78903306 -352307599 763859992 -390100637 -716430844 -587339329 438052893 239528322 108994465 163988183 -410681204 646677662 843675801 -228382734 -783804070 53889494 -212027601 351823009 950254711 -664011977 152270832 776302267 722374220 -386084255 327970507 -948708 592527016 261846681 -961405246 -305370533 883000305 706680180 269099739…
Output: -457455726 42753158 96342097 96342097 343311049 343311049 405982719 767711713 845800458 626720724 663204924 361909118 361909118 361909118 463897716 463897716 663204924 845800458 -398225814 58929812 63368839 354544309 -20284392 354544309 354544309 639268883 639268883 845800458 -324753985 329411266 329411266 346824515 571516077 -392646036 571516077 845800458 946711254 946711254 955671077 955671077 998566302 288482632 763859992 -78903306 763859992 763859992 843675801 438052893 -587339329 438052893 646677662 646677662 163988183 646677662 646677662 843675801 950254711 53889494 53889494 351823009 351823009 950254711 998566302 152270832 776302267 883000305 883000305 327970507 592527016 592527016 883000305 883000305 -305370533 883000305 932596347 846690031 677448840 -179626529 177579477 677448840 …

Example 2:

Input: 3267 406316806 210824882 -194500121 -961604003 -859910389 -283775195 834672637 -483359736 -775262115 -540100148 -588573789 309254016 423294785 441795956 537922426 -548832054 850176236 -140591815 854360796 -947824264 -987863794 -121502784 -319040689 -635124215 160789871 -692839450 -227677520 54617791 -76360074 327396309 -671955136 -219396228 -45444722 500175825 470753262 -222872471 -812430578 988750742 -805981102 935319159 675533174 -804249176 -470833315 903805270 479349297 495697080 -88143734 -279197282 951309041 -383980480 -974028425 -877620628 93337493 370139146 -407698922 539480142 -843032114 658431269 721716764 236777970 -818251680 -152467641 19774463 -60868262 -582847084 443469559 -982463279 -34595967 -604724825 991133415 -718218431 225482736 699465285 877262229 -340380287 -315027577 …
Output: 834672637 834672637 834672637 -859910389 -283775195 834672637 850176236 309254016 -540100148 309254016 309254016 423294785 441795956 537922426 850176236 850176236 854360796 854360796 988750742 -121502784 -121502784 160789871 160789871 160789871 327396309 -227677520 54617791 327396309 327396309 500175825 -219396228 -45444722 500175825 988750742 988750742 988750742 988750742 991133415 935319159 951309041 903805270 -470833315 903805270 951309041 495697080 951309041 951309041 951309041 991133415 93337493 -877620628 93337493 370139146 539480142 539480142 658431269 658431269 721716764 991133415 443469559 -152467641 19774463 443469559 443469559 443469559 991133415 -34595967 991133415 991133415 999654838 225482736 699465285 877262229 890834527 -315027577 512548896 784655120 784655120 789803735 -19…

Example 3:

Input: 1141 175709072 554764262 -252956395 632185316 -215774161 -729581156 750575277 90387667 -506950931 -71633493 859763794 467620291 -196430909 851247440 317708104 816938481 660057700 462390323 871814062 986533514 -858570142 242641384 353974542 -290288923 87397431 -980542563 -40700317 -14093232 -432483187 25155522 253323164 956210139 -550044670 705612103 -195952509 -109177631 -972385871 -4613632 -989366174 405356467 -533424591 -789185450 -538632899 251032282 -223108517 -265954939 -362909503 -316856156 156906329 658965784 -213778740 -125342229 -870076794 -603719005 -666873519 207732224 152992197 99534904 -999487803 -607516410 412207585 -650837291 630690665 312407469 -13782287 92016142 949296834 557090291 -512109676 382224998 -531240619 -101318913 326171815 -290195294 -107628729 693383173 -381976…
Output: 554764262 632185316 632185316 750575277 750575277 750575277 859763794 859763794 -71633493 859763794 871814062 851247440 851247440 871814062 816938481 871814062 871814062 871814062 986533514 999443360 242641384 353974542 956210139 87397431 253323164 -40700317 -14093232 25155522 25155522 253323164 956210139 961100294 705612103 949296834 -109177631 -4613632 -4613632 405356467 405356467 658965784 251032282 -538632899 251032282 658965784 156906329 156906329 -316856156 156906329 658965784 949296834 -125342229 207732224 -603719005 207732224 207732224 412207585 412207585 412207585 -607516410 412207585 630690665 630690665 949296834 949296834 92016142 949296834 961100294 693383173 382224998 693383173 -101318913 326171815 693383173 -107628729 693383173 750408189 310963842 310963842 602143332 -5383493…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.