結果
問題 | No.1972 Modulo Set |
ユーザー |
![]() |
提出日時 | 2022-06-10 21:25:50 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 128 ms / 2,000 ms |
コード長 | 757 bytes |
コンパイル時間 | 174 ms |
コンパイル使用メモリ | 82,080 KB |
実行使用メモリ | 106,112 KB |
最終ジャッジ日時 | 2024-10-05 01:22:53 |
合計ジャッジ時間 | 4,849 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
mod = 998244353def main():import sysinput = sys.stdin.readlineN, M = map(int, input().split())A = list(map(int, input().split()))cnt = {}for a in A:d = a % Mif d not in cnt:cnt[d] = 0cnt[d] += 1seen = set()ans = 0for d in cnt:if d in seen:continueseen.add(d)if d == 0:seen.add(0)ans += 1elif d * 2 == M:seen.add(d)ans += 1else:dd = M - dif dd not in cnt:ans += cnt[d]else:ans += max(cnt[d], cnt[dd])seen.add(dd)print(ans)if __name__ == '__main__':main()