#include "testlib.h" #include #include #include using namespace std; #define rep(i,n) for(int i=0; i<(n); i++) const int maxN = 100000; const int maxQ = 100000; const int maxT = 100000; struct Query { int i, t; bool isstarting; }; vector queries; int N, Q; vector playing; // for testing instructions duplicates int playing_cnt = 0; double X = 0.0; vector ansbuf; int main() { registerValidation(); cout << setprecision(10); N = inf.readInt(1,maxN); inf.readSpace(); Q = inf.readInt(1,maxQ); inf.readEoln(); playing.assign(N,0); ansbuf.assign(N,0.0); rep(q,Q) { int i = inf.readInt(1,N); inf.readSpace(); int s = inf.readInt(0,maxT); inf.readSpace(); int t = inf.readInt(0,maxT); inf.readEoln(); ensure(s < t); i--; queries.push_back({ i,s,true }); queries.push_back({ i,t,false }); } inf.readEof(); auto cmp_query_time = [](Query l, Query r)->bool { return make_pair(l.t,(l.isstarting?0:1)) < make_pair(r.t,(r.isstarting?0:1)); }; sort(queries.begin(), queries.end(), cmp_query_time); int T = 0; for (Query& q : queries) { if (playing_cnt != 0) X += double(q.t - T) / playing_cnt; if (q.isstarting) { ensure(playing[q.i] == 0); // instructions duplicate playing[q.i] = 1; ansbuf[q.i] -= X; playing_cnt++; } else { playing[q.i] = 0; ansbuf[q.i] += X; playing_cnt--; } T = q.t; } rep(i,N) cout << ansbuf[i] << "\n"; return 0; }