3648 - Lemonade Stand 3648 - Lemonade Stand 3648 - Lemonade Stand

Statistics Sub: 61 | AC: 29 | AC%: 47,54 | Score: 2,99
Created by None
Added by jlcastrillon (2016-05-25)
Limits
Total Time: 1500 MS |Memory: 5 GB | Output: 64 MB | Size: 16 KB
Enabled languages
Available in

Description

You are running a lemonade stand and have the good fortune of knowing exactly how many cups of lemonade customers are going to want to buy on each day that you run the lemonade stand. You hate to turn any customer away, so you would like to make sure that you always have enough lemons and sugar to make the appropriate number of cups of lemonade on each day. Unfortunately, the cost of lemons and sugar change daily, so you have to choose on which days you buy each, and how much of each to buy. You can buy individual lemons and five pound bags of sugar. (Note that there are 16 ounces in one pound.) On the days you choose to buy ingredients, you buy them in the morning, before any sales are made. (You're an early riser, so you can always get to the store and back before any customers would come.) Note that you can buy as little or as much as you wish on any day to minimize your overall cost, i.e., you have enough startup money (capital) to buy as much as you wish on any day.

Given that you always want to have enough lemons and sugar to serve each customer, determine the minimum cost of buying those lemons and sugar.
You are running a lemonade stand and have the good fortune of knowing exactly how many cups of lemonade customers are going to want to buy on each day that you run the lemonade stand. You hate to turn any customer away, so you would like to make sure that you always have enough lemons and sugar to make the appropriate number of cups of lemonade on each day. Unfortunately, the cost of lemons and sugar change daily, so you have to choose on which days you buy each, and how much of each to buy. You can buy individual lemons and five pound bags of sugar. (Note that there are 16 ounces in one pound.) On the days you choose to buy ingredients, you buy them in the morning, before any sales are made. (You're an early riser, so you can always get to the store and back before any customers would come.) Note that you can buy as little or as much as you wish on any day to minimize your overall cost, i.e., you have enough startup money (capital) to buy as much as you wish on any day.

Given that you always want to have enough lemons and sugar to serve each customer, determine the minimum cost of buying those lemons and sugar.
You are running a lemonade stand and have the good fortune of knowing exactly how many cups of lemonade customers are going to want to buy on each day that you run the lemonade stand. You hate to turn any customer away, so you would like to make sure that you always have enough lemons and sugar to make the appropriate number of cups of lemonade on each day. Unfortunately, the cost of lemons and sugar change daily, so you have to choose on which days you buy each, and how much of each to buy. You can buy individual lemons and five pound bags of sugar. (Note that there are 16 ounces in one pound.) On the days you choose to buy ingredients, you buy them in the morning, before any sales are made. (You're an early riser, so you can always get to the store and back before any customers would come.) Note that you can buy as little or as much as you wish on any day to minimize your overall cost, i.e., you have enough startup money (capital) to buy as much as you wish on any day.

Given that you always want to have enough lemons and sugar to serve each customer, determine the minimum cost of buying those lemons and sugar.

Input specification

The first input line will have a single integer, n (1 ≤ n ≤ 100), the number of cases to process. The first line of each test case will have three space-separated positive integers: d (1 ≤ d ≤ 1000), the number of days you'll run the lemonade stand, x (1 ≤ x ≤ 10), the number of lemons needed to make a single cup of lemonade, and s (1 ≤ s ≤ 10), the number of ounces of sugar needed to make a single cup of lemonade. The following d lines will contain data for days 1 through d, respectively. Each of these lines will have three integers separated by spaces: c (1 ≤ c ≤ 1000), the number of cups sold for that day, p l (1 ≤ p l ≤ 50), the price of a single lemon in cents for that day, and p s (1 ≤ p s ≤ 500), the price of a five pound bag of sugar in cents for that day. Note that the extra sugar and lemon from each day carry over to the next day.
The first input line will have a single integer, n (1 ≤ n ≤ 100), the number of cases to process. The first line of each test case will have three space-separated positive integers: d (1 ≤ d ≤ 1000), the number of days you'll run the lemonade stand, x (1 ≤ x ≤ 10), the number of lemons needed to make a single cup of lemonade, and s (1 ≤ s ≤ 10), the number of ounces of sugar needed to make a single cup of lemonade. The following d lines will contain data for days 1 through d, respectively. Each of these lines will have three integers separated by spaces: c (1 ≤ c ≤ 1000), the number of cups sold for that day, p l (1 ≤ p l ≤ 50), the price of a single lemon in cents for that day, and p s (1 ≤ p s ≤ 500), the price of a five pound bag of sugar in cents for that day. Note that the extra sugar and lemon from each day carry over to the next day.
The first input line will have a single integer, n (1 ≤ n ≤ 100), the number of cases to process. The first line of each test case will have three space-separated positive integers: d (1 ≤ d ≤ 1000), the number of days you'll run the lemonade stand, x (1 ≤ x ≤ 10), the number of lemons needed to make a single cup of lemonade, and s (1 ≤ s ≤ 10), the number of ounces of sugar needed to make a single cup of lemonade. The following d lines will contain data for days 1 through d, respectively. Each of these lines will have three integers separated by spaces: c (1 ≤ c ≤ 1000), the number of cups sold for that day, p l (1 ≤ p l ≤ 50), the price of a single lemon in cents for that day, and p s (1 ≤ p s ≤ 500), the price of a five pound bag of sugar in cents for that day. Note that the extra sugar and lemon from each day carry over to the next day.

Output specification

For each test case, print the minimum cost of supplies (in cents) necessary to make sure that no customer who wants a cup of lemonade gets turned away. ;jsessionid=E9C3E303EEBF6C686F35CB4376B3367C
For each test case, print the minimum cost of supplies (in cents) necessary to make sure that no customer who wants a cup of lemonade gets turned away. ;jsessionid=E9C3E303EEBF6C686F35CB4376B3367C
The first input line will have a single integer, n (1 ≤ n ≤ 100), the number of cases to process. The first line of each test case will have three space-separated positive integers: d (1 ≤ d ≤ 1000), the number of days you'll run the lemonade stand, x (1 ≤ x ≤ 10), the number of lemons needed to make a single cup of lemonade, and s (1 ≤ s ≤ 10), the number of ounces of sugar needed to make a single cup of lemonade. The following d lines will contain data for days 1 through d, respectively. Each of these lines will have three integers separated by spaces: c (1 ≤ c ≤ 1000), the number of cups sold for that day, p l (1 ≤ p l ≤ 50), the price of a single lemon in cents for that day, and p s (1 ≤ p s ≤ 500), the price of a five pound bag of sugar in cents for that day. Note that the extra sugar and lemon from each day carry over to the next day.

Sample input

2
3 3 2
200 10 399
300 8 499
400 12 499
2 5 10
9 10 199
8 20 99

Sample output

31977
1347

Hint(s)

;jsessionid=E9C3E303EEBF6C686F35CB4376B3367C
;jsessionid=E9C3E303EEBF6C686F35CB4376B3367C
;jsessionid=E9C3E303EEBF6C686F35CB4376B3367C

Recommendation

We have carefully selected several similar problems: 3376 | 2769 | 1873 | 2441 | 2534 | 2141