CT46569

The Rain Ledgers at Will-o-Wisp

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the fen lights of Will-o-Wisp pays by the answer, and Yusuf intends to earn it. First: the full register of windows. 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 <= 2806; 0 <= a[i] <= 1000.

Example 1:

Input: 1154 185 329 391 522 617 880 283 829 961 63 579 473 182 710 824 457 250 368 951 729 869 888 399 510 20 312 60 548 566 402 17 341 965 751 62 573 832 168 42 362 738 190 832 938 12 51 595 333 628 468 426 360 746 674 77 428 890 905 246 749 767 549 776 831 731 26 78 114 535 444 987 17 958 341 601 136 368 212 284 969 328 876 67 103 122 218 184 187 769 172 505 404 980 71 196 786 114 638 854 641 121 450 256 510 723 999 921 219 297 723 279 438 655 109 790 619 935 894 923 79 932 156 85 795 700 68 579 304 264 338 367 607 75 920 781 250 494 670 439 52 764 937 587 277 849 459 488 711 25 832 928 197 684 722 504 577 656 398 457 45 16 473 359 281 759 220 625 437 955 767 255 718 138 358 614 841 77 195 338 358 338 945 763 273 598 645 835 310 541 930 828 24 499 156 295 886 648 745 93 339 478 359 974 383 847 …
Output: 561433

Example 2:

Input: 270 793 109 998 658 407 867 561 734 717 513 719 486 457 958 54 109 496 113 578 183 501 819 993 993 530 825 404 890 447 622 872 153 810 798 196 960 485 15 435 400 347 894 296 10 999 833 366 767 820 414 665 776 586 520 279 419 785 447 342 806 667 155 915 90 268 433 401 237 233 657 14 91 991 67 309 862 850 635 157 639 475 332 92 507 136 453 483 252 740 779 174 255 675 64 258 183 977 44 107 211 675 266 279 756 569 277 276 133 965 235 966 549 684 809 533 319 801 151 432 872 476 123 40 657 195 803 49 906 787 144 176 367 988 827 779 405 745 189 256 963 782 113 209 855 251 149 569 152 20 629 131 811 216 208 743 251 70 330 735 848 300 759 264 61 346 122 788 688 883 448 477 700 872 281 58 373 842 941 62 609 870 17 762 835 856 225 840 401 987 623 375 136 855 752 505 893 369 288 240 690 358 348 780 79…
Output: 138151

Example 3:

Input: 1578 478 663 425 955 46 214 62 196 308 744 550 473 195 753 319 696 193 189 395 884 457 903 123 270 826 908 17 596 240 179 98 571 728 730 818 617 184 786 86 434 135 737 388 522 491 162 521 729 833 163 678 175 583 664 387 146 149 590 685 409 345 970 996 65 860 710 644 819 957 672 636 937 66 573 103 59 531 869 116 334 130 506 539 645 274 908 593 614 283 670 781 659 591 515 513 522 985 241 245 507 70 725 615 50 994 114 159 632 455 591 103 467 663 593 658 234 657 497 698 667 824 390 68 476 463 990 158 665 487 747 364 711 950 648 128 523 147 94 29 86 853 469 944 744 985 529 244 77 683 938 163 674 72 791 135 369 331 366 135 217 70 720 962 218 225 61 953 173 39 663 171 912 959 618 407 157 690 116 232 861 397 517 930 630 575 357 43 605 215 123 794 35 24 45 801 19 621 428 723 991 607 653 664 882 816…
Output: 790069

Constraints:

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

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