CT54539

Notary's Frugal Pairs Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the fox den of Rustwood as Notary unrolls the day's manifest of stretches. 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 <= 2077; 0 <= a[i],k <= 1000000.

Example 1:

Input: 470 924744 260409 936127 130055 811732 892582 137544 965330 494391 136658 257239 872786 751562 812714 142431 274898 90173 332861 449143 975289 286990 659385 144468 123048 137474 44648 811024 35851 941095 357451 794224 559259 47851 794746 480011 85069 639052 788366 858669 914553 975271 38581 714709 649371 945155 947842 618973 895112 203750 888745 948116 848783 813972 757420 143301 897650 477906 215739 582494 874035 925361 9108 12951 689080 183526 965906 197488 303463 611501 505317 192983 965284 60233 630991 698474 262539 201515 538611 889649 103894 668157 501572 587746 524349 33040 616790 210978 150144 463579 212646 144681 701885 687328 707826 434797 523185 165890 100407 656051 218049 172323 382665 820053 153184 505884 5188 521500 400929 311173 449724 975257 125765 42570 192161 751761 94951…
Output: 48215

Example 2:

Input: 769 107541 817026 322727 534967 808777 191325 488368 125991 72983 244514 419478 74009 126003 911679 10811 807160 186297 353820 159317 170518 50915 824396 622170 973947 611773 60887 969256 930341 455095 730737 894135 955495 23748 818676 801702 210906 39552 776461 661328 29282 713637 397748 312579 529205 150326 657639 465947 886701 470050 777829 727703 697616 978095 839710 224549 146924 52621 133281 341989 851683 827342 12364 169994 523869 417524 964923 375491 686854 546275 135359 8032 113090 34180 469886 382488 329350 938736 260584 763945 995769 325229 19387 929354 155616 349496 177444 321065 743418 574853 290815 636403 378125 883066 881065 763634 484863 350450 789136 408873 292179 538513 421405 654354 531405 277517 127609 234841 774229 645511 342537 610143 97628 964868 972069 240366 236187…
Output: 1668

Example 3:

Input: 881 311633 119019 69114 616135 226541 544125 672668 214819 116422 5857 763075 609661 47434 558979 777685 915485 606821 666598 741230 961225 698177 749707 994452 459332 886719 565418 745533 905786 295348 907562 531982 839709 609442 205920 461937 103890 910365 17815 680163 800127 304127 479661 688497 175325 662095 485293 240068 105647 143163 547131 498759 150054 177829 492974 604271 877363 201992 42560 806948 98655 300326 498398 34092 75896 304906 192179 856736 831063 607323 152649 363567 570499 523501 358900 404188 179879 40890 951734 662297 475455 790353 28015 12332 705873 568491 980575 711061 489565 766555 197381 376304 360609 301396 214841 11245 391033 861672 440049 990541 780535 470854 815320 493917 78746 636665 197094 128014 752459 680487 235994 478070 356777 268499 685344 753464 26784…
Output: 24737

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Notary's Frugal Pairs Ledger - MEDIUM Coding Problem | CodeTikki