結果

問題 No.1972 Modulo Set
ユーザー aaaaaaaaaa2230
提出日時 2022-06-10 22:29:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 480 bytes
コンパイル時間 510 ms
コンパイル使用メモリ 82,368 KB
実行使用メモリ 107,612 KB
最終ジャッジ日時 2024-10-05 01:35:18
合計ジャッジ時間 3,689 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
dic = {}
A = list(map(int,input().split()))
for a in A:
    dic[a%m] = dic.get(a%m,0) + 1
    
ans = 0
done = set()
for key,value in dic.items():
    if key in done:
        continue
    if key == 0:
        ans += 1
        continue
    if m-key in dic:
        if m-key == key:
            ans += 1
        else:
            val2 = dic[m-key]
            ans += max(value,val2)
            done.add(m-key)
    else:
        ans += value
print(ans)
0