CT57588

Bronze windows Rain Ledgers

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Morning light hits the railway depot of Cinderline as Yara unrolls the day's manifest of windows. The tally will decide the next shipment. 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 <= 2653; 0 <= a[i] <= 1000.

Example 1:

Input: 654 781 79 565 837 247 505 915 157 504 102 838 907 218 667 420 674 231 447 397 875 953 485 907 583 496 271 126 442 877 636 610 500 704 520 697 408 369 662 3 769 934 11 274 110 431 707 173 867 856 637 712 809 913 32 839 128 629 637 906 647 759 550 161 275 989 623 261 787 424 79 776 129 524 106 820 192 576 877 19 314 310 140 994 754 797 206 600 332 570 642 999 393 207 462 287 531 845 418 129 236 414 211 274 115 620 576 46 252 559 650 886 424 790 852 996 48 532 13 539 812 676 85 7 444 554 980 128 469 783 848 257 643 163 979 850 356 685 771 109 987 456 94 545 564 274 41 360 325 935 267 368 256 392 622 736 445 425 780 697 98 89 841 150 846 578 841 631 221 967 756 384 380 365 459 838 264 941 177 934 280 292 314 260 24 598 479 635 41 335 638 37 68 361 741 788 880 177 864 334 526 479 399 827 678 1…
Output: 316649

Example 2:

Input: 1854 978 998 563 87 264 104 211 723 388 435 321 925 590 565 688 184 791 339 856 245 38 929 938 431 862 415 828 708 198 493 647 573 709 732 898 332 769 295 499 531 78 600 164 886 352 965 341 312 444 662 579 722 64 510 176 102 780 858 728 823 196 207 859 863 431 21 708 951 315 853 845 146 747 310 394 72 924 833 45 969 245 949 915 955 408 358 346 152 964 299 95 404 134 851 619 792 830 897 374 477 397 935 390 424 792 803 365 3 873 423 266 762 615 232 85 363 891 243 628 420 708 610 188 700 291 709 418 43 434 778 70 657 877 523 723 980 119 901 204 766 693 579 34 408 512 916 232 109 793 518 955 433 114 3 589 220 506 408 241 263 963 777 316 334 939 134 132 939 712 265 805 233 550 938 967 993 800 588 27 931 533 629 543 149 746 720 935 426 39 363 166 321 207 831 984 593 525 259 176 812 282 685 757 4…
Output: 916080

Example 3:

Input: 914 885 182 450 275 573 571 145 423 875 307 508 257 684 375 534 642 52 707 296 723 895 625 586 353 408 172 417 64 255 114 359 162 513 685 438 360 117 564 483 574 323 494 293 914 901 264 42 316 884 134 799 200 189 974 828 881 881 532 516 943 145 292 36 583 136 405 378 76 27 520 14 200 761 94 619 13 215 710 926 573 559 558 543 492 324 713 369 591 882 690 923 218 758 421 468 408 84 464 913 208 901 680 565 359 564 54 967 440 389 297 367 898 505 21 627 242 32 923 274 222 246 175 222 806 580 674 897 75 416 260 631 263 152 196 718 181 73 45 872 441 425 34 513 304 203 202 410 630 289 498 829 19 349 625 976 721 217 765 318 239 959 111 638 759 127 99 502 834 278 877 301 667 931 340 330 119 991 944 951 576 997 216 66 908 361 860 906 633 317 867 233 568 992 841 899 158 121 607 368 456 53 852 712 183 3…
Output: 437663

Constraints:

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

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