結果
問題 | No.1972 Modulo Set |
ユーザー |
|
提出日時 | 2023-04-01 00:55:46 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 142 ms / 2,000 ms |
コード長 | 466 bytes |
コンパイル時間 | 701 ms |
コンパイル使用メモリ | 82,060 KB |
実行使用メモリ | 114,356 KB |
最終ジャッジ日時 | 2024-09-23 03:06:51 |
合計ジャッジ時間 | 4,958 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
n, m = map(int, input().split()) a = list(map(int, input().split())) if m == 1: print("1") exit() cnt = {} for i in range(n): x = a[i] % m cnt[x] = cnt.get(x, 0) + 1 ans = 0 used = {} for x in cnt.keys(): y = (m - x) % m if not used.get(x, None) is None or not used.get(y, None) is None: continue used[x] = True used[y] = True if x == y: ans += 1 else: ans += max(cnt.get(x, 0), cnt.get(y, 0)) if ans == 0: ans += 1 print(ans)