CT39399

The Frugal Pairs of Stillwater

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the crane marshes of Stillwater as Orin unrolls the day's manifest of panels. 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 <= 1967; -1000000 <= a[i],k <= 1000000000.

Example 1:

Input: 303 1663057593 387461750 895970826 846628536 869943507 224909212 798059829 549137624 581894796 137973438 657567496 732387419 117018333 518548914 508865962 730657855 49378544 986037383 225832657 201317541 882629977 743203369 448507175 267993800 507872887 598486017 201808248 994149112 79631799 696380963 408784596 153067505 494273933 592481996 501387390 331611319 137988375 619324084 147000852 751563604 933605288 707118134 518028917 804446031 841571485 280625731 899279302 350600773 22975703 16254622 462004138 429177139 664126878 726339579 433812869 277615277 321168132 270330303 235764137 680804707 334709570 544256115 36950952 204492822 176267813 95103469 345417 48519315 397829039 778847353 940825787 11554711 632987172 558012011 402749526 245841707 871173338 812763466 981636227 721393181 918152…
Output: 42876

Example 2:

Input: 1667 1473411926 619121011 3583781 998370361 7477939 776265158 585753874 181030218 997255591 713837149 729642256 196116222 990789026 816958235 861008062 801128469 446761633 577231197 687526966 1174785 165555552 303518118 100155926 606286832 171490497 804141771 222961061 225275493 838109748 291352058 768823045 237182589 888879009 856882263 386885867 320508511 253855187 878145081 676111337 633774161 781100993 619427844 993880407 661348738 569353510 23238850 688603383 182791564 941215639 249021243 585732391 821863944 851577513 474641277 265525504 312520488 229235226 321409217 878409624 256320892 284423446 73316526 661892057 130304055 334942852 138657482 371130851 964105864 320077363 994903778 887419468 996808593 764125894 745677381 156745341 831834074 689111302 15254349 144734752 656108614 304…
Output: 1208095

Example 3:

Input: 1959 948637438 112601282 552402667 591657539 531820747 224303362 737269594 399888041 98449479 104279889 879269238 275136381 112715898 53973224 185059933 261512243 356296630 256009654 961421865 893048646 384708695 908140672 292253703 264368593 799197283 985589554 41339319 447790827 483581188 396362663 684455986 825759820 628806166 599616562 96923518 235085688 564083939 12971314 316444814 634441619 840248308 30616677 401079643 294270450 767039041 21586460 684263895 952582567 969333453 520101681 812622511 705567865 107311597 202750534 457487101 671028639 445767287 351310605 385488915 670374167 739940165 160903439 263040582 73043553 291302661 551612364 781755655 970271494 918146177 307920006 75503727 969926024 788429818 826388955 27347666 318956280 980535773 18659712 232111686 22154260 6293606…
Output: 871049

Constraints:

2 <= n <= 1967; -1000000 <= a[i],k <= 1000000000.

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