CT60642

Faye's Shimmering ledgers

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Before the gates of the valley of Misthollow close for winter, Faye must finish the ledgers ledger - one figure at a time. 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: 1056 218253224 568731645 858991267 208713827 207252996 3271810 945770907 150209068 273717528 678946209 126534664 669043764 901609765 379948500 350957097 570540735 887976701 922875618 944492394 922193862 592164401 860651840 973065354 59737877 111341588 868460906 217993931 759634165 389867774 494018687 345365682 787482013 136568967 427127023 779778232 939204901 922737793 451392721 939825643 932707472 826360545 323559150 232925527 87981321 722472281 112175295 402358965 572048981 925294860 112930340 36032506 968082177 801435729 912307223 109745791 912801130 713235492 274588494 662082537 833356902 113387592 882982758 560488275 2978153 174646873 964185471 224275816 442110471 909450989 895067886 417592164 515531056 735188266 518759898 154005820 904672293 135377542 993105078 479824109 671425281 81…
Output: 7219024968

Example 2:

Input: 564 576434694 924508221 246617268 798401413 313921696 346690023 674987610 279297614 476048830 173979859 879896158 694086680 586981300 147751754 833378369 409667233 922596779 381161815 559045182 112034472 696634636 137426959 175862525 251362621 770958970 88460375 579659313 661779994 417828054 983501111 784270505 136706697 147501391 603710496 329633415 757384956 396435522 774889632 648665119 714581358 33373629 246485775 394219015 336912285 523224404 979621115 91410915 538938459 209837336 474282655 465210179 353799586 934733566 535304746 35182752 136903191 323334761 604961799 816011912 864049995 159121271 478528932 496062830 352118359 36727327 738618266 181558512 744342957 986123318 791868008 221728183 668836411 921840499 91064823 20172594 891654027 195651122 177988665 185377978 995573529 406…
Output: 7165600932

Example 3:

Input: 2445 354704273 514437180 520701352 53420933 501312479 277545338 877271745 395730126 807493770 624554903 564303089 869154711 838859630 23745600 244746172 914510280 473654630 177726219 754080133 964615558 937633313 172541613 31530205 898761674 506348267 123745338 277447892 542815518 468280401 80668899 498609192 862670495 610129287 724966712 418116611 673572511 872847519 350177959 754539915 91177976 398824817 326168309 276179565 256265711 130309829 650447037 981355301 223263412 724169023 542611982 222144038 310979286 382183380 148121576 717863881 483249213 339332770 965463915 910188420 474790425 276417910 365345560 113361321 775394789 855728204 627702520 695444713 56852404 419741106 901408507 737049798 223649769 168411263 956915541 869444345 397799697 896087939 901287008 643526032 101613218 5…
Output: 7928581464

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Faye's Shimmering ledgers - MEDIUM Coding Problem | CodeTikki