CT59507

Emir's Smoky Ledger

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The council of the obsidian flows of Blackglass pays by the answer, and Emir intends to earn it. First: the full register of stretches. 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 <= 1611; 0 <= a[i] <= 1000000000.

Example 1:

Input: 521 253842694 363277627 763345899 161296023 280793191 62761819 94407502 744336233 986586955 412250066 465996229 998405079 857962248 797932195 42760990 775285090 335663220 377454003 144437500 198405500 920480064 526533299 718590061 115616048 438855934 881437327 851065124 620556298 326843631 248749005 360456399 277352446 403065935 697863574 424624659 565966764 682562818 260518719 855603426 658792640 118214225 993873090 62874399 942017641 348330703 123899020 756263432 715914722 94341049 522820013 568628847 181692870 390902036 255650638 141904188 710830061 833479659 123888360 752154770 848629043 602084549 880237650 434999692 414929008 908783894 876004085 115940628 216738119 498526840 489611477 526394226 820729400 760821392 86674754 309215266 899391379 795404128 939192629 433039531 842894045 93…
Output: 246598094956

Example 2:

Input: 214 452232413 587553955 199820987 841749718 609127360 598353509 88652512 581503346 585561654 867150616 763694222 379623036 314362432 113861743 711236644 490215197 806305205 721841242 831311416 533829442 807150406 734988099 285551280 267091799 949639292 892008685 155404822 650920554 367471103 741949102 268852735 303238940 161940049 541330439 724927767 28736305 883034435 673870648 561780302 942404504 668705796 924494731 883510399 809408735 255743859 612382670 583507597 997084830 569277500 739784788 711114235 274678674 438859452 461840458 530531119 594669824 6959075 657486226 278749071 711386094 313486316 719651413 104389458 303682251 172449225 409294089 32566745 205644968 894138395 851597354 737244604 971101868 934199243 48309391 36216909 254648091 923167628 645628880 792422893 282589541 213…
Output: 88407803048

Example 3:

Input: 1333 711777675 772762678 619302466 585833253 964853972 715439153 513257406 460967691 449717333 570945688 338280105 661189079 41075456 130156297 657881232 919120896 242335415 9710704 231160827 438606843 795225459 366260443 260504143 135244066 381264999 941072362 81489336 168387588 688366668 508185959 405303743 961058049 895636833 917136158 47888166 794312425 260290488 978933559 714164126 687797043 608756123 304194089 443906824 396462410 762183303 570916105 73807935 392826097 876993055 877212551 597798984 898723730 711651455 864446183 284058176 44717260 98124624 272819551 716589150 623412983 967148146 202221701 118974034 391654143 940489606 855938597 585434703 832991057 80782119 596464183 823254939 289574065 794572515 573668200 122437242 908730441 326201238 844095931 432217218 487522971 1503…
Output: 660923311130

Constraints:

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

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