CT44126

Copper scrolls Frugal Pairs

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the peat bogs of Mossgrieve as Vesper unrolls the day's manifest of scrolls. The tally will decide the next shipment. 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 <= 3669; 1 <= a[i],k <= 1000000000.

Example 1:

Input: 1710 919544212 112904265 699172300 353090609 105942007 657615327 58774576 984864586 315281997 331138994 22091159 927298459 759729071 780208331 472584414 379175639 693472908 632377368 770104608 431038660 70151016 309198398 466973176 755127479 871796710 844185075 414076237 568515800 954250174 589975756 922511298 814427858 460084340 579699415 607054427 884334521 438403685 696885977 658902401 683241111 529399596 760752543 953774844 622476993 607379819 742661909 862851107 238754822 62650172 878526237 696328187 253106187 226857492 208700599 981001412 840256275 849624766 151791516 429029551 544501664 229467588 936799576 337985832 677255802 419678826 437297078 490947267 529220446 77573707 947011637 822424091 79906770 156714967 101295542 663716931 978655119 237128301 968094818 757923775 149462816 3…
Output: 595419

Example 2:

Input: 2946 1057849401 406183199 782031110 146311100 272892809 694416263 420930518 443687808 871761225 641682479 296813662 118093545 705772511 646174897 328619287 823062965 463636672 788668982 855378011 158534799 451556282 471811115 369851198 404435445 480515700 129588955 366292721 989058663 276710733 536554155 900433791 822689056 81575529 877130942 288749562 341096069 93803279 253227265 693406174 39357751 737834895 160080239 510150621 655490082 631932892 676536792 4769330 111791594 490912559 239659028 803754102 283078814 281040189 63897563 557950039 892885070 619201277 543239404 517455516 985413054 197157085 262238961 347239335 753352768 90354193 770110037 256949006 518944595 608526471 317513270 599485890 838178823 11548922 874247545 459517096 678111381 11080064 609940148 907608898 410228273 298…
Output: 2367389

Example 3:

Input: 1743 1844008894 516220133 787059333 265468862 93071071 259300350 415371557 853424130 744082114 351247541 786495581 798160186 671585106 188658088 817650514 346112214 374110180 445535414 134984131 652613192 309047758 765448739 489394999 59561844 113655208 445386186 867669808 782944344 487810390 601009308 45151648 243580583 960759287 906801167 968053947 22393819 987917090 299510424 876377376 274156031 850687710 396132160 390407821 954262833 101940 551552425 364298420 417295065 243749598 27037209 877793676 446350592 364320642 938565657 341710797 628568633 422941113 366411178 111577400 129976201 367177264 145162744 940662291 493663115 798321984 961593552 19828207 118263315 670892489 523440077 723401923 494457139 214742486 196838276 523828956 608217271 350620931 514338391 850862363 621812640 357…
Output: 1496929

Constraints:

2 <= n <= 3669; 1 <= a[i],k <= 1000000000.

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