CODE FESTIVAL 2016 Final

Submission #5493457

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(N):
    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]
    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状態 WA
Score得点 0
Source lengthソースコード長 841 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 17 ms 3064 KB
01-02.txt AC 64 ms 14008 KB
01-03.txt AC 66 ms 13812 KB
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 WA
01-11.txt AC 262 ms 17076 KB
01-12.txt AC 90 ms 13964 KB
01-13.txt AC 161 ms 13964 KB
01-14.txt AC 66 ms 13616 KB
01-15.txt AC 78 ms 13812 KB
01-16.txt AC 80 ms 13812 KB
01-17.txt AC 85 ms 13812 KB
01-18.txt AC 92 ms 14008 KB
01-19.txt AC 110 ms 13616 KB
01-20.txt AC 251 ms 18740 KB
01-21.txt AC 65 ms 14008 KB
01-22.txt WA
01-23.txt WA
01-24.txt WA
01-25.txt WA
01-26.txt AC 252 ms 15156 KB
01-27.txt AC 205 ms 14484 KB
01-28.txt AC 194 ms 10440 KB
01-29.txt AC 81 ms 5940 KB
01-30.txt AC 201 ms 10288 KB
sample-01.txt AC 17 ms 3064 KB
sample-02.txt AC 17 ms 3064 KB