CT50649

Jeweler and the Taller Ahead

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Jeweler inherited the loft at the cork grove of Barkhaven along with its curious bookkeeping system for signals. Time to make sense of it. 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: 3213 -178328369 106207628 -406118547 884196966 12109148 415656709 -208173240 -724250877 -793632143 -950972358 -705250655 431165318 830516948 109666352 444960252 -703665962 -581872328 357907785 528270766 -855147293 -413851855 418386601 775153482 69825752 -70892608 812938151 -714423248 -903023983 -777181032 961350245 -567774903 646868881 849897725 -805100892 613927634 -166358466 -339866596 -631511806 -367571804 280486199 -295038947 717438765 -23271665 -303261201 -847922024 513116217 155437100 928994845 215084254 652605952 4844679 926027351 -194412650 -229485623 203785227 -851905247 348441990 -332400242 -165619276 -312258424 -823815640 -933530772 -805709585 863371690 -663660680 -91983755 265825085 -741468702 234770766 973709316 61163793 993022496 -937896275 395532118 -599300514 -820732120 150…
Output: 106207628 884196966 884196966 961350245 415656709 431165318 431165318 -705250655 -705250655 -705250655 431165318 830516948 961350245 444960252 528270766 -581872328 357907785 528270766 775153482 -413851855 418386601 775153482 812938151 812938151 812938151 961350245 961350245 -777181032 961350245 973709316 646868881 849897725 928994845 613927634 717438765 280486199 280486199 -367571804 280486199 717438765 717438765 928994845 513116217 513116217 513116217 928994845 928994845 973709316 652605952 926027351 926027351 973709316 203785227 203785227 348441990 348441990 863371690 -165619276 863371690 863371690 -805709585 -805709585 863371690 973709316 -91983755 265825085 973709316 234770766 973709316 993022496 993022496 998508320 395532118 489506884 150425429 150425429 489506884 489506884 746782671 …

Example 2:

Input: 3325 606236424 697629368 -39097268 -282866088 -579048659 -100586101 213950123 -593658503 743012875 798676552 -449262567 754662822 -894943273 -75272727 363651265 215733450 -678249597 -38135384 -581487583 560908683 -972135562 -905393408 -661112186 -769824534 -360165961 4886740 -313957602 424997576 -502639295 -747755819 -678771933 -924687463 -346494400 946271410 798801826 322283181 155297549 708808993 262316903 749244848 -135695861 -687768138 -394178662 376909516 286355405 -646204666 740207098 -692809839 70543826 -884377838 185337141 -237650270 950821581 -513873774 300455924 860793239 -457561229 -295270286 181471169 -46478366 778172065 285245067 -466856135 -256227503 369386968 -131118523 136703032 -450292756 762685217 41372963 747413268 464861906 501413309 225705601 -308710495 724607675 -8460…
Output: 697629368 743012875 213950123 -100586101 -100586101 213950123 743012875 743012875 798676552 946271410 754662822 946271410 -75272727 363651265 560908683 560908683 -38135384 560908683 560908683 946271410 -905393408 -661112186 -360165961 -360165961 4886740 424997576 424997576 946271410 -346494400 -678771933 -346494400 -346494400 946271410 950821581 950821581 708808993 708808993 749244848 749244848 950821581 376909516 -394178662 376909516 740207098 740207098 740207098 950821581 70543826 185337141 185337141 950821581 950821581 964423523 300455924 860793239 910236626 -295270286 181471169 778172065 778172065 831818508 369386968 -256227503 369386968 762685217 136703032 762685217 762685217 831818508 747413268 831818508 501413309 724607675 724607675 724607675 831818508 276382896 464630260 464630260 …

Example 3:

Input: 3015 -52524498 39552819 -77279474 11834610 -972307162 -913736139 -276647629 335464363 -681560725 196688774 -525273242 -790415453 347096835 -852897274 -552271126 -478453198 485782009 -762423853 300077047 243886610 346939486 -14992521 -434664265 -345522019 676738809 -300529687 -276310214 -195672167 775923395 -64709202 740350898 643625826 -619120319 -904589184 256595418 -123022633 696194624 555025561 478126921 -89130790 -99384709 450515018 -556619269 -945034771 705778711 130792845 662451975 758311074 211885538 -7371416 -697955727 239999451 577679654 -979313782 -551247024 120257800 222069400 -218775025 263600434 -111576006 201387271 708022625 427639975 -995702972 -246501476 453255133 -332526779 467371063 -79525680 -210471393 488123329 104710250 -416340634 742712750 287801837 607873252 -4133879…
Output: 39552819 335464363 11834610 335464363 -913736139 -276647629 335464363 347096835 196688774 347096835 347096835 347096835 485782009 -552271126 -478453198 485782009 676738809 300077047 346939486 346939486 676738809 676738809 -345522019 676738809 775923395 -276310214 -195672167 775923395 776002560 740350898 758311074 696194624 256595418 256595418 696194624 696194624 705778711 705778711 705778711 450515018 450515018 705778711 705778711 705778711 758311074 662451975 758311074 776002560 239999451 239999451 239999451 577679654 708022625 -551247024 120257800 222069400 263600434 263600434 708022625 201387271 708022625 742712750 453255133 -246501476 453255133 467371063 467371063 488123329 488123329 488123329 742712750 742712750 742712750 776002560 607873252 776002560 -196115803 776002560 901023032 90…

Constraints:

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

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