CT60492

Pia's Silent Ledger

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

At the thorn maze of Bramblecourt, Pia records each signals in a worn leather ledger. The guild wants answers, not guesses. 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: 101 723125278 431992480 340664937 666309454 441814712 393729235 660965051 46601776 493306948 990095814 898793089 994826794 332961828 682456332 172603464 114696129 360549218 369122334 743606104 299297995 457350501 632415764 911843068 839810489 160746833 263418850 299372913 590126260 740333297 803679467 201682821 21558623 248364484 339907571 618542917 711409288 741396670 839268486 816103544 711776729 987516011 490780777 175952387 223500057 33045131 103291410 650801625 943250083 268921237 313594348 516823442 769032745 997738840 198337026 34325933 519726679 152361354 259134283 417921036 279814471 597348909 781729643 305038805 448037700 744834029 454376274 885591143 554801122 64385619 497513653 94126172 720207413 805087906 205259398 689032883 461631088 210216326 550126945 479693144 448852292 14…
Output: 4329800419

Example 2:

Input: 3081 230994841 114462388 422383794 782229092 620563356 420485112 565753949 936950074 317815793 143814017 703653749 207585764 805919010 816704833 749071413 893578129 706968924 399733277 97346790 39454839 315437030 559565410 205225820 817117526 49357391 809963928 528518733 628494244 997175218 678041830 811281285 28059916 894088050 180397370 235392110 93371989 35012688 563442693 660806728 587589307 364336758 183589742 133329788 398252778 35562638 166529119 382824396 895602563 957952334 817954762 919164300 302133522 747764260 791698567 262919668 890295684 262725091 623066156 701610701 854225095 46308145 110662995 548728049 146779252 126370775 241217971 219456220 623046228 573298407 187424418 315013416 776084547 929563573 465206982 368358117 382477250 306797603 688098685 338394400 386815695 406…
Output: 7022001300

Example 3:

Input: 3318 85626760 228164167 394561265 872707784 941279021 553455793 431897191 66235333 475286298 185935983 609569860 797682725 902856715 231848899 356594783 519134108 970758575 621904252 374957210 74733464 383401185 116949153 277542760 86129882 583253462 931873709 471830226 370808815 437363378 133701159 441029045 878168253 266486443 55360171 739478422 544373295 452263926 942785194 887741995 971760953 626614866 496794005 707301703 820645421 901228474 459493408 98672087 542988727 907907327 802464979 747339464 718468660 420225639 330781679 278880474 83019543 761022455 851225867 256809036 688835862 380328734 813575297 216558579 957195742 227239752 16132872 733957525 829289078 768836914 494433378 281252378 129725584 973991663 939584325 337673591 676727936 28924082 179853737 299928343 380688060 9670…
Output: 7707636273

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Pia's Silent Ledger - MEDIUM Coding Problem | CodeTikki