summaryrefslogtreecommitdiff
path: root/content/other/fastSubsetSum.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'content/other/fastSubsetSum.cpp')
-rw-r--r--content/other/fastSubsetSum.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/content/other/fastSubsetSum.cpp b/content/other/fastSubsetSum.cpp
index 84396f6..38a84b6 100644
--- a/content/other/fastSubsetSum.cpp
+++ b/content/other/fastSubsetSum.cpp
@@ -1,11 +1,11 @@
int fastSubsetSum(vector<int> w, int t){
int a = 0, b = 0;
- while(b < sz(w) && a + w[b] <= t) a += w[b++];
- if(b == sz(w)) return a;
- int m = *max_element(all(w));
+ while(b < ssize(w) && a + w[b] <= t) a += w[b++];
+ if(b == ssize(w)) return a;
+ int m = *ranges::max_element(w);
vector<int> dp(2*m, -1), old;
dp[m+a-t] = b;
- for(int i = b; i < sz(w); i++){
+ for(int i = b; i < ssize(w); i++){
old = dp;
for(int j = 0; j < m; j++){
dp[j+w[i]] = max(dp[j+w[i]], old[j]);
@@ -18,4 +18,4 @@ int fastSubsetSum(vector<int> w, int t){
}
for(a = t; dp[m+a-t] < 0; a--);
return a;
-} \ No newline at end of file
+}