CT50927

Last marks of Opal

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Opal inherited the archive at the ferry landing of Crosswater along with its curious bookkeeping system for marks. 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: 1125 33190686 -994504992 -766322137 860924897 886911685 -504204552 -35342975 467158540 441159653 -709320939 -421352782 -597287674 -653901496 278958144 918991528 910769251 8929928 982150152 -89447130 225713367 -384074125 -149830151 -93603997 138344353 -578025952 753036365 393879156 144431258 -704055219 900589132 -849025694 909275246 -735042899 -90570685 -489254718 -226630310 -179248584 -691984555 717266428 484374672 988634401 732775463 115548249 82374887 674312041 -427591978 -641059812 -276703135 7632662 -372915808 -849518510 176129818 813219194 -541003273 680020738 998305395 -387112454 -450591920 25746496 -80445484 237785782 -621003210 -601413504 -20953308 -175029980 -236267378 681484488 -745043184 353921749 -767587630 -644049419 758769933 712708306 464643208 2757169 211651702 -179798884 2…
Output: 860924897 -766322137 860924897 886911685 918991528 -35342975 467158540 918991528 918991528 -421352782 278958144 278958144 278958144 918991528 982150152 982150152 982150152 988634401 225713367 753036365 -149830151 -93603997 138344353 753036365 753036365 900589132 900589132 900589132 900589132 909275246 909275246 988634401 -90570685 717266428 -226630310 -179248584 717266428 717266428 988634401 988634401 998305395 813219194 674312041 674312041 813219194 -276703135 -276703135 7632662 176129818 176129818 176129818 813219194 998305395 680020738 998305395 999423035 25746496 25746496 237785782 237785782 681484488 -601413504 -20953308 681484488 681484488 681484488 758769933 353921749 758769933 -644049419 758769933 940356933 940356933 940356933 211651702 232947728 232947728 940356933 940356933 95297…

Example 2:

Input: 1231 -95572003 -596306919 742353052 -460458220 -960236759 543090231 992248989 946843401 -134625034 -368508587 970613168 -275123488 -97464258 -760281687 -824303197 739567241 948835881 -179419448 -60177334 400979929 -79141080 107672919 587166205 -959057015 -64494155 -501373131 -633320042 102088575 807058650 960783803 114947239 -316825970 -138000972 832258758 -406306777 732831106 681555739 692454112 -801004400 -888554900 -39832271 662887287 -526254002 744072571 -46790581 -48062596 132445671 -869574003 -106395433 579907989 369614860 -3963617 -806717190 -642572349 549548490 -653509792 745675303 -637514142 -238767068 -128387707 615859872 -29126781 973803961 302163814 964912585 876139893 -927849635 -202092373 -984231633 561188251 738507037 425149900 -593710539 334578541 179450708 890139186 735719…
Output: 742353052 742353052 992248989 543090231 543090231 992248989 995416398 970613168 970613168 970613168 973803961 -97464258 739567241 739567241 739567241 948835881 960783803 -60177334 400979929 587166205 107672919 587166205 807058650 -64494155 102088575 102088575 102088575 807058650 960783803 973803961 832258758 -138000972 832258758 973803961 732831106 744072571 692454112 744072571 -39832271 -39832271 662887287 744072571 744072571 745675303 132445671 132445671 579907989 -106395433 579907989 745675303 549548490 549548490 -642572349 549548490 745675303 745675303 973803961 -238767068 -128387707 615859872 973803961 973803961 991820330 964912585 966931162 890139186 -202092373 561188251 561188251 738507037 890139186 890139186 334578541 890139186 890139186 952396277 163094218 382814268 129774083 1297…

Example 3:

Input: 821 -409372283 -545274202 887355526 -816993570 421817186 -11103018 -344167508 -987993050 274191221 -176679420 394199524 417083813 456954655 617964873 452420771 -937733716 -640336485 -456123304 -39621053 -914948813 -24391550 -850940111 73366843 -576091886 -16358495 -676336643 -361118411 456758495 864818781 -42536677 -208396198 -576426562 -434542855 -226588895 299178484 -162147765 984339605 756693341 -773074043 -950653452 540139195 718045716 -662019510 260945349 -751628558 858891887 828931351 165715096 866112348 -643170727 821089852 -583514393 567248751 981653210 620686159 -858661973 -887878833 392119959 224610601 -940182004 -682060401 -252147646 886560427 650443682 -12044387 329792226 -439543020 325395863 50355639 -409100468 -104425230 799556267 -698447771 452758920 -33162207 -649641973 -67…
Output: 887355526 887355526 984339605 421817186 456954655 274191221 274191221 274191221 394199524 394199524 417083813 456954655 617964873 864818781 456758495 -640336485 -456123304 -39621053 -24391550 -24391550 73366843 73366843 456758495 -16358495 456758495 -361118411 456758495 864818781 984339605 299178484 299178484 -434542855 -226588895 299178484 984339605 984339605 985231883 858891887 540139195 540139195 718045716 858891887 260945349 858891887 858891887 866112348 866112348 866112348 981653210 821089852 981653210 567248751 981653210 985231883 886560427 392119959 392119959 886560427 886560427 -682060401 -252147646 886560427 908065580 799556267 329792226 799556267 325395863 799556267 799556267 -104425230 799556267 908065580 452758920 718535836 221107406 221107406 221107406 718535836 -579510344 718…

Constraints:

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

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