CT64950

The Grand Facade at Willowford

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Deep in the river town of Willowford, Nora studies rows of registers entries. One clean number will settle the guild's oldest argument. 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: 1400 911798639 408908146 631809865 542436855 462118672 219323090 865892032 858670206 975091084 431860994 776521132 259568914 16894577 48702886 774684880 975711931 44805273 583085713 735726178 703430508 953952118 851755067 741951614 239625043 210338572 559009689 705446802 730503683 910318190 706645620 223663683 303035645 389774973 761426543 797340827 982969413 156634013 80006365 513076144 355640918 695607504 161220244 96054839 572067109 176104793 563227617 877289511 353001347 605747829 89753773 590980695 230747483 60168039 559318191 122361703 469208701 362287903 795469257 145045283 68037440 504959105 90134996 581748460 353440654 664314396 94426270 922965459 741533252 36129781 954426026 100770611 178695438 726590186 890484378 983103610 61075698 182407757 930961158 321651086 600403874 7522702…
Output: 8645446656

Example 2:

Input: 3736 744552020 719569839 823950460 394297791 461547323 959323392 82613560 23754723 176870782 471570722 913814920 976827482 97603371 57432779 288493297 773470795 69924981 312674098 890743444 472278590 66776622 493155663 100465057 745682372 434024525 587543442 578892883 327273746 231457161 673215025 359054727 670283236 961152500 35281922 657482294 756597446 750602396 104200683 734474283 976061837 598472950 347539237 310390020 906458683 390103325 461694829 724285912 25281232 130942213 531059005 406565697 614297510 379100876 468405768 197256934 514626091 669099427 709721292 666869282 63907551 618442609 142018653 895077390 625683702 59766861 999254045 18980609 144654628 590820407 784083543 416483162 366579039 407836319 980047746 878845659 347217066 112253108 612335541 358000003 949180216 194556…
Output: 8435497560

Example 3:

Input: 285 676521757 719354427 928635342 355720514 664374345 349053170 376914 591204307 322347448 934833861 865969046 297447220 551450397 391997435 23539655 232916101 2037844 681194706 915642948 46471593 824297574 493348328 599411267 91516111 297767036 76057231 844050577 754383203 128519404 452587480 551867268 890448411 299699607 66689084 906978489 754289788 257206946 593369603 648705382 767286677 902331962 333945416 597490138 763829160 419017036 965310946 312120241 320775584 280803540 940178231 699194149 654673803 807748600 287556649 868696683 808267831 693905979 17058048 624136889 454499090 145230259 272360363 358693503 38112875 634878558 650940502 753792395 977765689 379500623 216528989 885778848 646295175 87398125 391392855 598557804 60233940 52170428 224260242 933880098 19754142 587464616 34…
Output: 5915759758

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Grand Facade at Willowford - MEDIUM Coding Problem | CodeTikki