CT59943

Opal ledgers Grand Facade

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Caravans arrive at the marble forum of Argentium with crates of ledgers, and Notary the chronicler must account for every last one. 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: 3819 294741759 328145596 275573955 580772350 582462747 865381231 641142890 168137686 374566624 224566894 988716875 17232187 261538818 955167770 396677626 423512376 601643145 155495463 192162905 280966480 329766928 451519154 418174263 925271876 681045364 161749051 638219522 6820532 725156736 562204461 453794173 992453833 759956762 156702120 750209717 612563977 830605375 736332689 479017225 395820855 137431528 782063682 123619018 324789762 259421621 208336479 768780341 889010855 126575350 229669161 604601646 184873545 638151770 216072266 209843619 84351863 62523165 719401325 911120779 685741804 874974214 748683787 876681914 77289462 39257445 285177669 734833985 774919048 113467730 923506564 969355383 237268524 971189619 822104207 132263667 363169478 578159054 120224564 76851902 863429806 725…
Output: 7305517593

Example 2:

Input: 2809 142813273 997039993 325375893 529294231 704267416 452918073 170903083 954327178 891339605 1424982 977100322 323996018 435913289 370281081 408917951 851771477 541634461 558935347 35628076 486512407 94165487 581512037 14749117 224722766 842180740 13993237 334054300 552685119 719648630 278323193 971871050 804820716 488705054 417747143 271205221 488209297 275800224 273422460 887566898 179518420 792919445 753323111 982272502 818488339 593234249 567818004 679187175 927841654 17734088 732200743 60508580 262991798 264712348 340927594 210422511 532757829 416418444 218173150 922904765 575707773 45581602 864131360 222373993 888821962 492004790 267766868 733508103 497003276 783275717 889430595 873537602 436712664 680671825 462745344 113425663 927755662 489292407 657382423 921517267 308363504 8492…
Output: 7163564100

Example 3:

Input: 3064 197341060 900374401 549122125 934781219 489986053 769831259 174548404 259694190 330005195 357218675 435663424 297982312 893374058 440284579 877228773 173774097 961060483 628221895 848342956 72426078 836274454 417105190 218351133 184765785 295001245 182915443 115759852 327915525 442487414 170496737 500386003 430757631 211764448 240452829 168380604 624657028 367697566 970927474 359763746 992031698 119383027 525671426 483885611 62366517 23082328 519907418 241282473 977687360 994191783 45807950 851181044 50988836 910530255 938477903 243913050 66347373 856775016 230614867 841967765 87607245 765644647 775383377 654526878 759554364 894797880 969959104 303744759 909186559 965433778 592102344 42515169 327231557 822168706 786144513 273141567 707834528 958714361 98165342 765580358 21773372 56397…
Output: 8361930270

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Opal ledgers Grand Facade - MEDIUM Coding Problem | CodeTikki