hdu1529 Cashier Employment--单源最短路径&差分约束
发布日期:2021-10-03 20:32:11
浏览次数:2
分类:技术文章
本文共 2323 字,大约阅读时间需要 7 分钟。
原题链接:
一:原题内容
Problem Description
A supermarket in Tehran is open 24 hours a day every day and needs a number of cashiers to fit its need. The supermarket manager has hired you to help him, solve his problem. The problem is that the supermarket needs different number of cashiers at different times of each day (for example, a few cashiers after midnight, and many in the afternoon) to provide good service to its customers, and he wants to hire the least number of cashiers for this job. The manager has provided you with the least number of cashiers needed for every one-hour slot of the day. This data is given as R(0), R(1), ..., R(23): R(0) represents the least number of cashiers needed from midnight to 1:00 A.M., R(1) shows this number for duration of 1:00 A.M. to 2:00 A.M., and so on. Note that these numbers are the same every day. There are N qualified applicants for this job. Each applicant i works non-stop once each 24 hours in a shift of exactly 8 hours starting from a specified hour, say ti (0 <= ti <= 23), exactly from the start of the hour mentioned. That is, if the ith applicant is hired, he/she will work starting from ti o'clock sharp for 8 hours. Cashiers do not replace one another and work exactly as scheduled, and there are enough cash registers and counters for those who are hired. You are to write a program to read the R(i) 's for i=0...23 and ti 's for i=1...N that are all, non-negative integer numbers and compute the least number of cashiers needed to be employed to meet the mentioned constraints. Note that there can be more cashiers than the least number needed for a specific slot.
Input
The first line of input is the number of test cases for this problem (at most 20). Each test case starts with 24 integer numbers representing the R(0), R(1), ..., R(23) in one line (R(i) can be at most 1000). Then there is N, number of applicants in another line (0 <= N <= 1000), after which come N lines each containing one ti (0 <= ti <= 23). There are no blank lines between test cases.
Output
For each test case, the output should be written in one line, which is the least number of cashiers needed. If there is no solution for the test case, you should write No Solution for that case.
Sample Input
11 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1502322110
Sample Output
1
二:分析理解
三:AC代码
转载地址:https://blog.csdn.net/LaoJiu_/article/details/51042842 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
关注你微信了!
[***.104.42.241]2024年04月07日 22时25分16秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
第6章-6 求指定层的元素个数 (40分)【python】
2019-04-26
第6章-7 找出总分最高的学生 (15分)【python】
2019-04-26
第6章-8 输出全排列 (20分)【python】
2019-04-26
eclipse中直接安装spring插件
2019-04-26
2020-09-27
2019-04-26
7-2 凯撒密码 (20分)
2019-04-26
7-4 承压计算 (25分)
2019-04-26
7-5 分巧克力 (30分)
2019-04-26
7-5 k倍区间 (30分)
2019-04-26
7-4 切原木问题 (25分)
2019-04-26
7-2 消掉ACM (20分)
2019-04-26
试题 历届试题 日期问题
2019-04-26
7-3 奇数阶魔阵 (25分)
2019-04-26
7-1 剁手 (10分)
2019-04-26
7-6 出栈序列的合法性 (25分)
2019-04-26
在windows环境中部署SSM项目到阿里云服务器-对象存储OSS
2019-04-26
微信小程序支付-云函数实现案例
2019-04-26