結果
| 問題 | No.1972 Modulo Set |
| コンテスト | |
| ユーザー |
ntuda
|
| 提出日時 | 2022-10-13 23:12:41 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 106 ms / 2,000 ms |
| コード長 | 493 bytes |
| 記録 | |
| コンパイル時間 | 340 ms |
| コンパイル使用メモリ | 85,248 KB |
| 実行使用メモリ | 128,128 KB |
| 最終ジャッジ日時 | 2026-03-13 05:10:59 |
| 合計ジャッジ時間 | 3,472 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 34 |
ソースコード
from collections import defaultdict
N, M = map(int, input().split())
A = list(map(int, input().split()))
dic = defaultdict(int)
for a in A:
dic[a % M] += 1
dic[M - a % M] += 0
ans = 0
for 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 = 1
print(ans)
ntuda