結果
問題 | No.1972 Modulo Set |
ユーザー |
![]() |
提出日時 | 2022-06-10 21:51:21 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 237 ms / 2,000 ms |
コード長 | 1,375 bytes |
コンパイル時間 | 217 ms |
コンパイル使用メモリ | 82,228 KB |
実行使用メモリ | 142,372 KB |
最終ジャッジ日時 | 2024-10-05 01:30:57 |
合計ジャッジ時間 | 8,525 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
from collections import Counter,defaultdict,dequefrom heapq import heappop,heappush,heapifyfrom bisect import bisect_left,bisect_rightimport sys,math,itertools,pprint,fractionssys.setrecursionlimit(10**8)mod = 998244353INF = 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 = 0for it in itertools.product([0,1],repeat=n):if sum(it) == 0:continueb = []for i,x in enumerate(it):if x:b.append(a[i])ln = len(b)ok = 1for i in range(ln):for j in range(i+1,ln):if (a[i] + a[j])%m:ok = 0if ok:res = max(res, ln)return resn,m = inpl()a = inpl()d = defaultdict(int)for x in a:d[x%m] += 1res = nseen = set()for key in list(d):if key in seen:continueif key == 0 or key == m-key:res -= d[key]-1seen.add(key)else:seen.add(key)seen.add(m-key)res -= min(d[key], d[m-key])print(res)