CT61793

Emeric's Ledger of scrolls

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The harbor bell rings at the observatory of Starfall; Emeric weighs the day's scrolls manifests and starts the calculations. 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 <= 1923; 0 <= a[i] <= 1000000000.

Example 1:

Input: 550 620280527 633860649 352494478 201305733 585618284 966526956 331135740 220992860 960243299 260647121 285128780 216010596 73339817 715981799 663984381 447042065 624386162 315014905 748550501 546912900 574318489 771538431 883973296 560460875 178971185 525569523 112525289 677136111 368972717 255484239 821537860 821310761 102596781 981864602 670861293 824327404 476666831 289529350 48242014 296783320 717548538 700966569 402955840 15147322 144774372 421521965 663453780 822374596 141588182 738403719 646471755 100207538 459560758 922528503 884430652 508275961 905787131 319711985 50185246 39988378 605975776 475106507 567846276 608930285 861473295 293596593 486704261 615404350 487156280 545472135 826466306 10765239 852337779 551758014 959905233 351862271 529174090 743001974 528219809 172742744 44…
Output: 255969728578

Example 2:

Input: 624 149886080 334957750 485767491 406694043 689682882 311660341 22652973 592189182 182752730 369325874 105133892 42920703 532269289 146850045 695044314 855150186 374543321 284696192 573292472 16432832 643635473 424916080 326683218 481937662 514901674 441280171 838417230 621077787 202062302 421879131 846337070 849930418 825891731 526566649 867354461 810858991 940196367 467450359 669131121 820074331 148619220 237523519 178586583 628023063 328128132 304606722 351982927 279602004 447589918 380105524 769731962 393589135 341717442 329964781 6405865 49968153 849097073 53216357 444311557 1508529 258191533 288061786 795644203 851512109 815157089 984654089 698297609 716758489 212552573 405177149 424304070 271991015 135887957 763611220 976710771 145839584 54116315 712112890 578821203 482611429 516392…
Output: 295937467937

Example 3:

Input: 1694 504822431 793465358 691670961 429653889 239486782 438259881 227893732 225284281 158769995 984009608 271358081 967410949 293272889 795922363 285547421 936466090 583686855 723779722 504961857 332981382 516779239 290862952 570327756 512913972 176081450 763109087 451381374 980063962 304276246 209372923 95327344 789808304 470040052 504617983 399189420 807767179 157645962 636255860 672559879 478606632 184280428 5370133 65741041 943630376 955343747 800507123 846175839 990467507 891336625 65825604 891293931 278247196 453055893 628098318 533063221 48509126 954905643 168980724 769351543 864668709 436696713 605142832 408608074 625350427 957117553 829636031 822185603 258700715 553428474 559127721 239969906 561487914 679996476 332479257 640972766 785927583 297190195 799653411 602890018 805798115 4…
Output: 821193373544

Constraints:

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

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