CODE FESTIVAL 2016 Final

Submission #1757397

Source codeソースコード

if __name__== "__main__":
    n,m = map(int,input().split(" "))
    x = list(map(int,input().split(" ")))
    x_mod = list(map(lambda x: x%m, x))
    s = [set() for _ in range(m)]
    num = [0 for _ in range(m)]
    pair = [0 for _ in range(m)]
    dic = [0 for _ in range(100001)]
    sum = 0
    sum_h = 0
    for i in range(n):
        s[x_mod[i]].add(x[i])
        num[x_mod[i]] += 1
        dic[x[i]] += 1
        if x_mod[i]==0:
            sum += 0.5
        if m%2==0 and x_mod[i] == m/2:
            sum_h += 0.5
    for i in range(1,m):
        if i == m/2:
            continue
        p = list(s[i])
        for j in range(len(s[i])):
            pair[i] += int(dic[p[j]]/2)
    
    sum = int(sum)
    sum_h = int(sum_h)
    sum += sum_h
    for i in range(1,int((m+1)/2)):
        i_1 = i
        i_2 = m-i
        if num[i]>num[m-i]:
            i_1 = m-i
            i_2 = i
        sum += num[i_1]
        sum += min(int((num[i_2]-num[i_1])/2), pair[i_2])
    print(int(sum))


Submission

Task問題 D - Pair Cards
User nameユーザ名 yuinityk
Created time投稿日時
Language言語 Python3 (3.4.3)
Status状態 AC
Score得点 700
Source lengthソースコード長 1034 Byte
File nameファイル名
Exec time実行時間 407 ms
Memory usageメモリ使用量 33788 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 21 ms 4020 KB
01-02.txt AC 126 ms 14008 KB
01-03.txt AC 147 ms 15232 KB
01-04.txt AC 149 ms 14008 KB
01-05.txt AC 153 ms 14008 KB
01-06.txt AC 150 ms 15488 KB
01-07.txt AC 162 ms 14008 KB
01-08.txt AC 158 ms 15232 KB
01-09.txt AC 179 ms 16000 KB
01-10.txt AC 265 ms 20224 KB
01-11.txt AC 400 ms 33788 KB
01-12.txt AC 140 ms 13964 KB
01-13.txt AC 213 ms 22488 KB
01-14.txt AC 144 ms 14948 KB
01-15.txt AC 151 ms 13812 KB
01-16.txt AC 189 ms 16484 KB
01-17.txt AC 165 ms 14564 KB
01-18.txt AC 174 ms 18304 KB
01-19.txt AC 197 ms 20608 KB
01-20.txt AC 407 ms 33636 KB
01-21.txt AC 140 ms 13812 KB
01-22.txt AC 124 ms 13812 KB
01-23.txt AC 142 ms 14004 KB
01-24.txt AC 129 ms 14008 KB
01-25.txt AC 195 ms 18172 KB
01-26.txt AC 308 ms 33636 KB
01-27.txt AC 306 ms 31260 KB
01-28.txt AC 207 ms 28652 KB
01-29.txt AC 87 ms 13636 KB
01-30.txt AC 197 ms 28464 KB
sample-01.txt AC 21 ms 4016 KB
sample-02.txt AC 21 ms 4016 KB