結果

問題 No.1390 Get together
ユーザー HAPPA
提出日時 2021-02-12 21:52:53
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 638 bytes
コンパイル時間 244 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 68,608 KB
最終ジャッジ日時 2024-07-19 21:08:01
合計ジャッジ時間 15,143 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())
    cnt_col = [0] * n
    box = [defaultdict(int) for _ in range(m)]
    for _ in range(n):
        b, c = map(lambda x: int(x) - 1, input().split())
        cnt_col[c] += 1
        box[b][c] += 1

    cnt_max = [0] * n
    for i in range(m):
        for k, v in box[i].items():
            cnt_max[k] = max(cnt_max[k], v)

    res = sum(cnt_col[i] - cnt_max[i] for i in range(n))
    print(res)


if __name__ == '__main__':
    resolve()
0