結果

問題 No.1972 Modulo Set
ユーザー Issei Mori
提出日時 2022-06-10 23:53:34
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 552 bytes
コンパイル時間 208 ms
コンパイル使用メモリ 82,188 KB
実行使用メモリ 135,684 KB
最終ジャッジ日時 2024-09-21 07:04:15
合計ジャッジ時間 6,277 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict


def get_list(ty=int):
    return list(map(ty, input().split()))


def get_int():
    return int(input())


def get_str():
    return input()


N, M = get_list()
A = get_list()

if M == 1:
    print(1)
    exit()

cnt = defaultdict(int)
for a in set(A):
    cnt[a % M] += 1

ans = 0
if cnt[0] > 0 or cnt[M//2] > 0:
    ans += 1

keys = cnt.keys()
used = {0, M//2}
for k in list(keys):
    if not k in used:
        used.add(k)
        k2 = M-k
        used.add(k2)
        ans += max(cnt[k], cnt[k2])

print(ans)


0