結果

問題 No.1972 Modulo Set
コンテスト
ユーザー pitP
提出日時 2022-06-10 22:05:00
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 90 ms / 2,000 ms
+ 905µs
コード長 563 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 86 ms
コンパイル使用メモリ 64,980 KB
実行使用メモリ 91,088 KB
最終ジャッジ日時 2026-10-15 22:23:10
合計ジャッジ時間 5,277 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

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