CT62530

Sarla's Ledger of signals

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Morning light hits the coral atoll of Pearldeep as Sarla unrolls the day's manifest of signals. The tally will decide the next shipment. 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: 3822 528244132 713461724 835554271 769714316 310107189 258352705 777103785 43811131 194486084 561318427 405093464 522595916 460422840 241436656 735072341 63777921 491489937 860919089 988337112 459598758 497656992 421153581 995132530 845908423 609818029 658963820 618711658 353874262 749105894 901437945 398813882 333861479 557319269 708959726 117935277 101250634 520436280 358848631 501916227 90532788 368988040 727629852 304306358 674883439 549574161 713010443 435671489 254481481 829049616 202467023 607150488 150194215 286373133 970419902 770907682 393990574 717755856 389904340 603211325 723564937 24420855 911364172 460822120 329931266 831869351 280195985 507673122 745847459 247924018 50959065 903168977 603135271 347049451 679295629 119964118 386090266 318576866 732846603 183211171 270151206 …
Output: 8769062952

Example 2:

Input: 2902 269322246 329497838 42114571 896858317 31207931 68151015 713877442 774928270 373115992 816708996 312151697 886026959 746650281 897912252 858086738 224055876 555701203 627820062 243991099 852639403 586429098 934141534 511004238 110192887 740258265 990499678 228202376 84584300 548351217 519642832 75763003 473555753 38769973 757433151 765947404 720682366 179299871 706134465 830571311 558894022 869591630 35235338 405884243 380925052 198988661 291085027 122468410 208421516 201754564 427388194 806970501 120414967 474142084 813051153 684482498 767475371 569989767 18648089 927282840 36997257 701887226 178649838 336513992 694822451 50427054 925957489 958835215 771128928 68049516 808018433 217629271 624442268 558631997 288207015 509417256 340024682 401036854 666834908 516464037 459723233 657810…
Output: 6781074360

Example 3:

Input: 3489 844442517 824175323 258927747 349518506 884528128 77573990 865584464 65272318 863279742 931431306 813816036 934426643 328321336 569179955 463297707 334922497 148869763 967364758 544545586 885254062 846581897 697344064 880968650 110999688 795982903 807814508 957443875 144086997 492231679 375826610 65025458 804371586 295773306 334357819 751300767 926471091 238798455 187933124 125798951 780980273 586916713 211498681 414484455 203584257 116390635 85797463 716230870 827174981 59483160 595424028 918071149 181287157 825619484 966007451 991575009 713645988 333814617 441883143 427948504 662414369 424702019 815650544 973091239 283506717 579131231 127158380 454815442 277203882 761971375 777254703 353022036 995266585 50756244 475406848 466362853 192453977 68693157 430768229 658060549 633984274 43…
Output: 10576202077

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Sarla's Ledger of signals - MEDIUM Coding Problem | CodeTikki