結果
問題 | No.1972 Modulo Set |
ユーザー | 8nd5t |
提出日時 | 2022-06-10 21:51:21 |
言語 | PyPy3 (7.3.13) |
結果 |
AC
|
実行時間 | 358 ms / 2,000 ms |
コード長 | 1,375 bytes |
コンパイル時間 | 344 ms |
コンパイル使用メモリ | 87,252 KB |
実行使用メモリ | 144,320 KB |
最終ジャッジ日時 | 2023-07-27 22:21:39 |
合計ジャッジ時間 | 13,599 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 245 ms
91,012 KB |
testcase_01 | AC | 244 ms
91,396 KB |
testcase_02 | AC | 247 ms
91,316 KB |
testcase_03 | AC | 263 ms
92,536 KB |
testcase_04 | AC | 266 ms
94,632 KB |
testcase_05 | AC | 263 ms
95,720 KB |
testcase_06 | AC | 270 ms
98,896 KB |
testcase_07 | AC | 284 ms
106,724 KB |
testcase_08 | AC | 261 ms
96,988 KB |
testcase_09 | AC | 264 ms
92,804 KB |
testcase_10 | AC | 265 ms
94,848 KB |
testcase_11 | AC | 291 ms
105,476 KB |
testcase_12 | AC | 267 ms
92,628 KB |
testcase_13 | AC | 263 ms
92,732 KB |
testcase_14 | AC | 266 ms
92,604 KB |
testcase_15 | AC | 302 ms
109,376 KB |
testcase_16 | AC | 310 ms
111,428 KB |
testcase_17 | AC | 277 ms
97,344 KB |
testcase_18 | AC | 249 ms
91,256 KB |
testcase_19 | AC | 301 ms
108,540 KB |
testcase_20 | AC | 311 ms
113,452 KB |
testcase_21 | AC | 276 ms
99,216 KB |
testcase_22 | AC | 292 ms
114,296 KB |
testcase_23 | AC | 342 ms
133,972 KB |
testcase_24 | AC | 292 ms
113,744 KB |
testcase_25 | AC | 310 ms
127,208 KB |
testcase_26 | AC | 307 ms
114,768 KB |
testcase_27 | AC | 341 ms
133,648 KB |
testcase_28 | AC | 282 ms
116,068 KB |
testcase_29 | AC | 306 ms
127,240 KB |
testcase_30 | AC | 320 ms
142,976 KB |
testcase_31 | AC | 255 ms
92,492 KB |
testcase_32 | AC | 313 ms
136,780 KB |
testcase_33 | AC | 353 ms
144,004 KB |
testcase_34 | AC | 358 ms
144,104 KB |
testcase_35 | AC | 358 ms
144,320 KB |
testcase_36 | AC | 355 ms
144,176 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)