本文因题意问题是错误代码,
正确代码见:https://blog.csdn.net/xiang_6/article/details/100135775
#include<bits/stdc++.h>
#include<cstring>
#define FI first
#define SE second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int maxn = 1000 + 7;
const int maxd = 100 + 7;
const int INF = 0x7f7f7f7f;
int n, m, k, q;
int a[maxn], b[maxn]; // 每个顾客的办公时间和结束时刻
int c[maxd]; // 每个窗口最晚空闲时刻
queue<int> qu[maxd]; // 窗口队列(结束时刻)
int getid() {
int res, min_ = INF;
for(int i = 1; i <= n; ++i) {
if(qu[i].size() >= m) continue;
if(c[i] < min_) {
min_ = c[i];
res = i;
}
}
return res;
}
int getid2() {
int res, min_ = INF;
for(int i = 1; i <= n; ++i) {
if(qu[i].size() == 0) continue;
if(qu[i].front() < min_) {
min_ = qu[i].front();
res = i;
}
}
return res;
}
void init() {
int M = n*m;
for(int i = 1; i <= M && i <= k; ++i) {
int id = getid();
c[id] += a[i];
b[i] = c[id];
qu[id].push(c[id]);
//cout << id << " +++ " << c[id] << endl;
}
//cout << "\n--------------\n" << endl;
for(int i = M+1; i <= k; ++i) {
int id = getid2();
c[id] += a[i];
b[i] = c[id];
qu[id].push(c[id]);
qu[id].pop();
//cout << id << " +++ " << c[id] << endl;
}
}
int main() {
scanf("%d%d%d%d", &n, &m, &k, &q);
for(int i = 1; i <= k; ++i) {
scanf("%d", &a[i]);
}
init();
int t;
for(int i = 1; i <= q; ++i) {
scanf("%d", &t);
if(b[t]-a[t] < 540) {
printf("%02d:%02d\n", (8+b[t]/60), (b[t]%60));
}
else {
puts("Sorry");
}
}
return 0;
}