CT42385

Jarl's Zigzag Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The store warden Jarl has been asked to rebuild the damaged itinerary. On the desk lies a long table of stretches readings. 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 <= 1287; -1000000 <= a[i],k <= 1000000000.

Example 1:

Input: 386 1168107309 515425327 53468376 850021700 580844792 728477358 126799524 351121173 313529235 657586305 491769314 352867711 659055103 396498626 884380141 469180376 698981610 827435483 500470368 567147307 987580296 752026977 818706247 673710598 104633865 498042273 141395396 809807612 177826844 713909370 425342514 850130629 149399778 676857816 970399822 351741091 231584493 801559142 806203954 66867860 506089332 954540716 702430583 512812557 97119804 670195482 101691532 207596503 932461825 856219735 801929900 228007230 150910021 135076154 498556711 587084109 718211516 127731108 678830382 170603549 310692308 272913415 86766073 625906312 368046765 42823734 32998520 707629242 930085003 131284187 110438361 481850066 22730974 240012336 582883994 325873302 228012976 857373218 601511532 796301904 36…
Output: 53249

Example 2:

Input: 448 1187224567 335605449 472839430 436463829 824675611 756598899 751704285 100096807 426983420 479732249 332786674 141285393 393256930 696227169 119664618 168929626 512972526 420350861 968989931 111363375 140435816 992959498 233394766 629640012 332525992 613508463 70747891 989748276 374178241 830398361 780048889 112414964 46747369 207626672 366968992 247202385 903233077 684843668 786434337 497815525 388454597 885450894 290191647 727913201 80543482 858389817 33440492 316123943 97177691 132731297 121650281 806558098 297257317 649361456 568129873 849815090 76153840 974793260 411187418 875116279 930412919 395666516 404179986 401435259 200545693 398458718 867388156 435681019 389047686 248639756 276337161 86044950 321995622 294843867 708929033 291047337 438558144 344391242 984771539 491519371 65…
Output: 69854

Example 3:

Input: 1026 126839781 838021664 170812053 768536044 247177440 512512 107874927 31442100 89948593 422130481 323352484 532235334 483042628 14971779 432965350 225268471 926886595 956276449 855895811 414477567 246558088 498912895 134163200 267681654 619939049 192317238 251039084 664358571 809302905 391605733 206071133 99448579 442770778 52623798 288669116 576283709 632420714 776968046 326146624 779659437 751492217 635322562 496504018 76052106 227118222 530544473 487325148 123646320 515603056 223794963 692594956 924202698 964084635 65371440 917242244 536226767 728728404 753455542 271417872 650556110 890259522 73480939 493326543 287529450 65635130 930251838 95970997 28304680 328009491 987904728 684121801 738012626 967402730 924871753 331085642 574487735 483536527 968847947 12255287 280076 100546603 150…
Output: 4134

Constraints:

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

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