CT54911

Zane's Frosted Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Legend says the vault under the quays of Driftwood opens only for a perfect tally of stretches. Zane means to find out. 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 <= 1748; 0 <= a[i],k <= 1000000000.

Example 1:

Input: 1231 1512173897 732009729 725429631 343594395 152130441 400997300 623345112 216646392 645397213 300936727 542137106 604603770 957700416 186907764 82199209 642783617 176218335 171152308 796074266 496813354 694303988 1050402 315955431 665161490 79443379 177969118 947380866 340115268 541315008 294675686 160912017 548153778 343357697 887334729 479104469 236874089 628706415 158602129 515564040 804575355 336057629 272038281 193710405 904468732 692591307 108008999 229595244 935827375 409172669 889266077 409081767 16552 383158155 113523583 172185149 445711410 558343049 57932619 734217150 55162512 965101366 206183174 739249852 212741238 89343594 29414407 243703418 476310257 87523153 904538566 670291675 324452008 570237353 134646511 713236168 937808341 524616506 855831784 937335087 620102951 3881452…
Output: 665914

Example 2:

Input: 1740 915485325 601225227 919154322 923121293 130317380 419088140 52926152 488768746 60026624 119371974 824322464 91972143 340612778 434160461 400789086 829376810 926473412 23697511 210463949 834741557 772370840 279896418 859079402 980012682 704071463 427786663 336524797 207277953 413283168 842350318 719560098 803158409 776760380 31242676 51426277 981210021 733179154 781056160 205385119 225207991 469979937 742586820 46328810 655192826 966842223 687947118 144619381 464669536 471537525 993456315 313496237 535752955 855136665 461883086 883130475 409764913 18521713 208696800 214051636 179615547 704224645 210024729 685152237 299858313 444125109 134068214 681053031 722234887 30325694 552537533 4034763 719546841 875832296 536316822 884144238 305326557 677911668 802446065 10629930 340928910 1151465…
Output: 622631

Example 3:

Input: 778 188136250 887986304 921064157 333403660 334917804 217303279 36802104 448341239 227031052 769046444 438756341 32154076 204547667 932902377 722794337 497834185 500618596 634662654 898454267 840553569 385779390 42498002 545808747 213363580 246724697 343663566 107017818 152158599 698529079 431469789 195304317 954258302 89552173 955813702 665192760 151081847 94652055 766445883 801494919 345599168 513427938 830616162 819058848 289348633 757403434 389203341 353209926 630999776 809537726 80536543 282738931 915271185 470018279 963661944 609228426 928941893 193324193 354440483 584902768 82222201 866842994 746960067 91750535 428952724 105285642 992647557 390484025 83328449 749376290 942303372 368495103 486891022 973585785 685688817 960559941 844082156 696857050 492120607 709923770 610962450 19104…
Output: 5322

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Zane's Frosted Ledger - MEDIUM Coding Problem | CodeTikki