CT38899

Prismatic beacons Taller Ahead

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the lily shoals of Padmore as Neel unrolls the day's manifest of beacons. The tally will decide the next shipment. 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: 2491 -916919397 277800700 -884532082 -434753185 309356572 758293263 -524544249 -783792360 476791338 68771564 -413068822 836265425 17386409 -348827934 -803017443 69557869 319971065 -246862648 382089166 870680190 584248508 -588257309 -551522148 566651538 968396875 591713966 -780731324 326216611 -756198200 43110808 -70469555 757236868 989865847 242862591 908168733 -32167443 849857865 -675420073 -946687210 850721001 -338234400 435301698 -157071813 980753362 549345373 -606350167 -901035164 -858987065 -807429795 236851433 -841337904 -116642271 530758313 812126277 463465355 -692696788 -312607983 -41458197 -170881599 -353767964 -764475244 524346773 583107124 491935195 -928930503 -243493432 -758662788 -230293242 799074198 -120247977 252708232 230107172 -472601312 824813284 -125029153 -57609041 -854…
Output: 277800700 309356572 -434753185 309356572 758293263 836265425 476791338 476791338 836265425 836265425 836265425 870680190 69557869 69557869 69557869 319971065 382089166 382089166 870680190 968396875 968396875 -551522148 566651538 968396875 989865847 757236868 326216611 757236868 43110808 757236868 757236868 989865847 994132649 908168733 980753362 849857865 850721001 850721001 850721001 980753362 435301698 980753362 980753362 984188225 812126277 236851433 -858987065 -807429795 236851433 530758313 -116642271 530758313 812126277 824813284 524346773 -312607983 -41458197 524346773 524346773 524346773 524346773 583107124 799074198 799074198 -243493432 -230293242 -230293242 799074198 824813284 252708232 824813284 824813284 824813284 984188225 -57609041 11589018 11589018 376862724 603624896 6379567…

Example 2:

Input: 1044 -629086495 559181444 910763228 -848168604 769743771 -591377845 -365035686 -186349431 -26704536 571400613 -58062030 957764453 -316340443 -550266158 -888089329 895972330 -98014510 -767526743 75132626 822521098 -503919447 980970349 257734607 328937289 100272392 -245752063 -512704464 307153568 354319098 294132987 81222948 724722446 113870040 640170851 -159102064 -684516999 -318076754 677102610 -716047919 227116382 824153064 -960654543 668550163 -895303285 150466843 300767136 -863337581 316717412 -24750047 -104919402 800621540 -400490806 -175197426 843058164 -7173315 -938741637 -378073547 106630307 63356925 225835343 130923293 633385193 -739709348 813386565 -417644289 428860964 330082748 138195607 -215679430 660079363 -861979589 -770464574 -929801110 653885853 183721861 -37537417 29817939 …
Output: 559181444 910763228 957764453 769743771 957764453 -365035686 -186349431 -26704536 571400613 957764453 957764453 980970349 895972330 895972330 895972330 980970349 75132626 75132626 822521098 980970349 980970349 985781301 328937289 354319098 307153568 307153568 307153568 354319098 724722446 724722446 724722446 824153064 640170851 677102610 677102610 -318076754 677102610 824153064 227116382 824153064 843058164 668550163 800621540 150466843 300767136 316717412 316717412 800621540 800621540 800621540 843058164 -175197426 843058164 955438161 106630307 -378073547 106630307 225835343 225835343 633385193 633385193 813386565 813386565 955438161 428860964 660079363 660079363 660079363 660079363 778549786 -770464574 653885853 653885853 778549786 395707336 29817939 395707336 485096754 485096754 7785497…

Example 3:

Input: 3669 345859416 873727834 -269955978 -739650448 230412397 273985659 -133413426 985394782 -79854548 510663855 -385308304 -952127945 16995684 -966924686 -952672665 667708193 -709933896 202141822 224229076 514493919 418962781 -26666267 -471264220 -498736350 -531194961 942170983 70942598 -809309068 646350517 -655761279 417071498 -195048028 -687537152 -171517038 -103073315 728437498 759473643 -524510595 526523312 -103545778 800939044 -438660389 668722673 -862393262 -646025317 -35979572 194963848 -853824033 461395568 -108835341 -738731433 798004777 316550379 -331084846 -296475597 578214563 -432067826 275196346 749698687 723696772 832959172 -847841691 -416430659 24810176 637788521 -212396347 333666478 848383339 448008684 -976626627 719354453 -429135181 -365022113 670316219 -886267404 173077807 -77…
Output: 873727834 985394782 230412397 230412397 273985659 985394782 985394782 993355286 510663855 667708193 16995684 16995684 667708193 -952672665 667708193 942170983 202141822 224229076 514493919 942170983 942170983 942170983 942170983 942170983 942170983 993355286 646350517 646350517 728437498 417071498 728437498 -171517038 -171517038 -103073315 728437498 759473643 800939044 526523312 800939044 800939044 832959172 668722673 798004777 -646025317 -35979572 194963848 461395568 461395568 798004777 798004777 798004777 832959172 578214563 -296475597 578214563 749698687 275196346 749698687 832959172 832959172 848383339 -416430659 24810176 637788521 848383339 333666478 848383339 993355286 719354453 719354453 993355286 -365022113 670316219 993355286 173077807 993355286 993355286 993355286 999229565 -3340…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Prismatic beacons Taller Ahead - MEDIUM Coding Problem | CodeTikki