CT63149

Dora and the Sterling windows

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Before the gates of the ember mines of Cindercrag close for winter, Dora must finish the windows ledger - one figure at a time. 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 <= 2159; 0 <= a[i] <= 1000.

Example 1:

Input: 298 878 755 973 246 64 839 261 524 499 276 264 270 422 280 140 991 396 533 306 319 672 927 487 331 34 949 418 215 546 354 146 939 603 54 280 131 449 990 305 300 341 158 512 731 487 289 181 197 617 679 102 154 637 135 449 219 126 782 696 824 664 226 355 633 667 528 611 444 676 50 685 726 854 831 909 303 505 769 467 238 454 956 478 792 374 390 912 77 911 652 207 10 670 373 689 617 678 451 166 193 553 291 652 479 938 937 195 856 693 538 687 485 933 672 642 662 645 956 66 259 959 988 993 234 886 203 657 345 655 334 668 415 333 129 329 611 78 279 945 285 434 848 585 106 468 181 466 444 683 212 719 360 772 897 521 190 236 506 102 472 414 545 442 503 395 860 243 830 152 679 880 251 493 172 805 752 693 535 910 440 279 239 896 225 649 884 690 371 690 96 889 755 354 150 52 414 257 723 308 882 270 34…
Output: 145816

Example 2:

Input: 720 345 999 262 361 398 586 464 387 333 958 46 71 522 335 900 723 70 182 554 476 392 517 994 248 987 82 110 114 111 799 486 942 520 277 912 705 802 260 136 327 91 1 45 557 840 223 99 898 645 165 703 642 915 404 534 195 990 162 890 67 865 816 954 265 856 327 967 405 504 243 526 470 518 108 60 431 899 81 896 553 795 343 276 305 494 151 673 652 159 358 828 277 190 693 468 828 669 537 320 539 193 594 689 213 469 482 281 418 298 196 456 460 370 572 856 288 737 708 506 755 613 405 640 236 775 417 213 620 619 120 575 352 952 879 181 516 784 605 990 699 215 905 419 746 147 910 772 658 177 363 731 702 408 992 466 35 433 82 702 756 484 388 237 970 918 339 765 78 214 508 272 366 139 553 870 888 443 416 847 20 283 779 651 34 690 671 455 103 126 229 77 940 565 425 393 619 450 959 922 681 388 939 701 76…
Output: 354193

Example 3:

Input: 1925 864 471 571 840 253 176 603 288 77 671 445 846 7 484 346 382 221 507 748 574 805 110 65 334 651 252 136 54 962 883 767 953 630 911 869 235 299 28 756 884 96 934 835 383 96 177 336 453 192 477 437 919 310 250 51 333 210 129 995 504 418 175 31 283 668 327 473 966 135 749 759 86 648 890 827 703 314 735 190 608 71 147 765 639 466 602 550 126 522 945 722 34 657 430 502 647 894 919 396 984 396 432 569 350 272 772 886 773 557 637 346 676 977 70 840 807 663 237 982 728 180 385 104 361 641 344 581 812 171 600 927 543 517 355 98 425 820 177 776 296 569 231 324 179 440 820 968 690 531 387 842 269 319 445 632 500 587 854 619 764 593 818 579 929 501 311 332 166 268 954 727 240 45 210 323 918 711 877 819 152 479 775 232 787 841 961 571 201 590 690 438 760 503 803 667 998 978 653 702 16 356 409 362 …
Output: 937877

Constraints:

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

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