CT64258

Archivist's Umber Ledger

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The harbor bell rings at the frontier camp of Duskwood; Archivist weighs the day's windows 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 <= 851; 0 <= a[i] <= 1000000000.

Example 1:

Input: 780 431478610 725855552 54764354 158637846 863322004 847525953 433923064 953439463 777566994 207711787 951288798 63974346 227205317 292589536 979562389 152045612 995334961 458498339 197641521 673491336 352823399 50008211 101283135 745684143 245021228 839174061 834725733 702952832 975937804 357071422 624054889 244126235 269660916 804079564 418736026 519686818 543782028 794107660 614716835 888935029 843889890 151377470 70633204 382969944 533512516 413398877 642223636 520987206 195305612 192144903 623063954 935064822 203328182 200257232 165215609 260758050 204121123 402221851 375445232 398524690 207590956 289460685 847439182 300141936 532943166 600198075 497815447 81252644 866043515 193668808 67299926 743663465 247530099 298877330 175953206 925185942 839496001 610706824 788667117 317120791 99…
Output: 377436056096

Example 2:

Input: 233 680669319 165676576 501193172 218432484 605443104 499564834 773896844 717870052 678505562 719970930 603745749 444343743 831808898 176220113 305503063 461874343 116325828 801889703 934252019 624076622 644358630 157382553 850223209 999797443 202143385 329857201 808151963 187034562 792301827 165686931 451934819 903645359 625408475 198126886 195825147 565367112 804231371 598207805 683053980 117535542 449421770 56466635 9072252 844967335 605929574 398931091 674952273 895847897 728318282 918751789 360048079 444450288 440511228 557441043 399378467 631776435 750671949 181885523 180483927 861180905 500496403 396686236 834118983 564341524 525481729 468713896 849702773 428937077 855744718 826638670 405902777 171597605 137965693 174337277 43648888 618912124 77564236 376299195 69144723 15198783 439…
Output: 100773710252

Example 3:

Input: 338 858841780 952805993 357651780 143189450 63231473 178860950 512035208 706687039 189913925 126190367 426488735 906392253 905543208 609065381 327515539 341294241 595812587 910300987 918350778 167645621 392669268 37169312 929546493 239747800 100740831 717042038 533587498 448197503 809279812 948409689 324542134 575174468 957538806 681002516 356683352 935475004 773520652 496662764 782362640 123559595 189205524 301152626 434593108 785619356 259111086 659566795 638332988 607753147 65653850 586096843 25932895 424140939 496790815 158189841 43118003 407379169 922561293 625920355 467678850 324279560 51167308 120726203 472647897 643765369 916432243 555614394 731653251 868483126 757828646 383933898 427708491 460955595 492256125 547399014 62948841 432229938 379306595 214026032 31161392 24146449 48835…
Output: 152127271728

Constraints:

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

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