CODE FESTIVAL 2016 Final

Submission #7458819

Source codeソースコード

#!/usr/bin/env python3
from collections import defaultdict
N,M=map(int,input().split())
X=list(map(int,input().split()))
tab=[0]*M
cnts=[defaultdict(lambda: 0) for _ in range(M)]
for x in X:
    tab[x%M]+=1
    cnts[x%M][x]+=1
    
ans=0
for i in range(M//2+1):
    if i==0 or (M%2==0 and i==M//2):
        npair = tab[i]//2
        tab[i]-= 2*npair
        ans += npair
    else:
        npair = min(tab[i],tab[M-i])
        tab[i]-= npair
        tab[M-i]-= npair
        ans += npair

for remn, d in zip(tab, cnts):
    tmp=0
    for _,n in d.items():
        tmp += (n//2)
    ans += min(tmp, remn//2)

print(ans)

Submission

Task問題 D - Pair Cards
User nameユーザ名 とりみ
Created time投稿日時
Language言語 PyPy3 (2.4.0)
Status状態 AC
Score得点 700
Source lengthソースコード長 647 Byte
File nameファイル名
Exec time実行時間 376 ms
Memory usageメモリ使用量 102124 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 177 ms 38256 KB
01-02.txt AC 237 ms 55792 KB
01-03.txt AC 234 ms 59376 KB
01-04.txt AC 239 ms 54512 KB
01-05.txt AC 231 ms 55152 KB
01-06.txt AC 240 ms 62316 KB
01-07.txt AC 232 ms 56556 KB
01-08.txt AC 246 ms 59116 KB
01-09.txt AC 259 ms 60268 KB
01-10.txt AC 317 ms 72940 KB
01-11.txt AC 364 ms 94060 KB
01-12.txt AC 214 ms 52804 KB
01-13.txt AC 257 ms 62404 KB
01-14.txt AC 234 ms 59884 KB
01-15.txt AC 230 ms 56812 KB
01-16.txt AC 236 ms 61164 KB
01-17.txt AC 237 ms 58092 KB
01-18.txt AC 268 ms 63340 KB
01-19.txt AC 285 ms 67692 KB
01-20.txt AC 376 ms 102124 KB
01-21.txt AC 229 ms 52460 KB
01-22.txt AC 223 ms 52464 KB
01-23.txt AC 222 ms 52336 KB
01-24.txt AC 241 ms 52720 KB
01-25.txt AC 267 ms 60528 KB
01-26.txt AC 290 ms 78060 KB
01-27.txt AC 293 ms 84116 KB
01-28.txt AC 253 ms 68956 KB
01-29.txt AC 217 ms 51676 KB
01-30.txt AC 247 ms 66908 KB
sample-01.txt AC 172 ms 38256 KB
sample-02.txt AC 167 ms 38256 KB