CT63860

Painted panels Rain Ledgers

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

It is audit day at the crystal caves of Luminar. Chavi spreads the panels records across the table and picks up a sharp pencil. 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 <= 2384; 0 <= a[i] <= 1000000000.

Example 1:

Input: 11 829225650 822674949 855789847 101650491 150167633 435957193 726126946 969415343 46369608 601335997 776806470
Output: 2921715161

Example 2:

Input: 199 347600731 216534701 596227837 981179973 499361042 126140983 501619373 551419299 201838589 637791857 780848701 966605895 441646098 41718381 109836667 567534451 181246034 834183691 695586646 948530203 158317816 441119 208816853 425725727 2972474 597009207 975123626 290275184 675533955 732408100 914745923 888724292 52663486 639537745 185949801 733941016 305186033 212786980 945324214 492479161 733419937 15113463 883859518 78579135 526949335 349880310 42179873 339495629 360261155 804796977 594960631 515759128 853627992 707664216 329539857 507280257 588269972 515291478 232263979 551910683 439146752 369819382 478246734 612601729 266829923 240041891 878895172 249697749 828848301 408411166 143643413 789012168 42933979 345370924 945598000 489359797 487851222 457740599 817208967 916911123 4213519…
Output: 91141767596

Example 3:

Input: 1882 866301113 343219861 205961703 236814994 502081870 820856937 557710125 114569651 378997237 454186413 596683820 601452473 409042169 610972913 584803091 222374836 488162313 779222764 159572020 395416736 96639973 383923380 199403232 402022574 414132142 718776893 427530305 277386569 298661825 664805490 753307165 620515815 884130404 694018731 790643972 243788293 866827399 577098115 346235557 324896360 511716973 792192901 535556247 590414977 584134782 536305611 921582454 913129079 812879391 123278726 54462003 75566697 911691304 108390741 839526268 602391676 901297267 788376267 820753869 913011701 786713924 640296840 742621263 368854444 783306570 132977301 701131845 536082432 604056124 757307922 297900201 61005228 390833600 390493139 904884178 148666472 538938154 386236706 429155749 597100951…
Output: 909958568024

Constraints:

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

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