CT33609

The windows at Crosswater

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The harbor bell rings at the ferry landing of Crosswater; Lothar weighs the day's windows manifests and starts the calculations. 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 <= 2441; 0 <= a[i],k <= 1000000.

Example 1:

Input: 397 1645778 40974 376578 259422 361291 5918 319773 905711 849357 477791 253911 186992 436230 126104 75588 811397 71729 605170 728659 308589 822012 514371 183016 508462 99642 673007 908737 661133 439897 974304 311601 854155 675211 941588 818259 23670 347548 70365 921276 483604 624484 456940 898128 738429 893238 379486 121448 283646 657857 689907 202086 189018 628445 84055 199305 338951 121842 490453 668807 1786 931587 31127 672318 932137 856811 419110 412720 220241 19273 469394 40926 492794 209888 241319 591984 308900 165813 594587 397146 220486 406512 820734 764272 933081 203604 418858 205532 633963 368643 613495 174610 707018 715442 434265 466408 768471 398611 864680 349925 239725 471185 242076 795508 110130 30368 508035 40529 109711 740604 978595 350994 882766 488153 172477 564153 647025…
Output: 74509

Example 2:

Input: 400 46289 393364 132788 988040 263549 862620 56663 263096 448001 60944 145280 303793 489708 816265 171660 183255 317219 387244 460283 379388 793558 505508 912325 708658 402505 240879 376321 432851 602770 390789 93285 547153 621375 528174 342727 810338 555671 60703 158515 277821 518055 234672 610175 235367 589470 387244 718071 937213 236610 20922 950057 908210 128415 772063 126059 454688 792169 100101 7806 322717 184825 938900 861636 705077 633977 65417 501028 395657 285162 823542 980236 955462 776642 29732 727190 366833 751552 308007 199926 81420 622897 46396 944934 222385 254903 267731 137427 261582 870256 405469 142256 18283 567818 11761 807214 425377 31397 42229 135951 557477 720593 787211 321720 993168 323671 533321 773828 848907 700858 429534 641775 769661 320155 405939 18439 461243 5…
Output: 111

Example 3:

Input: 758 727278 130180 573359 413248 962612 898707 437884 806599 936151 437409 574491 414162 149612 256044 291342 166060 813637 520532 841979 541224 337861 294546 584038 240585 341881 795235 531319 161083 940542 536548 824243 495827 505257 8899 56962 316905 302828 160816 953993 647830 820141 164142 816916 822581 46536 574156 919230 324278 476446 292765 622703 703977 32668 219367 228625 166407 96400 271526 448556 843713 348826 542323 341645 997028 426950 901201 821170 897549 572964 579704 913430 985456 849801 392198 518016 851400 356840 554464 822392 585067 36564 422396 177462 773713 129624 870938 366853 467567 456863 943694 328267 664475 13235 569337 189571 889168 670759 654667 522144 56123 842634 706615 720880 386847 773505 707328 751294 858679 116818 147435 413443 873085 916816 452658 815495 …
Output: 79474

Constraints:

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

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