CODE FESTIVAL 2016 Final

Submission #7458787

Source codeソースコード

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]-=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状態 WA
Score得点 0
Source lengthソースコード長 614 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
sample - sample-01.txt,sample-02.txt
all 0 / 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 164 ms 38256 KB
01-02.txt WA
01-03.txt WA
01-04.txt WA
01-05.txt WA
01-06.txt WA
01-07.txt WA
01-08.txt WA
01-09.txt WA
01-10.txt AC 343 ms 73068 KB
01-11.txt AC 364 ms 94188 KB
01-12.txt AC 215 ms 52804 KB
01-13.txt AC 251 ms 62532 KB
01-14.txt AC 225 ms 59884 KB
01-15.txt AC 228 ms 56812 KB
01-16.txt AC 236 ms 61036 KB
01-17.txt AC 233 ms 57836 KB
01-18.txt AC 264 ms 63340 KB
01-19.txt AC 276 ms 67692 KB
01-20.txt AC 355 ms 102252 KB
01-21.txt WA
01-22.txt WA
01-23.txt WA
01-24.txt WA
01-25.txt AC 262 ms 60528 KB
01-26.txt AC 290 ms 78060 KB
01-27.txt AC 304 ms 84116 KB
01-28.txt AC 255 ms 68956 KB
01-29.txt AC 219 ms 51676 KB
01-30.txt AC 243 ms 67036 KB
sample-01.txt AC 166 ms 38256 KB
sample-02.txt WA