結果

問題 No.1972 Modulo Set
ユーザー roaris
提出日時 2022-06-10 22:27:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 129 ms / 2,000 ms
コード長 424 bytes
コンパイル時間 227 ms
コンパイル使用メモリ 81,880 KB
実行使用メモリ 114,320 KB
最終ジャッジ日時 2024-10-05 01:34:42
合計ジャッジ時間 4,362 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

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