結果
| 問題 |
No.1972 Modulo Set
|
| コンテスト | |
| ユーザー |
tamato
|
| 提出日時 | 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 = 998244353
def main():
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
A = list(map(int, input().split()))
cnt = {}
for a in A:
d = a % M
if d not in cnt:
cnt[d] = 0
cnt[d] += 1
seen = set()
ans = 0
for d in cnt:
if d in seen:
continue
seen.add(d)
if d == 0:
seen.add(0)
ans += 1
elif d * 2 == M:
seen.add(d)
ans += 1
else:
dd = M - d
if dd not in cnt:
ans += cnt[d]
else:
ans += max(cnt[d], cnt[dd])
seen.add(dd)
print(ans)
if __name__ == '__main__':
main()
tamato