結果
問題 | No.1972 Modulo Set |
ユーザー |
![]() |
提出日時 | 2022-10-13 23:12:41 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 133 ms / 2,000 ms |
コード長 | 493 bytes |
コンパイル時間 | 549 ms |
コンパイル使用メモリ | 81,976 KB |
実行使用メモリ | 109,952 KB |
最終ジャッジ日時 | 2024-06-26 12:12:39 |
合計ジャッジ時間 | 4,877 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
from collections import defaultdictN, M = map(int, input().split())A = list(map(int, input().split()))dic = defaultdict(int)for a in A:dic[a % M] += 1dic[M - a % M] += 0ans = 0for k, v in dic.items():if k == 0:ans += min(1, dic[k])elif k == M // 2:if M % 2 == 0:ans += min(1, dic[k])else:ans += max(dic[k], dic[M - k])elif k < M//2:ans += max(dic[k], dic[M - k])if ans == 0:ans = 1print(ans)