#include #include #include #include #include #include #include #include #include using namespace std; ifstream inF("transfer.in"); ofstream outF("transfer.out"); #define cin inF #define cout outF const int MAX_N = 1e5 + 5; typedef unsigned long long ull; typedef long long sll; struct File { int idx; ull t, s; double endT; }; sll n, v; File file[MAX_N]; void input() { cin >> n >> v; for (int i = 0; i < n; ++i) { file[i].idx = i; cin >> file[i].t >> file[i].s; } } void output() { for (int i = 0; i < n; ++i) { cout << fixed << setprecision(7) << file[i].endT << "\n"; } } bool cmpT(const File& a, const File& b) { return a.t < b.t; } bool cmpIdx(const File& a, const File& b) { return a.idx < b.idx; } void solve() { sort(file, file + n, cmpT); sll numFiles = 0; double perFile = 0; priority_queue> pq; double currT = file[0].t; for (int i = 0; i < n; ++i) { //cerr << "enter " << i << " at " << currT << " with " << perFile << " for files " << numFiles << endl; while (!pq.empty()) { pair ti = pq.top(); ti.first = -ti.first; if (currT + (ti.first - perFile) * numFiles / v <= file[i].t) { currT += (ti.first - perFile) * numFiles / v; file[ti.second].endT = currT; perFile = ti.first; --numFiles; pq.pop(); //cerr << "remove " << ti.second << " at " << currT << " with " << perFile << " for files " << numFiles << endl; } else break; } if (numFiles > 0) perFile += (file[i].t - currT) * v / numFiles; currT = file[i].t; ++numFiles; pq.push({-perFile - file[i].s, i}); //cerr << "add " << i << " at " << currT << " with " << perFile << " for files " << numFiles << endl; } while (!pq.empty()) { pair ti = pq.top(); ti.first = -ti.first; currT += (ti.first - perFile) * numFiles / v; file[ti.second].endT = currT; perFile = ti.first; --numFiles; pq.pop(); //cerr << "remove " << ti.second << " at " << currT << " with " << perFile << " for files " << numFiles << endl; } sort(file, file + n, cmpIdx); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); /*int t; cin >> t; for (int i = 0; i < t; ++i)*/ { input(); solve(); output(); } return 0; }