CT40165

The Beryl Rain Ledgers

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

In the canyon post of Redrock, Kabir the customs officer keeps careful count of the panels. settle the inheritance fairly, 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 <= 1380; 0 <= a[i] <= 1000000.

Example 1:

Input: 348 891130 530552 482871 644860 524571 906651 299882 961687 507700 444874 833732 528040 504183 535868 950886 688944 572741 983842 576450 682087 689562 149451 88429 933391 367809 158082 677008 554393 488677 83556 893642 356143 146538 592209 816461 817575 679957 520650 876622 928353 694930 740670 194711 433364 593455 675199 136053 503238 185986 784691 275280 85820 346463 637946 728923 191996 118612 140003 920563 168269 961927 165771 384315 927751 717662 529352 654878 916160 323540 567250 124518 469061 743922 868204 760878 805397 682507 741882 779055 51209 475754 446795 968665 68024 750670 427672 456119 259190 342609 530212 34910 676267 464339 117132 907940 734408 451376 39194 900510 401697 806014 276463 7531 376234 367744 84739 564617 946519 244272 966120 995682 541622 527542 870103 434489 4…
Output: 161162146

Example 2:

Input: 740 712967 884247 291331 548596 895628 545848 435812 986036 434833 983611 413961 318350 101764 168786 271580 850690 800222 133632 962991 806917 739064 971801 353602 202076 308598 252608 539665 441328 481807 525292 235947 946836 904577 701462 365106 343270 164850 218367 497616 648834 435307 136420 171880 31486 709281 470603 184528 14768 673403 946614 504311 521459 655227 389417 117535 744485 327221 300918 86005 730897 376770 98599 529693 148867 922092 56144 929430 931624 99572 126503 593564 978428 579963 485304 14078 609902 795123 730123 837465 407715 285794 629046 438211 62066 165092 181633 951063 702786 186634 412163 74182 427418 459771 169698 308539 592488 355792 874904 600568 599315 109597 859545 271908 395584 258778 59747 276252 89684 820038 86578 733293 639851 694935 467309 70340 5267…
Output: 367863332

Example 3:

Input: 481 499422 914581 227905 818239 94811 126009 965786 30270 788847 627525 832450 528962 901180 623814 842996 865508 836689 280796 977018 857946 920082 508031 123267 141195 647701 349028 341967 591777 126786 693232 965580 457320 631796 209483 896047 316976 898552 16562 995006 865343 367503 112579 89245 542850 345222 906169 413125 253481 354107 351473 219065 383328 245902 692910 253143 174158 777230 834660 839167 37753 129689 466686 893372 322512 844833 326054 70904 641087 535145 932668 86064 30191 968104 392921 588091 513014 630118 82818 405556 361458 883618 366796 514595 211375 949189 184171 794717 657075 403582 132555 675614 526091 877153 764905 2201 217228 582012 20216 258919 429086 365417 81957 828787 319604 10420 740126 653924 113968 369740 36446 894014 497239 980750 393151 123073 80059 …
Output: 236219352

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Beryl Rain Ledgers - MEDIUM Coding Problem | CodeTikki