CT62689

Neel's signals Grand Facade

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The accountant Neel has been asked to settle a dispute between crews. On the desk lies a long table of signals 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: 434 741369635 209172737 787317723 680406438 23983845 389791948 932742033 432057953 10132863 128717622 238495832 943457690 645945090 785805993 233211437 422095504 182416231 570829758 371263989 943682667 658480491 961139444 675556879 885198354 394899009 64867352 291590000 909113855 994436800 620866148 398419200 961292255 449554424 549668918 746789042 588080414 717493271 635303454 433517444 460132845 280546501 351203722 989564253 450807377 562973526 790159453 754266467 503649691 237636851 890378400 233818225 942431771 503766360 609100233 932586063 137429113 51769209 266965337 543954702 358627706 523968558 392361713 838764039 47962132 260117308 225176383 386563974 740874288 981141139 269626360 396421168 303202060 523535436 732116483 703207068 244838636 287663269 541238080 201283092 630893363 3…
Output: 9816846180

Example 2:

Input: 2348 111394968 139011974 877741676 594980631 5124200 791489524 959927364 255535712 129071897 889943848 513139056 162489770 590081574 857016532 12904145 348157613 793943287 63772750 878236364 562693219 398897982 417586857 61069201 246375204 805001721 655013083 831752243 277013905 687623576 396733149 223203226 148345867 357154172 384553030 16905729 995629605 272365310 900037088 490283760 645182776 645477838 274905661 435060771 91799422 5307149 372161704 308413845 868694835 76552712 85077427 139835920 301154370 32292517 735240811 465020397 161748490 155862529 405943582 423068012 590553984 18828657 464870856 978244548 749357059 189457491 906729611 12068019 470713959 493155503 607218406 479656161 531331437 42643870 628498462 157251971 757318142 144183125 290632655 118445026 822368182 558235713 …
Output: 7527119523

Example 3:

Input: 2860 623188462 701934462 68785561 16932497 88906492 369890232 876896097 781078501 695384480 809904775 32525389 138683139 280827970 475917096 185883584 980538033 302037829 749789891 730891911 130984639 217022529 232571511 308472931 421844576 745704605 993667323 942523475 286028386 497887871 301857 59075940 400079861 493966777 687872773 998630491 107329626 339280676 215749276 311912673 820911936 143260641 719505897 404356219 527674994 593245172 261670328 459401400 9740630 394351115 497817563 282018243 206313805 953136796 581920740 80865888 437025205 940646575 348426383 121543033 396347604 609988939 117516994 480020884 946652145 528239440 630770367 820670482 366617381 432356485 778546101 933542392 541281961 551360417 140811730 263952065 181104803 492548410 956169615 786771555 741639172 428197…
Output: 8449332672

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Neel's signals Grand Facade - MEDIUM Coding Problem | CodeTikki