CT58490

Indu's Topaz marks

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The harbor bell rings at the tulip beds of Bloomhaven; Indu weighs the day's marks manifests and starts the calculations. 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: 2664 839686339 722389491 520474421 223099695 507841862 18907440 399936636 474720602 735303431 233698171 794954330 604760967 520261779 364320169 723013208 203333866 447966775 978103473 873249928 174363567 585235972 215633759 499319098 644434597 110196224 782750909 279798294 326582622 527075738 792619310 859783126 148219386 29007554 518324082 608742955 796232428 625911816 457357141 625505789 138217295 456067610 807703015 557682521 849412200 386598944 314136011 599322822 217738866 312190655 958838319 924353534 186152003 159687560 675138607 891291065 632720755 713742713 910550085 516971136 67802992 275972045 40619356 352549158 148553208 1029520 7962081 263620448 525558586 514344593 484786666 380002826 453211408 12836634 946474491 143442463 365471948 649119282 510587090 67417778 972045621 22892…
Output: 6392090991

Example 2:

Input: 1362 750209288 949283535 606441928 35332657 302954525 570533102 414080899 321032012 244827958 454266797 734313165 364057415 883797012 890855205 803580458 958138883 983753603 295083700 227454612 416068408 50098243 271103731 106561406 384034020 346057457 457361146 570612812 112620776 333526813 353737420 104092433 634119020 683022156 813434564 71806379 801100829 709760729 548541358 167160761 49983677 394084586 11650733 74539988 103259544 134347005 708910690 512737366 330579979 52109516 780133485 64195436 342800153 655557642 640085975 292307758 489096087 14256919 763818409 648490078 55818339 881315582 981483215 589638883 245475921 963055746 780656887 643942958 208327360 462157718 171412918 457760994 269274410 866395143 909103506 328594433 78714192 885574184 52204449 263616743 88144944 71100582…
Output: 6914330644

Example 3:

Input: 2965 211790495 615940781 875181447 598563455 998292429 186578086 559524059 8033859 981589632 603262014 297901813 844353825 477525209 396137895 17328556 989400353 83226065 431141277 261191353 103309973 879401695 64760243 462125210 304288720 412479603 385141132 448283471 466414348 616471093 222813766 507855954 431577283 424892592 26788327 198589045 247698923 923806973 570423061 598012461 598556375 834078742 846745237 731150225 459095625 209402605 897252774 224030357 440926529 470073299 698706762 230179272 592209520 265167798 910171285 237851958 597803543 735034550 254300264 278320599 37323707 111678482 318084344 334992401 643181484 380042383 478593550 688215677 506936194 678149251 26840139 538945827 188257474 528358460 99693097 815257492 687343128 387252961 880394351 770523269 511910635 1436…
Output: 7931818664

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Indu's Topaz marks - MEDIUM Coding Problem | CodeTikki