Submission #5548568


Source Code Expand

from collections import defaultdict, Counter
def inpl(): return list(map(int, input().split()))

N, M = inpl()
X = sorted(inpl())
C = Counter(X)
D = defaultdict(int)
E = defaultdict(int)
for k, v in C.items():
    D[k%M] += v
    E[k%M] += v//2

ans = D[0] // 2

for i in range(1, M):
    j = M - i
    if i < j:
        x = min(D[i], D[j])
        y = min((D[i] - x)//2, E[i]) + min((D[j] - x)//2, E[j])
        ans += x + y
    elif i == j:
        ans += D[i] //2
    else:
        break

print(ans)

Submission Info

Submission Time
Task D - Pair Cards
User nadare881
Language PyPy3 (2.4.0)
Score 700
Code Size 527 Byte
Status AC
Exec Time 310 ms
Memory 82920 KB

Judge Result

Set Name sample all
Score / Max Score 0 / 0 700 / 700
Status
AC × 2
AC × 34
Set Name Test Cases
sample sample-01.txt, sample-02.txt
all sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt, 01-27.txt, 01-28.txt, 01-29.txt, 01-30.txt, sample-01.txt, sample-02.txt
Case Name Status Exec Time Memory
01-01.txt AC 163 ms 38256 KB
01-02.txt AC 237 ms 56048 KB
01-03.txt AC 236 ms 56176 KB
01-04.txt AC 231 ms 56048 KB
01-05.txt AC 230 ms 56048 KB
01-06.txt AC 231 ms 56044 KB
01-07.txt AC 229 ms 56044 KB
01-08.txt AC 232 ms 56172 KB
01-09.txt AC 245 ms 56044 KB
01-10.txt AC 303 ms 68076 KB
01-11.txt AC 310 ms 79724 KB
01-12.txt AC 202 ms 52804 KB
01-13.txt AC 241 ms 61252 KB
01-14.txt AC 235 ms 62828 KB
01-15.txt AC 229 ms 62700 KB
01-16.txt AC 230 ms 62700 KB
01-17.txt AC 230 ms 62700 KB
01-18.txt AC 248 ms 62572 KB
01-19.txt AC 259 ms 62824 KB
01-20.txt AC 262 ms 82920 KB
01-21.txt AC 218 ms 52332 KB
01-22.txt AC 219 ms 52336 KB
01-23.txt AC 221 ms 52336 KB
01-24.txt AC 230 ms 52464 KB
01-25.txt AC 272 ms 62320 KB
01-26.txt AC 274 ms 74092 KB
01-27.txt AC 234 ms 70932 KB
01-28.txt AC 221 ms 62700 KB
01-29.txt AC 213 ms 49388 KB
01-30.txt AC 193 ms 59884 KB
sample-01.txt AC 161 ms 38256 KB
sample-02.txt AC 162 ms 38384 KB