update
This commit is contained in:
parent
d76d8efbaf
commit
a4290931ad
5
src/P5020/1.in
Normal file
5
src/P5020/1.in
Normal file
@ -0,0 +1,5 @@
|
||||
2
|
||||
4
|
||||
3 19 10 6
|
||||
5
|
||||
11 29 13 19 17
|
26
src/P5020/P5020.py
Normal file
26
src/P5020/P5020.py
Normal file
@ -0,0 +1,26 @@
|
||||
from sys import stdin
|
||||
|
||||
def compute(n:int, arr:list[int])->None:
|
||||
# print(n,arr)
|
||||
arr.sort()
|
||||
ans = n
|
||||
an = arr[len(arr)-1]
|
||||
dp:list[bool] = [False]*(an+1)
|
||||
# print(dp)
|
||||
dp[0]=True
|
||||
for i in arr:
|
||||
if dp[i]:
|
||||
ans-=1
|
||||
continue
|
||||
for j in range(i,an+1):
|
||||
dp[j] = dp[j] or dp[j-i]
|
||||
# print(dp)
|
||||
print(f"{ans}")
|
||||
|
||||
input_strs = stdin.read().splitlines()
|
||||
t:int = int(input_strs.pop(0).strip())
|
||||
|
||||
for _ in range(t):
|
||||
n:int = int(input_strs.pop(0).strip())
|
||||
arr:list[int] = list(map(int,input_strs.pop(0).strip().split(' ')))
|
||||
compute(n,arr)
|
0
src/P5424/P5424.cpp
Normal file
0
src/P5424/P5424.cpp
Normal file
Loading…
Reference in New Issue
Block a user