CT43600

The Rain Ledgers of Screech Point

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

At the gull cliffs of Screech Point, Milo records each ribbons in a worn leather ledger. The guild wants answers, not guesses. 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 <= 3627; 0 <= a[i] <= 1000.

Example 1:

Input: 1392 960 26 262 484 154 280 352 237 435 898 609 857 685 567 273 840 446 580 124 404 508 919 494 148 588 813 775 615 732 302 636 109 217 58 867 469 260 90 141 590 985 172 233 158 481 629 61 218 233 235 735 964 263 449 424 830 116 171 603 398 399 593 284 697 214 969 891 631 804 453 431 168 414 773 186 57 250 227 668 834 950 882 177 97 338 428 579 214 769 825 457 137 509 196 235 65 54 502 364 397 789 343 480 305 734 566 494 433 85 948 164 611 915 625 292 640 452 805 21 245 529 963 244 349 129 648 659 561 808 286 897 33 617 248 994 521 1 501 445 968 918 869 133 268 756 774 134 25 229 236 338 972 121 808 578 502 537 376 538 107 488 300 761 758 518 164 251 954 352 298 204 667 29 927 605 312 950 234 49 632 816 239 91 386 41 287 786 679 334 768 530 804 483 477 829 575 200 578 119 862 933 20 501 54…
Output: 696385

Example 2:

Input: 1070 218 474 964 328 255 676 942 481 245 180 240 801 753 193 886 300 765 321 311 560 363 173 200 339 176 390 751 614 218 167 317 879 858 335 482 708 566 72 445 78 411 415 111 112 193 952 742 475 969 289 231 61 766 51 966 731 328 327 562 214 572 293 833 101 126 754 508 325 933 308 424 996 290 319 216 676 530 492 928 59 641 635 21 242 820 167 20 284 209 857 17 383 610 579 83 712 196 67 607 274 336 124 171 389 543 302 677 650 41 434 989 415 813 343 394 208 529 596 20 227 195 389 341 610 543 883 934 158 790 303 687 981 677 340 403 96 629 137 840 187 585 828 0 847 905 32 489 77 134 307 2 351 570 329 422 646 30 614 464 511 644 497 232 897 30 647 514 340 598 156 217 262 132 167 624 418 913 494 443 188 380 99 296 516 406 624 558 288 850 804 736 346 417 761 744 530 671 751 469 755 832 172 89 378 43…
Output: 543431

Example 3:

Input: 3304 286 667 315 377 86 106 837 898 176 607 699 104 74 388 29 691 354 836 965 798 229 967 122 935 568 323 736 151 3 445 546 181 781 791 649 959 647 52 372 525 474 9 699 255 632 476 659 412 374 147 829 775 884 242 267 751 676 52 280 597 491 700 486 195 789 930 436 652 952 592 521 322 992 573 816 248 178 136 419 618 589 972 351 305 790 608 449 975 615 614 862 760 57 285 659 520 478 749 358 750 25 604 536 660 453 651 743 987 236 383 479 463 277 56 168 818 258 997 849 92 196 624 769 545 9 423 6 383 129 442 914 986 71 385 466 469 853 521 318 302 69 380 210 683 463 979 232 667 566 759 467 156 445 665 777 417 697 933 5 552 818 281 613 460 806 874 129 808 877 192 727 405 229 261 468 731 491 506 602 220 843 334 771 492 617 464 698 752 606 518 538 449 515 665 872 959 396 370 272 735 587 566 795 887 …
Output: 1644506

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Rain Ledgers of Screech Point - MEDIUM Coding Problem | CodeTikki