Untitled
unknown
plain_text
9 months ago
801 B
8
Indexable
void dxt(int test_case){
int n,x,y;
cin >> n >> x >> y;
vector<int> p(n), t(n);
rep(i, 0, n - 1) cin >> p[i] >> t[i];
int Q;
cin >> Q;
vector<int> que(Q);
rep(i, 0, Q){
cin >> que[i];
}
vector<int> cost(8, 0);
for(int i = 0; i < 8; ++i){
int curr = i;
for(int j = 0; j < n - 1; ++j){
int wait;
if(curr == 0) wait = 0;
else wait = p[j] - (curr % p[j]);
int travel = t[j];
int total = wait + travel;
cost[i] += total;
if(total % p[j + 1] == 0) curr = 0;
else curr = p[j + 1] - (total % p[j + 1]);
}
}
for(auto &q : que){
int wait_time = (q + x) % p[0];
cout << q + x + cost[wait_time] + y << endl;
}
}Editor is loading...
Leave a Comment