CT46858

Zephyr's Roving windows

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Zephyr inherited the kiln at the lantern lake of Firefly Mere along with its curious bookkeeping system for windows. Time to make sense of it. Task: Print the number of index pairs (i,j), i<j, with a[i]+a[j] <= k. Input format: First line: n and k. Second line: n integers. Output format: Print the pair count (fits 64-bit). Constraints: 2 <= n <= 2804; 1 <= a[i],k <= 1000000.

Example 1:

Input: 1005 48289 741467 671282 466617 559086 263942 448632 580039 911533 418103 241207 283268 220821 519712 401996 67555 456352 610152 804548 893634 520731 581826 54236 958137 602374 200107 197647 663779 735246 605547 725105 826756 736269 287010 967153 390597 844895 364759 913980 245522 721269 564055 833648 714908 20895 812775 930570 446468 904675 785341 202371 891664 7657 788693 761492 588385 974191 487741 856542 839642 283708 845321 704154 112196 102211 196022 97896 110208 46557 897070 201868 188053 922416 171796 90060 237205 92153 77174 940352 135039 662193 646071 48897 257033 715945 871806 526804 521425 709756 970886 881249 233063 279555 287929 470115 430926 216109 471486 345493 510791 171268 708529 460716 596910 712944 955168 212253 457134 482012 467787 889663 442273 842424 177303 64673 311…
Output: 606

Example 2:

Input: 1414 555046 244397 295350 63914 569728 735121 550058 460768 338531 796362 682497 945615 389500 57588 261892 375618 676232 257438 47161 142529 840053 505499 826551 433517 154790 673143 911995 780739 657569 544559 345612 461759 755905 731609 488001 892811 13769 147105 886494 431328 835214 82153 323737 733000 594484 103735 835964 759265 220087 87257 784514 16666 259651 460604 420659 5857 965621 558901 440856 649342 800989 815453 675235 170733 402922 525423 699766 684949 191863 297844 815956 81205 491692 178647 267599 569841 58754 140951 689886 15286 430689 765729 881109 238545 97245 398485 76080 633846 584616 567401 3146 997043 406544 474315 186824 645509 41689 284347 600017 917645 311323 203690 846255 335569 275841 634198 226279 375519 589935 239869 997390 194103 18930 451590 529533 21161 66…
Output: 173967

Example 3:

Input: 2483 106991 81104 570331 954855 187870 624205 726176 422184 975706 786113 199847 563644 669300 855674 558806 671129 324748 812255 227566 361154 812337 912921 901486 576706 516335 299237 596466 390303 124713 922599 454526 735674 867701 339824 533418 450331 850071 452587 34930 620850 417209 700511 54030 824142 465482 729223 972458 497021 289677 831516 121746 655338 552963 144564 2313 27096 882029 172380 898865 804224 451846 671356 636716 422678 605069 907334 799178 299300 303502 151121 761720 41307 581798 243451 957177 145026 510600 923419 278699 908667 944352 170684 204188 522808 123775 891865 791668 269546 573656 317406 716238 58624 41795 414489 67304 743954 191695 209725 408491 849445 449693 832465 490631 398681 760407 418074 621188 625690 645059 90972 486476 88266 810679 420575 229156 14…
Output: 22197

Constraints:

2 <= n <= 2804; 1 <= a[i],k <= 1000000.

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