CODE FESTIVAL 2016 Final

Submission #6342616

Source codeソースコード

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

Task問題 D - Pair Cards
User nameユーザ名 nagitaosu
Created time投稿日時
Language言語 Python3 (3.4.3)
Status状態 AC
Score得点 700
Source lengthソースコード長 672 Byte
File nameファイル名
Exec time実行時間 495 ms
Memory usageメモリ使用量 19036 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 20 ms 3316 KB
01-02.txt AC 68 ms 14188 KB
01-03.txt AC 67 ms 14188 KB
01-04.txt AC 76 ms 14188 KB
01-05.txt AC 75 ms 14188 KB
01-06.txt AC 78 ms 14188 KB
01-07.txt AC 82 ms 14188 KB
01-08.txt AC 88 ms 14188 KB
01-09.txt AC 97 ms 14188 KB
01-10.txt AC 260 ms 14188 KB
01-11.txt AC 495 ms 17372 KB
01-12.txt AC 73 ms 14212 KB
01-13.txt AC 231 ms 14208 KB
01-14.txt AC 65 ms 14188 KB
01-15.txt AC 78 ms 14188 KB
01-16.txt AC 87 ms 14188 KB
01-17.txt AC 88 ms 14188 KB
01-18.txt AC 98 ms 14188 KB
01-19.txt AC 138 ms 14188 KB
01-20.txt AC 471 ms 19036 KB
01-21.txt AC 64 ms 14188 KB
01-22.txt AC 69 ms 14188 KB
01-23.txt AC 74 ms 14188 KB
01-24.txt AC 82 ms 14188 KB
01-25.txt AC 193 ms 14188 KB
01-26.txt AC 432 ms 15708 KB
01-27.txt AC 489 ms 14732 KB
01-28.txt AC 390 ms 10792 KB
01-29.txt AC 165 ms 6224 KB
01-30.txt AC 380 ms 10556 KB
sample-01.txt AC 20 ms 3316 KB
sample-02.txt AC 21 ms 3316 KB