CT58161

Jessa's beacons Grand Facade

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Jessa the valuer watches over the granite steps of Stonehallow's stores of beacons. A careful computation stands between order and chaos. 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: 2912 357670717 718874601 232516467 888476733 811235058 673786275 232271090 996907095 602673008 929327403 632136015 612410085 683306814 641981783 620403761 781254594 673172949 247544368 597761777 639919742 973156508 497055795 535093925 568394359 939832193 100112459 205982493 140835953 727411077 819125073 599640477 103407517 648101978 62231266 921503476 579418342 55410184 78421 432714174 53912297 153349725 184313246 440003624 733115402 35887548 853136200 904802428 241095253 943471519 540855799 499225666 346376795 827333449 95282470 948741052 827735817 696560465 914170685 19157908 223480404 69924855 222038703 167449856 582474756 69292192 685474932 522209942 572925466 395024541 79782635 294336216 156347063 169344554 426047972 96754529 970575202 556533959 368866069 990165927 396780475 259499152…
Output: 7174618626

Example 2:

Input: 498 846180459 787629524 600631402 187710245 28145801 930478545 170911853 859583083 469728976 467292786 203525252 876424091 20093321 8102574 39143877 629907839 643495297 713984849 999343036 908979730 445143221 883308818 218465497 334553390 976888959 254903688 171647437 21196349 540692151 693249293 856165259 256517123 177750804 252852877 332427300 275263949 933640413 104251581 295561389 324937581 723385696 884620616 897274927 308043670 986415765 333379254 185904249 503868518 125090390 34203060 829525916 782952262 295789042 951921436 470566759 386684812 626182923 217497426 381719044 28257837 167187396 941829676 902419797 118570852 693788919 623341061 333760720 700026652 469383880 438052000 597751806 29323722 454008920 443575223 173517485 968079866 830671396 51985532 266182309 165819577 731993…
Output: 6659011216

Example 3:

Input: 2312 312337784 922787205 270195531 540543030 690673632 726819371 847931035 812932869 433080179 509489885 72321205 991053915 487693528 996944797 64806117 408426729 157097569 866443675 504696092 309055577 6729811 847506174 868851580 999560658 779776709 855332609 267614251 233192022 202262772 351159205 148943736 482254762 607215666 536574921 598528335 512073352 990136601 390983554 541278357 644818427 837243875 718622239 441183743 464158613 280016500 755214226 677159691 342196359 653735962 631592139 199421002 158002726 233896009 163792483 848062504 150849805 344195815 347247383 925041876 149611905 524486345 765994968 231573048 535174648 834623261 323804343 558256686 967918120 885093580 900210690 954356831 116784475 477044090 521958393 157141707 359665699 408182993 618253964 285389395 528426106…
Output: 8019393750

Constraints:

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

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