CT33827

Elowen's scrolls Reckoning

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Elowen runs the print shop at the tannery row of Leatherwick. Today the books show a list of scrolls, and the numbers must be worked out before sundown. 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 <= 3474; -1000000 <= a[i],k <= 1000000.

Example 1:

Input: 1005 987386 -645418 -624225 704295 -545602 -245318 127292 147380 -304781 -147916 318441 -574559 834959 697158 -493161 582079 606435 -684160 437146 -935208 -908706 -110606 -53651 908567 -902832 -909236 524030 931961 394559 -861058 282111 118765 598191 580151 -660304 -742217 951663 538623 308423 -60067 714390 790441 998109 344874 470125 -373113 -843210 -926127 -704888 403798 -823771 -891117 -519284 798160 -831208 -24137 -590921 744678 855234 -133547 -536125 -491280 -13309 437890 686174 662829 73137 733265 279022 387639 171007 -696389 -426961 -266391 -178872 -758123 593782 -404892 -795266 474811 -161218 897940 -449543 193959 -470281 78029 351343 42751 416646 -791025 660731 -369046 222534 202924 -914059 30943 -990874 -280128 -853811 -925344 48001 -386905 -815359 814421 -707369 347160 899892 -2…
Output: 439986

Example 2:

Input: 323 -907382 -31129 -215457 -472241 -544327 920364 -474709 -945631 -71190 -256307 -308870 -378707 253543 -559035 50440 344646 -911855 -845671 -78058 902176 -707728 -425394 -370748 -490498 990072 -587708 491768 -633438 -737335 522392 -179607 389992 975380 -802358 -543500 -501451 -800811 -531598 486786 248532 898098 730309 -760934 974477 -24545 -757933 -304946 338161 118130 108997 172898 -215838 521743 694808 -274597 -502423 -428143 -190609 -387382 -409932 251158 568975 972251 -31033 -115409 -158694 877990 364461 -206372 -632877 24667 438488 -688543 297700 -982028 -777765 813129 424793 902105 289118 -485462 987305 -475424 204664 853046 -235635 -853910 14493 699476 199116 940973 307040 -530857 -920260 -745988 105868 222324 308923 -455350 -968797 -180759 427158 409231 -159069 970164 -609321 -56…
Output: 7539

Example 3:

Input: 2082 -392673 -927135 590992 794493 19962 16347 -414365 222937 -88357 -591893 -659484 -257267 -625213 -182579 925862 161545 942848 -662986 -139747 980705 186123 -56811 -830810 791010 822637 236930 -471711 629769 -399365 44359 926044 -313195 -134088 91756 85172 -720490 170386 315293 161217 982817 -255961 -891729 -671440 -677554 338586 -654478 -483263 -733895 389675 349803 -302919 -563108 -938893 -709592 -705729 -970120 906579 -238822 901921 -350871 211811 -118298 -245908 982959 -112301 -213410 880058 409813 -312895 -451792 -826636 -660588 -659438 215294 759404 -139390 892819 -176724 898713 -4420 -427428 -391053 127222 -892628 176334 919451 -87244 648095 919194 605175 -95122 523514 467164 -210269 -494163 202073 92202 -921238 -953786 413121 -222447 -597726 806614 156945 -270444 870925 -620245 …
Output: 732407

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Elowen's scrolls Reckoning - MEDIUM Coding Problem | CodeTikki