CT43944

Nila's windows Reckoning

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Nila found an old ledger of windows in the shed attic at the glass towers of Prismhaven. 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 <= 2509; -1000000 <= a[i],k <= 1000000000.

Example 1:

Input: 1184 880062183 671129607 428264098 340002992 935094781 954021441 510728653 291657717 272373600 877168587 53826858 481736222 587467532 76644373 742115110 201389761 718681215 883019309 429742958 782960884 22809075 296448750 800167837 83863097 198231958 292752903 34374377 172212524 744946761 710143095 464776018 666450394 249731574 681345270 337277020 889964329 48121648 812445719 879261801 153909720 603322915 159844866 343160136 470448716 210944331 700096351 117794364 636214930 165483178 969608322 556849054 626953117 994862579 602407841 81016805 808415298 879572687 212394275 99341424 302676110 446929736 153968118 535494268 153227635 171493656 456651672 680392019 607079902 347384292 782505329 217507563 832737850 929901262 254726443 472384172 570710253 704447985 306338791 216976618 813413400 578…
Output: 280894

Example 2:

Input: 91 1753951832 497054339 319551754 126193450 853229262 698085603 212362169 415603414 933719414 490211578 889077923 410891673 362320786 655808184 658867028 771282296 871019088 251167912 341552462 700550351 243665540 356751262 415741844 420926815 960623482 669640384 695902459 895447933 30874681 321124355 616077560 197837121 554754354 439602861 869063206 677492585 2726578 570818268 588603040 409061806 210891885 389939159 410839464 641741480 445923516 173500290 811924303 125401412 115761547 546507090 47240916 853662938 454144528 822853095 237772820 365001746 341401075 802176701 167201334 658228519 968998286 50808634 220820875 675679767 668003021 338453211 548593905 30558185 971381185 370667535 781317191 630929006 475999627 416739245 618504081 568718443 998980292 126471897 148279789 566621361 46…
Output: 4010

Example 3:

Input: 401 1683330437 704596517 312223388 909552406 513596362 560007507 324779173 203523441 946803920 603853551 892778572 309724939 281175011 885648571 311001974 815844185 267774713 295617430 278792579 125667370 623840304 473505495 765678982 795393320 106321440 108999988 138003422 705394404 119098356 626969907 116206771 835525814 665106692 125965645 945293436 994086231 310525370 555994612 714141264 407268722 26496422 599250037 917688716 148745566 24405010 205519161 966735246 147947472 206099611 69744287 398688284 610358711 576122239 547926711 760672855 310329594 238256932 898756822 15929563 464852175 203591861 246886271 188055050 39189552 889232076 297069264 191449846 829186202 436548309 242275693 392081083 299415781 49791895 700382863 191537900 258627629 587019592 888950022 51317987 774709055 51…
Output: 75703

Constraints:

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

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