結果

問題 No.1972 Modulo Set
ユーザー lloyzlloyz
提出日時 2022-06-10 21:35:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 194 ms / 2,000 ms
コード長 483 bytes
コンパイル時間 282 ms
コンパイル使用メモリ 82,076 KB
実行使用メモリ 107,824 KB
最終ジャッジ日時 2024-04-15 08:47:59
合計ジャッジ時間 5,137 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
53,568 KB
testcase_01 AC 46 ms
53,224 KB
testcase_02 AC 43 ms
54,416 KB
testcase_03 AC 64 ms
71,276 KB
testcase_04 AC 66 ms
73,480 KB
testcase_05 AC 65 ms
74,480 KB
testcase_06 AC 74 ms
81,108 KB
testcase_07 AC 90 ms
90,192 KB
testcase_08 AC 62 ms
73,712 KB
testcase_09 AC 55 ms
65,236 KB
testcase_10 AC 63 ms
73,288 KB
testcase_11 AC 89 ms
88,544 KB
testcase_12 AC 62 ms
69,584 KB
testcase_13 AC 58 ms
65,508 KB
testcase_14 AC 59 ms
67,044 KB
testcase_15 AC 103 ms
91,924 KB
testcase_16 AC 113 ms
94,268 KB
testcase_17 AC 79 ms
76,836 KB
testcase_18 AC 43 ms
54,196 KB
testcase_19 AC 105 ms
90,700 KB
testcase_20 AC 113 ms
96,208 KB
testcase_21 AC 79 ms
79,868 KB
testcase_22 AC 93 ms
89,736 KB
testcase_23 AC 148 ms
105,012 KB
testcase_24 AC 86 ms
84,280 KB
testcase_25 AC 106 ms
94,276 KB
testcase_26 AC 115 ms
96,952 KB
testcase_27 AC 153 ms
105,052 KB
testcase_28 AC 84 ms
85,344 KB
testcase_29 AC 101 ms
93,472 KB
testcase_30 AC 125 ms
104,652 KB
testcase_31 AC 57 ms
66,264 KB
testcase_32 AC 118 ms
101,868 KB
testcase_33 AC 162 ms
107,564 KB
testcase_34 AC 194 ms
107,824 KB
testcase_35 AC 184 ms
107,696 KB
testcase_36 AC 159 ms
107,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

n, m = map(int, input().split())
A = list(map(int, input().split()))

RD = defaultdict(int)
for i in range(n):
    RD[A[i] % m] += 1

R = sorted(RD.keys())
ans = 0
for r in R:
    if RD[r] == 0:
        continue
    if r == 0:
        ans += min(1, RD[r])
        continue
    if r == m // 2:
        if m % 2 == 0:
            ans += min(1, RD[r])
            continue
    ans += max(RD[r], RD[m - r])
    RD[r] = 0
    RD[m - r] = 0
print(ans)
0