CODE FESTIVAL 2016 Final

Submission #5493755

Source codeソースコード

N,m=map(int,input().split())

X=list(map(int,input().split()))

#print(X)

M=[[]for i in range(m)]
for i in range(len(X)):
    M[X[i]%m].append(X[i])
    
#print(M)

ans=len(M[0])//2
if m%2==0:
    ans+=len(M[m//2])//2
#print(0,ans)
for i in range(1,(m//2)+1):
    if m%2==0:
        if i==(m//2):
            break
    ans+=min(len(M[i]),len(M[m-i]))
    #print(i,ans)
    L=[0]
    cnt=1
    if len(M[i])>len(M[m-i]):
        A=M[i]
    else:
        A=M[m-i]
    A.sort()
    for j in range(1,max(len(M[i]),len(M[m-i]))):
        if A[j]==A[j-1]:
            cnt+=1
        else:
            L.append(cnt//2)
            cnt=1
    L.append(cnt//2)
    #print(L)
    if (abs(len(M[i])-len(M[m-i]))//2)<=sum(L):
        ans+=(abs(len(M[i])-len(M[m-i]))//2)
    else:
        ans+=sum(L)
    #print(i,ans)
print(ans)

Submission

Task問題 D - Pair Cards
User nameユーザ名 syunsuke
Created time投稿日時
Language言語 Python3 (3.4.3)
Status状態 AC
Score得点 700
Source lengthソースコード長 860 Byte
File nameファイル名
Exec time実行時間 275 ms
Memory usageメモリ使用量 18788 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 17 ms 3064 KB
01-02.txt AC 66 ms 13812 KB
01-03.txt AC 65 ms 14008 KB
01-04.txt AC 88 ms 14008 KB
01-05.txt AC 82 ms 13812 KB
01-06.txt AC 91 ms 13812 KB
01-07.txt AC 93 ms 13812 KB
01-08.txt AC 92 ms 13812 KB
01-09.txt AC 98 ms 13812 KB
01-10.txt AC 167 ms 13812 KB
01-11.txt AC 275 ms 16996 KB
01-12.txt AC 92 ms 14096 KB
01-13.txt AC 164 ms 13968 KB
01-14.txt AC 67 ms 13812 KB
01-15.txt AC 89 ms 14008 KB
01-16.txt AC 91 ms 14008 KB
01-17.txt AC 91 ms 13812 KB
01-18.txt AC 94 ms 14008 KB
01-19.txt AC 112 ms 13812 KB
01-20.txt AC 264 ms 18788 KB
01-21.txt AC 69 ms 13940 KB
01-22.txt AC 88 ms 13812 KB
01-23.txt AC 89 ms 14008 KB
01-24.txt AC 94 ms 14008 KB
01-25.txt AC 151 ms 14008 KB
01-26.txt AC 267 ms 15332 KB
01-27.txt AC 211 ms 14364 KB
01-28.txt AC 200 ms 10356 KB
01-29.txt AC 82 ms 5936 KB
01-30.txt AC 198 ms 10288 KB
sample-01.txt AC 17 ms 3064 KB
sample-02.txt AC 17 ms 3064 KB