CT57664

The Azure Grand Facade

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Anaya inherited the ropewalk at the saffron fields of Marigold Row along with its curious bookkeeping system for registers. Time to make sense of it. 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: 3815 113820957 685926385 43336981 978856393 77866863 542560574 176535041 10168025 326559866 27232671 343207371 156958391 187162680 38754397 412331222 104306588 74903576 323240430 220273451 686911605 909133760 943709976 889261290 887198328 273646529 365710712 599463609 729349768 511482478 47627908 769406427 45242677 33950266 774296575 334346461 703982842 390446719 900171818 214679975 753195559 352320547 410551588 990910146 457579703 135076048 752042081 38108923 817724413 31507738 292262650 475276417 270294387 53358918 24878780 727159246 501016070 932303421 273052543 953342707 380664641 221963556 99082283 22887040 606944888 654168682 321148116 682351783 447321117 545580740 394389067 76541378 114268889 289185026 233204690 654311972 457966278 667211242 991478028 963769697 124806291 918378964 7…
Output: 9489829350

Example 2:

Input: 3670 407038528 670820808 894438390 994414028 841862421 218272597 996931735 509832855 4412703 192940192 179395789 177775730 456962765 605536144 115068864 890615443 60271145 702977484 57521443 717971319 860648291 178143242 105562710 41038716 917696065 822367478 39957234 72051367 646150498 221735249 15979320 810247325 303140253 603093630 154153459 520514511 785186467 603767663 828013406 145696739 314328799 446286469 836888394 293880876 413228165 350164648 420708955 198507496 434183769 92901476 322756630 213073190 846998715 707874311 878543038 969700701 39549854 362768637 503986733 403219099 768581007 934645929 95212453 269421991 351108306 28210847 758934267 25762604 193615270 426616063 560703123 136273556 524794137 996168697 677921582 397532310 750680801 829396575 353381127 150649055 12930528…
Output: 7508216487

Example 3:

Input: 3401 494089151 537339514 417386475 71532258 441301485 371484364 926558449 973325411 904951202 325431971 258211148 511587429 426866525 416103158 359695117 393801511 530745485 944875276 107093125 296124922 366206861 95595129 362347830 918698588 689855198 566703506 705627052 46110560 824644524 844606938 164038065 296326413 277382708 180220472 669721037 187195937 230657696 685433091 752437496 247935113 342634227 637756041 920332252 226268067 632569962 770533335 294099566 209197469 242459688 248207029 931339773 116598393 809116816 533352210 606005785 791465672 728798128 902695155 803752380 860026692 974255492 961427998 391682811 260094950 776274673 55666349 756348885 524441482 30330351 996651143 291322896 501465046 325254956 747135555 258632892 366526272 631009901 160092977 421711971 987128071 …
Output: 8353662909

Constraints:

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

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