Untitled

 avatar
unknown
c_cpp
17 days ago
812 B
6
Indexable
void dxt(int test_case){
    int n,x,y;
    cin >> n >> x >> y;

    vector<int> p(n - 1), t(n - 1);
    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 < p.size(); ++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