CT45924

Arjun's Ledger of segments

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Before the gates of the ivy courts of Vineward close for winter, Arjun must finish the segments ledger - one figure at a time. 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 <= 2409; 1 <= a[i],k <= 1000000.

Example 1:

Input: 1611 1580189 436722 690989 216201 945589 247120 60011 573774 458733 527452 567664 834909 703642 113201 257624 656420 196533 209493 314670 161336 234243 963399 317471 542419 713446 210483 915762 744947 387529 947676 151300 452329 919040 730761 430425 351026 587707 528600 167091 481450 747304 924156 842791 996092 353037 746086 779731 522608 167935 470917 60289 429532 865329 894485 878289 10305 537585 478190 17648 867515 823126 245709 9324 57704 987146 57683 531830 302551 25777 776891 617543 103960 208911 731771 556591 379447 102298 937069 854796 599172 243416 406777 282068 91891 140157 717026 734450 405850 443789 685519 169651 551027 550077 310707 2481 229290 393609 694017 643814 173501 750407 617126 594544 12624 503607 853730 105451 332265 463146 395104 257519 239556 285657 101193 817011 98…
Output: 1180326

Example 2:

Input: 258 1537175 192268 481706 131148 918795 677214 493787 999462 981848 972632 752963 90096 998991 992750 135830 658936 768905 234608 357140 886950 53908 837396 66419 961692 889113 820652 660650 858199 748680 387378 159929 500649 167988 953346 52026 195737 160043 917684 890689 623378 356718 436485 767951 510897 953540 36534 53425 400920 698584 69946 114442 36588 568771 554829 526937 765708 189453 266267 249215 554927 879836 634427 383754 899395 480207 777071 533298 823641 972701 292542 290334 443964 710205 471176 25126 622927 560229 72163 728602 126878 354139 511275 456696 43376 244673 403377 924863 944764 374896 645994 944494 783828 890118 352484 215518 752518 969884 917296 608664 269522 297952 347811 522735 255041 827634 546626 521269 409157 541754 424765 986577 122174 326789 988328 119067 9…
Output: 28947

Example 3:

Input: 553 438849 838122 634242 99302 320672 396639 119778 128095 481146 487511 590786 520375 560421 430291 139752 898746 504502 505315 472246 835697 683174 517037 926415 607432 225187 924072 206656 111161 250716 421957 189767 834825 193017 431348 607958 558627 388124 40721 128837 606586 346624 706487 469489 872003 677637 715959 943485 134760 962407 211024 478899 286103 624265 635682 990572 255666 211054 408975 881766 54204 104371 771003 114795 553845 689282 403422 893151 947513 589921 968421 956972 905801 120620 737347 623718 509914 14290 20793 392040 749924 922548 335264 635946 83609 397252 528888 914046 761999 598928 108454 512696 588050 891024 749373 948316 878490 371670 279652 329401 669754 105162 307040 30489 473470 668098 376474 136788 616580 543650 27792 220598 711717 553295 725243 182760…
Output: 13917

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Arjun's Ledger of segments - MEDIUM Coding Problem | CodeTikki