CT65356

Yusuf's stretches Reckoning

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The council of the floating docks of Skyharbor pays by the answer, and Yusuf 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 <= 2473; 0 <= a[i] <= 1000000.

Example 1:

Input: 2234 812682 65622 531942 970585 661874 490202 102446 704992 654461 442676 556455 700734 675164 357843 540447 443417 283614 54443 253963 127367 250326 633818 341825 874243 663909 532903 476301 657682 875040 572339 581408 375986 535001 903879 850937 348544 577570 104152 958717 278746 560918 824932 813525 653856 419974 460874 275399 65268 219926 596668 379419 814425 944241 361286 51458 528229 475984 36130 305754 381736 985416 113065 814373 159388 878933 494296 36446 246269 206976 695078 46933 421881 295349 33298 70186 604621 15030 46965 634003 352991 732655 686146 169624 10278 887030 783313 407469 458620 652836 700493 655123 561274 823465 794561 593968 37470 759965 33247 681816 190259 840511 460201 589219 640505 685916 539506 348822 55054 479116 818391 63041 454048 255386 28464 847253 4818 96…
Output: 1111608465

Example 2:

Input: 1865 590190 746863 278212 264618 518266 317057 807178 123043 534194 346485 506324 355511 752829 510142 680518 485176 102862 547498 464780 691667 423008 140851 428547 8339 322354 727679 124237 702742 826693 478080 25110 658754 668069 624694 289726 925353 223557 447522 649480 43961 868814 318394 416065 115500 770265 974296 901209 796096 756477 126397 754063 975120 204485 718147 246552 223095 929577 292931 977659 757432 379813 769712 68153 823512 63516 456552 971664 52432 465249 235335 26034 157599 809961 519098 678591 597124 128220 974112 275049 736460 575826 545705 964527 940316 129750 151696 419036 693153 930581 394134 470887 812093 604333 76738 718872 798998 159345 784115 436249 98347 341524 764543 510945 388046 310262 179330 943309 909773 511462 410839 861334 151872 850316 324814 775959 …
Output: 902687457

Example 3:

Input: 2450 303265 690868 756800 943242 317060 580497 880088 805110 428827 212640 512859 703479 694264 690536 347433 901131 564417 245934 597215 951376 799871 357336 629594 859850 218298 579535 97181 857054 779893 565457 426928 409060 483125 82613 164512 169157 667119 600819 745407 991581 331328 867216 181328 237895 53882 254511 613282 63296 561538 190781 807918 536878 683882 436740 405097 603365 935648 554318 637526 405046 120162 135273 683700 227694 31086 42106 217663 55276 940816 133895 5603 901014 771681 945785 521951 304001 134626 124749 164785 152447 56278 668951 514447 338817 244626 119397 896861 459709 389605 940783 739392 875214 987466 920421 367547 684260 343189 79900 347981 294944 326416 612579 356287 728908 16149 909052 340037 421734 74826 917576 701269 704767 584627 42450 273830 6668…
Output: 1207199929

Constraints:

1 <= n <= 2473; 0 <= a[i] <= 1000000.

Loading...
Test Cases:No test cases
No test cases available.
Yusuf's stretches Reckoning - MEDIUM Coding Problem | CodeTikki