CT30847

Orin's Topaz Ledger

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Every season at the frontier camp of Duskwood, someone must schedule the next expedition. This year the task falls to Orin, armed only with the stretches register. 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 <= 3616; 1 <= a[i],k <= 1000000.

Example 1:

Input: 3047 751490 585128 857105 153505 748307 583428 598261 576968 957692 2640 375480 824747 485539 814810 194890 92899 820263 691063 455458 562301 665151 922451 775687 399909 156879 963739 863663 877754 77017 99637 346471 400364 959528 477898 347010 837872 971124 606012 96316 565625 527185 449914 22071 993043 788903 984089 265957 454346 450949 14658 970152 619214 866672 125626 626146 405414 567987 256059 321516 140741 424929 799706 790582 466170 184266 472792 892828 559809 323827 810668 705625 722821 493984 49997 803623 998156 329577 696840 188877 760261 499813 17967 298270 479331 519316 996167 725508 210184 517922 764090 232861 247045 52226 267946 338228 679354 527449 31863 145236 709722 244557 905940 188144 396563 251066 505955 497228 631409 226364 653822 569496 523136 884544 696672 13460 102…
Output: 1360794

Example 2:

Input: 1937 1743364 891038 448392 803968 695823 696770 256489 420636 133594 639134 389507 348157 137876 91804 91618 20980 880547 218137 642926 452710 140674 769243 483601 740924 392308 157302 827522 702304 461444 805626 198094 64857 132350 558291 577047 152204 853774 534756 31068 651348 667895 810945 852563 658557 277089 85369 1460 732842 794190 332574 910705 120392 127709 960375 79721 473332 386940 528110 97417 634575 673521 565742 64713 285658 558724 472220 333428 997324 179322 658365 140394 749364 113961 11665 667707 443859 980976 541204 8905 174138 354714 252645 522421 125542 127239 862874 851267 480002 702049 606553 667135 190529 498622 924800 684454 329680 252170 236010 177380 507534 140681 893231 221142 389202 595837 355740 782087 116757 604548 42283 875898 432522 686334 233408 886927 3025…
Output: 1826455

Example 3:

Input: 565 1605070 884895 201326 334764 328704 126330 732579 408569 471944 951220 805663 682547 448155 90044 607183 170136 227897 854489 754524 818383 796254 616709 92460 827365 72025 547126 788714 452834 927636 567485 844408 908960 619815 54657 978704 658456 476605 504971 799400 590731 896495 573377 343491 836112 453488 200680 772759 334012 270716 716323 703924 844488 239584 466239 978250 625318 521029 283564 393576 85405 84232 62648 490084 130730 962168 866422 548053 977898 54135 750438 308295 508424 35602 630435 228074 697546 550298 735354 752474 551518 632363 252235 476217 81560 673769 64164 133815 132097 103078 527254 749284 454535 612156 613854 914701 207941 426744 316646 737622 434445 356394 977138 595517 658809 239308 973829 385730 808977 182426 512344 276070 534774 792966 180558 899417 8…
Output: 147496

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Orin's Topaz Ledger - MEDIUM Coding Problem | CodeTikki