CT31955

Navigator's Ledger of stretches

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The council of the northern keep of Frostgate pays by the answer, and Navigator intends to earn it. First: the full register of stretches. 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 <= 1090; 1 <= a[i],k <= 1000000000.

Example 1:

Input: 201 1482653349 650408748 912929912 752187789 754209172 605360715 863146752 638899036 836024633 343843057 924755771 983725000 126485961 153918851 897756549 13606013 55875357 497573273 486723989 171926457 557293990 749984207 494965513 246420116 436687924 944005784 783044835 928144206 248235156 497016816 251566119 749140381 908503160 596822615 469137874 690150067 451265097 294301014 469374337 653749085 253391337 862264229 573037940 198114814 268049577 725853530 114293953 593249527 114349516 396570940 306923296 211305852 460568003 109529908 639684297 376849882 369268820 52857871 931349389 739313764 805199047 77323128 842144166 352812024 108569757 629791353 708868676 784737625 202767599 956558105 900727503 940189187 145478224 348410171 986951295 984987395 94054635 205983819 311507778 827805939 …
Output: 17776

Example 2:

Input: 289 1648336049 704356220 561262560 204185783 188068745 618908404 724270383 68480876 167026032 392397599 695621602 784257121 959659438 194478590 371770990 189929544 294002129 921004607 907418810 926150260 714330881 569358251 855508913 9264336 796332430 690377569 275440700 867560887 118634977 913252030 876661504 502102920 721320558 349361432 814969082 897526734 131925552 48296978 387724540 353116332 940801819 77865492 464060074 41187207 202159247 881751101 567344012 143951246 982845111 338696665 75408452 237860203 200001032 448190160 443334541 130863142 661640691 829893718 638165768 485637481 561146393 546774993 526965144 513251270 601239646 465160406 248231004 702342079 82927043 373918551 917084325 678639532 509911376 416805534 160390508 466891284 410717837 149467187 991985513 819196999 286…
Output: 38663

Example 3:

Input: 546 1009149929 355151214 326163339 941826289 350288634 70251720 986919645 626442991 693349737 515532794 76638259 806418381 318293581 747256922 965719709 897066201 245418456 376422934 401189535 39380526 760292231 855784837 537339811 708211077 886121003 687926607 291367917 687420617 572672503 617176205 827599253 762070792 873813509 322489176 487912289 90714274 172442686 510146087 818364574 408102788 448113110 563128763 968242703 755991149 411982658 388157420 157461867 223754679 482803449 854294218 887407882 151511063 907145849 674792799 659107231 318246009 185608432 923029939 62680911 898755876 12790782 545328737 541550667 375728450 107368192 723325803 126716967 466817095 715734977 152053360 318613968 453751427 197266206 773166479 846456723 381469548 481748253 994304071 697868978 55439314 65…
Output: 73248

Constraints:

2 <= n <= 1090; 1 <= a[i],k <= 1000000000.

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