CT37057

The Frugal Pairs of the Northern windows

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the snowberry thicket of Winterholt pays by the answer, and Wasim intends to earn it. First: the full register of windows. 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 <= 2980; 0 <= a[i],k <= 1000000.

Example 1:

Input: 2359 1106024 67652 615531 719861 654687 238557 461038 87816 568839 87794 149042 154172 935228 412590 750392 513351 475015 135378 776109 146901 181518 290371 426516 55235 117129 832383 323887 853352 807646 662793 844442 28898 172603 439179 717563 352397 50262 562895 873083 646152 106796 325843 633891 884647 536892 100546 421010 476243 161179 198168 177802 101255 246703 696133 140999 571596 900761 54711 481467 819426 211316 114757 636736 128524 236981 126884 159184 244870 647556 325006 243934 790881 945631 604278 345073 277023 138553 52031 333474 129717 716449 433524 853441 151879 686398 38980 855417 506486 954310 109567 779550 497016 829684 123581 703612 31086 118212 267082 382584 914933 993544 190327 98192 298195 932819 783221 606251 626250 59698 328777 696114 17156 261340 231295 244162 46…
Output: 1696746

Example 2:

Input: 2792 800930 935763 359470 742473 459147 745318 908737 245679 204848 19128 136595 67992 267263 552480 610866 670103 524219 546652 480167 498645 430355 521771 985214 250573 764649 934793 458077 105096 166786 449255 714520 883419 25073 802543 158813 290744 209397 783251 19869 833009 581200 747529 404836 38559 836908 18909 900483 750749 707135 710539 313800 695911 734330 155307 567978 23656 678803 886439 920286 583178 755618 608922 778263 107714 98819 40079 726622 668028 270122 375232 212540 823303 54081 532109 933320 888112 60720 569184 96755 5100 993492 216832 201819 720276 405996 64188 594569 406187 264105 822101 497069 100295 41204 673333 749782 280163 604626 361994 773835 463112 625041 725841 435063 950977 875017 463379 24076 24876 599160 189874 784373 330351 874232 937534 27361 987839 80…
Output: 1268102

Example 3:

Input: 2352 1958813 879567 549232 934212 31127 726123 144346 179576 230134 489687 325317 927232 394415 627581 769811 870748 438469 172533 641795 766452 561588 281630 491178 556552 98115 114643 101847 340483 848570 854542 584031 48515 69085 896961 801047 457682 276395 476073 91543 258740 999437 414958 773025 284773 683434 292889 931079 575560 635656 608363 256161 516505 125056 240660 804936 137025 364346 927112 918626 367738 906575 924854 392272 576923 657700 799559 230716 981926 470925 346665 639391 393439 590767 270524 275613 284890 517592 868166 549285 721926 516289 172422 925606 862967 653196 725411 877600 645589 736620 960594 41176 112925 295171 160002 553880 297853 44064 648035 642492 132480 997343 58010 498897 932962 930751 475034 414197 969512 717685 741197 132614 229197 597262 869521 8992…
Output: 2761690

Constraints:

2 <= n <= 2980; 0 <= a[i],k <= 1000000.

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