Seg Tree + Binary Search
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
#include <vector>
#include <climits>
using namespace std;

class SegTree {
public:
    int l, r, val;
    SegTree *left, *right;

    SegTree(int l, int r) : l(l), r(r) {
        if (l == r) {
            val = 0;
            left = right = nullptr;
        } else {
            int mid = (l + r) / 2;
            left = new SegTree(l, mid);
            right = new SegTree(mid + 1, r);
            val = min(left->val, right->val);
        }
    }

    int get(int ql, int qr) {
        if (l > qr || r < ql) return INT_MAX;
        if (ql <= l && r <= qr) return val;
        return min(left->get(ql, qr), right->get(ql, qr));
    }

    void update(int idx, int newVal) {
        if (l > idx || r < idx) return;
        if (l == r && l == idx) {
            val = newVal;
        } else {
            left->update(idx, newVal);
            right->update(idx, newVal);
            val = min(left->val, right->val);
        }
    }
};

class Solution {
public:
    vector<int> busiestServers(int k, vector<int>& arrival, vector<int>& load) {
        SegTree* root = new SegTree(0, k - 1);
        
        auto findLessThan = [&](int l, int r, int target) -> int {
            if (r < l) return -1;
            if (root->get(l, r) > target) return -1;

            while (l < r) {
                int mid = l + (r - l) / 2;
                if (root->get(l, mid) <= target) {
                    r = mid;
                } else {
                    l = mid + 1;
                }
            }

            return r;
        };

        int maxRequest = 0;
        vector<int> requestsHandled(k, 0);

        for (int i = 0; i < arrival.size(); ++i) {
            int idx = findLessThan(i % k, k - 1, arrival[i]);

            if (idx == -1) {
                idx = findLessThan(0, (i % k) - 1, arrival[i]);
            }

            if (idx != -1) {
                requestsHandled[idx] += 1;
                maxRequest = max(maxRequest, requestsHandled[idx]);
                root->update(idx, arrival[i] + load[i]);
            }
        }

        vector<int> ans;
        for (int i = 0; i < k; ++i) {
            if (requestsHandled[i] == maxRequest) {
                ans.push_back(i);
            }
        }

        return ans;
    }
};

```
['C++']