結果

問題 No.1972 Modulo Set
ユーザー pitPpitP
提出日時 2022-06-10 22:05:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 148 ms / 2,000 ms
コード長 563 bytes
コンパイル時間 301 ms
コンパイル使用メモリ 82,364 KB
実行使用メモリ 105,416 KB
最終ジャッジ日時 2024-04-15 08:50:46
合計ジャッジ時間 5,032 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
54,248 KB
testcase_01 AC 44 ms
53,724 KB
testcase_02 AC 46 ms
53,668 KB
testcase_03 AC 73 ms
71,872 KB
testcase_04 AC 70 ms
74,848 KB
testcase_05 AC 72 ms
75,520 KB
testcase_06 AC 82 ms
81,496 KB
testcase_07 AC 100 ms
90,832 KB
testcase_08 AC 70 ms
77,008 KB
testcase_09 AC 59 ms
65,804 KB
testcase_10 AC 72 ms
75,752 KB
testcase_11 AC 97 ms
89,320 KB
testcase_12 AC 65 ms
70,052 KB
testcase_13 AC 58 ms
66,908 KB
testcase_14 AC 59 ms
66,836 KB
testcase_15 AC 106 ms
92,488 KB
testcase_16 AC 113 ms
94,932 KB
testcase_17 AC 84 ms
78,752 KB
testcase_18 AC 45 ms
55,056 KB
testcase_19 AC 106 ms
90,580 KB
testcase_20 AC 113 ms
96,492 KB
testcase_21 AC 83 ms
78,980 KB
testcase_22 AC 103 ms
88,324 KB
testcase_23 AC 134 ms
104,852 KB
testcase_24 AC 83 ms
84,280 KB
testcase_25 AC 99 ms
94,660 KB
testcase_26 AC 118 ms
93,044 KB
testcase_27 AC 136 ms
105,052 KB
testcase_28 AC 81 ms
83,776 KB
testcase_29 AC 96 ms
93,232 KB
testcase_30 AC 108 ms
105,384 KB
testcase_31 AC 57 ms
64,792 KB
testcase_32 AC 103 ms
100,156 KB
testcase_33 AC 148 ms
105,364 KB
testcase_34 AC 143 ms
105,416 KB
testcase_35 AC 144 ms
105,296 KB
testcase_36 AC 145 ms
105,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
n,m = map(int,input().split())
a = list(map(int,input().split()))
b = [num%m for num in a]

d = defaultdict(int)
ans = 0
for num in b:
    if num == 0:
        ans |= 1
    else:
        d[num] += 1

if m%2:
    for num in b:
        ans += max(d[num],d[m-num])
        d[num] = 0
        d[m-num] = 0
else:
    boo = False
    for num in b:
        if num * 2 == m:
            boo = True
            continue
        ans += max(d[num],d[m-num])
        d[num] = 0
        d[m-num] = 0
    if boo:
        ans += 1

print(ans)
0