CT54478

The Rain Ledgers of the Pearl windows

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

It is audit day at the orchid house of Bloomglass. Weaver spreads the windows records across the table and picks up a sharp pencil. 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 <= 1669; 0 <= a[i] <= 1000000.

Example 1:

Input: 58 77470 176158 103366 233395 262889 699116 212318 505792 543998 790863 119559 100105 264927 403874 727896 457262 687735 926475 902511 330339 516082 125349 868387 292220 422400 194094 372000 236432 650354 48780 70892 673262 745989 665920 407577 50713 717747 489719 319503 676071 762616 768443 891033 97016 584386 138340 192165 302682 167789 167207 176942 19351 575919 997652 115513 843867 322771 844515
Output: 22740504

Example 2:

Input: 1093 280297 384842 856254 949385 29896 47205 21223 435009 150042 601318 209768 475432 222921 356372 598287 339281 969175 601093 239483 572673 52089 683827 212439 509887 855738 188254 372747 806068 220256 49856 665652 141277 78640 834668 703273 160582 315732 785876 840839 498077 60527 533358 970861 262799 242103 411734 110290 808837 223904 179090 618890 208087 711067 692623 502180 268707 327750 705372 763012 533912 95767 485363 116796 794901 567763 70223 485187 722546 261350 971186 901844 174233 734479 44978 252478 642585 87259 864029 579612 160840 822958 507761 836828 933083 239519 77955 906071 226203 702117 832296 389660 252785 716216 252505 577818 33843 213276 264723 524421 13117 450312 567280 544651 230938 960949 152113 311813 710733 919838 87367 366182 990692 213310 466671 849446 92903…
Output: 529054873

Example 3:

Input: 402 775613 115399 317563 417267 891 131743 837674 160211 245580 3859 397252 737272 973825 319407 420273 439158 754652 428245 845614 332643 383899 432714 727120 75703 844244 331913 122679 921160 277186 367777 848089 443860 397138 388782 625181 546678 723170 455623 929603 770159 952108 387798 740768 252392 783762 479236 597394 942650 742088 968251 907489 24995 488653 623859 14586 473882 76754 146056 974441 832781 906880 18834 122156 729284 695328 864582 401241 182307 382686 345438 152255 154555 752831 377366 424036 313700 765615 338884 28330 67678 139302 634048 615593 250409 993016 216581 738680 103712 337410 864749 583967 468180 869445 560751 756332 296132 36190 305943 574184 600011 622546 104200 258637 698017 200944 635416 163970 450679 874500 958158 751323 99480 100111 179011 875549 49371…
Output: 192340743

Constraints:

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

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