CT34296

The segments at Keelwind

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

At the shipyard of Keelwind, Botanist records each segments in a worn leather ledger. The guild wants answers, not guesses. 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 <= 2288; 1 <= a[i],k <= 1000000000.

Example 1:

Input: 755 168925253 846749163 459762451 604771969 122433321 50035023 209440732 394114967 840701082 669996598 682805936 729077748 284332437 798880726 478402071 725900972 287907269 380756063 768665628 990859588 169591134 526599291 661294541 779117823 978299003 689215400 418648448 271243648 601604624 331565145 11411463 567699624 625356150 494848589 11891526 125667469 848315267 639416609 249358303 617452680 345296675 654896342 852515251 703822837 207978221 501571310 882116073 427626212 588738833 898364323 280310880 179116746 489638453 477619503 232922186 100611556 564046136 938336195 288395474 540554870 417658081 117683842 871218906 812227145 798634665 877365211 874260537 686611455 972948121 419643951 263818583 38307438 733300399 574947489 488325454 562495391 233135279 364740808 720225008 230292577 …
Output: 3229

Example 2:

Input: 1190 1529100258 671925850 857300916 992237067 749272667 432496758 96162904 997572190 47874957 390456799 264823953 407554103 314097491 596015096 666665753 765912238 474516174 172820980 624748094 247803581 256226344 252367063 582186020 833236160 831118013 264467969 883669821 623830600 693852265 457695429 87465908 197452755 993611337 485675055 313783780 452047373 610045382 49204830 572016346 598544129 507616875 84738068 870096644 576588075 542523379 892865870 84063715 433054430 534975513 382291801 178483005 487903943 158494663 45414898 869783151 781485385 275107140 17677404 806294955 241916499 60560751 701430905 742590777 559839339 960754337 994213607 761299829 673305762 592852330 32280800 240764197 64756109 352065097 633583126 356857648 522551 199135480 814512990 93040097 706359173 83490793 …
Output: 625514

Example 3:

Input: 1605 752981182 289315498 590849694 150042884 547209122 458657808 961170346 89681958 689182281 368587532 268597993 659471518 436793232 961674582 100933861 662457837 956207726 541579279 221016271 242653773 383748864 445712832 920823497 471123126 466397223 898337660 570602813 331652697 905376703 637686360 653897110 642027569 118144599 831660371 344746629 37641182 394214417 530889344 476998788 85170081 143388983 264815165 88725165 53217577 350022129 248823889 378466870 970147414 781445734 897647257 530218473 647465102 165875080 242080237 285254577 377630587 705161966 750779999 580511734 595946645 46514752 900928121 662699620 773633768 396969062 768140669 33529172 979890846 795067760 993380960 59156033 550700686 297750836 579830896 926472946 21275613 339182800 237340971 394931339 37066248 86969…
Output: 364666

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.