CT31724

Shepherd's scrolls Reckoning

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

In the ivy courts of Vineward, Shepherd the archivist keeps careful count of the scrolls. reconcile two mismatched ledgers, 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 <= 2248; -1000000 <= a[i],k <= 1000000000.

Example 1:

Input: 74 811548855 600228177 932196930 211763820 667145128 76400985 568146240 719751499 124516079 295862772 998219715 614301103 441062553 53508751 470681455 207615579 775871335 372733511 931366154 708185509 439259438 602143558 417660840 689772090 928382230 528658403 696352374 572007421 79888230 636082118 106528331 909812507 267022530 161848962 357248639 574156330 275801647 767376314 831665666 277711500 611420550 43406776 170794928 605184479 26400130 518052270 667841256 375945640 922286556 598560346 571742601 846435301 354543315 114988694 184625881 530982287 983382743 104809323 388652515 793618456 683900327 122239685 590606300 751090826 505126158 495872893 963399829 288461815 520386952 613675422 78339240 4966833 480872483 964892192 436892527
Output: 909

Example 2:

Input: 43 56590718 244880865 644517005 367344207 885012518 168938335 709924928 807036912 20715738 922831411 600761251 711621058 80747767 8727352 480584054 355156461 847663361 931527795 60762261 371883250 284864095 848333822 326245268 25173588 550087187 42993081 341935871 496872 259764626 159882544 496297478 983585109 968312069 409521154 605681726 84855663 734537975 253543339 804801650 775647018 216081941 998838185 603860885 272792662
Output: 8

Example 3:

Input: 899 1879226569 67136919 541350189 663980181 704133305 811486573 147990226 862043821 959274306 448067563 660137807 198845295 164682913 347483370 650197817 124932212 297891748 997706508 340852433 997251859 884021099 286832928 128222711 616660072 787935251 437538720 948977633 972836891 15544696 226151527 648769897 837926937 216269467 47726584 882901805 662093563 436187967 448054321 756325285 209223033 718029308 205060326 299283972 795544903 374475822 654533365 899643825 547484974 953147251 979590899 837820703 459604430 180638952 475615295 684145772 656973087 197441523 497943073 217419600 814507730 799420757 536496062 420476328 191309690 754595943 866696279 379966800 975773716 457194300 256738650 751276230 238332097 200267113 607588197 914524576 109288207 68613785 137364033 136499216 392364087…
Output: 400028

Constraints:

2 <= n <= 2248; -1000000 <= a[i],k <= 1000000000.

Loading...
Test Cases:No test cases
No test cases available.
Shepherd's scrolls Reckoning - MEDIUM Coding Problem | CodeTikki