結果

問題 No.1972 Modulo Set
コンテスト
ユーザー pitP
提出日時 2022-06-10 22:05:00
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 563 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 208 ms
コンパイル使用メモリ 85,504 KB
実行使用メモリ 122,752 KB
最終ジャッジ日時 2026-04-20 17:31:55
合計ジャッジ時間 3,377 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import defaultdict
n,m = map(int,input().split())
a = list(map(int,input().split()))
b = [num%m for num in a]

d = defaultdict(int)
ans = 0
for num in b:
    if num == 0:
        ans |= 1
    else:
        d[num] += 1

if m%2:
    for num in b:
        ans += max(d[num],d[m-num])
        d[num] = 0
        d[m-num] = 0
else:
    boo = False
    for num in b:
        if num * 2 == m:
            boo = True
            continue
        ans += max(d[num],d[m-num])
        d[num] = 0
        d[m-num] = 0
    if boo:
        ans += 1

print(ans)
0