CT63346

Tailor's Ledger of windows

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Every season at the fen lights of Will-o-Wisp, someone must rebuild the damaged itinerary. This year the task falls to Tailor, armed only with the windows register. 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 <= 1727; 0 <= a[i] <= 1000000000.

Example 1:

Input: 263 120219182 697452198 464029759 194100928 108129724 815850812 208031018 513373215 893556529 655165373 974250313 688972399 136057241 819394677 776936144 722706990 39068686 942581297 488847503 869724168 890715392 477580736 641437644 807036177 127884221 374166549 9121973 759097795 201145223 57396210 432551732 581179702 6105974 230034171 121293255 182433166 926988681 755730484 756807317 141165047 108956154 228757148 360243148 848027041 957275295 275622470 805363801 761896726 562837957 581502714 262601592 367754566 72519429 939118035 541781679 893780479 226609837 49508774 562805817 624690168 546639681 321881571 412524766 415249643 120576000 800516126 798681978 891832411 694291981 846405572 931628299 583746081 703760244 939764900 220680864 159616146 894317028 319199214 24267267 412899805 25440…
Output: 123605308286

Example 2:

Input: 690 820613523 382515473 997309243 567028715 493231853 613257969 244424044 556921824 47795764 382231531 8096505 268317641 99633449 372315693 684784207 30856801 431232412 671779061 464290713 715384537 894562715 452368443 816848663 411801149 379533545 436881999 949916112 419499523 692302244 230556297 526257273 351648708 442463493 224962034 753488730 383824458 929472373 84788850 189722435 10397764 629897406 754507190 225718329 759327859 337122745 771876609 183415549 836818828 405908129 893643127 329520436 470160236 46509884 382078485 489065466 270098434 962047698 625229135 14587167 361196800 893617648 445596258 755786134 119473364 638162779 561701046 841609781 407181012 182193290 150608181 502606629 79034878 891561589 334824477 578607256 628617065 303507567 851865785 963749008 18800811 1859173…
Output: 353517583535

Example 3:

Input: 712 785564298 439998327 557079416 64359941 605982998 424286948 194256135 437229664 718808601 835034082 567823539 133476755 27427953 518799288 347118005 606679296 410612461 289715793 916359080 856163039 108849752 564366564 9134078 719016165 569302563 907875008 294533293 688722461 390186039 757615259 239085374 944203199 373003120 444590773 461950971 175366985 623038032 387918332 295472748 302735443 689794898 235745831 573209349 610915934 32291528 649051390 423866914 754973243 822723246 468558108 520952506 72129655 405518307 258614258 169383042 894661547 665434332 412702699 703121730 384895661 226604803 214723973 660166509 24447088 526688234 125956654 388681656 565429981 484600187 30425613 21526005 206443496 728705789 98743009 256095916 832047931 490461116 318192816 197707627 618395560 641508…
Output: 352828791428

Constraints:

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

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