結果

問題 No.1972 Modulo Set
ユーザー gr1msl3y
提出日時 2022-06-11 01:13:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 379 ms / 2,000 ms
コード長 330 bytes
コンパイル時間 173 ms
コンパイル使用メモリ 82,260 KB
実行使用メモリ 119,684 KB
最終ジャッジ日時 2024-10-05 01:41:58
合計ジャッジ時間 6,868 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
N,M=map(int,input().split())
A=list(map(int,input().split()))
D=defaultdict(int)
for a in A:
	D[a%M]+=1
B=[[D[k],k] for k in D if D[k]]
B.sort(reverse=True)
S=set()
ans=0
for c,v in B:
	if 2*v%M==0:
		ans+=(c>0)
		S.add(v)
	else:
		if v not in S:
			ans+=c
			S.add(v)
			S.add(M-v)
print(ans)
0