CT36306

The Frosted panels of Pavel

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The harbor bell rings at the garden city of Petalbrook; Pavel weighs the day's panels manifests and starts the calculations. 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 <= 2314; 0 <= a[i] <= 1000000000.

Example 1:

Input: 1476 703731947 404290759 725856268 362096756 498668309 592881125 848084875 693730644 981737793 658216280 771683034 544331794 649537014 788176382 681764545 649800088 54009138 398577877 9989953 234257705 326635677 554666816 47092445 458302067 927909866 892144069 836060845 34056874 818218774 907463546 430192395 737696255 696000451 709408625 218132236 871592885 626553219 26099378 156644601 56099787 230620876 872160196 734572989 283055786 569526063 703726994 885222438 826332912 389784569 832971067 814920205 967348983 45026289 537453681 920506205 311221046 564319983 324166475 670855871 969499578 852829920 757737317 144265886 911400184 996670137 541860123 284131872 128543449 959907508 313454370 428807714 705965905 110740137 228271224 750076859 26392427 606187130 489928848 782453243 359890892 3625…
Output: 720964154278

Example 2:

Input: 1147 637632811 610826273 236775677 161887923 411469140 505760167 875595206 609339123 562752753 52227607 667897899 297113256 662652978 252979109 809064313 778972988 34136883 934944094 25185180 535268615 143316274 93391195 352670063 345063797 540012909 252366490 679975925 789200821 327760963 19986406 800941589 418548790 829969844 521499971 559624984 505688548 659232703 102044843 928021311 385796350 186218329 182299853 120510286 738774506 642288037 561254334 672944513 97685183 49621819 509278709 606714498 448069251 427858397 864221771 317959220 743557848 602556025 398814623 193433594 158837400 83853647 619382905 147660753 87920738 519688161 384997639 536968468 144236072 17743451 232893944 925122857 304821453 902491352 352257061 898221511 737041363 293861992 673236856 794311375 763463110 88665…
Output: 565756808769

Example 3:

Input: 1387 5710202 784466667 183819702 879435827 809871946 508415413 868245873 509974066 908029248 357258889 188401055 922482515 361686449 901753495 658378238 745876991 298112737 103822248 470583322 729912932 203731991 459699526 861784031 457130651 548448780 499024979 996469871 462167162 367419037 75493647 152092418 590779545 300597336 624381695 237764824 602411556 843071088 692726244 805064486 370592725 133442546 152023647 662970240 780560412 123864767 443758881 254306220 254180454 51805128 771738766 442605867 371902421 943320167 677074302 710216134 282668422 897928153 142654089 899655968 38556609 336914110 41228706 283759773 62561409 791370497 973826495 69217307 311831418 820088688 846605131 209074782 181615351 983966857 728605747 721218547 759832519 37008382 506879654 343202620 100917690 8248…
Output: 683516136954

Constraints:

1 <= n <= 2314; 0 <= a[i] <= 1000000000.

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