CF85B.Embassy Queue
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
In an embassy of a well-known kingdom an electronic queue is organised. Every person who comes to the embassy, needs to make the following three actions: show the ID, pay money to the cashier and be fingerprinted. Besides, the actions should be performed in the given order.
For each action several separate windows are singled out: _k_1 separate windows for the first action (the first type windows), _k_2 windows for the second one (the second type windows), and _k_3 for the third one (the third type windows). The service time for one person in any of the first type window equals to _t_1. Similarly, it takes _t_2 time to serve a person in any of the second type windows. And it takes _t_3 to serve one person in any of the third type windows. Thus, the service time depends only on the window type and is independent from the person who is applying for visa.
At some moment n people come to the embassy, the i-th person comes at the moment of time c__i. The person is registered under some number. After that he sits in the hall and waits for his number to be shown on a special board. Besides the person's number the board shows the number of the window where one should go and the person goes there immediately. Let's consider that the time needed to approach the window is negligible. The table can show information for no more than one person at a time. The electronic queue works so as to immediately start working with the person who has approached the window, as there are no other people in front of the window.
The Client Service Quality inspectors noticed that several people spend too much time in the embassy (this is particularly tiresome as the embassy has no mobile phone reception and 3G). It was decided to organise the system so that the largest time a person spends in the embassy were minimum. Help the inspectors organise the queue. Consider that all actions except for being served in at the window, happen instantly.
某知名王国的大使馆内设有电子排队系统。每位到访大使馆的人员需依次完成以下三项操作:出示身份证件、在出纳窗口缴费、进行指纹采集。此外,这三项操作必须严格按照给定顺序执行。
每项操作均设有若干个独立的服务窗口:第一项操作(第一类窗口)设有 k1 个独立窗口,第二项操作(第二类窗口)设有 k2 个窗口,第三项操作(第三类窗口)设有 k3 个窗口。任一第一类窗口为单人服务所需时间为 t1;同理,任一第二类窗口为单人服务所需时间为 t2;任一第三类窗口为单人服务所需时间为 t3。因此,服务时间仅取决于窗口类型,与申请签证的人员无关。
某一时刻,共有 n 位人员抵达大使馆,其中第 i 位人员于时刻 ci 到达。该人员被分配一个编号。随后,他进入大厅就座并等待其编号显示在专用电子显示屏上。除人员编号外,显示屏还同时显示其应前往的窗口编号,该人员将立即前往该窗口。假设从大厅走到窗口所需时间可忽略不计。显示屏同一时刻最多仅能显示一位人员的信息。电子排队系统的工作机制是:一旦某人到达窗口且窗口前无其他人在等待,则系统立即开始为其提供服务。
客户服务质量监察员注意到,部分人员在大使馆内停留时间过长(尤其令人困扰的是,大使馆内无手机信号及3G网络覆盖)。为此,决定优化排队系统,使得所有人员在大使馆内的最大停留时间最小化。请协助监察员设计该排队系统。注意:除在窗口接受服务外,其余所有操作均可视为瞬时完成。
输入格式
The first line contains three space-separated integers _k_1, _k_2, _k_3 (1 ≤ k__i ≤ 109), they are the number of windows of the first, second and third type correspondingly.
The second line contains three space-separated integers _t_1, _t_2, _t_3 (1 ≤ t__i ≤ 105), they are the periods of time needed to serve one person in the window of the first, second and third type correspondingly.
The third line contains an integer n (1 ≤ n ≤ 105), it is the number of people.
The fourth line contains n space-separated integers c__i (1 ≤ c__i ≤ 109) in the non-decreasing order; c__i is the time when the person number i comes to the embassy.
第一行包含三个用空格分隔的整数 k1、k2、k3(1 ≤ ki ≤ 109),分别表示第一类、第二类和第三类窗口的数量。
第二行包含三个用空格分隔的整数 t1、t2、t3(1 ≤ ti ≤ 105),分别表示在第一类、第二类和第三类窗口中为一名顾客服务所需的时间。
第三行包含一个整数 n(1 ≤ n ≤ 105),表示顾客人数。
第四行包含 n 个用空格分隔的整数 ci(1 ≤ ci ≤ 109),按非递减顺序排列;ci 表示第 i 号顾客到达使馆的时间。
输出格式
Print the single number, the maximum time a person will spend in the embassy if the queue is organized optimally.
Please, do not use the %lld specificator to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams (also you may use the %I64d specificator).
输出单个数字,即在队列被最优组织的情况下,一个人在使馆中花费的最长时间。
请注意,在 C++ 中不要使用 %lld 格式说明符来读取或写入 64 位整数。推荐使用 cin 和 cout 流(当然也可以使用 %I64d 格式说明符)。
输入输出样例
输入#1
1 1 1 1 1 1 5 1 1 1 1 1
输出#1
7
输入#2
2 1 1 5 1 1 5 1 2 3 3 5
输出#2
13
说明/提示
In the first test 5 people come simultaneously at the moment of time equal to 1. There is one window of every type, it takes 1 unit of time to be served at each window. That's why the maximal time a person spends in the embassy is the time needed to be served at the windows (3 units of time) plus the time the last person who comes to the first window waits (4 units of time).
Windows in the second test work like this:
The first window of the first type: [1, 6) — the first person, [6, 11) — third person, [11, 16) — fifth person
The second window of the first type: [2, 7) — the second person, [7, 12) — the fourth person
The only second type window: [6, 7) — first, [7, 8) — second, [11, 12) — third, [12, 13) — fourth, [16, 17) — fifth
The only third type window: [7, 8) — first, [8, 9) — second, [12, 13) — third, [13, 14) — fourth, [17, 18) — fifth
We can see that it takes most time to serve the fifth person.
在第一个测试用例中,5 个人同时于时刻 1 到达。每种类型的窗口各有一个,且在每个窗口办理业务均需耗时 1 个单位时间。因此,一个人在使馆中花费的最长时间等于其在各窗口办理业务所需的时间(3 个单位时间)加上最后一位到达第一个窗口的人所需等待的时间(4 个单位时间)。
第二个测试用例中各窗口的工作情况如下:
第一类窗口的第一个窗口:
[1, 6) — 第一个人,
[6, 11) — 第三个人,
[11, 16) — 第五个人
第一类窗口的第二个窗口:
[2, 7) — 第二个人,
[7, 12) — 第四个人
唯一的第二类窗口:
[6, 7) — 第一个人,
[7, 8) — 第二个人,
[11, 12) — 第三个人,
[12, 13) — 第四个人,
[16, 17) — 第五个人
唯一的第三类窗口:
[7, 8) — 第一个人,
[8, 9) — 第二个人,
[12, 13) — 第三个人,
[13, 14) — 第四个人,
[17, 18) — 第五个人
可以看出,服务第五个人所花费的时间最长。
输入解题思路,AI测评打分。不知道怎么写?