CODE FESTIVAL 2016 Final

Submission #7927561

Source codeソースコード

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

Task問題 D - Pair Cards
User nameユーザ名 st2d
Created time投稿日時
Language言語 Python3 (3.4.3)
Status状態 AC
Score得点 700
Source lengthソースコード長 516 Byte
File nameファイル名
Exec time実行時間 266 ms
Memory usageメモリ使用量 38652 KB

Test case

Set

Set name Score得点 / Max score Cases
sample - 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
01-01.txt AC 28 ms 3572 KB
01-02.txt AC 84 ms 13880 KB
01-03.txt AC 85 ms 14008 KB
01-04.txt AC 86 ms 14008 KB
01-05.txt AC 85 ms 14008 KB
01-06.txt AC 89 ms 14008 KB
01-07.txt AC 87 ms 13812 KB
01-08.txt AC 98 ms 14004 KB
01-09.txt AC 97 ms 14008 KB
01-10.txt AC 150 ms 19812 KB
01-11.txt AC 250 ms 38652 KB
01-12.txt AC 69 ms 13864 KB
01-13.txt AC 127 ms 20944 KB
01-14.txt AC 92 ms 16760 KB
01-15.txt AC 89 ms 14308 KB
01-16.txt AC 95 ms 13812 KB
01-17.txt AC 95 ms 15356 KB
01-18.txt AC 98 ms 13924 KB
01-19.txt AC 114 ms 14564 KB
01-20.txt AC 266 ms 38628 KB
01-21.txt AC 71 ms 14008 KB
01-22.txt AC 70 ms 13812 KB
01-23.txt AC 72 ms 13812 KB
01-24.txt AC 75 ms 14008 KB
01-25.txt AC 116 ms 16740 KB
01-26.txt AC 222 ms 38568 KB
01-27.txt AC 211 ms 36632 KB
01-28.txt AC 170 ms 36852 KB
01-29.txt AC 75 ms 15732 KB
01-30.txt AC 165 ms 34676 KB
sample-01.txt AC 21 ms 3316 KB
sample-02.txt AC 21 ms 3316 KB