CT60123

Last windows of Vani

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The harbor bell rings at the zephyr cliffs of Galeholm; Vani 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 <= 1533; 0 <= a[i] <= 1000000000.

Example 1:

Input: 1140 97018671 32293153 785701442 658584931 679227848 934129540 509318912 177272795 770951214 848090347 995350526 304360576 494248289 914223993 631596890 638717443 377586947 927342740 715842590 444646940 252017160 141824366 47073571 559168768 663528474 779666081 829617330 444788834 244924392 102871085 868739347 606527191 922938660 392217432 377913552 126288061 329108397 996853087 497527844 443390745 206528002 964199400 299504740 104212741 160950394 851235562 755232622 67314509 338388392 557037880 145127906 587763806 84833141 974249697 23509203 506418790 578432316 701130132 952365106 862588963 482124096 720059212 185954668 596990088 822459956 957718246 497675812 386824243 373912752 910712824 968046991 738623561 152118595 357478710 31125959 883563716 871720374 640396870 17911507 875377497 159…
Output: 576087003264

Example 2:

Input: 702 531945882 418158714 346255893 81339538 614034598 348458576 427086695 516926093 209466343 368937261 33708470 463265821 212298476 564676111 660583250 796214726 617128693 806687015 381623100 12424877 863399925 259794943 314406603 379679517 317763136 513351221 462717480 373839441 807349869 434137170 821642110 308166705 799651817 827872768 386876506 451365652 925466490 634016145 305449833 414882686 756440726 440594053 907081322 250265737 848907788 982778260 982288513 894480729 244420140 198853546 716596442 47123323 113079920 183869047 484189077 401990444 322971809 926871829 11137632 246846773 194641543 877917066 294446558 719523323 809599211 337416628 328470582 557609081 883437282 408823635 652537293 525950950 528786755 118160342 961262174 464177450 740553049 991910136 668408210 639987705 2…
Output: 343276549780

Example 3:

Input: 1087 102207225 620644495 313375581 64258602 513501238 482456470 826446506 416241357 344867986 240041997 328793065 885215108 595842161 794338261 498277578 977871405 717342460 352689087 864158175 440398082 808268978 395447861 776379252 737456142 98701803 73056844 362007446 962187169 157671527 405234649 424428789 345160417 877219720 900899041 362061014 995553693 112963675 869775682 265856998 507565405 758518544 246248504 664333235 283875020 977927127 405990441 339985286 256799310 878670972 838981630 913488138 569013894 105729424 280227172 546039706 836702705 163569604 245588898 102164409 640874988 247231587 39989291 701338719 826222974 352965155 768597680 766149060 704979539 413942666 684298580 421778172 656818991 466922571 678452882 899639109 942505951 890866397 232653172 927895729 569508153…
Output: 515065523893

Constraints:

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

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