CT63086

The Rain Ledgers of the Silver windows

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The council of the galleon yard of Masthead pays by the answer, and Envoy intends to earn it. First: the full register of windows. Task: Heights a[i] form a skyline; after rain, water rests between higher bars. Print the total trapped water. Input format: First line: n. Second line: n nonnegative integers. Output format: Print the trapped water volume (fits 64-bit). Constraints: 1 <= n <= 1705; 0 <= a[i] <= 1000000000.

Example 1:

Input: 1177 374107223 186261640 372885575 446027964 381142805 749398637 121405013 974768271 452939567 847197000 775788495 684860065 786394267 414911155 852016719 615416615 624495486 171817677 25896431 844952738 622152774 359504409 78915676 787636044 526632262 429282455 979624062 182668107 585897920 565436890 544385079 169285643 455184515 608062492 535787678 605245658 475862165 582233921 967111960 245319197 542675302 314729434 455181986 58596960 482015851 848015940 574527253 357635852 236174185 488821469 294962434 929709672 573334775 545322416 902589872 757076649 562742884 826610681 69699552 607287882 625511217 658098752 471758826 292116488 734200413 755306667 778141508 840911739 780803023 299948398 988072228 836550389 664776888 784074836 785683857 29102705 711936025 86647807 455331183 468113396 1…
Output: 570053841962

Example 2:

Input: 1109 480153896 260967718 310469173 465390881 612956821 699381488 556658807 176623318 118407788 4741974 274755499 922377776 400788415 720845192 838006884 897231778 207004679 844891989 890546082 256744971 513316768 698615808 961507214 333364902 452787940 289996159 133491377 515227008 411645381 911036961 66527711 163927073 687008208 111241718 608754510 649530508 328259440 806772734 973587586 477137661 322690321 282460610 350054834 594220865 860658289 898813345 491387943 796678065 612616404 37409337 895661077 384212462 909532822 944570086 812530315 577059569 546283333 999083058 994437703 954511885 483424234 871482653 569297271 166366238 780795533 226330545 427596986 613597711 119786300 814210026 834305027 3850166 776868122 618135721 431344769 263810812 818959234 997682483 325141236 549553948 8…
Output: 535025822026

Example 3:

Input: 517 655083660 436767471 733023460 701567315 666035247 212255655 857895511 5925071 856507880 211820128 375745125 911508019 960449236 614053128 39968987 834643576 422944484 508915992 937823015 548915518 501416343 833004195 198895390 490660747 954449298 359452190 477053200 84860653 820466047 926791623 674956755 898980853 691941268 83551020 569561242 820958396 749137593 897639674 174713823 681208530 421767284 528395439 195819784 25682385 62195425 529543145 872505735 917333046 704854044 286812205 448499417 792590866 310894445 690579003 542061607 230346768 365804764 635631784 306216254 674195222 573544910 402907349 406191520 967195243 802230708 943003845 142078001 588379479 599959063 769718525 426377278 712802683 382496528 979996678 792480508 658437849 467460961 657067856 980500132 323559470 778…
Output: 233076027613

Constraints:

1 <= n <= 1705; 0 <= a[i] <= 1000000000.

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