UV 14000 Lighting System Design (DP)

Source: Internet
Author: User

You are given the task to design a lighting system for a huge conference hall. after doing a lot of Calculation & sketching, you have figured out the requirements for an energy-efficient design that can properly illuminate the entire hall. according to your design, you need lampsNDifferent power ratings. for some strange current regulation method, all the lamps need to be fed with the same amount of current. so, each category of lamp has a corresponding voltage rating. now, you know the number of lamps & Cost of every single unit of lamp for each category. but the problem is, you are to buy equivalent voltage sources for all the lamp categories. you can buy a single voltage source for each category (each source is capable of supplying to infinite number of lamps of its voltage rating .) & complete the design. but the Accounts Section of your company soon figures out that they might be able to reduce the total system cost by eliminating some of the Voltage Sources & replacing the lamps of that category with higher rating lamps. certainly you can never replace a lamp by a lower rating lamp as some portion of the hall might not be illuminated then. you are more concerned about money-saving than energy-saving. find the minimum possible cost to design the system.

Input

Each case in the input begins with N (1 <= n <= 1000), denoting the number of categories. each of the following n lines describes a category. A category is described by 4 integers-V(1 <= V <= 132000), the voltage rating, K (1 <= k <= 1000), the cost of a voltage source of this rating, C (1 <= C <= 10), the cost of a lamp of this rating & L (1 <= L <= 100), the number of lamps required in this category. the input terminates with a test case where n = 0. this case shoshould not be processed.

Output

For each test case, print the minimum possible cost to design the system.

Sample input ?????????????????????????????????????? ??????????? Output for sample input

3

100 500 10 20

120 600 8 16

220 400 7 18

0

778

Minimum cost of replacing low voltage with high voltage

# Include <iostream> # include <cstdio> # include <cstring> # include <algorithm> # include <limits. h> typedef long ll; using namespace STD; struct node {int v, k, C, L;} A [1100]; int sum [1100], N; int DP [1100]; int CMP (node L1, node l2) {return l1.v <l2.v;} int main () {While (~ Scanf ("% d", & N) {for (INT I = 1; I <= N; I ++) scanf ("% d", & A [I]. v, & A [I]. k, & A [I]. c, & A [I]. l); sort (a + 1, A + n + 1, CMP); For (INT I = 1; I <= N; I ++) sum [I] = sum [I-1] + A [I]. l; // prefix and for (INT I = 1; I <= N; I ++) {DP [I] = int_max; For (Int J = I-1; j> = 0; j --) DP [I] = min (DP [I], DP [J] + A [I]. K + A [I]. C * (sum [I]-sum [J]); // replace the previous Filipino Commission: power cost K + total light bulb cost} printf ("% d \ n ", DP [N]);} return 0 ;}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.