結果

問題 No.1972 Modulo Set
ユーザー EguyEguy
提出日時 2022-06-10 21:35:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 613 bytes
コンパイル時間 135 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 115,200 KB
最終ジャッジ日時 2024-10-05 01:27:27
合計ジャッジ時間 4,374 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, math
sys.setrecursionlimit(1000000)
INF = 1 << 100
#mod = 1000000007
mod = 998244353
input = lambda: sys.stdin.readline().rstrip()
li = lambda: list(map(int, input().split()))
from collections import defaultdict

N, M = li()
A = li()
A = [i % M for i in A]

dic = defaultdict(int)
for a in A:
    dic[a] += 1

ans = 0
st = set()
for k, v in dic.items():
    if k in st:
        continue
    if k + k == M:
        ans += 1
    elif k == 0:
        ans += 1
    else:
        v2 = 0
        if M - k in dic:
            v2 = dic[M-k]
        ans += max(v, v2)

    st.add(k)
    st.add(M-k)
print(ans)
0