CT47388

Hema's Ledger of panels

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The registry keeper Hema has been asked to decode the foreman's shorthand notes. On the desk lies a long table of panels 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 <= 2395; 0 <= a[i],k <= 1000000000.

Example 1:

Input: 2170 360567167 829571115 633747108 661984103 741010059 938007321 88772507 192697347 249533231 961400841 176874729 90187023 787672868 40814665 22990947 111634920 662281086 283389920 318705028 619992660 14392404 781842039 947399885 292326644 427319514 976352738 369933415 866295296 561616851 210632856 174286441 783597096 785988529 371856005 951810711 151768282 839357636 587666645 92424607 560333996 551262287 923828133 121162982 949045248 473738833 39649493 501315591 915739464 900647816 509675260 355948743 370497954 846342750 752481832 872360134 406830059 624375443 406105041 703183085 571356180 161697657 136575038 758696881 187326718 195554407 42482738 847609692 641420610 875935596 383245202 265588225 697190175 494027906 990698361 900576102 665312678 235215158 777521445 848472616 851063486 981…
Output: 166415

Example 2:

Input: 1850 698038159 518600469 565073088 434468569 671648498 905321878 974751078 65795573 794025998 914968522 76230606 122631152 698372197 690868160 735456605 395559137 652356188 304428138 244834514 395173092 468583045 686510176 811041085 876518897 867052874 954776058 827373359 845655448 69336861 296448713 208335131 536404167 468599385 312013319 729914237 525903771 743532571 33721265 869443182 982256777 4093019 800677087 478573661 381554702 291282693 262199674 66957615 543747846 138789290 316856016 404564721 352801027 176281369 291828427 587184438 559900960 936809383 54603474 84865191 142430734 364510153 666994054 259559752 692209890 207120279 706478594 578806294 501269579 9116134 1671617 232697802 931959438 798201163 708612122 484874049 471058400 856352043 964880719 426469485 606764174 76795512…
Output: 419004

Example 3:

Input: 34 849067048 277621448 226813683 521099077 214074573 198402958 486228693 984178411 173206818 972217497 265051728 290128936 402940435 645123088 573973071 711228412 980092479 189952921 843058052 730463782 993106933 210533835 48382473 884233681 747942242 297393414 151161823 886334723 609590128 955641934 122362887 381739426 769907509 32259427 785862402
Output: 187

Constraints:

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

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