CT58341

The signals at Greystone

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The harbor bell rings at the shale slopes of Greystone; Surveyor weighs the day's signals manifests and starts the calculations. 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: 493 112547529 445062671 188891553 637561828 893573967 207035633 997879419 235054393 928001938 925835142 715142999 301050962 414280064 570080853 210122292 216833238 615611107 875482845 325999058 140543703 876857489 521423332 215272016 934743815 400707904 482194852 588350333 114823374 597774735 49455078 608278685 190312967 561250546 190978051 656017450 270735676 816462847 935599229 542390857 74196606 3730828 338030755 155305983 507215574 93687019 251655926 623211562 89425884 667898963 379400616 276550942 201307737 106595598 803920836 813500449 156356128 98376596 975638833 186494354 897205249 990790995 250532381 763955809 817233307 365958056 745147401 826294147 956791100 122216223 728794576 267045764 311387070 105055996 442023563 738049363 340859684 961207727 367147655 970083084 316589487 602…
Output: 6365605764

Example 2:

Input: 103 654042040 826059706 941806791 792036550 476611273 730233592 608660815 877283418 624237115 252083374 850031367 474425443 577598705 269198838 745845488 15637924 734509897 274501657 311547059 295749942 795979675 60786337 966656551 680059912 540654718 27313577 728061395 89845450 230092551 425852432 902005632 267005293 994228044 26867586 351039050 806400933 89495678 8371516 90244293 122004696 663442725 557104579 333478826 959593142 722374785 779973127 405471633 234607209 166989355 449548495 321480684 727731817 251741627 370496522 251615409 126110791 315920270 635199158 144304855 80485934 696467263 852307937 746935413 835412715 435652249 964431561 669568243 691209023 390772911 366610428 720324828 183295227 517200910 466808038 291941735 33729569 572890913 966204645 437921397 360677457 3185193…
Output: 4289501457

Example 3:

Input: 853 585141181 834760702 927485582 466523162 951897444 930577719 377173130 398343568 207783236 101174520 788200158 157802226 769101403 602873640 376561441 54437819 381071638 278784360 735403611 606876048 616167459 784564358 754857220 864943016 259446125 31101376 981479599 562401868 115426835 462777148 188422271 659286825 565356452 340889293 248785366 699926206 400110275 662435877 14374344 707648620 915422263 162249435 858226412 266991500 186269988 138302686 152112729 495171035 149202674 285437986 789050913 824724663 147041849 736078974 646993418 518917051 446454998 548116201 399103769 135815842 417539675 908573221 161884473 880201482 346126789 766562666 462045196 901289776 711656845 494323665 391353536 529079681 439945225 16261388 184595070 783675978 658276841 420780261 602231587 92466476 8…
Output: 7175495355

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.