CT32209

The ribbons at Galeholm

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Scribe found an old ledger of ribbons in the kitchen attic at the zephyr cliffs of Galeholm. The margin notes pose a precise question. 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 <= 3630; -1000000 <= a[i],k <= 1000000000.

Example 1:

Input: 2843 1832832301 401966368 89042518 847273120 376511870 490298956 619380071 89739783 308667436 144749051 589061782 285685453 999344789 506216490 327372414 921331977 846907730 934565929 693013021 375527591 249614026 934477720 987933436 260529047 960144816 88344930 580563088 32981540 730066602 579582471 527060915 484075180 237699865 38285637 831025906 296174852 362817147 128158337 946292896 810948180 689501759 393364421 516623156 869542264 317620881 529977493 51433026 862223120 972802172 976552875 275712554 647233318 127523500 987003846 867298764 18160519 668728157 3197517 640077363 667088236 143231457 620812502 847229504 588022955 146414789 279462357 835373456 979177538 607785654 134015396 404888991 733909093 142721098 443993269 888369158 970196330 178587477 284067199 577989179 502726656 306…
Output: 3982287

Example 2:

Input: 548 175967454 286600492 509056658 731972645 298564394 459116012 739918938 820799226 62399113 28269497 286405443 633357490 417338552 957272364 164249897 730243231 534380640 131453253 954126876 100896235 798894864 213920982 980871037 480311206 831564391 276435992 258054192 921740419 410874905 775751459 171185704 860874886 407114727 547147089 534873702 956779265 905376585 968054923 131384288 222893131 686148244 474482600 383973835 311201586 589961682 268214056 982397103 399258226 96233271 397172699 342160264 65053746 110827136 323572276 181390619 670599831 35481066 794950116 146552061 988833212 97725881 673885500 628050966 976659552 890831502 64742729 718504452 421698016 828678475 232673213 177783531 502466272 87022164 150175879 22250351 959642718 852656478 245164743 48582124 772894782 562853…
Output: 2190

Example 3:

Input: 904 226413372 806391564 468761034 748354181 51927100 860840745 180946487 11711621 975404159 60056559 494698566 912804479 568345956 29199309 268712779 219478932 639089968 893386569 400590106 897873510 517135969 760020692 501146349 210540456 509580332 187719880 593141558 343666790 87728559 49810282 101589894 308610091 853972242 307634271 950548134 834489819 93741383 897405124 649005260 478769494 942694689 286481900 521606762 920514528 992917867 935086941 551846495 697669709 299002425 404976567 88213262 618423414 541533854 525110078 959919974 722603447 593641142 293568856 519136660 655892633 296585052 830690435 870612360 696624798 769984865 379858621 376522502 58634997 257850423 428196891 8194091 972901703 32643691 258774524 606182359 889704298 748909216 348755713 377460237 291829033 98136166…
Output: 12598

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The ribbons at Galeholm - MEDIUM Coding Problem | CodeTikki