結果

問題 No.1972 Modulo Set
ユーザー roarisroaris
提出日時 2022-06-10 22:27:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 158 ms / 2,000 ms
コード長 424 bytes
コンパイル時間 320 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 114,424 KB
最終ジャッジ日時 2024-04-15 08:52:31
合計ジャッジ時間 5,242 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
54,712 KB
testcase_01 AC 43 ms
53,724 KB
testcase_02 AC 42 ms
54,072 KB
testcase_03 AC 62 ms
71,912 KB
testcase_04 AC 62 ms
73,316 KB
testcase_05 AC 64 ms
75,280 KB
testcase_06 AC 71 ms
80,516 KB
testcase_07 AC 87 ms
89,328 KB
testcase_08 AC 60 ms
73,288 KB
testcase_09 AC 59 ms
66,216 KB
testcase_10 AC 63 ms
73,832 KB
testcase_11 AC 84 ms
87,960 KB
testcase_12 AC 60 ms
69,468 KB
testcase_13 AC 57 ms
66,972 KB
testcase_14 AC 59 ms
68,672 KB
testcase_15 AC 94 ms
91,080 KB
testcase_16 AC 101 ms
93,444 KB
testcase_17 AC 72 ms
78,152 KB
testcase_18 AC 42 ms
54,108 KB
testcase_19 AC 95 ms
89,580 KB
testcase_20 AC 109 ms
95,068 KB
testcase_21 AC 72 ms
78,508 KB
testcase_22 AC 87 ms
91,296 KB
testcase_23 AC 141 ms
103,408 KB
testcase_24 AC 84 ms
87,844 KB
testcase_25 AC 105 ms
101,388 KB
testcase_26 AC 107 ms
95,816 KB
testcase_27 AC 142 ms
103,832 KB
testcase_28 AC 81 ms
89,308 KB
testcase_29 AC 99 ms
101,088 KB
testcase_30 AC 119 ms
114,424 KB
testcase_31 AC 55 ms
65,828 KB
testcase_32 AC 115 ms
108,920 KB
testcase_33 AC 154 ms
108,504 KB
testcase_34 AC 153 ms
108,856 KB
testcase_35 AC 158 ms
108,660 KB
testcase_36 AC 153 ms
108,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from collections import *

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

for Ai in A:
    cnt[Ai%M] += 1

ans = 0
s = set()
l = list(cnt.keys())

for k in l:
    if k in s:
        continue
    
    if k==0 or (M%2==0 and k==M//2):
        ans += min(1, cnt[k])
    else:
        ans += max(cnt[k], cnt[M-k])
        s.add(M-k)

print(ans)
0