CT50515

Admiral's Rain Ledgers Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the salt flats of Palemere pays by the answer, and Admiral intends to earn it. First: the full register of panels. 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 <= 2304; 0 <= a[i] <= 1000000.

Example 1:

Input: 1042 398589 433888 321683 71736 93462 915964 779377 687187 605690 675188 478402 692512 696221 682281 219067 304592 312924 946757 400688 20576 818538 333899 445747 621328 985669 88642 229422 857347 986929 969058 168273 498553 11983 647482 121549 317526 384400 764704 415216 775896 189659 617587 244716 304937 128434 860158 486464 342612 431599 183848 625887 658944 858372 72559 92468 935246 89951 551855 103921 256826 993033 551340 839394 542242 123755 60461 385898 195009 628376 831602 751615 968428 701669 538710 683148 870960 5029 833930 160663 558553 94469 330613 511345 979744 684018 684390 237611 304169 305632 701054 815769 526090 416053 871754 299703 736179 919584 174159 156014 101903 101358 11887 962434 470061 665294 951125 853858 730975 433162 720190 934776 656821 564626 638860 916054 195…
Output: 502809787

Example 2:

Input: 63 614829 622925 722932 94921 937731 687434 465774 915143 229567 997280 547466 70104 895294 142865 89076 352173 14565 868071 465342 292121 896127 922673 322184 499105 692845 178540 769218 2813 211161 145038 731158 137992 974643 852231 299554 576953 382661 954112 814625 438386 425289 716833 196662 146744 333726 862728 196352 217827 782558 53738 768780 863803 174510 776945 328149 54611 747390 855716 611550 38433 876098 860984 570318
Output: 24851082

Example 3:

Input: 1055 179048 704006 499948 567213 644919 230941 456798 884048 674196 308725 910305 58680 426350 874224 631402 655453 132262 687139 915197 676028 92711 466044 662058 936842 191939 827946 358784 239697 567873 124755 154033 229283 335591 630731 73070 536623 3988 5516 816556 484216 200835 698913 720783 908221 373901 525849 430298 987679 431030 10594 974836 860521 326295 254850 119735 871009 64032 669015 171737 189045 264980 597591 885239 54486 434186 624318 937585 926873 83052 120497 456958 221008 474337 521782 387653 800443 919674 475477 737493 154286 728540 286227 593277 587279 780178 119470 451950 60770 747565 167766 825792 997847 799311 898062 591389 732080 760063 729116 261934 829009 687024 394736 472159 488586 269271 624939 946380 136318 132952 232123 515089 446330 514077 698624 505630 54…
Output: 527162980

Constraints:

1 <= n <= 2304; 0 <= a[i] <= 1000000.

Loading...
Test Cases:No test cases
No test cases available.
Admiral's Rain Ledgers Ledger - MEDIUM Coding Problem | CodeTikki