CT35853

The Peculiar Taller Ahead

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Before the gates of the quartz ridge of Glimmerfell close for winter, Cobbler must finish the beacons ledger - one figure at a time. 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: 1110 201968494 -639112225 -866265629 621447052 -644902246 559592491 -58323190 -817063135 794290406 347668953 -352872228 -747528715 265450669 -326680039 -125127738 265454949 806958178 369559817 -104755669 668609826 -158709361 380529118 275568194 -959457215 5609180 55448024 -88026262 998548104 381979779 -851163733 488640758 488337885 -585799120 697305121 -18813941 265155399 -133740962 812095354 -433110182 301803441 156170392 755518126 -452610503 -341075358 -691998895 993001507 931145204 856296104 -423082528 -419094437 -105849146 978317773 -387154554 321211521 -673457488 868016425 -185887228 -925988864 685397296 -614170268 723473968 -678974928 -598746276 -846901768 -901505 -745124182 949151249 110470065 -626457569 -427003150 929691741 995777473 -164095689 792809541 -961512904 545317474 438204…
Output: 621447052 621447052 621447052 794290406 559592491 794290406 794290406 794290406 806958178 806958178 265450669 265450669 265454949 -125127738 265454949 806958178 998548104 668609826 668609826 998548104 380529118 998548104 998548104 5609180 55448024 998548104 998548104 999344745 488640758 488640758 697305121 697305121 697305121 812095354 265155399 812095354 812095354 993001507 301803441 755518126 755518126 993001507 -341075358 993001507 993001507 995777473 978317773 978317773 -419094437 -105849146 978317773 995777473 321211521 868016425 868016425 949151249 685397296 685397296 723473968 723473968 949151249 -598746276 -901505 -901505 949151249 949151249 995777473 929691741 -427003150 929691741 995777473 999344745 792809541 967621400 545317474 618034145 618034145 618034145 -290368754 -140351996…

Example 2:

Input: 2372 -386380958 908920981 370863210 49073537 209256899 -912050604 -890487098 420466482 -880112394 123697470 -698043691 -15748781 -32148516 157276178 397106793 911671581 -389893903 498541264 -329348830 -400799374 95459268 -252186656 -764134310 217127029 -873760155 -520739936 361249856 187591974 -635754567 779625769 165470611 -443358685 -37379364 917036581 -922918988 326861858 -55829022 79231144 675836950 -377521176 -363986578 62810367 -412526868 46248773 400838381 615904264 -586535662 -715586187 -881997564 768754633 811815377 -677681690 -941837308 -41645026 178931779 -210548052 -682516873 534768184 240053501 -119522881 463076380 85076823 -527753509 -23181135 988158712 951401375 -760335099 -752589130 818966179 -177709699 -403443263 470180048 530394278 -685047456 -657342055 657974462 -1802252…
Output: 908920981 911671581 420466482 209256899 420466482 -890487098 420466482 911671581 123697470 157276178 -15748781 157276178 157276178 397106793 911671581 917036581 498541264 779625769 95459268 95459268 217127029 217127029 217127029 361249856 -520739936 361249856 779625769 779625769 779625769 917036581 917036581 -37379364 917036581 988158712 326861858 675836950 79231144 675836950 768754633 -363986578 62810367 400838381 46248773 400838381 615904264 768754633 768754633 768754633 768754633 811815377 988158712 -41645026 -41645026 178931779 534768184 534768184 534768184 988158712 463076380 463076380 988158712 988158712 -23181135 988158712 994064087 957925873 -752589130 818966179 910423354 470180048 470180048 530394278 657974462 -657342055 657974462 736133166 128274695 206065396 736133166 -40588181 …

Example 3:

Input: 2676 -690096603 161419213 174419136 -416265019 -50194582 926235594 -305099897 378777049 944302247 175522110 653602903 513220727 -517455123 789658075 -429259697 -949716434 -517028385 852049140 481578604 -638684801 966713131 -825790341 -539859282 80338199 -863710143 349421706 -250150425 -978496379 -536421517 -875909540 753063922 -924927582 59852284 -555937358 636984350 9034238 579820074 808730880 -71429473 -316671444 327210488 940856684 376378013 -956810753 -758665968 560952542 526231438 -612612136 74958659 -333976586 326075401 997565183 83359958 -78875414 -696983363 375867616 -892936580 839463677 475537881 991488581 -211179375 -557539515 950576483 624231475 896739605 794607230 140853943 -248525575 -811591920 182702433 -885660845 243665702 943748540 -617271430 406273179 557001465 450196485 -…
Output: 161419213 174419136 926235594 -50194582 926235594 944302247 378777049 944302247 966713131 653602903 789658075 789658075 789658075 852049140 852049140 -517028385 852049140 966713131 966713131 966713131 997565183 -539859282 80338199 349421706 349421706 753063922 753063922 -536421517 753063922 753063922 808730880 59852284 636984350 636984350 808730880 579820074 808730880 940856684 327210488 327210488 940856684 997565183 560952542 -758665968 560952542 997565183 997565183 74958659 326075401 326075401 997565183 -1 375867616 375867616 375867616 839463677 839463677 991488581 991488581 994722730 950576483 950576483 994722730 896739605 943748540 943748540 182702433 182702433 182702433 243665702 243665702 943748540 994722730 406273179 557001465 615737672 615737672 372878102 615737672 615737672 -53012…

Constraints:

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

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