CT58014

Ashen ledgers Grand Facade

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Koda inherited the kiln at the valley of Misthollow along with its curious bookkeeping system for ledgers. 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: 2178 70242074 5558763 567678197 68612053 581109649 671068328 965496188 544916251 704703205 751377174 180014028 282422562 365860191 259923108 312458692 224321912 962226726 693858915 552745681 211344434 721044947 282990722 202357805 419210517 716414996 170954136 900649059 316309570 985832872 240305559 544356058 588940957 916030920 512815730 263070893 55479675 829557758 98418632 231339291 917441712 58403971 944663664 955046964 634592766 299592899 891484055 556676388 772340733 760666459 468570356 697283106 85638909 997284459 723931759 89496527 109499893 670557570 727489248 836306969 942793368 896308425 158482997 801793194 785150981 245984421 420736973 602029117 93773786 772219885 218920958 907141020 544902387 31786950 311061126 374422336 477146833 813491522 457864547 359273137 265307450 533576…
Output: 7964290990

Example 2:

Input: 1170 890071325 623758884 683724509 334919209 468282783 100348046 862084148 201633915 451198976 329410137 289542766 394863477 41548243 123051784 741538795 228672195 389536285 948268144 49354464 47661619 520196353 366805075 717638279 410313023 579423946 302037110 889069410 729389316 712432369 205841460 223167507 975629019 960856327 898676811 273034814 877845281 957394123 852939745 620015082 92475518 733199928 120196370 9866064 339424257 376499752 381887909 930967913 632701944 892995076 797804764 386330380 128093025 69917706 280808919 141665437 403021908 715247988 319689445 396079322 308913914 957757788 134538347 229453241 520220007 486417629 932561471 802555849 994769193 321971346 348783818 124158349 213535322 318394795 296971655 27370644 367198288 491298461 164012057 672905422 274274215 446…
Output: 10553667850

Example 3:

Input: 1765 228838072 649430065 773075222 164107595 635865271 405810810 17145161 283256179 672582255 573707330 401442854 215772520 343125295 828408330 647039734 553490943 269441044 39871125 527612748 857471349 427380936 124889057 527354041 465115212 251258654 736960713 639013349 651085251 683654123 546153026 269745615 466306034 157055327 627305415 30928004 465833506 464840933 220735863 601171594 807607150 913655883 974299548 46031373 654321059 310967370 44469227 405155855 749944507 269652650 733050371 694981938 972218260 325627988 421609366 927703926 938613670 838837074 247757943 365981884 102459943 262005418 166427225 2175584 479998141 593003834 116856576 22535033 705215027 768558198 640492814 9753474 475878953 67507252 298755941 888805462 638255852 947231508 274843724 690894781 304693449 413225…
Output: 7817046939

Constraints:

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

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