CT59116

Lila's Northern Ledger

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

In the cotton rows of Whitewick, Lila the store warden keeps careful count of the signals. Certify the cargo before shipping, every figure matters. 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: 2745 777980104 39559500 523746748 808433121 300611040 169636853 863758003 105584950 932126315 818997966 66886667 632969070 759107727 764940950 736300588 721440463 474005341 15001525 950400548 669183478 294615349 934025341 510735415 913520408 781524206 415216429 303749863 845087206 896502784 985815240 455299956 49618124 362215391 699446521 118226568 159194534 516886296 639983360 582560422 73945118 551617157 376788294 906316582 417496901 102812211 541235537 193240234 844397941 785172003 713641626 114987338 972509488 705338955 985155253 700862424 906944737 661741392 598316975 682743513 393607414 252256343 798084269 31875530 935360628 433093246 669448175 279688636 412395813 560599488 528959679 992006117 630351984 643340929 829957848 333927941 771873855 812306296 395228492 480066778 833625719 5…
Output: 8469123880

Example 2:

Input: 2834 250317115 260349996 252705658 733882073 2551878 940272326 945465823 346222780 226177741 318862976 499032800 317414509 577614761 349313782 634718575 744964032 702498992 347715329 707422976 95380826 984126909 14465386 892058711 830710080 729617967 932431721 351607555 625035495 915004431 151169068 647956687 467974521 923337677 872071771 107352075 603920397 805734030 553786581 851083151 845584649 82929213 395917893 585682730 406011366 786867731 17372997 365724299 416201550 451219897 346906331 764731020 104077487 456167718 449207214 658792529 808000234 190527405 765976729 636856111 112301925 636086927 545905722 995522612 45267305 764843759 254931156 58733195 882303496 779097341 705149928 986983781 981339672 485739744 988877383 137277908 484080813 276264788 248694154 565061549 534508872 944…
Output: 7464576344

Example 3:

Input: 458 959269961 221727168 300074456 741334111 85106797 366026675 908797329 488075812 120892993 336502174 79407262 851111902 664987220 374888085 329995205 817997832 17572697 3751776 835097457 428726510 215799733 511339148 218808422 15815220 602630425 85002226 266098391 128525878 207519826 102023112 871601718 282098894 761830320 613363190 226692848 791243682 215382362 815087643 289770442 71044504 298546235 582905514 169531111 375761009 288234947 699448248 495755331 697202744 781726055 996489270 573615322 192323081 365671806 951784142 386911747 348305555 376834348 400109218 463993 410056241 189706624 672854299 178404243 333819845 616705487 840005479 590247596 376662725 192102572 785250277 22584852 961140392 531979510 56817915 961584252 318805403 542428789 391100976 959021144 673366886 265340808…
Output: 7712506023

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Lila's Northern Ledger - MEDIUM Coding Problem | CodeTikki