結果

問題 No.1972 Modulo Set
ユーザー titia
提出日時 2022-06-10 21:30:25
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 271 ms / 2,000 ms
コード長 419 bytes
コンパイル時間 183 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 40,160 KB
最終ジャッジ日時 2024-10-05 01:25:21
合計ジャッジ時間 5,708 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

X=Counter()

for a in A:
    X[a%M]+=1

ANS=0
USE=set()

for x in X:
    #print(x,USE)
    if x!=M/2 and x!=0 and not(x in USE):
        y=M-x

        ANS+=max(X[x],X[y])
        USE.add(x)
        USE.add(y)
    elif x==M/2:
        ANS+=1
    elif x==0:
        ANS+=1

print(ANS)

0