結果

問題 No.1972 Modulo Set
コンテスト
ユーザー とりゐ
提出日時 2022-06-10 22:05:13
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 96 ms / 2,000 ms
+ 855µs
コード長 312 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 80 ms
コンパイル使用メモリ 64,764 KB
実行使用メモリ 92,624 KB
最終ジャッジ日時 2026-10-15 22:23:26
合計ジャッジ時間 5,931 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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