CT60170

Draper's panels Rain Ledgers

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Before the gates of the steppe camp of Horselord Plains close for winter, Draper must finish the panels ledger - one figure at a time. 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 <= 1605; 0 <= a[i] <= 1000.

Example 1:

Input: 479 1 24 898 747 114 877 260 507 368 989 600 842 680 151 236 759 948 188 800 560 93 432 459 485 447 475 623 592 719 194 919 211 311 62 388 740 288 479 433 569 952 324 260 39 884 608 852 936 817 412 486 87 575 187 398 5 266 377 392 743 168 70 263 906 287 943 694 846 704 442 843 56 532 241 526 341 720 378 61 836 442 630 389 3 511 361 530 253 721 422 626 71 53 258 491 319 316 963 997 528 418 253 679 36 23 731 456 626 559 770 959 647 357 452 1000 16 384 886 357 633 579 616 168 839 309 78 918 474 991 4 886 828 398 373 116 591 827 140 728 954 323 350 140 200 680 39 502 433 638 912 499 327 105 879 71 388 5 737 785 332 978 574 857 161 881 78 733 495 685 135 879 379 891 312 318 209 553 439 340 269 743 246 115 181 948 910 640 3 683 36 740 703 415 40 637 551 543 525 533 523 126 859 452 527 290 870 61…
Output: 234958

Example 2:

Input: 1409 997 775 583 172 653 639 407 752 762 270 121 252 430 344 680 145 617 279 318 590 242 439 854 823 850 440 975 448 370 178 157 563 1 231 922 259 282 668 565 693 497 496 79 893 8 303 347 269 388 240 629 446 710 537 11 906 569 103 563 822 190 324 661 199 228 243 178 159 302 551 598 334 537 371 581 305 10 8 454 561 354 9 418 329 920 856 280 933 179 274 423 384 485 91 545 188 766 60 127 515 845 458 414 757 785 772 823 683 752 882 879 122 239 198 218 869 994 61 39 856 625 250 393 599 959 369 345 234 301 823 784 653 206 2 968 528 550 439 154 276 877 448 624 115 497 106 238 354 41 340 921 972 845 96 172 177 234 92 72 999 735 868 381 658 363 922 215 202 739 914 223 336 896 876 137 595 895 423 472 502 565 425 921 492 775 953 861 555 852 916 456 186 765 562 944 239 672 75 588 43 897 676 257 539 17…
Output: 714379

Example 3:

Input: 39 588 300 332 695 705 294 856 196 892 399 884 539 239 209 218 49 249 302 795 427 28 867 265 274 571 846 211 264 122 479 895 384 430 326 165 219 879 284 21
Output: 14981

Constraints:

1 <= n <= 1605; 0 <= a[i] <= 1000.

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