CT46063

The Rain Ledgers of Crowhaven

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the rookery of Crowhaven pays by the answer, and Sarla intends to earn it. First: the full register of panels. 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 <= 3516; 0 <= a[i] <= 1000000000.

Example 1:

Input: 260 358257444 902218807 2492869 825615463 494029559 581938467 976531476 381482585 271761547 319091670 360613142 669148271 391559805 527801098 78116949 251045996 974403602 716191882 557436974 550420040 265824343 525150136 46404427 631269618 304178876 980511886 887290679 595593961 167191233 27313181 280790461 599346727 234253064 545481152 653755921 879398648 881934910 47913703 15045766 974339624 200486734 913484384 275243470 294107475 534414397 938282617 125910599 685474759 948398849 592599542 610924720 945611305 540003101 938575346 796359267 111598056 433177130 617786388 635947882 311484598 853063156 383593283 49337916 440167373 934976951 370836231 531303771 472359507 395985196 518061198 804575955 510074687 136837435 919300945 348858179 506834355 15431683 160810466 243744113 245819820 92601…
Output: 114011335734

Example 2:

Input: 1710 507016940 587420427 405216865 149733708 372749466 664959728 634346731 631500688 876532856 241875862 635799243 258867391 527154309 466142651 365304503 378328008 692098959 248441769 169487552 419210557 518052088 515532570 319369394 468523866 98315713 337506983 864369932 398889034 246769419 879861283 787081316 527029781 426273113 930632973 789844684 912811202 611847036 697459204 982228617 788684319 979700911 419468963 714167621 465538571 157031622 783084650 541516529 480763370 919840307 111403589 720233509 199069102 19682787 301777634 857076378 249672145 114181436 585152351 561418600 464247235 919612152 320118145 199117010 950200772 276810538 783178552 914738177 313714206 293940966 223227618 523381824 334192943 649328490 676884411 644760609 89473443 345840173 802802556 954032749 18298075…
Output: 843457358417

Example 3:

Input: 625 309777366 37460661 969872176 225849599 396904919 301994696 184189348 638595956 94658610 140693872 392749129 640777591 95976853 585150816 873072179 330981175 167909541 669244228 442261737 893250473 120377323 237988841 926396609 565489616 671101529 114199842 222578599 183533874 887937495 922109446 271810950 777833743 874125976 365206756 855433154 243001457 728811719 536777877 539963981 960237360 945560475 408077799 629173032 661682331 901121381 389871975 881949262 393485327 768366793 655269073 642070328 907647908 805245345 713764286 190592625 967540696 353426215 406863582 182903656 752939904 772327859 514544910 304618148 761172615 300452113 349318986 931168326 266120960 519281325 690418011 550150740 755532057 334402023 997597244 928327489 31638362 21562843 982669692 983612063 797588302 2…
Output: 298135268511

Constraints:

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

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