Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【甲级1014另解】1014 Waiting in Line #160

Open
rid-sun opened this issue Jul 1, 2021 · 0 comments
Open

【甲级1014另解】1014 Waiting in Line #160

rid-sun opened this issue Jul 1, 2021 · 0 comments

Comments

@rid-sun
Copy link

rid-sun commented Jul 1, 2021

#include<iostream>
#include<queue>
using namespace std;

int n, m, k, q, v[1005], mtime[25], vis[1005];
queue<int> line[25];

int main(){
    cin >> n >> m >> k >> q;
    for (int i = 1; i <= k;i++){
        cin >> v[i];
        if(i <= n * m){
            if(i % n == 0) line[n].push(i);
            else line[i % n].push(i);
        } 
    }
    int t = k > m * n ? m * n + 1 : k + 1;
    for (int i = 1; i <= 540;i++){
        for (int j = 1; j <= n;j++){
            if(!line[j].empty()){
                if(i == v[line[j].front()] + mtime[j]){
                    mtime[j] = v[line[j].front()] = i;
                    vis[line[j].front()] = 1;
                    line[j].pop();
                    if(t <= k) line[j].push(t++);
                }else if(i == 540 && mtime[j] <= i){
                    v[line[j].front()] += mtime[j];
                    vis[line[j].front()] = 1;
                }
            } 
        }
    }
    while(q--){
        int id;
        cin >> id;
        if(vis[id] == 0) 
            cout << "Sorry" << endl;
        else
            printf("%02d:%02d\n", v[id] / 60 + 8, v[id] % 60);
    }
    return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant