diff options
| author | Gloria Mundi <gloria@gloria-mundi.eu> | 2024-11-16 01:24:14 +0100 |
|---|---|---|
| committer | Gloria Mundi <gloria@gloria-mundi.eu> | 2024-11-16 01:24:14 +0100 |
| commit | 98567ec798aa8ca2cfbcb85c774dd470f30e30d4 (patch) | |
| tree | 5113d5cc24d1ad5f93810b6442ce584a36950dc8 /content/other/pbs.cpp | |
| parent | ad3856a6b766087df0036de0b556f4700a6498c9 (diff) | |
| parent | 8d11c6c8213f46f0fa19826917c255edd5d43cb1 (diff) | |
mzuenni tests
Diffstat (limited to 'content/other/pbs.cpp')
| -rw-r--r-- | content/other/pbs.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/content/other/pbs.cpp b/content/other/pbs.cpp new file mode 100644 index 0000000..7cb60e5 --- /dev/null +++ b/content/other/pbs.cpp @@ -0,0 +1,19 @@ +// Q = # of queries, bucket sort is sometimes faster +vector<int> low(Q, 0), high(Q, MAX_OPERATIONS); +while (true) { + vector<pair<int, int>> focus; + for (int i = 0; i < Q; i++) if (low[i] < high[i]) { + focus.emplace_back((low[i] + high[i]) / 2, i); + } + if (focus.empty()) break; + sort(all(focus)); + + // reset simulation + for (int step = 0; auto [mid, i] : focus) { + while (step <= mid) { + // simulation step + step++; + } + if (/* requirement already fulfilled */) high[i] = mid; + else low[i] = mid + 1; +}} // answer in low (and high) |
