CT38008

Bishop and the Rain Ledgers

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the ferry landing of Crosswater pays by the answer, and Bishop 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 <= 1721; 0 <= a[i] <= 1000.

Example 1:

Input: 403 312 439 524 469 129 588 719 702 749 370 942 135 713 449 510 593 696 152 385 816 984 715 945 612 969 499 108 816 438 316 417 990 150 671 439 471 625 889 891 364 532 381 135 758 296 154 306 772 182 505 256 944 499 72 61 88 677 740 282 788 688 592 702 940 36 786 942 192 908 842 990 738 467 749 128 637 322 159 665 416 227 137 534 282 999 329 642 833 517 639 12 67 566 52 516 346 611 713 727 375 944 519 797 8 880 414 933 910 71 134 147 942 498 901 283 616 767 658 227 610 908 842 2 297 761 41 94 678 826 660 342 248 604 754 255 135 37 613 851 755 958 279 919 585 798 990 255 745 453 363 436 468 261 607 513 28 76 295 79 777 712 499 697 994 107 954 223 634 957 464 965 712 339 698 419 911 67 623 491 235 532 789 625 626 279 245 441 710 168 443 879 852 287 407 877 434 385 710 256 943 971 102 327 222…
Output: 181464

Example 2:

Input: 1551 798 187 645 884 379 958 715 930 327 416 336 233 29 524 339 872 345 336 692 165 370 863 580 734 317 218 597 58 213 156 358 42 663 658 677 93 951 203 625 108 790 907 200 135 347 696 891 974 118 615 748 315 460 523 63 491 978 986 693 353 868 464 179 673 133 883 182 492 623 103 905 220 415 352 322 769 168 216 502 318 866 892 753 766 995 727 145 302 565 801 100 163 725 805 665 631 117 915 962 767 247 324 551 676 536 484 505 859 98 570 644 653 523 668 532 832 821 625 185 191 838 75 613 555 31 752 311 918 427 80 301 169 497 78 993 18 261 208 572 303 652 997 985 91 531 643 431 145 407 847 764 731 214 520 545 248 259 560 329 291 475 277 880 342 361 973 730 199 889 772 134 376 92 647 205 109 95 523 561 435 273 665 176 834 721 205 285 63 58 946 412 443 788 913 357 805 251 485 954 143 92 836 12 1…
Output: 766434

Example 3:

Input: 1292 339 1 348 843 396 317 966 499 543 160 204 609 98 276 654 533 981 380 681 471 12 654 644 823 119 164 708 84 345 770 372 726 254 322 125 715 547 263 662 665 81 604 105 914 639 388 939 740 19 748 56 201 731 269 699 87 932 39 837 685 313 186 484 872 981 27 167 232 716 989 586 986 583 928 221 557 703 318 667 516 833 744 369 345 711 470 230 312 798 631 388 200 748 543 680 364 526 925 242 147 787 877 825 828 203 553 702 181 168 986 196 485 57 664 90 90 411 62 997 502 210 410 81 263 99 650 823 901 92 60 365 226 99 801 23 67 428 818 648 960 260 16 654 104 549 495 404 822 382 382 276 855 691 363 404 965 25 621 905 715 80 393 714 235 182 9 186 939 511 773 908 620 3 553 567 678 282 574 107 901 834 849 253 459 796 68 201 839 14 686 927 296 930 171 852 710 786 944 510 384 453 928 299 693 570 98 885…
Output: 635474

Constraints:

1 <= n <= 1721; 0 <= a[i] <= 1000.

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