AGE2 - Age of Empires
This is the hard version of problem SC1.
"Age of Empires" is a famous real-time strategy game. Resource is one of the most important consideration when playing this game. In this game, there are four different types of resources: food, wood, stone and gold.
The Villager is a common civilian unit for almost every game. They are the backbone of all civilizations. The Villagers are arguably the most important units in the game because they are able to collect all the resources. Each villager could gather A1 units of food, or B1 units of wood, or C1 units of stone, or D1 units of gold. Note that the villager can not split one second into smaller pieces to gather different types of resource. For example, a single villager can not gather A1/2 units of food and B1/2 units of wood for a single second. Moreover, all kinds of recourse are gathered exactly the end of that second. Nevertheless, different villagers could gather different types of resources at a time.
You can also train more villagers to speed up the process of gathering. To train a villager, you must spend X units of food at the beginning of a second, and a new villager will able to work after T seconds. Please note that at the beginning of the second you start to train a villager, you must have not less than X units of food. All villagers are trained at the Town Center but unfortunately there is only one Town Center, so your can only train one villager at a time.
You have N villagers at the beginning of the game with initially no food, wood, stone or gold at all. You are interested in the fastest way to gather enough resources, more precisely, at least A2 units of food and B2 units of wood and C2 units of stone and D2 units of gold.
Input
Each test case consists of three lines. The first line contains four integers A1, B1, C1 and D1 (1 <= A1, B1, C1, D1 <= 10^18), indicating the amount of resource a villager can gather for each type in a second. The second line also contains four integers A2, B2, C2 and D2 (0 <= A2, B2, C2, D2 <= 10^18), indicating the amount of resource required. The third line contains three integers N, X and T (1 <= N,X,T <= 10^5), indicating that you have N villager at the beginning of the game, and it will spend X units of food and T seconds to train each new villager.
All integers are sepearted by single spaces.
Process until EOF is reached.
Output
For each test case, output a integer - the minimum time to gain enough resources. See the example for more format details.
Example
Input: 1 1 1 1 1 1 1 1 4 1 1 1 1 1 1 2 2 2 2 1 1 1 1 1 1 1 10 10 10 10 1 1 25 Output: Case 1: 1 Case 2: 5 Case 3: 34
hide comments
[Rampage] Blue.Mary:
2017-04-21 19:45:57
The sample is correct. You must have something wrong in your solution. |
|
nithinj:
2017-04-21 18:32:26
I'm getting 33 for Case3. |
Added by: | Fudan University Problem Setters |
Date: | 2012-11-21 |
Time limit: | 4s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 GOSU |
Resource: | Author: g201513, used in ACM/ICPC Regional Contest, Chengdu 2012 |