CT64830

The Sable panels of Faye

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The harbor bell rings at the saffron fields of Marigold Row; Faye weighs the day's panels 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 <= 2546; 0 <= a[i] <= 1000.

Example 1:

Input: 122 700 558 983 107 71 998 444 786 932 568 585 360 881 613 406 496 21 168 694 814 615 988 657 980 431 881 587 393 286 884 889 820 4 413 585 641 89 714 665 780 531 101 125 126 448 469 628 417 732 680 893 669 265 283 956 776 57 625 324 452 799 412 48 377 296 291 201 453 721 661 778 81 714 991 540 759 857 196 887 300 50 773 961 153 910 934 868 134 504 857 943 430 440 350 894 915 55 810 432 946 638 74 41 699 410 585 769 221 813 602 373 204 856 751 412 453 662 289 997 369 805 163
Output: 52830

Example 2:

Input: 1844 24 649 328 440 824 300 823 433 800 753 42 552 285 466 221 85 448 453 976 850 326 470 653 297 817 80 388 607 846 167 76 669 43 266 1 887 143 456 64 257 863 383 716 846 354 301 822 676 281 8 416 869 546 1 691 624 969 630 243 246 942 105 25 382 696 1000 503 713 307 563 307 945 122 263 297 572 511 104 990 247 654 580 922 726 998 164 248 376 30 125 28 496 843 130 858 347 155 970 348 730 215 24 805 731 925 338 476 437 44 837 961 476 58 133 989 610 69 647 712 378 857 257 595 120 369 603 199 972 189 231 553 241 699 581 829 758 737 784 553 27 811 697 648 380 964 401 558 210 182 861 267 953 77 693 445 574 676 915 705 331 428 69 677 374 303 225 893 13 122 483 430 772 136 150 761 779 346 585 29 280 638 693 731 905 495 51 148 295 420 364 925 379 80 940 565 620 264 144 60 815 552 649 786 60 412 887…
Output: 903494

Example 3:

Input: 1527 758 211 15 6 844 873 333 940 245 275 620 942 260 678 267 917 824 206 934 917 815 120 714 321 433 622 200 890 32 295 663 232 63 456 199 929 321 718 71 905 237 535 843 479 59 570 148 98 66 952 678 413 578 299 324 21 591 918 650 659 974 816 408 867 127 618 265 27 522 51 189 100 65 734 53 945 878 878 310 752 21 464 724 731 734 693 987 289 20 91 697 894 700 999 13 551 692 10 769 142 886 464 509 193 767 414 199 334 279 70 627 457 373 674 643 212 380 514 458 803 245 607 403 574 162 574 543 422 805 709 88 740 299 962 328 357 445 741 598 930 670 491 211 521 950 643 704 639 818 440 317 439 805 658 683 84 116 162 917 330 668 945 521 609 509 295 716 985 281 201 958 329 327 584 332 131 41 517 169 220 311 720 332 69 210 903 916 162 889 996 190 789 817 923 928 814 395 334 865 84 251 198 506 56 78 66…
Output: 752364

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Sable panels of Faye - MEDIUM Coding Problem | CodeTikki