1014 Waiting in Line --队列模拟
来源:互联网 发布:网络销售好做吗做金融 编辑:程序博客网 时间:2024/05/21 06:24
模拟题,注意题意。。。
for those customers who cannot be served before 17:00, you must output “Sorry” instead.
17点之前被接待了,服务超过17点也不要紧。
#include <cstdio>#include <cstring>#include <queue>#include <algorithm>using namespace std;struct node { int id, time; node(int i, int t):id(i), time(t) {} friend bool operator<(const node &a, const node &b) { a.time < b.time; }};queue<node> que[25];int wdt[25];int cus[1010], ans[1010];void print(int x) { if (!x) { printf("Sorry\n"); return; } int h = x / 60 + 8; int m = x % 60; printf("%02d:%02d\n", h, m);}int main() { int n, m, k, q; scanf("%d%d%d%d", &n, &m, &k, &q); for (int i = 1; i <= k; i++) scanf("%d", cus+i); int ptr = 1, inque = 0; memset(wdt, 0, sizeof(wdt)); do { while (ptr <= k && inque < n*m) { int mi = 1; for (int i = 2; i <= n; i++) if (que[i].size() < que[mi].size()) mi = i; que[mi].push(node(ptr, wdt[mi] + cus[ptr])); if (wdt[mi] < 540) ans[ptr] = wdt[mi] + cus[ptr]; else ans[ptr] = 0; wdt[mi] += cus[ptr]; inque++; ptr++; } int ti; bool first = true; for (int i = 1; i <= n; i++) { if (first && !que[i].empty()) { ti = i; first = false; }else if (!first && que[i].front().time < que[ti].front().time) ti = i; } node t = que[ti].front(); que[ti].pop(); inque--; } while (inque); while (q--) { int x; scanf("%d", &x); print(ans[x]); } return 0;}
0 0
- 1014 Waiting in Line --队列模拟
- PAT 1014 Waiting in Line(模拟+队列操作)
- PAT 1014 Waiting in Line 模拟
- PAT 1014 Waiting in Line (模拟)
- PAT 1014. Waiting in Line (30) 队列模拟 +简单消费者生产者
- [PAT][1014] Waiting in Line
- PAT 1014 Waiting in Line
- 1014 Waiting in Line (30)
- PAT 1014 Waiting in Line
- PAT 1014 Waiting in line
- PAT 甲 1014. Waiting in Line (30)(优先队列)
- 【PAT1014】 Waiting in Line (30) queue模拟排队
- 1014. Waiting in Line (30) 模拟银行排队
- pat 1014 Waiting in Line (30)
- PAT 1014 Waiting in Line (30)
- PAT 1014 Waiting in Line (30)
- Waiting in Line
- PAT_1014: Waiting in Line
- foreachRDD常见问题
- Codeforces Round #382 (Div. 2)
- Oil Deposits(深度优先搜索DFS)
- 蓝桥杯第七届 寒假作业(dfs)
- Linux 关于读者与写者同步互斥问题的解析
- 1014 Waiting in Line --队列模拟
- 需求从0到1
- Hadoop,master和slave简单的搭建
- 外观模式
- Blue Jeans
- Ultra-QuickSort
- 阻塞队列BlockingQueue
- LeetCode 290. Word Pattern
- 高精度加法