From a4290931adcb08a37e1756d586c52ab4aeeb7102 Mon Sep 17 00:00:00 2001 From: Zengtudor Date: Fri, 18 Oct 2024 15:00:42 +0800 Subject: [PATCH] update --- src/P5020/1.in | 5 +++++ src/P5020/P5020.py | 26 ++++++++++++++++++++++++++ src/P5424/P5424.cpp | 0 3 files changed, 31 insertions(+) create mode 100644 src/P5020/1.in create mode 100644 src/P5020/P5020.py create mode 100644 src/P5424/P5424.cpp diff --git a/src/P5020/1.in b/src/P5020/1.in new file mode 100644 index 0000000..09ac99c --- /dev/null +++ b/src/P5020/1.in @@ -0,0 +1,5 @@ +2 +4 +3 19 10 6 +5 +11 29 13 19 17 \ No newline at end of file diff --git a/src/P5020/P5020.py b/src/P5020/P5020.py new file mode 100644 index 0000000..b60f79a --- /dev/null +++ b/src/P5020/P5020.py @@ -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) diff --git a/src/P5424/P5424.cpp b/src/P5424/P5424.cpp new file mode 100644 index 0000000..e69de29