diff options
| author | Gloria Mundi <gloria@gloria-mundi.eu> | 2024-11-16 21:17:29 +0100 |
|---|---|---|
| committer | Gloria Mundi <gloria@gloria-mundi.eu> | 2024-11-16 21:17:29 +0100 |
| commit | 1880ccb6d85c6eb79e724593457877bab431951c (patch) | |
| tree | 23eddd5bd0b29b3024e170a5ef9023eda9226ab5 /content/other/fastSubsetSum.cpp | |
| parent | e95f59debd69ee7d45d5c966ce466d23264e1c3c (diff) | |
get rid of all() and sz()
Diffstat (limited to 'content/other/fastSubsetSum.cpp')
| -rw-r--r-- | content/other/fastSubsetSum.cpp | 10 |
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 +} |
