結果
問題 | No.1972 Modulo Set |
ユーザー | 8nd5t |
提出日時 | 2022-06-10 21:51:21 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 352 ms / 2,000 ms |
コード長 | 1,375 bytes |
コンパイル時間 | 264 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 142,440 KB |
最終ジャッジ日時 | 2024-04-15 08:49:53 |
合計ジャッジ時間 | 11,373 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 198 ms
84,128 KB |
testcase_01 | AC | 201 ms
83,968 KB |
testcase_02 | AC | 187 ms
84,600 KB |
testcase_03 | AC | 208 ms
85,104 KB |
testcase_04 | AC | 210 ms
86,732 KB |
testcase_05 | AC | 212 ms
87,572 KB |
testcase_06 | AC | 228 ms
92,536 KB |
testcase_07 | AC | 238 ms
98,052 KB |
testcase_08 | AC | 206 ms
89,524 KB |
testcase_09 | AC | 203 ms
85,276 KB |
testcase_10 | AC | 216 ms
87,428 KB |
testcase_11 | AC | 230 ms
96,536 KB |
testcase_12 | AC | 211 ms
84,868 KB |
testcase_13 | AC | 203 ms
85,272 KB |
testcase_14 | AC | 205 ms
85,312 KB |
testcase_15 | AC | 242 ms
98,100 KB |
testcase_16 | AC | 255 ms
101,020 KB |
testcase_17 | AC | 223 ms
89,368 KB |
testcase_18 | AC | 187 ms
84,296 KB |
testcase_19 | AC | 249 ms
98,876 KB |
testcase_20 | AC | 264 ms
104,168 KB |
testcase_21 | AC | 236 ms
90,556 KB |
testcase_22 | AC | 244 ms
99,096 KB |
testcase_23 | AC | 309 ms
131,440 KB |
testcase_24 | AC | 261 ms
100,504 KB |
testcase_25 | AC | 266 ms
110,328 KB |
testcase_26 | AC | 258 ms
100,504 KB |
testcase_27 | AC | 315 ms
132,228 KB |
testcase_28 | AC | 244 ms
108,228 KB |
testcase_29 | AC | 262 ms
109,952 KB |
testcase_30 | AC | 283 ms
121,148 KB |
testcase_31 | AC | 201 ms
84,796 KB |
testcase_32 | AC | 277 ms
116,760 KB |
testcase_33 | AC | 339 ms
142,440 KB |
testcase_34 | AC | 352 ms
141,888 KB |
testcase_35 | AC | 346 ms
142,032 KB |
testcase_36 | AC | 351 ms
142,404 KB |
ソースコード
from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify from bisect import bisect_left,bisect_right import sys,math,itertools,pprint,fractions sys.setrecursionlimit(10**8) mod = 998244353 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) def inpl_1(): return list(map(lambda x:int(x)-1, sys.stdin.readline().split())) def inplm(): return map(int, sys.stdin.readline().split()) def inpl_1m(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) def err(x): print(x); exit() def sol(n,m,a): res = 0 for it in itertools.product([0,1],repeat=n): if sum(it) == 0: continue b = [] for i,x in enumerate(it): if x: b.append(a[i]) ln = len(b) ok = 1 for i in range(ln): for j in range(i+1,ln): if (a[i] + a[j])%m: ok = 0 if ok: res = max(res, ln) return res n,m = inpl() a = inpl() d = defaultdict(int) for x in a: d[x%m] += 1 res = n seen = set() for key in list(d): if key in seen: continue if key == 0 or key == m-key: res -= d[key]-1 seen.add(key) else: seen.add(key) seen.add(m-key) res -= min(d[key], d[m-key]) print(res)