結果

問題 No.1972 Modulo Set
ユーザー gr1msl3ygr1msl3y
提出日時 2022-06-11 01:13:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 570 ms / 2,000 ms
コード長 330 bytes
コンパイル時間 235 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 119,956 KB
最終ジャッジ日時 2024-04-15 08:56:49
合計ジャッジ時間 9,854 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
53,632 KB
testcase_01 AC 51 ms
53,632 KB
testcase_02 AC 49 ms
54,016 KB
testcase_03 AC 85 ms
74,624 KB
testcase_04 AC 84 ms
76,120 KB
testcase_05 AC 81 ms
75,264 KB
testcase_06 AC 111 ms
84,440 KB
testcase_07 AC 125 ms
90,728 KB
testcase_08 AC 80 ms
74,112 KB
testcase_09 AC 71 ms
66,560 KB
testcase_10 AC 82 ms
75,264 KB
testcase_11 AC 119 ms
89,536 KB
testcase_12 AC 79 ms
71,936 KB
testcase_13 AC 77 ms
69,504 KB
testcase_14 AC 81 ms
70,272 KB
testcase_15 AC 200 ms
93,004 KB
testcase_16 AC 248 ms
94,968 KB
testcase_17 AC 126 ms
82,304 KB
testcase_18 AC 59 ms
53,888 KB
testcase_19 AC 251 ms
93,396 KB
testcase_20 AC 277 ms
96,600 KB
testcase_21 AC 135 ms
83,252 KB
testcase_22 AC 228 ms
92,376 KB
testcase_23 AC 462 ms
112,260 KB
testcase_24 AC 202 ms
90,184 KB
testcase_25 AC 291 ms
99,548 KB
testcase_26 AC 247 ms
96,920 KB
testcase_27 AC 461 ms
113,028 KB
testcase_28 AC 200 ms
91,172 KB
testcase_29 AC 305 ms
99,976 KB
testcase_30 AC 377 ms
107,820 KB
testcase_31 AC 74 ms
68,224 KB
testcase_32 AC 351 ms
105,600 KB
testcase_33 AC 549 ms
119,640 KB
testcase_34 AC 570 ms
119,956 KB
testcase_35 AC 557 ms
119,828 KB
testcase_36 AC 537 ms
119,820 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
N,M=map(int,input().split())
A=list(map(int,input().split()))
D=defaultdict(int)
for a in A:
	D[a%M]+=1
B=[[D[k],k] for k in D if D[k]]
B.sort(reverse=True)
S=set()
ans=0
for c,v in B:
	if 2*v%M==0:
		ans+=(c>0)
		S.add(v)
	else:
		if v not in S:
			ans+=c
			S.add(v)
			S.add(M-v)
print(ans)
0