CT52628

Jarl and the Obsidian segments

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Deep in the steppe camp of Horselord Plains, Jarl studies rows of segments entries. One clean number will settle the guild's oldest argument. 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 <= 2263; 1 <= a[i],k <= 1000000.

Example 1:

Input: 1518 946714 245021 929758 587305 36945 66406 734336 2577 965427 277561 518725 699443 618286 312796 332528 186111 859149 930488 678675 63604 771455 806767 754152 113225 309250 201909 852236 696951 120746 35293 357120 769913 763132 848176 298305 316441 843500 588631 478036 716240 770086 68585 631005 292077 852371 251672 659683 589369 941661 150678 47703 149601 912358 406374 281634 933921 961431 604765 454293 189882 307103 643050 227033 556247 866304 268446 619716 325892 796015 414805 862408 294728 694070 744436 844054 472414 544871 287897 848013 750236 875944 765068 343272 217995 284223 324463 109839 28597 264990 498537 454224 446684 204170 475211 652294 785359 242440 592429 316148 436583 528387 450442 398883 824776 184642 828152 366966 572745 57637 672083 157195 312704 236579 972763 801834 …
Output: 521924

Example 2:

Input: 963 35457 524208 877819 545069 605714 4651 628128 628476 858544 362301 15906 280116 649783 331392 633245 528635 727903 371475 733885 666660 868038 898233 615143 31142 591161 927637 10212 523856 296849 715839 405895 580696 510973 541060 903668 233946 484633 153093 465447 673137 252076 847211 848357 345850 365971 617564 399417 651290 547916 288000 582783 161050 538015 312719 227225 390575 820107 695193 53789 912204 274130 234576 995900 674628 800598 751928 103645 361230 359147 430109 201384 743784 210642 361996 619553 16449 946044 762367 748874 758768 341930 46992 272830 104334 519589 227279 631348 854439 909235 991649 184790 461858 338861 560059 65680 386754 784123 356317 60692 257112 448312 147406 34970 150866 213646 801157 361774 958782 760257 953529 742357 143016 82170 374257 21970 14065…
Output: 429

Example 3:

Input: 1043 1550622 9805 447877 969248 547749 160565 744854 831129 838381 936451 900012 171527 774601 462866 914651 117750 739319 667238 260092 291889 70719 82548 119066 819776 231126 19480 325745 201026 676157 211036 359740 220940 721995 607550 258511 625166 419316 142805 960801 599865 212232 288541 707558 696805 766388 5877 34546 506478 19670 716035 618347 947656 996145 960894 927116 969736 369207 107283 128792 49136 767952 287469 624861 298258 129587 37563 257747 481792 350932 810767 874419 203489 952124 844075 999946 837530 474083 661787 842312 284700 746059 903455 95065 506989 580858 821282 372127 190891 546156 532382 496227 298230 19519 127634 569281 648926 908366 684203 554299 63720 368048 307280 139145 437981 474000 367658 136244 280889 916676 305206 439970 388549 598592 64326 180692 3136…
Output: 494622

Constraints:

2 <= n <= 2263; 1 <= a[i],k <= 1000000.

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