結果

問題 No.1972 Modulo Set
ユーザー minimumminimum
提出日時 2022-06-10 21:35:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 222 ms / 2,000 ms
コード長 524 bytes
コンパイル時間 244 ms
コンパイル使用メモリ 81,528 KB
実行使用メモリ 125,568 KB
最終ジャッジ日時 2024-04-15 08:48:05
合計ジャッジ時間 5,937 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
53,504 KB
testcase_01 AC 49 ms
54,016 KB
testcase_02 AC 55 ms
53,552 KB
testcase_03 AC 75 ms
71,168 KB
testcase_04 AC 76 ms
73,984 KB
testcase_05 AC 76 ms
74,240 KB
testcase_06 AC 87 ms
81,760 KB
testcase_07 AC 102 ms
89,856 KB
testcase_08 AC 73 ms
72,960 KB
testcase_09 AC 67 ms
65,408 KB
testcase_10 AC 76 ms
73,728 KB
testcase_11 AC 101 ms
88,552 KB
testcase_12 AC 74 ms
69,888 KB
testcase_13 AC 67 ms
67,072 KB
testcase_14 AC 70 ms
67,456 KB
testcase_15 AC 119 ms
92,416 KB
testcase_16 AC 126 ms
96,568 KB
testcase_17 AC 84 ms
77,312 KB
testcase_18 AC 55 ms
53,888 KB
testcase_19 AC 121 ms
93,184 KB
testcase_20 AC 132 ms
98,944 KB
testcase_21 AC 88 ms
79,688 KB
testcase_22 AC 111 ms
96,384 KB
testcase_23 AC 190 ms
114,288 KB
testcase_24 AC 107 ms
93,184 KB
testcase_25 AC 135 ms
108,672 KB
testcase_26 AC 124 ms
96,132 KB
testcase_27 AC 199 ms
114,688 KB
testcase_28 AC 106 ms
95,104 KB
testcase_29 AC 129 ms
108,032 KB
testcase_30 AC 161 ms
125,568 KB
testcase_31 AC 65 ms
66,176 KB
testcase_32 AC 150 ms
118,656 KB
testcase_33 AC 214 ms
117,384 KB
testcase_34 AC 217 ms
117,404 KB
testcase_35 AC 213 ms
117,020 KB
testcase_36 AC 222 ms
117,064 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict


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

r = defaultdict(int)
for i in range(N):
    r[A[i] % M] += 1
    if M - (A[i] % M) not in r:
        r[M - (A[i] % M)] = 0

ans = 0
done = set()
if 0 in r:
    ans += 1
    done.add(0)
    done.add(M)
if M % 2 == 0 and (M // 2 in r):
    ans += 1
    done.add(M // 2)

for i in r:
    if i in done:
        continue
    else:
        ans += max(r[i], r[M - i])
        done.add(i)
        done.add(M - i)

print(ans)
0