diff options
Diffstat (limited to 'content/other')
| -rw-r--r-- | content/other/fastSubsetSum.cpp | 10 | ||||
| -rw-r--r-- | content/other/pbs.cpp | 2 | ||||
| -rw-r--r-- | content/other/sos.cpp | 4 |
3 files changed, 8 insertions, 8 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 +} diff --git a/content/other/pbs.cpp b/content/other/pbs.cpp index f4db2fd..e6bfeac 100644 --- a/content/other/pbs.cpp +++ b/content/other/pbs.cpp @@ -7,7 +7,7 @@ while (true) { focus.emplace_back((low[i] + high[i]) / 2, i); }} if (focus.empty()) break; - sort(all(focus)); + ranges::sort(focus); // reset simulation for (int step = 0; auto [mid, i] : focus) { diff --git a/content/other/sos.cpp b/content/other/sos.cpp index 01bc44c..892a47c 100644 --- a/content/other/sos.cpp +++ b/content/other/sos.cpp @@ -1,6 +1,6 @@ vector<ll> res(in); -for (int i = 1; i < sz(res); i *= 2) { - for (int mask = 0; mask < sz(res); mask++){ +for (int i = 1; i < ssize(res); i *= 2) { + for (int mask = 0; mask < ssize(res); mask++){ if (mask & i) { res[mask] += res[mask ^ i]; }}} |
