CT58294

The Rain Ledgers of the Honeyed panels

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Morning light hits the tulip beds of Bloomhaven as Lakshya unrolls the day's manifest of panels. 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 <= 2035; 0 <= a[i] <= 1000000000.

Example 1:

Input: 1758 645789148 511279185 217821798 8200490 412953024 590502629 649986835 952448294 276299920 243272477 398423338 48768947 496227512 267513027 792966902 444869845 293041733 808639369 623801710 489801036 551872686 71312439 4447991 237082086 609431592 870295891 955124956 898498719 700762907 399237508 229498935 326981407 458302966 325399385 651598561 91882997 354013751 681795337 605625379 596493972 774447206 218693119 436580915 945309483 263649734 619844117 935471798 676774732 992226693 576278562 130608036 747040715 751059617 552595476 592710553 376501300 288169630 748438693 470166661 496233963 558431147 505585206 509726479 507489830 404028784 141075839 88693503 324308214 919521333 418487606 779334373 135044374 116769690 132524096 248612518 254196423 661918989 824806521 827434248 39713755 3686…
Output: 868097482142

Example 2:

Input: 963 298474656 481313659 200587719 877626715 53759109 76778342 364720583 250709688 235913233 944795972 984545258 892741808 458831768 374468271 186355506 580484743 162985655 867908701 954047478 650075241 89861529 716082389 356864549 992280030 231222656 311751325 314955944 325049594 304788756 727142711 39851490 702556521 589601598 173981859 617523862 747026105 487476181 666531762 571821565 165824465 184017149 703287284 151211251 288471719 33216310 511551449 872084727 316716604 249421304 849826011 252948142 864291928 535435434 228886960 713036321 326178483 722434758 18395031 551004307 560368821 455358884 74751747 187067065 348925894 690903736 977460992 268208519 285110652 902520087 48873427 638890344 453154453 332869851 803861182 325107708 89775243 816922286 506505195 74315246 668887954 890373…
Output: 494652246975

Example 3:

Input: 1941 128262685 844317729 953682047 631809720 863031185 957259338 916332758 308116029 88522219 860176561 455368095 932684232 546985556 123017791 389595537 90794342 604517917 812266617 519355539 215946257 865980289 489853323 516505005 268682862 804953923 688211655 6107433 373351486 218912286 573035587 743841061 72615433 740064849 79322485 624926575 276155664 970527040 934507624 990252966 611231376 475194634 444401492 878697280 323674906 538643545 118363249 190412455 273994350 473049197 651247528 873170700 166191487 309424085 298127131 369229370 53356882 49741153 341857766 944927321 73796531 725416349 772067816 314896836 265791090 701812074 770852328 287646985 342297871 901560700 53483059 197689522 594116986 872604180 751095011 945616770 975489372 361725800 278198792 293771596 334878975 62961…
Output: 950317334336

Constraints:

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

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