結果

問題 No.1972 Modulo Set
ユーザー ntudantuda
提出日時 2022-10-13 23:12:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 184 ms / 2,000 ms
コード長 493 bytes
コンパイル時間 582 ms
コンパイル使用メモリ 86,988 KB
実行使用メモリ 121,840 KB
最終ジャッジ日時 2023-09-08 19:17:09
合計ジャッジ時間 7,519 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
71,340 KB
testcase_01 AC 95 ms
71,704 KB
testcase_02 AC 92 ms
71,584 KB
testcase_03 AC 123 ms
77,956 KB
testcase_04 AC 114 ms
80,384 KB
testcase_05 AC 116 ms
81,720 KB
testcase_06 AC 122 ms
85,360 KB
testcase_07 AC 129 ms
91,560 KB
testcase_08 AC 110 ms
83,104 KB
testcase_09 AC 108 ms
77,728 KB
testcase_10 AC 114 ms
80,688 KB
testcase_11 AC 130 ms
89,880 KB
testcase_12 AC 113 ms
78,008 KB
testcase_13 AC 108 ms
77,988 KB
testcase_14 AC 108 ms
77,960 KB
testcase_15 AC 136 ms
93,628 KB
testcase_16 AC 141 ms
97,564 KB
testcase_17 AC 115 ms
81,616 KB
testcase_18 AC 91 ms
71,728 KB
testcase_19 AC 137 ms
93,660 KB
testcase_20 AC 143 ms
99,528 KB
testcase_21 AC 120 ms
83,140 KB
testcase_22 AC 131 ms
92,272 KB
testcase_23 AC 169 ms
114,392 KB
testcase_24 AC 128 ms
90,612 KB
testcase_25 AC 141 ms
98,600 KB
testcase_26 AC 148 ms
98,920 KB
testcase_27 AC 173 ms
114,876 KB
testcase_28 AC 127 ms
91,832 KB
testcase_29 AC 142 ms
98,772 KB
testcase_30 AC 158 ms
108,356 KB
testcase_31 AC 108 ms
77,960 KB
testcase_32 AC 152 ms
105,100 KB
testcase_33 AC 184 ms
121,600 KB
testcase_34 AC 179 ms
121,716 KB
testcase_35 AC 178 ms
121,536 KB
testcase_36 AC 183 ms
121,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

N, M = map(int, input().split())
A = list(map(int, input().split()))
dic = defaultdict(int)
for a in A:
    dic[a % M] += 1
    dic[M - a % M] += 0
ans = 0
for k, v in dic.items():
    if k == 0:
        ans += min(1, dic[k])
    elif k == M // 2:
        if M % 2 == 0:
            ans += min(1, dic[k])
        else:
            ans += max(dic[k], dic[M - k])
    elif k < M//2:
        ans += max(dic[k], dic[M - k])
if ans == 0:
    ans = 1
print(ans)
0