CT39970

The ribbons at Rootwater

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Before the gates of the mangrove channels of Rootwater close for winter, Dante must finish the ribbons ledger - one figure at a time. 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 <= 2678; 0 <= a[i],k <= 1000000000.

Example 1:

Input: 581 1765600597 341137164 443132893 552689712 360554669 796770029 592105791 49433695 622275249 583278174 112790507 63771855 400617788 745081704 984500087 914708500 205891108 607532800 751010382 801347322 256254898 517069239 790273993 587004743 1248200 110593668 275392357 699619585 925964419 308178068 729603317 839864865 573036498 576297697 44290835 893347429 11827909 290777852 815255646 207720166 648678919 844409864 89066469 592877466 150688506 77252924 487318645 825996733 964372301 698667909 834971706 304475633 475633063 817941475 485958881 532271535 187823224 90246688 485251413 623017381 388280539 944993673 536079573 217875428 122515603 825821974 44750721 460553344 203734006 172975046 293937951 97181855 404452571 224118080 420124846 75118484 427650476 209513520 259150143 19287647 47545033…
Output: 164144

Example 2:

Input: 386 1369954101 941461195 953963258 525506393 583164042 446666646 416061100 467432811 4236289 13948430 813528321 946254349 532999059 515915697 937459319 241795579 638084880 611642221 316556019 317403354 929430886 156820804 658546789 327620076 724203781 184854056 743518775 608327991 553150118 775450067 156035533 60223079 845065538 407052296 502492863 454977032 429388259 184073313 948745816 469694190 32780471 266126066 894086072 63123323 335958174 93719248 563687639 929284563 321274487 881174744 654389178 826781336 891747493 833045969 739874512 507643140 698819662 261566712 593042995 600495664 132684264 380462283 918358403 837285531 685439007 394113575 422244743 734913171 906363458 653815363 249394061 285206848 644245387 454389330 571247846 261072440 287730236 604144681 348675294 617953719 72…
Output: 59742

Example 3:

Input: 2455 83473456 195981328 450229512 185520521 259868850 370386861 666196633 693506152 149482466 735613957 902402358 240220120 93956003 985666836 725745151 108897824 981894000 737502172 292594340 224302001 250959770 594070994 550835614 792961327 952647207 783160106 439861002 285907635 884518790 677049439 901105750 799243744 867741794 387699919 186135028 691815385 801169235 841674055 918276871 643539260 174820071 690197144 659210129 635092330 664302044 625622566 709563695 411530819 346564947 683559587 308763671 43303557 89548318 373758376 446882612 241223660 541316070 127561649 432424379 537325440 545653032 406540575 258831105 643292595 143044174 344598910 522697211 69133992 345647390 460116239 749319069 228159775 956499872 522952515 396365643 581357326 957608453 995469852 208009548 242894644 …
Output: 9902

Constraints:

2 <= n <= 2678; 0 <= a[i],k <= 1000000000.

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