結果

問題 No.1972 Modulo Set
ユーザー とりゐ
提出日時 2022-06-10 22:05:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 312 bytes
コンパイル時間 168 ms
コンパイル使用メモリ 82,216 KB
実行使用メモリ 118,036 KB
最終ジャッジ日時 2024-10-05 01:32:29
合計ジャッジ時間 4,473 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

n,m=map(int,input().split())
a=list(map(int,input().split()))
cnt=defaultdict(int)
s=set()
for i in a:
  cnt[i%m]+=1
  s.add(i%m)

ans=0
for i in s:
  if i==0:
    ans+=1
    
  elif i*2==m:
    ans+=1
  else:
    ans+=max(cnt[i],cnt[m-i])
    cnt[i],cnt[m-i]=0,0

print(ans)
0