結果

問題 No.1972 Modulo Set
ユーザー pitP
提出日時 2022-06-10 21:38:20
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 625 bytes
コンパイル時間 191 ms
コンパイル使用メモリ 81,716 KB
実行使用メモリ 134,348 KB
最終ジャッジ日時 2024-09-21 06:04:52
合計ジャッジ時間 4,993 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
n,m = map(int,input().split())
a = list(map(int,input().split()))
amod = [num%m for num in a]
if sum(amod) == 0:
    print(0)
    exit()

d = defaultdict(int)
db = defaultdict(bool)
d0 = defaultdict(int)
for idx,num in enumerate(amod):
    if num == 0:
        d0[a[idx]] += 1
    else:
        d[num] += 1
        db[num] = True

ans = 0
for num in amod:
    if num != 0 and db[num]:
        db[num] = False
        db[m-num] = False
        ans += max(d[num],d[m-num])


max0 = 0
for idx , num in enumerate(amod):
    if num == 0:
        max0 = max(max0 , d0[a[idx]])

print(ans + max0)
0