CT40870

The Taller Ahead of Whitesnow

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Farhan runs the loom house at the tundra station of Whitesnow. Today the books show a list of beacons, and the numbers must be worked out before sundown. 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: 2336 -216822763 704977939 655045379 -845694859 -463629258 -514641313 845550917 -967814720 608441882 170167602 -192218973 331649326 612666237 -565734077 -748676101 -62001921 132109533 373229515 910914358 912204022 -261784494 559894817 -122466870 -493863745 385926478 -177095304 129318507 -722810864 -579477026 584826967 -234827616 -69035768 -516263725 -87534294 -464125877 880816144 723132393 450240427 671691935 560381989 319097454 976630007 -143746177 -317652801 803182204 -784932330 236043988 783885107 82867530 -294675876 -773870627 -599856596 593200904 475918319 473337704 389221571 -154316184 -838967898 -966991600 806215816 -895264498 -473687840 -30876472 -534813653 -336311153 623429849 528129431 642498435 -856553801 -461095121 570036158 470212253 682243215 325068459 580615889 308009515 -793…
Output: 704977939 845550917 845550917 -463629258 845550917 845550917 910914358 608441882 612666237 331649326 331649326 612666237 910914358 -62001921 -62001921 132109533 373229515 910914358 912204022 976630007 559894817 584826967 385926478 385926478 584826967 129318507 584826967 -579477026 584826967 880816144 -69035768 880816144 -87534294 880816144 880816144 976630007 976630007 671691935 976630007 976630007 976630007 999033396 803182204 803182204 806215816 236043988 783885107 806215816 593200904 593200904 -599856596 593200904 806215816 806215816 806215816 806215816 806215816 806215816 806215816 877967872 -473687840 -30876472 623429849 -336311153 623429849 642498435 642498435 682243215 -461095121 570036158 682243215 682243215 687371121 580615889 687371121 687371121 225536088 687371121 -169220341 687…

Example 2:

Input: 1631 256622797 963462491 -123964721 -306106424 589817200 -266786806 -678706625 -625781453 -476362930 139142923 430598720 885300062 722027142 -437531506 -206942049 -152314235 961098446 -489115576 980855584 968331216 -359639130 -167961600 535044916 902520711 -722039474 -908376776 -401217561 -724608912 -443732388 -62813946 115382300 -552851251 -867568137 -917490994 -985655919 -11499076 448225141 -128758468 396071004 692538692 446857133 729296752 520908243 434934855 -668637210 -695617776 326090924 154496831 -805969206 -376348726 -714046051 320896443 -495642142 473974551 678936258 -330378812 35560377 910665454 981381343 -273552824 471481480 223439599 -603299642 -657982022 263051782 13116176 -787550322 -821872456 -87388396 391046826 -522250379 -321527159 91380235 185672283 607344383 -601570605 6…
Output: 963462491 980855584 589817200 589817200 885300062 139142923 -625781453 -476362930 139142923 430598720 885300062 961098446 961098446 -206942049 -152314235 961098446 980855584 980855584 981381343 981381343 -167961600 535044916 902520711 910665454 -401217561 -401217561 -62813946 -443732388 -62813946 115382300 448225141 -11499076 -11499076 -11499076 -11499076 448225141 692538692 396071004 692538692 729296752 729296752 910665454 678936258 473974551 326090924 326090924 473974551 320896443 -376348726 320896443 320896443 473974551 473974551 678936258 910665454 35560377 910665454 981381343 983379828 471481480 607344383 263051782 263051782 263051782 391046826 391046826 -87388396 -87388396 391046826 607344383 -321527159 91380235 185672283 607344383 690830046 605357127 690830046 562914791 690830046 69…

Example 3:

Input: 1382 -728374224 324390548 910482015 -325381010 37237418 -489376161 333864815 -173403789 495438419 522033054 -571684608 217851459 -77011383 -201717341 -382143846 -593102412 449517417 -42910467 -72055891 -127265382 587731484 -271056975 899789350 264591902 263859940 568223757 -304466239 371634916 4234496 -990209658 782189770 190045440 -917264006 -938941789 -647158638 788513589 151855604 -351730311 -212480680 -70311544 -639769988 -386380475 -605744649 929457113 144896795 136088101 -632766322 186086434 852838284 -848274604 421857176 -34061963 -20853640 -236622754 456540674 636240157 -628209290 401340685 373544720 -82062924 -749520355 -543292431 -232399187 -387295774 -809196100 -591187135 586310380 86606909 171740913 382565593 -539032215 919412628 628933608 -601857749 343458748 292920722 -632482…
Output: 324390548 910482015 929457113 37237418 333864815 333864815 495438419 495438419 522033054 587731484 217851459 449517417 449517417 449517417 449517417 449517417 587731484 587731484 587731484 587731484 899789350 899789350 929457113 568223757 568223757 782189770 371634916 782189770 782189770 782189770 788513589 788513589 -647158638 -647158638 788513589 929457113 929457113 -212480680 -70311544 929457113 -386380475 929457113 929457113 941957550 186086434 186086434 186086434 852838284 919412628 421857176 456540674 -20853640 456540674 456540674 636240157 919412628 401340685 586310380 586310380 586310380 -543292431 -232399187 586310380 586310380 -591187135 586310380 919412628 171740913 382565593 919412628 919412628 941957550 941957550 343458748 941957550 300739623 300739623 941957550 -229676165 941…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Taller Ahead of Whitesnow - MEDIUM Coding Problem | CodeTikki