CT58242

The Copper registers of Yuri

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Before the gates of the shale slopes of Greystone close for winter, Yuri must finish the registers ledger - one figure at a time. Task: Bars of heights h[i] stand side by side with width 1. Print the largest rectangle area that fits inside the histogram. Input format: First line: n. Second line: n heights. Output format: Print the maximum area (fits 64-bit). Constraints: 1 <= n <= 4000; 0 <= h[i] <= 10^9.

Example 1:

Input: 1602 897057735 453994415 30326093 583642952 267830752 310590915 628230774 784483472 71291012 921046976 369969516 345619596 189034296 460947228 109078702 271736037 545012901 57084986 478320516 807724795 243140123 571591870 964186750 343919017 741341762 399161832 127445736 504382112 892390809 617145629 876100277 569661976 141012942 140462225 973613569 549792367 778150867 456931555 950241706 68396905 47924312 818841513 616129753 635920058 535130566 778155545 868728610 568422313 534645238 711707504 924797955 537958887 131039814 262182990 172620299 713975145 501525203 976118245 700748472 413036333 890743522 122229768 146665410 423069603 625879765 622870832 869707964 999284421 229626943 127553141 346207905 365764047 556394622 27991898 394138217 389147180 578332548 788233034 683547766 881621280 7…
Output: 6713138016

Example 2:

Input: 1846 23057067 823813054 942552953 572916023 51109157 746533288 21836497 188414985 316955363 840059840 63319471 420963997 445758620 115755397 415141578 53299631 593873155 341453308 517467630 165975673 367416539 483904012 301730126 79100280 705350716 105903301 284313645 247667417 275626813 479505154 582514672 749467538 889960619 262921443 942070882 817053285 568583006 509372913 418074091 186769875 315288821 392088154 710784430 513777900 866701324 431712514 78563187 949693010 888486629 650051534 324928010 656842166 804417337 246780162 873149681 31474057 286617406 256861852 424618800 910541253 187620389 415158096 824383689 987669317 588944903 476780262 488774353 470214930 358806590 481737168 527394552 265526818 597373762 608640944 789467109 275912039 366986564 165384879 745156527 966852822 531…
Output: 7670832120

Example 3:

Input: 3755 455390151 360942540 620919703 388404615 400149759 12789225 596156875 684971432 103220678 895958445 822232150 188213367 105225609 11098299 200492333 262765342 209592742 902784306 853900440 793237667 450122839 141256023 457892744 477604548 539793582 689944871 922248896 546300848 503326869 351976530 562807515 328604667 603144129 456756925 907754692 59452079 185571863 165655677 659773196 724392486 707213456 113948622 880880476 337789965 438685501 922067467 883665521 610612355 278251833 369860898 17074568 411964062 935848568 488880180 970575145 270498166 656983198 506562960 841027 6486823 823143503 939978399 263513859 236136149 4683651 464308227 243561578 398453098 77368646 794207088 358882843 886345759 953491203 595514656 528515746 847549798 509811914 827657845 890388915 716755794 5445558…
Output: 8687494101

Constraints:

1 <= n <= 4000; 0 <= h[i] <= 10^9.

Loading...
Test Cases:No test cases
No test cases available.
The Copper registers of Yuri - MEDIUM Coding Problem | CodeTikki