CT38003

The panels at Starfall

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

In the observatory of Starfall, Xavi the archivist keeps careful count of the panels. plan the beacon maintenance rota, every figure matters. 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 <= 1523; 0 <= a[i],k <= 1000000000.

Example 1:

Input: 1431 128193648 648007598 614835875 694857130 456688041 458959249 648857521 255704558 939263891 21646937 123326596 178772322 505649033 688366251 594200421 175278753 29179486 433394947 59539739 891586396 94537517 119535751 27509209 254659251 812233909 479938737 475586712 48283916 911731214 585923295 286160711 807939133 381796437 13494670 554388211 281774892 368759345 727886410 151695145 813079864 873403529 616774041 886475382 731552584 415749133 509061515 648640906 692875895 33878094 559392684 368442356 830465374 442289286 705162062 163014030 127414419 107525456 915656354 543359850 973865986 113212036 708088553 943177541 484919610 696336974 826924188 609529220 869685788 620343809 175531713 521869864 945680417 942217993 935169142 480635289 116407710 340735417 739287705 50724957 94822724 46154…
Output: 7563

Example 2:

Input: 548 1389176807 396830469 487656126 372911101 593117029 515385848 900138930 41310356 849614614 29903589 977942179 122231444 711880086 952864402 449692944 551497001 511901933 798311634 387151784 552130520 293715940 225015452 551672256 949123781 978342530 401265394 620139258 797552174 456836785 349457467 46235193 585106960 83438149 552441397 367575611 344815748 830297123 280266084 515619677 54502817 645793114 738567452 176383488 108182906 942040370 353168463 522124985 488038592 89984377 562970324 718389386 606940778 916771349 752506783 367068684 698878697 691424492 550082765 416584169 321335940 331666804 528002348 105952205 179402268 678576504 610407835 318790571 971527633 823799961 136988437 224683646 938648688 494866302 715325178 304520734 423969017 281343182 346173909 268153831 56083767 22…
Output: 122359

Example 3:

Input: 668 583201281 64348702 341829606 212823754 791882584 839370611 163789245 335356584 444885287 562667814 452802419 617965560 536252425 490852280 264737197 734282871 387673152 176848313 379858665 629328672 875680032 898297704 214756286 692094524 430612256 393422822 713303383 973770279 558486970 440533607 307802575 129880533 91043292 744658257 381564316 101039465 834336658 207906240 597699970 393609736 420878922 150991213 606492911 322692730 838756348 298243534 216377560 535788069 625754860 596363241 31108245 620313967 600472536 856795006 633890908 218992734 366642799 914300593 658759092 403665371 120501864 785217230 179758640 71953594 884708273 812592815 789943175 906419210 924155023 769411573 870447059 669082016 577454522 260227803 167431823 776587027 6905976 251326666 813209551 918783922 17…
Output: 35584

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The panels at Starfall - MEDIUM Coding Problem | CodeTikki