CT64462

Grey's Grand Facade Ledger

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The harbor bell rings at the garden city of Petalbrook; Grey weighs the day's registers 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: 705 180403682 688768132 753375980 342293031 731455311 400765952 578886088 412973137 193210488 374041999 198669665 123794472 435198660 775262454 500225117 710231148 918064419 660854715 802124068 874635771 73195724 93592336 420780768 407742023 578766471 763194341 657705619 983529855 460594747 329454721 871094500 493428084 18280400 688275695 598381547 797141988 860890263 613629443 143631985 480158258 547922528 994545549 488169163 485415691 594766089 218778375 477117947 61315130 42776266 785870790 263162726 119494691 340815210 823944371 901528859 13674592 963074926 254094197 623442813 75297445 779988823 797772138 238943984 497870205 943913010 983650754 167846166 171427156 634543827 573457933 550667213 769052461 494525562 804652074 822754829 476021438 630316877 414862669 994252948 183609538 601…
Output: 6063070431

Example 2:

Input: 1789 872003867 290879741 793657971 641276396 953229885 429320203 31830476 710273836 60137512 613056100 953378887 356538507 584361178 204864354 326551052 146990580 6033189 582991426 474921192 945645094 881965749 524738811 570258731 498702944 99996299 619777293 77478306 386791272 374440931 361607838 894384734 173560912 399716339 803950836 874744302 360392351 104705049 792559278 745419637 510410221 632350216 302153589 891125031 562073443 803602552 5757165 771437947 294285295 810801393 166493769 205389454 680935618 574969670 798080099 728830399 696568888 278536490 631563136 264161162 725239963 60488826 399491195 732249049 216400556 245809060 97169284 607120053 934982539 132737931 367140323 106955260 78304819 437444223 913328793 56425667 389253904 721179759 804210268 918147751 63495731 60997517…
Output: 9051218860

Example 3:

Input: 2541 70366838 838151278 223869973 450417067 407866791 680336674 934082671 777519184 168756965 972983647 654724186 286464855 924247297 514226282 351593275 179632952 219875907 450563961 605264451 266444714 837229458 864000433 856941946 258336602 894370348 21663228 968329686 2216560 893483578 172531301 166421464 102632125 354067424 992208917 779951492 664192785 22186691 629940557 48986163 207033165 956951675 36912058 956185754 720300577 101283099 990025487 283815590 735214916 206459106 731245120 614004637 6061950 905132004 509131130 553433843 144196271 863805062 893750115 329967965 272535372 64854101 917065153 915955432 767194668 599813255 584686798 625127645 363108361 946703725 108507626 702761740 73793826 812622064 573266169 599715344 203488209 990310511 704080311 256306877 906137166 902101…
Output: 8536202485

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Grey's Grand Facade Ledger - MEDIUM Coding Problem | CodeTikki