CT64657

The Rain Ledgers of the Solar scrolls

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Morning light hits the honey farms of Buzzwell as Nora unrolls the day's manifest of scrolls. The tally will decide the next shipment. 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 <= 2448; 0 <= a[i] <= 1000.

Example 1:

Input: 1655 819 915 598 157 486 53 955 549 257 222 929 37 333 499 263 250 719 711 107 695 812 541 284 411 609 443 769 593 986 647 61 377 395 292 263 731 850 847 705 573 785 319 636 593 459 665 510 715 215 344 362 389 871 341 624 388 510 791 357 481 641 447 694 376 243 772 360 187 129 688 992 479 944 616 967 148 326 642 127 810 295 355 229 524 731 873 628 883 411 958 354 842 167 725 121 919 969 617 502 33 990 585 630 654 912 281 419 851 999 62 685 270 646 936 122 736 965 186 27 905 989 919 745 80 117 168 572 920 181 607 586 227 279 884 538 313 909 909 504 231 334 727 155 46 344 196 648 344 767 486 735 465 800 631 183 403 650 945 624 964 881 233 613 507 140 492 507 656 640 960 172 981 128 82 699 766 767 57 157 873 775 253 790 350 17 58 310 22 737 942 947 83 524 843 365 97 900 300 933 535 746 902 89…
Output: 808775

Example 2:

Input: 410 174 439 40 683 344 821 361 843 907 885 729 525 103 638 793 883 511 618 743 424 972 328 688 72 472 107 515 534 956 373 960 831 532 19 81 459 412 982 814 893 998 959 135 526 929 975 320 359 155 921 318 150 941 923 687 757 316 485 808 446 66 212 675 140 232 662 638 146 326 373 538 288 236 229 39 94 621 976 544 358 957 979 735 192 163 477 152 366 409 132 407 349 841 585 624 709 254 495 826 813 63 401 514 425 126 665 293 480 119 289 209 859 422 520 128 811 773 501 984 981 339 688 836 122 464 929 933 308 894 364 778 649 946 4 21 755 107 949 357 988 88 69 699 210 504 835 493 837 882 577 313 12 109 84 155 212 361 426 851 919 130 460 327 775 349 535 55 890 533 950 314 370 299 214 405 424 150 50 427 663 638 275 981 246 503 942 810 117 998 188 792 283 59 632 4 860 591 921 496 188 184 492 485 558 …
Output: 187423

Example 3:

Input: 1304 950 728 603 932 761 611 97 448 237 139 98 628 939 956 2 640 47 31 696 717 122 111 103 162 64 633 321 116 376 637 166 702 314 108 745 358 80 8 52 614 157 166 64 952 632 653 658 500 638 456 811 888 339 840 924 406 497 146 398 555 724 24 518 631 466 433 859 253 375 749 65 23 785 279 494 402 714 885 516 55 348 573 683 483 308 355 310 661 978 586 315 215 525 473 180 914 563 175 825 48 581 584 411 422 982 950 832 77 489 924 775 603 772 891 770 752 846 205 114 822 963 15 73 146 801 855 277 896 940 362 450 924 305 814 862 841 124 706 919 628 513 655 299 887 420 858 623 503 15 629 816 411 349 47 672 215 879 834 787 973 76 238 160 348 532 449 778 968 632 495 115 92 444 373 818 517 484 487 956 606 367 88 185 14 67 107 490 247 204 430 528 580 866 227 807 144 529 712 606 949 381 546 691 537 939 53…
Output: 655691

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Rain Ledgers of the Solar scrolls - MEDIUM Coding Problem | CodeTikki