CODE FESTIVAL 2016 Final

Submission #1757402

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 = dict()
    sum = 0
    sum_h = 0
    for i in range(n):
        s[x_mod[i]].add(x[i])
        num[x_mod[i]] += 1
        if str(x[i]) in dic.keys():
            dic[str(x[i])] += 1
        else:
            dic[str(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[str(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ソースコード長 1112 Byte
File nameファイル名
Exec time実行時間 579 ms
Memory usageメモリ使用量 48148 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 208 ms 16956 KB
01-03.txt AC 226 ms 19896 KB
01-04.txt AC 236 ms 17720 KB
01-05.txt AC 246 ms 17344 KB
01-06.txt AC 243 ms 20892 KB
01-07.txt AC 273 ms 18480 KB
01-08.txt AC 260 ms 21128 KB
01-09.txt AC 302 ms 21768 KB
01-10.txt AC 391 ms 27188 KB
01-11.txt AC 557 ms 41760 KB
01-12.txt AC 215 ms 13964 KB
01-13.txt AC 273 ms 21720 KB
01-14.txt AC 227 ms 28704 KB
01-15.txt AC 255 ms 25132 KB
01-16.txt AC 284 ms 28100 KB
01-17.txt AC 293 ms 27544 KB
01-18.txt AC 299 ms 31508 KB
01-19.txt AC 325 ms 33580 KB
01-20.txt AC 579 ms 48148 KB
01-21.txt AC 217 ms 14008 KB
01-22.txt AC 201 ms 13812 KB
01-23.txt AC 210 ms 14008 KB
01-24.txt AC 205 ms 14004 KB
01-25.txt AC 285 ms 17992 KB
01-26.txt AC 386 ms 33112 KB
01-27.txt AC 376 ms 37112 KB
01-28.txt AC 205 ms 28284 KB
01-29.txt AC 84 ms 12916 KB
01-30.txt AC 198 ms 27696 KB
sample-01.txt AC 17 ms 3064 KB
sample-02.txt AC 17 ms 3064 KB