CT61465

Hans's Rain Ledgers Ledger

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The council of the cotton rows of Whitewick pays by the answer, and Hans intends to earn it. First: the full register of stretches. 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 <= 2608; 0 <= a[i] <= 1000000.

Example 1:

Input: 2119 376588 731251 98493 178583 416896 612110 837119 461536 499117 256326 794253 641128 860268 830862 928038 165971 97629 649512 206972 80958 272446 652560 64241 432333 979620 167480 943018 180934 34973 307027 825448 889170 896091 353979 699853 630884 413441 54878 81566 650150 138413 964061 771721 741679 488750 908296 89900 195367 515698 543231 895239 154597 976661 294674 871327 519844 784197 328918 531362 39555 116821 145503 131167 103732 179999 293062 890444 624377 650529 30116 146906 313772 170118 831953 645913 452783 907793 207783 133726 562281 36837 123759 782268 972236 89329 855577 366632 185455 339020 750908 143874 943427 74574 977832 374929 145195 706965 333071 371799 178616 516214 138390 708117 912481 295084 716284 343549 454693 511713 283600 874196 513251 923143 95902 515355 3477…
Output: 1063832635

Example 2:

Input: 772 16290 719921 647392 507345 214918 683620 260490 744352 536285 862655 34018 735379 260516 677097 265873 747762 367266 818509 341942 616373 404757 583631 762524 833291 304653 281349 514540 722513 904245 228488 248778 290686 492313 97811 666256 493362 287962 749146 269725 607394 97067 627160 94327 451115 572304 768123 608617 777265 45413 923695 910252 611552 484575 845200 952687 990157 185982 192526 228269 738014 182407 496624 672608 257238 97306 269966 37466 810887 276995 635511 410850 400691 286133 308051 381450 114609 909056 650039 504717 10394 757675 844089 441971 66746 578676 20266 130701 902349 364673 589172 590578 299661 981901 653622 45321 916623 562543 155021 745508 90656 331614 325978 35349 189711 287968 42722 329816 225450 716503 899202 352345 684106 559861 765933 190850 591003…
Output: 359586392

Example 3:

Input: 972 391738 919622 255358 150922 179825 53142 631810 223493 431951 498499 189505 210809 952978 405099 189349 344716 634872 958985 978303 483974 607669 917845 137278 835971 402813 182349 557665 140412 294163 706969 108347 327124 820748 899779 688162 425389 469052 206411 479224 244244 710057 122930 410237 546424 551320 758177 241873 523188 191133 890763 582377 120028 443695 542436 781567 679775 513912 675732 866730 487022 853116 266580 519786 319002 482224 630490 852526 566917 678552 829463 625734 265932 113030 519120 532962 111030 333372 311796 922572 550249 379482 307242 206825 923052 461058 917295 985099 843817 236142 849563 698598 344107 505101 688708 727026 931406 20129 350566 690686 538815 128401 522410 328267 952312 578122 806399 640719 375059 382286 700587 327864 107928 643985 128215 …
Output: 480534293

Constraints:

1 <= n <= 2608; 0 <= a[i] <= 1000000.

Loading...
Test Cases:No test cases
No test cases available.
Hans's Rain Ledgers Ledger - MEDIUM Coding Problem | CodeTikki