Submission #6342616


Source Code Expand

Copy
from collections import Counter
n, m = [int(item) for item in input().split()]
x = [int(item) for item in input().split()]

modm = [[] for _ in range(m)]
ans = 0
for item in x:
    modm[item % m].append(item)
for i in range(m//2+1):
    if i == 0:
        ans += len(modm[i]) // 2
    elif m % 2 == 0 and i == m // 2:
        ans += len(modm[i]) // 2
    else:
        a = modm[i]
        b = modm[m - i]
        if len(b) < len(a):
            a, b = b[:], a[:]
        ans += len(a)
        cnt = Counter(b)
        val = 0
        for key in cnt.keys():
            val += cnt[key] // 2
        ans += min(val, (len(b) - len(a)) // 2)
print(ans)

Submission Info

Submission Time
Task D - Pair Cards
User nagitaosu
Language Python3 (3.4.3)
Score 700
Code Size 672 Byte
Status
Exec Time 495 ms
Memory 19036 KB

Judge Result

Set Name Score / Max Score Test Cases
sample 0 / 0 sample-01.txt, sample-02.txt
all 700 / 700 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 20 ms 3316 KB
01-02.txt 68 ms 14188 KB
01-03.txt 67 ms 14188 KB
01-04.txt 76 ms 14188 KB
01-05.txt 75 ms 14188 KB
01-06.txt 78 ms 14188 KB
01-07.txt 82 ms 14188 KB
01-08.txt 88 ms 14188 KB
01-09.txt 97 ms 14188 KB
01-10.txt 260 ms 14188 KB
01-11.txt 495 ms 17372 KB
01-12.txt 73 ms 14212 KB
01-13.txt 231 ms 14208 KB
01-14.txt 65 ms 14188 KB
01-15.txt 78 ms 14188 KB
01-16.txt 87 ms 14188 KB
01-17.txt 88 ms 14188 KB
01-18.txt 98 ms 14188 KB
01-19.txt 138 ms 14188 KB
01-20.txt 471 ms 19036 KB
01-21.txt 64 ms 14188 KB
01-22.txt 69 ms 14188 KB
01-23.txt 74 ms 14188 KB
01-24.txt 82 ms 14188 KB
01-25.txt 193 ms 14188 KB
01-26.txt 432 ms 15708 KB
01-27.txt 489 ms 14732 KB
01-28.txt 390 ms 10792 KB
01-29.txt 165 ms 6224 KB
01-30.txt 380 ms 10556 KB
sample-01.txt 20 ms 3316 KB
sample-02.txt 21 ms 3316 KB