#include using namespace std; using int64 = long long; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int64 N; if(!(cin >> N)) return 0; vector S(N); for(int i=0;i> S[i]; int Q; cin >> Q; vector> events(Q); for(int i=0;i> T >> F; events[i] = {T, F}; } // 時刻を "半時間単位" (0.5h = 1) で整数化 vector> intervals; bool has = false; int64 cur_s = 0, cur_e = 0; // in halves for(auto &ev : events){ int64 T = ev.first; int64 F = ev.second; int64 t2 = T * 2; // event time in halves int64 start_dur = 2*F + 1; // F + 0.5 -> halves int64 extend = 2*F; // extend by F hours -> halves if(!has || cur_e <= t2){ if(has) intervals.emplace_back(cur_s, cur_e); cur_s = t2; cur_e = t2 + start_dur; has = true; } else { // currently ongoing -> extend end by F hours cur_e += extend; } } if(has) intervals.emplace_back(cur_s, cur_e); // 各フレンズについて各区間の floor( (length_hours) / S_i ) // length_hours = (cur_e - cur_s) / 2 // floor => floor( (length_halves) / (2 * S_i) ) for(int i=0;i