CT63283

Uday's Grand Facade Ledger

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

It is audit day at the jade shrine of Serpentis. Uday spreads the signals records across the table and picks up a sharp pencil. 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: 1734 232973072 521348956 892209614 244154616 378683935 119877531 674080735 521175349 437891311 36565381 687265946 300434493 83841446 613522147 787552819 534409933 672417314 359566853 925969330 404737760 628368887 179615119 142593323 72536635 574037648 33907112 270039252 204537862 265141796 768072434 532850178 855735171 960076180 703607090 982944897 650804755 297752948 658860256 453483827 701512080 419539657 340770161 143583366 979381348 443906136 71479565 603334091 152130073 736687972 987635739 182464211 48789963 44321842 271854787 516496328 858694286 588957312 762328137 501216154 68359955 277165334 567849140 830976897 148717186 284352831 629650842 445941732 479646094 821280124 516938859 668789094 573438743 17749676 173030049 358812371 641280653 251718960 899540729 916175810 500948650 5058…
Output: 7296099856

Example 2:

Input: 1353 659640569 297505572 542618526 843661651 722964164 952741228 558817008 627400024 598621369 610417259 718340937 489009613 79490677 259563740 902023379 372933387 869394641 243832398 473884857 63746448 703311577 610058753 190212366 335348165 614009611 436411322 286308018 152690505 829930438 906224091 309757878 697674416 855504247 776218625 838787664 570375507 693424225 606275068 80392366 221121595 490680638 370233043 470540908 916502851 814330053 822466727 207820592 130138901 40907084 117316546 733062262 145505911 86310208 565372869 7296668 131016741 560616448 180759515 781698015 188752079 57795076 259179267 949214791 352290681 878754314 83154470 487725460 962809164 794924582 191270093 473044648 418322319 609529893 203012220 444828237 991208358 585221890 130252499 389555334 566409286 8551…
Output: 8302761450

Example 3:

Input: 2932 700723678 614012758 269644450 302777614 122987573 89270829 998809431 894678789 426567593 626751620 662850333 204615315 664760454 671156364 593396272 962852093 644361336 158610261 989595971 229512540 555554172 741694083 278084226 748763227 932554779 449324283 249333703 508431577 854993718 433023115 914876945 389394186 342574708 940767676 7543792 434132809 634019190 778842969 35442888 857992482 439341403 621386961 209501364 890544637 325078043 460478325 409636057 538002744 636217418 449568875 787831230 144562302 118914733 425469775 721438854 15712589 351283203 356719160 86365894 587278169 813963284 177123198 413887474 860755199 284927517 728613202 322040090 509366969 73417234 581967965 444231647 581445857 158630742 141158667 598343331 335060919 438727401 854594907 387620650 439044474 78…
Output: 8738951469

Constraints:

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

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