CT46567

Tailor Counts the stretches

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The harbor bell rings at the obsidian flows of Blackglass; Tailor weighs the day's stretches 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 <= 2353; 0 <= a[i] <= 1000.

Example 1:

Input: 1455 886 498 804 86 707 903 359 810 109 353 335 999 967 37 712 620 472 25 49 758 329 262 300 803 228 228 660 798 623 477 488 842 988 300 246 267 17 881 654 605 498 352 275 859 67 917 649 479 69 804 327 827 947 73 600 47 985 34 604 995 864 284 779 79 884 580 647 77 602 727 8 576 42 318 934 44 657 159 7 50 661 803 509 510 728 373 177 376 109 249 350 387 516 370 508 369 108 629 933 903 140 887 618 141 69 432 976 384 205 99 19 37 868 641 945 532 659 97 206 466 208 206 211 7 107 496 510 91 784 503 874 609 117 261 203 783 702 541 932 714 317 278 574 538 627 950 126 295 276 26 775 745 314 670 303 903 964 922 340 249 467 276 854 10 902 195 629 860 98 372 759 32 20 651 539 890 914 471 710 779 422 891 641 998 1000 478 30 91 850 128 757 145 264 564 642 301 644 636 142 889 387 969 353 125 119 743 211 …
Output: 730078

Example 2:

Input: 2012 400 148 405 102 169 734 307 923 277 56 444 930 830 884 540 232 744 490 887 60 422 704 626 440 204 458 126 140 293 568 193 892 217 692 841 855 583 228 597 534 753 402 90 719 188 999 371 71 108 769 89 139 288 902 864 488 420 759 178 491 993 585 695 739 851 424 169 284 833 609 432 846 964 386 675 310 133 331 638 620 56 904 42 414 749 723 233 683 94 975 203 318 109 893 181 485 620 295 645 693 402 214 183 869 913 694 664 235 947 840 118 849 372 561 975 691 758 706 243 845 26 891 621 130 268 236 35 48 384 963 962 34 602 704 921 565 65 277 162 535 814 986 629 554 800 502 70 684 710 492 853 312 414 679 210 629 20 800 374 12 782 809 396 285 461 551 412 209 342 96 272 399 216 416 301 899 357 103 956 532 709 834 990 475 307 811 231 470 73 503 239 265 120 968 874 228 690 210 769 20 396 839 126 25…
Output: 1011395

Example 3:

Input: 1698 903 436 861 456 454 110 777 925 183 173 745 106 407 203 541 710 989 210 488 725 810 298 979 14 893 320 850 885 685 651 698 978 316 940 317 155 410 143 43 834 464 369 871 902 810 806 572 972 274 827 49 686 303 403 804 245 484 475 613 997 623 472 491 971 743 433 130 416 559 640 152 642 623 217 315 184 270 584 328 956 646 421 709 63 506 169 260 707 672 719 99 469 442 613 731 810 3 817 259 696 461 526 27 479 870 309 181 332 742 213 639 649 194 629 803 823 914 795 537 940 631 797 62 97 410 795 255 643 8 590 743 342 688 669 66 878 302 845 646 80 717 60 52 607 344 551 817 623 281 236 880 687 566 480 584 152 197 601 10 483 453 162 939 181 490 632 639 913 279 868 665 198 252 714 578 402 195 791 445 421 47 653 457 987 537 197 552 883 10 180 744 517 446 181 264 46 14 14 900 766 823 540 924 416 4…
Output: 826408

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Tailor Counts the stretches - MEDIUM Coding Problem | CodeTikki