CT63188

Diya's Indigo Ledger

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The store warden Diya has been asked to rank apprentices for the new term. 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: 268 754673361 963473794 498012693 429193174 475864132 879772640 140464387 344641240 245759495 205379347 305769941 485921547 956997522 195971784 442122261 236898098 886936265 567761735 253859044 727100553 473232955 845257458 746915746 686132081 63416625 475425165 88292451 768838847 502851291 453375467 986636585 68926660 920946353 877242757 573912032 410070467 368038668 693760616 763576178 543565379 368493487 394327408 368447988 115362815 409106403 693816417 86444140 492009353 342768838 221339730 115417555 374815360 764456828 745947885 428189044 35492633 151978995 772303578 88272120 298800389 685749680 399553100 332813605 383518912 927726582 6661621 806508516 967714189 692707095 272854924 770622501 943947751 749184004 423059119 537246877 33927432 341404083 768455944 19924932 450542566 826670…
Output: 4932965933

Example 2:

Input: 3786 916404086 431944782 265514362 856678232 986045927 55043267 654745738 493172197 306828850 592921694 957980808 749997300 529132592 163320527 974604572 383078173 169757419 356260320 793374062 704425911 453010124 815478081 787552757 194955869 433215128 86324717 172926821 307499877 93252411 190216279 45125991 871849244 787673148 321970622 121112568 991007181 621045854 302182535 436212510 689233473 7263666 797771090 548353675 408654544 7580779 20996073 429803472 369155233 273732292 811517144 803523505 839244331 833242928 985707625 375122967 820653963 999827946 143056869 818150869 12341987 541022300 355283657 568396556 503497561 209659873 1543786 318363651 270814945 504895877 866800807 90577178 968983452 52932385 708734954 380592613 653806227 410287155 386655264 923476909 938160040 581739358…
Output: 8100973216

Example 3:

Input: 3832 103354314 650118856 395914935 346059141 13477922 985481652 340904689 837064555 984633406 194462262 740523302 14938877 676390079 435449957 439701021 322147899 903630186 894761294 301585663 575134721 926773368 41849543 8380768 414527248 383676829 476284812 42565170 89285858 869764289 155790055 731261212 785743813 829002015 716550644 445683343 496685211 636094365 687108196 437351316 919102938 421703870 922878134 644147245 479789435 536763727 781240573 84745635 592156538 960154374 220757533 24376230 320717410 617220062 934875685 776700534 462989028 843581685 784109460 463197116 311125185 860325496 525658122 318987986 974967751 214269633 779186501 95115890 131814141 78190654 338926745 920144447 169591880 896080249 583590307 853949093 321337487 30819490 780680598 440872019 496894830 5680492…
Output: 9435843209

Constraints:

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

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