CODE FESTIVAL 2016 Final

Submission #1757348

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])] = 0
        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
        for j in range(len(s[i])):
            pair[i] += dic[str(list(s[i])[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((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状態 WA
Score得点 0
Source lengthソースコード長 1081 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 18 ms 3064 KB
01-02.txt AC 232 ms 16960 KB
01-03.txt AC 262 ms 20900 KB
01-04.txt TLE
01-05.txt TLE
01-06.txt TLE
01-07.txt TLE
01-08.txt WA
01-09.txt WA
01-10.txt WA
01-11.txt WA
01-12.txt AC 211 ms 13968 KB
01-13.txt WA
01-14.txt AC 251 ms 28704 KB
01-15.txt TLE
01-16.txt TLE
01-17.txt AC 521 ms 27564 KB
01-18.txt AC 402 ms 31528 KB
01-19.txt AC 404 ms 33584 KB
01-20.txt AC 662 ms 48148 KB
01-21.txt AC 226 ms 13812 KB
01-22.txt AC 215 ms 14008 KB
01-23.txt WA
01-24.txt WA
01-25.txt WA
01-26.txt WA
01-27.txt AC 423 ms 37112 KB
01-28.txt WA
01-29.txt AC 83 ms 12848 KB
01-30.txt AC 192 ms 27696 KB
sample-01.txt AC 18 ms 3064 KB
sample-02.txt AC 18 ms 3064 KB