結果

問題 No.1972 Modulo Set
ユーザー Shirotsume
提出日時 2022-06-11 00:04:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 643 bytes
コンパイル時間 184 ms
コンパイル使用メモリ 81,908 KB
実行使用メモリ 114,652 KB
最終ジャッジ日時 2024-10-05 01:40:17
合計ジャッジ時間 5,110 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
INF = 2 ** 63 - 1
mod = 998244353

from collections import Counter


n, m = mi() 

a = li()

C = Counter()

for v in a:
    C[v % m] += 1

ans = 0
s = set()
for c, v in C.items():
    if c in s or m - c in s: continue
    if c == 0:
        s.add(c)
        ans += 1
    elif m % 2 == 0 and c == m // 2:
        s.add(c)
        ans += min(v, 1)
    else:
        s.add(c)
        s.add(m - c)
        if v > C[m - c]:
            ans += v
        else:
            ans += C[m - c]
    
print(ans)
0