Submission #7927561


Source Code Expand

Copy
N,M=map(int,input().split())
X=list(map(int,input().split()))
from collections import defaultdict
r=[defaultdict(int) for i in range(M)]
for x in X:
    r[x%M][x]+=1
a=sum(r[0].values())//2
for m in range(1,-(-M//2)):
    v1,v2=sum(r[m].values()),sum(r[M-m].values())
    if v1>v2:
        p=sum([e//2 for e in r[m].values()])
        a+=v2+min(p,(v1-v2)//2)
    else:
        p=sum([e//2 for e in r[M-m].values()])
        a+=v1+min(p,(v2-v1)//2)
if M%2==0:
    a+=sum(r[M//2].values())//2
print(a)

Submission Info

Submission Time
Task D - Pair Cards
User st2d
Language Python (3.4.3)
Score 700
Code Size 516 Byte
Status
Exec Time 266 ms
Memory 38652 KB

Judge Result

Set Name sample all
Score / Max Score 0 / 0 700 / 700
Status
Test Cases sample-01.txt, sample-02.txt 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
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 28 ms 3572 KB
01-02.txt 84 ms 13880 KB
01-03.txt 85 ms 14008 KB
01-04.txt 86 ms 14008 KB
01-05.txt 85 ms 14008 KB
01-06.txt 89 ms 14008 KB
01-07.txt 87 ms 13812 KB
01-08.txt 98 ms 14004 KB
01-09.txt 97 ms 14008 KB
01-10.txt 150 ms 19812 KB
01-11.txt 250 ms 38652 KB
01-12.txt 69 ms 13864 KB
01-13.txt 127 ms 20944 KB
01-14.txt 92 ms 16760 KB
01-15.txt 89 ms 14308 KB
01-16.txt 95 ms 13812 KB
01-17.txt 95 ms 15356 KB
01-18.txt 98 ms 13924 KB
01-19.txt 114 ms 14564 KB
01-20.txt 266 ms 38628 KB
01-21.txt 71 ms 14008 KB
01-22.txt 70 ms 13812 KB
01-23.txt 72 ms 13812 KB
01-24.txt 75 ms 14008 KB
01-25.txt 116 ms 16740 KB
01-26.txt 222 ms 38568 KB
01-27.txt 211 ms 36632 KB
01-28.txt 170 ms 36852 KB
01-29.txt 75 ms 15732 KB
01-30.txt 165 ms 34676 KB
sample-01.txt 21 ms 3316 KB
sample-02.txt 21 ms 3316 KB