Company: Rubrik_23nov
Difficulty: medium
Where to Place Servers? Problem Description Imagine a data center rack with n slots, numbered 1 through n from left to right. When a new server is deployed, the system assigns an empty slot that maximizes the minimum physical distance from all the nearest active servers. If multiple such slots exist, the system selects the one with the lowest index (left most). If the rack is entirely empty, the server is assigned slot 1. The physical distance between slots numbered i and j is defined as |i - j|. Given a chronological record of server deployments and decommissionings, determine the assigned slot for each newly deployed server. Input Format The first line contains two integers, n and m, representing the number of rack slots and the number of records, respectively. The following m lines each contain two integers. ti and idi: * If ti = 1, it indicates the deployment of server idi * If ti = 2, it indicates the decommissioning of server idi The records are provided in chronological order, w