CT57465

The Violet Rain Ledgers

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

In the ember mines of Cindercrag, Cleo the reckoner keeps careful count of the segments. rebuild the damaged itinerary, every figure matters. 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 <= 2695; 0 <= a[i] <= 1000000000.

Example 1:

Input: 1914 688996620 680835283 485023316 976575686 673758800 455213277 961321210 202331111 330375704 231759371 832465018 138462241 303497335 317806900 597231326 745676457 351960813 751695212 239190154 756484468 729630925 847080282 453636067 809080973 4769036 266544413 36532916 260779445 552956189 876597578 542757365 782137129 613853560 694115195 10061393 394653355 92995874 776103542 793802214 511242442 47272169 202310272 633118178 411725079 128387260 65764233 332889100 130341844 798504070 258109244 914246843 92995716 622881841 992789764 844295827 240174668 855932170 108953307 21873239 7950328 49242969 953906378 880126398 376406873 482940224 255028191 578377860 747076141 585091421 737964976 352275652 145166432 309035592 87767680 93934877 939310048 279130638 844845549 853335575 991976724 514751800…
Output: 956640151836

Example 2:

Input: 1857 77076487 514309078 806921199 998721562 196928234 82321504 78192378 928131176 614743633 585850392 588339325 100085349 828760510 390576854 563647617 443664055 360170570 973598721 45240595 185308149 745592306 493760842 628014868 241167591 964337013 170804894 440457 680269883 169222065 899944164 970006818 62670791 829818671 701178730 791086150 146348162 429259526 190771948 613342939 211679566 872900595 158833247 148643334 756028177 937242536 494506450 952057628 853657164 953986543 675105040 68918080 986381482 308389964 172753540 233387458 998830437 751716755 36872739 701288153 563397799 924640220 911824403 198639772 987721974 791804559 226766030 255964953 535099038 571520870 529951995 75981632 700548499 656934644 783235825 763975880 780729628 823600669 968674633 421066373 646740291 330595…
Output: 907311447875

Example 3:

Input: 704 199528389 286345467 226034630 996355312 37129002 647463947 793415868 418301974 639434531 917520639 339803966 971290793 611888495 917466008 72183479 316208763 232352785 862786511 67144065 42659577 482690813 877961715 255561350 552157220 303009240 780689369 759290365 314037103 189629078 542781392 171045637 214779486 533582254 407544111 466535108 17449870 805152828 465818452 39263159 306271816 583222767 543798745 924059164 793869894 84210918 438777049 178166980 75745981 763118801 223233967 97311828 885036500 117700687 913344475 291490141 301535977 549069054 972955251 218410086 569193187 605090461 7111161 616170977 969244761 910245500 62935388 699486465 993315247 410023506 102887664 368624666 111796258 949471045 47595603 373367609 690652558 173914755 396680829 146612100 38029897 606310548 …
Output: 332431492932

Constraints:

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

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