CT30950

Finn and the Brass panels

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Every season at the alabaster quarry of Whitestone, someone must win the guild's seasonal contest. This year the task falls to Finn, armed only with the panels register. 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 <= 2431; -1000000 <= a[i],k <= 1000.

Example 1:

Input: 739 -55788 -689781 -174041 -819139 -558392 -764830 -259078 -968940 -698390 -951695 -894362 -186121 -967959 -741685 -817257 -189432 -326584 -376012 -623412 -783733 -719164 -979071 -140868 -68323 -33575 -170776 -114172 -592458 -745590 -758376 -75194 -583302 -628314 -484537 -411784 -496513 -819448 -589103 -203218 -896688 -560490 -156064 -623660 -639010 -521190 -685802 -582081 -553959 -658047 -82153 -751732 -879430 -648861 -415950 -725006 -731299 -13170 -96032 -853800 -195703 -506604 -158019 -472939 -983579 -546237 -194919 -593790 -562419 -57153 -648953 -651279 -615547 -28901 -309781 -328416 -275220 -363768 -767131 -774632 -680964 -314248 -822212 -897582 -822782 -790011 -68302 -251395 -747541 -870951 -280215 -38003 -259829 -833371 -151567 -710243 -739074 -479479 -16285 -736777 -443402 -643342 …
Output: 272300

Example 2:

Input: 1045 -689651 -690187 -655707 -45638 -337990 -338740 -759570 -12883 -410325 -749635 -554409 -219305 -218685 -955707 -149985 -811723 -629527 -79158 -376194 -709428 -457325 -353759 -539937 -20195 -934470 -516430 -594251 -717619 -775815 -932396 -500705 -906229 -251459 -663806 -542960 -965778 -499209 -649655 -2790 -593767 -25516 -545946 -232195 -360769 -846857 -879876 -50020 -699981 -251742 -703354 -978245 -477765 -630446 -536476 -932198 -942599 -561788 -110733 -256898 -385022 -221115 -622929 -389937 -37186 -658331 -698101 -720687 -184701 -301463 -238206 -607026 -653172 -871631 -199164 -271911 -305437 -589549 -89062 -988698 -687194 -571115 -792881 -715205 -962121 -974571 -359653 -385216 -999070 -475283 -196701 -717578 -650112 -325237 -962764 -361287 -694085 -547049 -900984 -789540 -481519 -7870…
Output: 420699

Example 3:

Input: 1312 -311588 -671910 -373906 -187049 -382110 -645925 -291845 -64297 -921159 -988492 -447292 -930622 -376134 -36560 -678892 -925081 -753646 -157942 -695936 -806489 -781990 -233880 -336576 -186312 -362755 -783055 -950310 -714653 -760066 -671505 -397717 -417091 -929114 -757930 -517559 -66077 -841121 -431724 -335327 -352526 -983135 -841710 -738631 -270700 -370114 -381414 -970224 -666174 -140834 -608004 -568938 -583219 -633906 -876112 -105383 -289819 -218419 -407746 -795305 -616840 -506918 -41633 -209396 -583271 -816169 -350238 -442401 -89397 -495533 -507293 -320014 -681377 -608039 -748795 -702440 -649719 -481297 -574985 -932196 -614289 -297063 -878830 -332607 -218205 -734390 -798913 -333123 -278293 -121615 -424509 -981045 -160705 -401174 -634032 -103728 -18374 -793479 -757509 -239979 -736460 -…
Output: 813636

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Finn and the Brass panels - MEDIUM Coding Problem | CodeTikki