CT43927

Bhanu Counts the beacons

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Bhanu runs the boathouse at the caldera rim of Firewatch. 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: 3748 -311306583 -528386133 -384299817 872935618 -340008350 -52243334 -325488181 323701728 -630383699 300582882 327687850 226869190 -354757644 -647615562 669440380 573140874 -18572372 -623824712 800299941 -826372451 -96594778 649517261 984857099 189816947 -428605405 -691863147 -155324327 -285722383 -565440605 395091862 607406399 -834890776 -778190313 102876791 -998930855 -198854170 887246182 -675491003 194969697 -604804858 -679982433 -702694646 -872943274 877520648 -913894933 149006058 -677002447 669736137 -717248421 -690291399 -933435855 531255421 847593668 -581028219 356649032 -268521205 -757149201 -697264236 322376668 -45986641 -453397853 484394966 232424103 -991132456 -708806452 420091207 -735273903 -715313009 -930810539 -189975049 215272811 943342048 926611718 196969034 -82280398 -3811…
Output: 872935618 -384299817 872935618 984857099 -52243334 323701728 323701728 327687850 300582882 327687850 669440380 669440380 669440380 669440380 800299941 800299941 800299941 800299941 984857099 -96594778 649517261 984857099 992284328 395091862 -155324327 -155324327 395091862 395091862 395091862 607406399 887246182 -778190313 102876791 887246182 -198854170 887246182 943342048 194969697 877520648 877520648 877520648 877520648 877520648 943342048 149006058 669736137 669736137 847593668 -690291399 531255421 531255421 847593668 943342048 356649032 484394966 322376668 -697264236 322376668 484394966 484394966 484394966 943342048 420091207 -708806452 420091207 943342048 -715313009 -189975049 -189975049 215272811 943342048 953468294 953468294 558473316 101522490 101522490 558473316 -63246701 71160786 …

Example 2:

Input: 988 8733870 151634578 -547006695 -655073700 707907603 -315591256 123133433 476049703 -483906409 721619509 203058795 -87312678 -454607827 -467492197 -169201342 680118975 361907212 932384496 820123987 -872112469 301519140 532910122 -56035161 836240521 -484516264 -370404819 -748645896 -413887879 -875414433 -73279854 -488249099 33665998 -953643514 892780324 -320893545 639934723 568005105 655896000 515781389 -71583190 752224870 -913307542 265980254 -977248353 884259894 2873862 -527644107 -770487906 -540254103 821596183 -702720138 213432297 -493823199 -839008938 400805291 -36381177 -470591189 -417657820 288106426 891248015 -746785159 -600249578 574097628 -874640499 -652073267 172854364 151666329 -730198822 699332654 164075879 -917881759 -207314664 626858125 991054128 -160085779 906785514 7518197…
Output: 151634578 707907603 707907603 707907603 721619509 123133433 476049703 721619509 721619509 932384496 680118975 680118975 -169201342 -169201342 680118975 932384496 932384496 991054128 836240521 301519140 532910122 836240521 836240521 892780324 -370404819 -73279854 -413887879 -73279854 -73279854 33665998 33665998 892780324 892780324 991054128 639934723 655896000 655896000 752224870 752224870 752224870 884259894 265980254 884259894 884259894 891248015 821596183 821596183 -540254103 821596183 891248015 213432297 400805291 400805291 400805291 891248015 288106426 -417657820 288106426 891248015 991054128 -600249578 574097628 699332654 -652073267 172854364 699332654 699332654 699332654 991054128 626858125 -207314664 626858125 991054128 991354232 906785514 955506650 798431739 469315131 -193705108 -7…

Example 3:

Input: 2864 726844149 -634916351 -140039279 -580335814 -199566102 -868529032 153803495 -23681382 710655582 -24359532 324609714 136152106 688734697 -647685817 529620883 -305394364 103433632 -894810468 -412968539 624317710 -631781861 -810259460 33257818 -721511712 -932470962 -864141005 -161046732 853047485 -115944385 513442043 -745105942 146791665 903317147 470580790 -892354808 -55400391 -605284158 -214121833 164945399 782879113 -518022950 165590417 -496824042 -716171823 -865970525 244596262 889631976 -666324193 941098611 -919833986 389059635 99049360 360878207 17992636 350654687 -127506619 -692429058 -640466754 275103039 164067879 808592184 -962748610 684047619 -98909847 596756646 -548724850 299708032 795032674 -355285947 597897498 969231638 -595265290 -532360863 905369072 -549008221 45172040 -935…
Output: 853047485 -140039279 153803495 -199566102 153803495 153803495 710655582 710655582 853047485 324609714 688734697 688734697 853047485 529620883 624317710 103433632 624317710 -412968539 624317710 853047485 33257818 33257818 853047485 -161046732 -864141005 -161046732 853047485 903317147 513442043 903317147 146791665 903317147 941098611 782879113 -55400391 164945399 -214121833 164945399 782879113 889631976 165590417 244596262 244596262 244596262 244596262 889631976 941098611 941098611 969231638 389059635 808592184 360878207 808592184 350654687 808592184 275103039 -640466754 275103039 808592184 808592184 969231638 684047619 795032674 596756646 795032674 299708032 795032674 969231638 597897498 969231638 972878435 -532360863 905369072 946980155 45172040 347180763 347180763 404499014 773404300 9584…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Bhanu Counts the beacons - MEDIUM Coding Problem | CodeTikki