CT38276

The Frugal Pairs Beneath Whitesnow

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Gail runs the dairy at the tundra station of Whitesnow. Today the books show a list of stretches, and the numbers must be worked out before sundown. 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 <= 2552; 0 <= a[i],k <= 1000000000.

Example 1:

Input: 1860 1571497707 584345999 730531198 426209856 23180806 406534076 387522807 939603182 81493809 729493776 735196323 219199053 67056613 194951921 248274094 490432901 202795762 691204370 393041549 779597856 929290602 748967457 124581335 804409300 702825916 847858625 884676381 747881020 784706154 373827932 772392008 531434652 68910895 987748590 219533396 966720116 86626626 95495855 218525795 78594229 85142734 667336717 914187638 334287605 786529890 234525510 566818473 893130526 789860442 139981779 27588906 93371437 877145793 221873982 791366693 441512907 536803120 300862116 170215256 305018162 316131735 181866204 980056923 347659018 117693840 555324060 769819513 911698306 136282794 137735263 390777402 907818147 962280268 859356058 909770231 423971980 100670836 935153479 677223983 524928821 8994…
Output: 1559795

Example 2:

Input: 111 1268777052 897898758 746250331 969980160 724459853 886931676 890166031 968780865 300280512 261221343 492918206 374418594 640461878 450123142 136685730 280830925 278474382 188486687 139373225 791089225 891084895 784384761 326140566 315318993 814885141 285372350 468822535 25554755 658857714 734920658 211348584 135176310 788278333 373348455 207006456 81336012 736008556 421884272 882804925 579965711 592132591 851488432 421050281 98326729 642357784 351093898 726277072 20126699 759089288 875757606 861674825 30141974 12400748 988951279 162202679 812753164 363745917 717971264 486582082 572388388 776774430 49254568 382282200 13687700 293893779 62043144 617234683 771613054 132400000 395179432 105759981 94759879 397463191 927464052 466736991 752246357 281415189 478896032 810685818 833641696 81828…
Output: 4516

Example 3:

Input: 922 1964793649 373203371 214986585 530890896 349151179 544368899 116755319 953503561 604747502 671079718 205387994 573316793 66005426 857177111 61725761 84498304 924340506 988477083 904512626 539622818 907674665 376327698 38244919 392963542 112336881 360208832 714884296 104313708 638159492 463646178 166203757 493140435 737063824 438253525 867128583 864794287 378394766 220152085 114949776 704088750 574343723 569153042 306140355 279395633 624084384 410982843 506972967 583237041 416293232 241514350 263805656 271488040 843390524 742403689 889104837 275901524 707950919 715874265 293607722 360552236 58275695 224998228 915072041 852643034 475125828 48360381 929485491 790032822 703478701 478853798 730229858 468827204 942032388 633975776 747073454 444907479 853010010 32020851 525026822 338022766 79…
Output: 424272

Constraints:

2 <= n <= 2552; 0 <= a[i],k <= 1000000000.

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