return distA < distB;
return true;
};
pq = set<pair<int, int>, decltype(cmp)>(cmp);
auto mPair = std::make_pair(-1, n);
addInterval(mPair);
}
int seat() {
auto longest = *pq.rbegin();
int x = longest.first;
int y = longest.second;
int seat = 0;
if (x == -1) {
seat = 0;
} else if (y == N) {
seat = N - 1;
} else {
seat = (y - x) / 2 + x;
}
auto left = std::make_pair(x, seat);
auto right = std::make_pair(seat, y);
removeInterval(longest);
addInterval(left);
addInterval(right);
return seat;
}
void leave(int p) {
auto left = leftIntervalMap[p];
auto right = rightIntervalMap[p];
auto merged = std::make_pair(left.first, right.second);
removeInterval(left);
removeInterval(right);
addInterval(merged);
}
};
/
* Your ExamRoom object will be instantiated and called as such:
* ExamRoom obj = new ExamRoom(n);
* int param_1 = obj->seat();
* obj->leave(p);
/
int main() {
printf(“hello world n“);