CT35470

Zane and the Rain Ledgers

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the gull cliffs of Screech Point as Zane unrolls the day's manifest of windows. The tally will decide the next shipment. 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 <= 3471; 0 <= a[i] <= 1000000.

Example 1:

Input: 1816 117846 914499 471002 11271 296338 74753 545860 453033 553811 514742 93769 919471 696458 989828 479877 757852 518096 20887 363315 323487 433718 394834 658897 52942 138792 110381 921986 673252 447707 128449 326484 519166 181097 721276 772892 460985 91484 125150 784997 233100 93436 416573 921783 88463 746747 646807 906944 785692 379053 848465 968736 562700 522127 979338 419124 645113 671775 360411 281407 231981 405732 221413 219720 282881 848126 219023 328171 499879 436768 472886 750078 571675 494302 536155 542349 675068 468416 278154 640273 201987 17383 982398 782563 94881 714887 949008 764018 785782 216285 825085 421219 96830 18513 622097 510185 875454 978528 606982 742712 666297 562042 193660 9800 364013 150168 589936 538220 326994 217977 159714 794793 106380 461175 20904 259624 37158…
Output: 907311369

Example 2:

Input: 1788 54394 279223 228214 711757 153973 302965 231068 146421 424913 208438 922349 245115 479947 97244 629858 437447 284829 279749 651063 967582 563386 572749 279085 22071 202476 476481 678833 830690 414980 690498 704616 254617 211907 392427 175882 768820 208731 525019 429136 410000 889971 78630 984412 196111 785109 740844 45337 88442 573622 649253 271065 324505 3614 69612 957877 936824 233779 513279 856664 864717 158161 47232 478462 550556 965412 860101 559603 222967 999565 365211 427833 62194 160892 933056 63015 434108 139052 583181 803386 346884 58984 83592 951891 220039 863404 660685 749239 117067 557104 981275 32825 629132 842305 224179 544778 899931 4876 591881 435009 46569 74430 42942 676485 910921 338582 709169 569396 501186 409012 909631 259700 52899 708053 983797 922027 836465 2146…
Output: 886447862

Example 3:

Input: 1272 174342 221787 326434 735554 109101 180852 32223 73151 611309 870154 518190 73187 494637 43832 748093 24810 619813 268925 37613 273745 726765 455625 567490 769414 832030 894573 517110 389662 950040 198046 582947 844781 357397 452954 531954 101318 937645 486212 56673 561761 459044 749768 705871 993746 839329 281665 434232 756865 697469 220161 238022 344942 679828 956300 843033 591023 12580 97907 617090 950949 765129 733213 288690 567989 814446 529858 363171 458229 212855 715255 910712 565172 830318 903900 476055 255117 315535 791476 943805 472186 243801 936272 275421 263531 799447 426095 341651 130399 667942 114752 957269 620810 603435 155330 123912 413800 573243 74977 794486 404324 530462 520390 328199 92471 653358 849507 762313 561937 838600 266661 641932 22532 516846 817155 891547 44…
Output: 625969163

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Zane and the Rain Ledgers - MEDIUM Coding Problem | CodeTikki