CT61114

The Grand Facade of the Peculiar marks

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The log keeper Hema has been asked to reorganize the archive shelves. On the desk lies a long table of marks readings. 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: 2438 201142739 15028571 873980035 900975004 399731698 528916256 794031082 992623612 553052920 93000600 919467180 839039184 136956530 83040041 882074835 907068269 986454010 516201748 965498144 158313190 550148662 196978795 179140348 228211694 206919596 557129427 963273574 243210648 78599894 489954455 611951327 147676859 992091096 733875575 822633495 128197851 680920350 144674412 549209871 44982556 531136235 42823064 845502980 626170277 732582390 144568016 157356118 105160661 227338197 376118902 874209413 126482090 844073419 805658287 764954275 931572948 353414693 52485984 747091856 510129320 303980118 806275742 289985379 547094460 420762050 109234634 551752590 504493379 941916507 309635445 627801099 992768967 315347356 611868352 868203514 473209171 207029717 227397768 213298614 303089337 70…
Output: 7116974640

Example 2:

Input: 2647 112866332 909887543 791369999 277989951 286727008 919624191 510526091 542900719 446244018 794855844 457285500 62853382 635733703 595186644 91638440 261263848 527413471 32104459 149164086 847894783 632530278 677459070 724674465 899987566 316571744 440162159 830487083 697681679 731331701 456460831 477117507 836529732 333577328 315064141 181453818 822574488 970634059 477470159 595991188 66611026 250911266 622103615 649621750 682099341 859904953 702357234 398247234 925595795 457126516 603297794 94515426 654824895 995796056 152395305 330352176 675703491 848942956 106041426 311284493 628982791 908384851 916833169 902799614 912873480 549390352 268590062 198682888 457248485 88848041 907808234 616342756 147009016 425733182 677246809 35386532 379226302 167359224 219865867 918392194 418441593 88…
Output: 7735445620

Example 3:

Input: 2236 626576586 435561219 766508041 632128696 388877360 682337249 144653211 669966346 890051286 46035757 489995103 941180546 462807910 590346838 845617375 842656255 688334529 214923395 540322961 993881292 934077186 790095973 700863858 421439122 372509974 387734360 812411804 42620922 427964849 481467578 780877263 224626543 334282019 914203223 959436028 940834698 589509612 789995307 202531089 573123371 876032579 817086183 426319966 311539246 336246853 803272800 155495279 577927932 499344268 628287859 654792111 825997137 581126864 738538513 359306512 755750071 549124690 473040433 655785097 966940986 896329878 272421327 113637293 212690957 37113558 33364780 825117607 29020225 711114225 80267224 573705107 295617523 934407578 222250034 571735750 707251653 179293021 607740913 26875527 642358334 35…
Output: 9933962568

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Grand Facade of the Peculiar marks - MEDIUM Coding Problem | CodeTikki