AtCoder Grand Contest 018

Submission #1450906

Source codeソースコード

import sys
from collections import deque
readline = sys.stdin.readline

N, M = map(int, readline().split())
a = [[] for _ in [None]*N]
for i in range(N):
    a[i] = deque(map(int, readline().split()))

def count(a):
    result = 0
    x = 0
    d = {}
    for n in a:
        d[n] = d.get(n, 0) + 1
        if result < d[n]:
            result = d[n]
            x = n

    return result, x

current = [a[i].popleft() for i in range(N)]
deleted = set()
add = deleted.add
result = float("inf")
try:
    while True:
        _result, max_n = count(current)
        result = _result if _result < result else result
        add(max_n)
        for i in range(N):
            while current[i] in deleted:
                current[i] = a[i].popleft()
except:
    print(result)

Submission

Task問題 B - Sports Festival
User nameユーザ名 htkb
Created time投稿日時
Language言語 Python3 (3.4.3)
Status状態 AC
Score得点 700
Source lengthソースコード長 801 Byte
File nameファイル名
Exec time実行時間 89 ms
Memory usageメモリ使用量 4592 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - sample_01.txt,sample_02.txt,sample_03.txt
All 700 / 700 sample_01.txt,sample_02.txt,sample_03.txt,sample_01.txt,sample_02.txt,sample_03.txt,subtask_1_01.txt,subtask_1_02.txt,subtask_1_03.txt,subtask_1_04.txt,subtask_1_05.txt,subtask_1_06.txt,subtask_1_07.txt,subtask_1_08.txt,subtask_1_09.txt,subtask_1_10.txt,subtask_1_11.txt,subtask_1_12.txt,subtask_1_13.txt,subtask_1_14.txt,subtask_1_15.txt,subtask_1_16.txt,subtask_1_17.txt,subtask_1_18.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
sample_01.txt AC 20 ms 3316 KB
sample_02.txt AC 20 ms 3316 KB
sample_03.txt AC 20 ms 3316 KB
subtask_1_01.txt AC 20 ms 3316 KB
subtask_1_02.txt AC 20 ms 3316 KB
subtask_1_03.txt AC 23 ms 3316 KB
subtask_1_04.txt AC 26 ms 3440 KB
subtask_1_05.txt AC 21 ms 3316 KB
subtask_1_06.txt AC 35 ms 3696 KB
subtask_1_07.txt AC 40 ms 3696 KB
subtask_1_08.txt AC 27 ms 3568 KB
subtask_1_09.txt AC 21 ms 3440 KB
subtask_1_10.txt AC 26 ms 3440 KB
subtask_1_11.txt AC 32 ms 3568 KB
subtask_1_12.txt AC 23 ms 3440 KB
subtask_1_13.txt AC 38 ms 3696 KB
subtask_1_14.txt AC 74 ms 4592 KB
subtask_1_15.txt AC 82 ms 4548 KB
subtask_1_16.txt AC 82 ms 4568 KB
subtask_1_17.txt AC 76 ms 4592 KB
subtask_1_18.txt AC 89 ms 4592 KB