CT35507

The Frugal Pairs Beneath Whitestone

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The harbor bell rings at the alabaster quarry of Whitestone; Harish weighs the day's ribbons 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 <= 1718; -1000000 <= a[i],k <= 1000000000.

Example 1:

Input: 365 402333456 455671034 361183989 703316358 837110626 189798571 637263466 365971962 20342270 2582535 838532116 930239453 46628494 974610166 38743197 100378430 938877052 387881396 448412291 583987598 219350730 295318154 727198648 414859813 974384893 660751275 695779572 301886883 16353831 925540837 187518637 43447426 353881401 852362851 365435930 445541278 286309056 210846274 653681771 78892628 137924276 532569817 569682312 899539549 829307618 634180872 215978468 39931211 969865684 696231264 130301741 194942363 673325161 529605269 134588685 738458676 857243223 413459695 319426578 722506282 864701727 599035509 158365186 744055771 754537507 424139308 199206943 908588595 603454811 213973276 336149271 567307464 925508673 945735420 199013444 978361453 845398886 55817619 199974336 137086344 348374…
Output: 5484

Example 2:

Input: 1705 1632228591 116275590 108816748 587143641 310390436 704592865 136131319 738820392 626589976 936320062 187816986 408454831 543044519 11315845 964351521 849708512 849891484 757437050 825949563 65081605 901519374 683166152 229305055 207239184 263647397 65401559 249468930 84206410 591566111 186306636 114194332 594672089 208279263 383518678 134351492 189636171 497393015 232987589 256956714 638544068 975654450 620299201 417389853 111283851 712760274 686873447 604553459 965246426 522503188 214902884 601211811 545092144 39729419 801719546 532384549 134947028 392119398 972702547 132993593 156907624 170745945 756087047 417566971 714142043 385432884 801407773 140729592 491861000 810591161 173601385 957322576 592140498 822827409 914201921 241828558 448848555 321624853 95669631 239595031 22796333 9…
Output: 1363585

Example 3:

Input: 461 9972284 262260502 78671156 519979468 512575650 737264821 124444861 488345613 256452895 130076611 153987411 81004385 208922955 331178557 641376414 665228617 222438079 978339682 825480413 829632182 787936629 564143441 761234172 131380251 117098506 781303932 62142982 747350965 28856860 209936341 80823005 359383983 686567812 341277747 277172604 808084126 7701702 693019892 560251851 88243111 998269543 595217766 923738674 306536629 95783222 244504770 277707461 758565262 772164764 378250370 104169830 349829346 680964393 652323664 851829850 376205695 373767598 991054952 200258564 572850560 15117687 62880651 364511635 187085962 146519050 491875775 948148236 363302541 448538724 418986564 653500823 231526974 78331683 415374467 613447388 601456650 37685881 208288447 48548649 290332267 787942969 93…
Output: 7

Constraints:

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

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