結果
問題 | No.1972 Modulo Set |
ユーザー |
![]() |
提出日時 | 2022-06-12 01:54:37 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 179 ms / 2,000 ms |
コード長 | 486 bytes |
コンパイル時間 | 447 ms |
コンパイル使用メモリ | 82,852 KB |
実行使用メモリ | 126,252 KB |
最終ジャッジ日時 | 2024-10-05 01:45:20 |
合計ジャッジ時間 | 5,363 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
from collections import defaultdictN,M = map(int,input().split())A = list(map(int,input().split()))seen = defaultdict(bool)cnt = defaultdict(int)ans = 0for a in A:cnt[a%M] += 1keys = list(cnt.keys())for key in keys:if key == 0:ans += 1continueif seen[key]:continueinv = M - keyif key == M //2 and M % 2 == 0:ans += 1else:ans += max(cnt[key],cnt[inv])seen[key] = Trueseen[inv] = Trueprint(ans)