結果

問題 No.1972 Modulo Set
コンテスト
ユーザー roaris
提出日時 2022-06-10 22:27:15
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 96 ms / 2,000 ms
+ 276µs
コード長 424 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 70 ms
コンパイル使用メモリ 80,896 KB
実行使用メモリ 137,728 KB
最終ジャッジ日時 2026-09-10 10:45:58
合計ジャッジ時間 4,454 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
input = sys.stdin.readline
from collections import *

N, M = map(int, input().split())
A = list(map(int, input().split()))
cnt = defaultdict(int)

for Ai in A:
    cnt[Ai%M] += 1

ans = 0
s = set()
l = list(cnt.keys())

for k in l:
    if k in s:
        continue
    
    if k==0 or (M%2==0 and k==M//2):
        ans += min(1, cnt[k])
    else:
        ans += max(cnt[k], cnt[M-k])
        s.add(M-k)

print(ans)
0