CT31450

The panels at Prismhaven

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The harbor bell rings at the glass towers of Prismhaven; Petr weighs the day's panels manifests and starts the calculations. 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 <= 2134; -1000000 <= a[i],k <= 1000000000.

Example 1:

Input: 97 1455430981 20476433 578991473 101620117 509860009 130655739 847325869 673757516 885700718 128074499 484192845 707409533 788532084 530270008 510259026 339199954 65897638 10888464 762133222 804068491 797075064 755277723 333596426 264296339 572121802 42662706 115944539 180057641 121358045 591524637 922096555 904417139 828835589 880741928 636001629 963368839 307271969 10001083 361722914 655318740 952299752 381154797 374501129 963871862 645963025 496237830 605325547 917532952 743382067 691294246 199788088 151454855 631455476 883679969 506989497 906593824 264688900 148732021 764633311 686587497 246734034 345503304 241720978 63969068 89597682 548455166 688449157 796789817 190835073 699668571 815487904 559966282 177077608 481709733 195273675 852739183 214679722 361629199 25275675 819575718 7471…
Output: 4062

Example 2:

Input: 1128 1566655338 900884547 644179445 212091995 611385687 416945848 130630224 247060052 348961204 961155205 150176310 642151972 873527740 438493871 47811767 821219315 483647929 902640505 834137861 801424102 817135130 77398942 227363082 526510747 154408702 146824917 133439181 544956647 88578086 82088885 33558616 64661620 304964391 457864990 270773225 764654533 793220578 417717934 465343163 624814245 534651175 307275067 514744871 690902626 362734330 891473017 337502446 755197671 901240343 189808826 991714709 457603511 329004545 223234194 46558573 365671108 630865968 75750095 882437393 477418678 323320649 598560265 296251677 321254162 149809847 483124016 842968863 521751266 159166689 110414573 764400306 125542813 152881750 322214501 572213032 872205203 599797957 337691442 571603417 616761116 83…
Output: 586099

Example 3:

Input: 825 1351559552 689841547 494442474 740838899 350057112 286600744 58945489 765453622 295526358 611188604 865987031 656980265 814796171 696565749 971814813 709782685 148771271 706909618 909254812 234164817 439646840 87947308 912919012 441494420 542934260 315201667 347756855 366822794 980313061 462688600 581389541 356832605 577340557 572080978 942816312 15446699 549937699 184563384 128279684 384627532 455664703 478089118 825516962 916256898 212569353 334750977 155565219 662044511 686640361 63197611 889914534 753721969 960447178 169508716 309700390 636938646 630156499 804810530 277227432 201913070 570702575 371518387 18322223 905415370 433949906 330835211 910858446 382705656 738107623 756431078 364668702 572651028 93430474 541466126 896113978 142735199 986080422 105945183 971920578 325268543 7…
Output: 272469

Constraints:

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

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