CT54092

Coral stretches Rain Ledgers

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Deep in the lantern lake of Firefly Mere, Faye studies rows of stretches entries. One clean number will settle the guild's oldest argument. 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 <= 3742; 0 <= a[i] <= 1000.

Example 1:

Input: 1755 675 477 270 461 496 572 277 542 527 599 888 447 547 446 458 330 311 516 268 963 522 465 389 405 316 806 892 77 712 564 40 591 536 387 496 530 31 509 862 247 850 18 54 400 172 45 601 744 522 853 68 259 698 662 884 782 550 956 877 897 455 740 419 970 82 485 408 743 437 727 234 764 440 459 531 566 692 799 973 539 416 337 742 865 516 912 676 977 460 3 729 550 555 336 927 117 818 575 174 597 390 797 162 120 766 837 149 485 504 598 903 387 127 519 567 117 836 896 746 845 735 715 404 869 97 894 631 122 327 609 894 168 143 946 431 697 408 161 322 820 954 238 545 164 851 266 728 987 808 487 946 943 126 823 171 319 297 560 89 540 928 758 940 127 588 127 122 422 48 57 432 308 870 9 892 10 530 261 867 365 662 529 124 597 964 843 973 487 31 118 567 433 963 166 226 210 450 318 405 392 381 80 957 43…
Output: 862370

Example 2:

Input: 1305 143 295 380 689 344 43 540 756 895 719 981 590 109 294 180 637 44 400 971 842 435 592 164 600 602 958 962 547 497 686 351 674 218 381 651 181 570 653 292 667 446 368 36 601 10 956 316 266 131 104 117 433 148 661 385 285 442 916 875 702 307 660 882 674 901 802 938 151 713 348 860 479 90 40 964 738 475 430 302 854 442 849 169 944 328 380 417 635 495 217 731 47 426 977 107 204 153 754 724 983 610 540 828 632 101 269 397 919 454 351 69 554 900 148 235 77 940 212 128 622 664 486 113 657 725 134 675 290 98 943 810 585 131 489 707 744 624 776 167 381 431 481 575 746 541 965 842 858 595 73 29 577 299 438 61 702 755 855 872 752 793 374 310 519 856 397 777 78 212 773 836 532 999 264 636 198 935 196 801 956 478 414 805 354 193 497 652 655 385 130 779 41 521 503 696 206 455 781 124 217 972 694 43…
Output: 638309

Example 3:

Input: 509 616 547 795 637 368 42 895 523 421 607 350 621 653 471 625 174 79 65 861 446 140 82 668 35 11 503 406 685 781 516 603 818 453 876 552 54 70 265 728 787 127 976 979 446 582 111 670 752 833 369 467 206 153 231 288 641 650 565 206 593 981 694 329 673 484 790 468 641 59 894 223 562 280 832 405 68 182 926 144 427 233 93 797 867 783 438 390 977 339 247 707 795 877 434 702 55 705 342 615 318 32 787 785 125 305 63 356 21 580 573 373 927 94 155 815 945 228 584 604 906 307 110 462 286 745 269 808 714 254 150 3 935 812 245 467 779 570 890 254 228 991 835 350 352 129 851 152 15 22 584 875 259 931 737 425 563 629 7 369 189 770 390 800 287 226 171 922 893 22 27 440 383 362 895 766 801 940 802 135 188 482 287 82 515 649 543 858 375 502 615 750 954 819 771 716 942 674 546 24 454 992 701 598 486 725 19…
Output: 246841

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Coral stretches Rain Ledgers - MEDIUM Coding Problem | CodeTikki