CT62836

Lila's panels Rain Ledgers

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Deep in the northern keep of Frostgate, Lila studies rows of panels entries. One clean number will settle the guild's oldest argument. 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 <= 1509; 0 <= a[i] <= 1000000000.

Example 1:

Input: 201 305074169 492871721 661631689 236358211 976747434 34084189 209896991 600828430 805796876 628406000 904182529 293453964 660774631 437987369 62263012 292250827 957138752 833051574 990968321 81441238 769686770 486798611 125700683 788295114 928890820 842494392 542612808 702579695 282595873 545905438 408882948 591557634 871123051 177659920 251367097 872335130 850536339 504986630 21992403 549245496 535168533 225703719 942102342 249564653 851796597 185040449 455582954 668478807 643056208 728977214 631734521 707800472 783956362 827617445 827124271 307153064 374114557 45471919 633020743 365902957 941719586 67716040 430642944 29487032 773885220 693307878 205960163 541406986 265547652 215561974 117108180 931073864 489058429 625748907 733305407 277834524 547584503 694599777 899348830 404503392 414…
Output: 91959262551

Example 2:

Input: 792 113900321 394215322 198890846 862272657 996917419 705434046 72435477 124769781 422908398 718467998 8471910 517543854 181728988 78634446 460968490 639939116 721285592 169694060 948880054 722424046 297527376 729985382 863314242 343555342 709586712 848078045 134715824 472717901 474716754 905444179 722761581 439478566 178173168 263282937 705116146 385467550 313450884 389855184 184099563 20826633 265244291 385010765 603501892 981300060 610078244 345105137 462145632 515534962 27473253 756729071 706434608 490396535 251103454 888448653 765558389 220589426 710156831 430650012 175438207 180167371 386575028 233942803 681837799 484283531 735773796 555525619 180067218 342514944 911960165 734322209 973491081 732762058 74768678 709695005 472165197 596145040 668160858 191123205 389204932 214061686 459…
Output: 389212201821

Example 3:

Input: 429 673995157 366146283 218929216 252851473 684788655 568887664 444696634 816761139 100259910 919937291 604765744 779997116 815246521 64727983 138931763 873594795 724444310 402061095 579905497 120915435 293042810 366750251 738884385 80700376 950439886 698461445 254341533 755195103 530662489 683979050 127806416 394001170 629337180 8813898 504233898 875314640 852765246 409452831 470485712 309440993 650511383 358846046 518025927 459642894 153241951 408783545 998625262 784789185 702058354 265627982 49360425 911867803 105265090 940945807 167866654 577248688 455387562 692168118 757360282 470017170 788024009 152103258 83307771 706962838 823619072 808873078 893830074 843107928 603162314 272103624 248683482 781492938 661316298 739790914 635276521 691783159 423383938 420458089 538164288 696055123 62…
Output: 194245360678

Constraints:

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

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