CT39335

The Rain Ledgers of the Timeworn windows

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the frontier camp of Duskwood pays by the answer, and Petra intends to earn it. First: the full register of windows. 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 <= 2091; 0 <= a[i] <= 1000000000.

Example 1:

Input: 386 488681150 49999100 400738196 355392400 513489985 810334169 37376348 18583568 86151102 913951050 375054462 430309274 836420180 134561320 203626937 215016437 999652443 826369909 569985830 15589413 132602470 500601130 931913792 601140459 847475265 208619638 404067528 493276018 128371208 469074251 713902138 164853333 361575928 548513798 277154532 832599651 295106812 158339547 991986575 234423695 175362136 130580355 706422958 213137399 853054601 374761458 319457545 539461513 105949122 907489373 689174022 807237010 969817683 303516566 481388796 905003346 316688678 711737103 101089785 853468328 30819552 932146701 60983977 409020273 488884623 47571893 382620844 968780950 250139449 339995269 849503322 676330704 810598411 824135644 832342541 355627803 267862913 672026277 857360862 393087204 6000…
Output: 186030178114

Example 2:

Input: 1044 899571496 132433481 944063637 426898379 779754290 739701201 697794521 877989756 646965154 712688806 874339812 11730024 626237037 759965361 6970373 920275443 601067292 460741435 73546074 9107017 302666355 869441854 366882067 564053434 796674423 31027556 100456930 267198945 472212270 615629982 775500771 600900574 651676791 844520361 497434853 612727502 83992431 418722411 295239994 445669389 835814134 463292210 623787447 909664911 369805529 338944973 402025216 382135453 247999027 469771671 532136209 333283565 666711920 286737735 811168339 340300263 377699034 388800306 551534944 467481970 910099280 815336870 24306101 917788274 816590272 740972462 900546624 876386818 83547111 829591711 956966661 954505728 316616205 725870960 936947402 855447982 982848712 874109384 571617867 277978130 23066…
Output: 519153138507

Example 3:

Input: 726 384087876 850801931 159631321 233812661 735799688 241761416 280792947 48896333 367325179 378482316 831906621 679691501 558390480 126432368 423201625 56023294 163430294 807680958 957176885 918175829 363453185 523040190 454398055 513081371 534333633 393475508 638320576 304838636 905566573 767363083 355402085 823440893 43689931 583904666 178025029 646751205 159153687 462404832 660434527 448291661 109992501 642873006 369105354 18274244 871947726 820996387 479437845 978972137 848144127 761515366 33602915 246902323 598026520 668182679 952509111 353453167 772054499 460361077 56576896 880259484 412505990 431970586 561666910 636593205 900181692 943765907 999826744 629572865 875570612 57789856 604404925 105034569 588269552 539982050 228103085 303505547 458734898 164701204 642618883 187701993 551…
Output: 351313400422

Constraints:

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

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