CT50120

Urmila Counts the segments

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

In the seal rocks of Barking Cove, Urmila the store warden keeps careful count of the segments. Price the new merchandise line, every figure matters. 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 <= 3866; 0 <= a[i],k <= 1000000000.

Example 1:

Input: 2581 1298560123 675277482 809767838 947790084 230754796 787369218 205705848 772077824 92501570 420781364 930127102 758670785 328741432 709414542 622450263 455151094 773510131 496644145 589318074 93582435 671832387 284914385 263950825 348388273 941163454 370508278 493248163 321224940 729824000 278002775 23137751 763900518 436104257 724126551 481356062 744768027 806582289 144753790 949733100 329517577 687372714 94332580 198681624 241809272 304640195 954369792 188667222 836536023 418635729 245868679 425169538 407036474 792858568 149452805 77515506 984873170 764953709 409609723 808633539 751925359 677710301 20870084 734352738 523790457 272201285 173991416 611556944 4471749 440218242 637903854 382944565 438166397 723908763 255884380 993905388 883371118 155681632 699937126 510348118 141774067 46…
Output: 2505016

Example 2:

Input: 3759 1117939879 477610848 970600386 959186552 22616342 324705457 677559227 791171267 375009409 835274331 223160717 834884935 750354673 703839098 922068027 951860094 173958455 343173598 404409400 65030594 210684162 813447363 745130467 584410732 532645747 37774299 299880783 842576946 487475786 611032512 80697813 567829642 111722069 675286888 858000640 870506518 899621864 220083979 844209741 697681243 289539890 423010980 202619968 652438529 757191130 116925585 732372174 915475069 970870950 244432229 420466484 678867913 840226689 949743376 210234101 409866644 929085966 429658950 995274706 327182294 203820690 505429493 668160651 597489350 673755665 209022806 12397498 666265533 39423743 637580762 868987063 755113764 422938302 875824433 37445569 974028664 252310105 89580968 518871607 846463295 76…
Output: 4388061

Example 3:

Input: 693 1055172456 165796495 247385437 951615734 561870774 65735350 102539226 615987752 360155188 707097009 523060884 133909378 862857577 212725655 930570524 312546986 397806713 185743288 700733354 867715345 393121322 39385357 68736519 410770948 394635873 51175981 476113997 726110917 273721942 664955926 417230284 151325945 973034958 275524900 238600991 966460788 396234581 391650510 629382493 45119469 510242179 319570300 573333635 767128676 255196867 307890877 553138898 871536166 713372715 16789609 325319640 79086213 295263628 546756870 610138226 604632811 63538117 433988856 96564029 86508917 938222213 707827442 294665764 116691791 54829719 234533021 510742712 144380340 188940191 281814238 831018219 213115899 58093372 147160217 6983458 652502037 8013070 535707577 797602155 596813713 515609950 2…
Output: 143353

Constraints:

2 <= n <= 3866; 0 <= a[i],k <= 1000000000.

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