CT44734

Shepherd's Rain Ledgers Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Shepherd the valuer watches over the coastal hub of Tidewater's stores of ribbons. A careful computation stands between order and chaos. 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 <= 2337; 0 <= a[i] <= 1000000000.

Example 1:

Input: 2191 998301444 361939357 651625737 983615289 660996785 891917198 850548179 285023468 704585524 819838974 836185916 265419049 695332863 898239265 806462664 906482157 398789541 266840195 575696025 24127842 339474101 477353327 926352872 760260536 752433993 285238195 352254998 261181897 875128468 858801369 794439333 64767861 350097771 396344096 977165729 461822602 158116081 829578024 826685455 162413259 284915573 809893583 129556976 925184585 381948014 92156336 470748106 620158553 628130166 588091907 831315920 854338495 152976363 508213611 811022052 668888584 27442666 606030360 897233345 318865747 6817622 260989655 697329595 557891975 474298341 485495935 441830307 11884909 682724387 167008720 582890547 461538892 342547056 345469609 445043850 299723068 99424962 813026250 103249870 874458637 967…
Output: 1073636302093

Example 2:

Input: 1917 620392341 282873142 688781262 801203078 341364725 141986257 929790188 817069833 963988082 937176818 822787136 155858573 541251318 841382294 628903106 105741049 668236023 198481748 413830992 902670522 29534053 993791290 120840413 835572564 575305012 262082013 349400138 670851957 875596321 69272204 457329431 409104650 587474829 613079704 698424915 419374265 112967554 793233414 54178599 607001685 31884744 156235052 388638310 442180088 736704415 79589345 704669182 627772213 738231394 595569449 388076031 556343565 419885803 624579556 668955233 153930563 571230324 116945296 168263728 312103444 638232121 325597639 629287669 620419791 409432941 400491054 440341719 303271901 700421681 201068717 396141527 606821290 989697625 860888398 180836891 989508834 42160634 799756654 686524666 506319131 3…
Output: 942834830289

Example 3:

Input: 200 659499590 959682879 739838101 982731229 114729541 974801117 759888456 221097867 359244451 569694467 176989246 243000969 433567392 473862742 893594248 549721909 397484949 855069051 452301520 990375936 570081818 99786491 386187658 894498449 272723211 445903048 957838253 591153444 303677641 334421 600524436 708943737 867758896 962190972 577205168 273756360 830067962 220398783 255752299 460132300 808902015 74359316 517367262 185783878 383731306 463292665 975327964 594439157 117119006 749277903 281492223 571429834 148681969 457107053 108501949 811316539 848364201 433828817 910594071 603716228 292018534 258016910 54343913 570269459 733276396 273007502 34929353 368151368 103572194 721338958 351281345 320666015 598812563 349740131 490683081 336310471 252181714 117536731 829370626 580762526 763…
Output: 90794567261

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Shepherd's Rain Ledgers Ledger - MEDIUM Coding Problem | CodeTikki