CT54462

Wren and the Taller Ahead

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Caravans arrive at the terraced vines of Grapehollow with crates of marks, and Wren the factor must account for every last one. 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: 2972 305397276 489477354 -711429619 -984772123 621149223 -756730704 432373502 -398256208 238697550 402240036 -235630714 -805427718 -479828753 140859135 -485661550 718669379 -493264159 521473561 991644675 -628381424 -630082919 -40840354 -848182633 -648939170 -878609530 -324141055 -815868093 383218264 82850757 -963075217 -386918961 -197083009 -790932857 -996853995 -227328580 -549067636 958575089 -419126217 926299221 415119510 907466966 -724131048 -125445512 802167785 -829524651 341152835 570364408 453313832 -464250098 903154210 610867939 550468671 -611831725 653437201 592052306 -905701039 460055994 522405496 -489485147 -798792855 -310904048 50875508 -697969423 384316845 608545363 922523937 806167449 -222479055 -652448705 -488305020 -758712606 -908172775 -418294056 -42120015 -750521663 -15269…
Output: 489477354 621149223 621149223 621149223 718669379 432373502 718669379 238697550 402240036 718669379 140859135 -479828753 140859135 718669379 718669379 991644675 521473561 991644675 995636931 -40840354 -40840354 383218264 -648939170 -324141055 -324141055 383218264 383218264 958575089 958575089 -386918961 -197083009 958575089 -227328580 -227328580 958575089 958575089 995636931 926299221 995636931 907466966 922523937 -125445512 802167785 903154210 341152835 570364408 903154210 903154210 903154210 922523937 653437201 653437201 653437201 922523937 608545363 460055994 522405496 608545363 -310904048 -310904048 50875508 384316845 384316845 608545363 922523937 995636931 995636931 -42120015 -488305020 -418294056 -418294056 -418294056 -42120015 772387620 -152698997 772387620 772387620 800608095 80060…

Example 2:

Input: 3785 984800023 120483702 -24194750 -721856871 271356086 -987950896 -873710673 -64490130 -783306846 -255442710 782044797 382420864 -177823348 -194189191 -453736677 57038298 344076625 -31587769 870898718 -446354488 -738227346 381111067 831748777 696171402 785849908 -51775182 704011321 130013833 253958445 188613382 -591717128 980545188 -213298871 -778742375 -125769530 -313580542 232611666 -6100423 -697104023 42378391 832694465 -881151606 677328658 448379361 -449297776 -135546191 296670557 940475921 -697130148 161057320 -37636114 -92709329 220923507 557919055 -371467821 -826076245 -723743438 329188493 -654701476 537515896 -159116478 906964983 -353068959 805376309 572340024 -224389655 393697706 -122244301 -399524648 -239638478 669728904 10679224 71271480 -340975030 737780841 172029763 451353532…
Output: 991269099 271356086 271356086 271356086 782044797 -873710673 -64490130 782044797 -255442710 782044797 870898718 870898718 57038298 57038298 57038298 344076625 870898718 870898718 980545188 381111067 381111067 831748777 980545188 785849908 980545188 704011321 980545188 253958445 980545188 980545188 980545188 991269099 -125769530 -125769530 232611666 232611666 832694465 42378391 42378391 832694465 940475921 677328658 940475921 940475921 -135546191 296670557 940475921 957009371 161057320 220923507 220923507 220923507 557919055 906964983 329188493 -723743438 329188493 537515896 537515896 906964983 906964983 957009371 805376309 957009371 669728904 393697706 669728904 669728904 -239638478 669728904 737780841 71271480 737780841 737780841 957009371 451353532 717711758 232325817 717711758 957009371…

Example 3:

Input: 432 -228789368 40784469 918002198 -125850740 -108597930 -784530370 -181291045 -371962726 -346376726 937954118 -825175667 372440807 -415687693 987529144 -118445305 -820872910 -461379399 -452183157 184357098 61365327 -201667126 664458758 392542633 -320394884 558917240 -893512866 -963802058 -420538300 767671110 17501959 379321002 195776065 -386470020 -508981836 844108336 -41220289 543289024 -841356425 112618597 126640293 -383659639 387003002 -766545117 122829045 405502619 870513530 826352740 -762304073 -823530779 -627066124 -463260316 -563976917 633256120 919355167 -720375327 -894961034 453443860 -150942132 -664799746 40749590 -37705980 -280346018 -991478786 702996762 207019644 410674866 402660911 -76140355 315525585 -519125601 -193820770 665847156 -336895961 -783591160 -569966609 -968561736 …
Output: 40784469 918002198 937954118 -108597930 937954118 -181291045 937954118 -346376726 937954118 987529144 372440807 987529144 987529144 992164888 184357098 -461379399 -452183157 184357098 664458758 664458758 664458758 767671110 558917240 558917240 767671110 -420538300 -420538300 767671110 844108336 379321002 844108336 844108336 844108336 844108336 870513530 543289024 870513530 112618597 126640293 387003002 387003002 405502619 122829045 405502619 870513530 919355167 919355167 -627066124 -627066124 -463260316 633256120 633256120 919355167 924616130 453443860 453443860 702996762 40749590 40749590 702996762 702996762 702996762 702996762 898580341 410674866 665847156 665847156 315525585 665847156 -193820770 665847156 898580341 -151186270 -569966609 -151186270 -697572925 -151186270 -151186270 898580…

Constraints:

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

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