HDU 1074 Doing Homework (pressure DP)

Source: Internet
Author: User

Doing HomeworkTime limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 6299 Accepted Submission (s): 2708


Problem Descriptionignatius have just come back school from the 30th ACM/ICPC. Now he had a lot of homework to do. Every teacher gives him a deadline of handing in the homework. If Ignatius hands in the homework after the deadline, the teacher would reduce his score of the final Test, 1 day for 1 poi Nt. And as you know, doing homework always takes a long time. So Ignatius wants-to-help him to arrange the order of doing homework to minimize the reduced score.
Inputthe input contains several test cases. The first line of the input was a single integer T which is the number of test cases. T test Cases follow.
Each test case is start with a positive integer N (1<=n<=15) which indicate the number of homework. Then N lines follow. Each line contains a string S (the subject's name, each string would at the most have characters) and a integers D (the dead Line of the subject), C (what many days would it take Ignatius to finish this subject ' s homework).

Note:all the subject names is given in the alphabet increasing order. So, may process the problem much easier.

Outputfor should output the smallest total reduced score and then give out the order of the subjects, one Subject in a line. If there is more than one orders, you should output the alphabet smallest one.

Sample Input
23Computer 3 3English 1Math 3 23Computer 3 3English 6 3Math 6 3

Sample Output
2computermathenglish3computerenglishmathHintin the second Test case, both Computer->english->math and  Computer->math->english leads to reduce 3 points, but the word "中文版" appears earlier than the word "Math", so we Choose the first Order. That is so-called alphabet order.

Authorignatius.l

/* After reading the topic and think about the same as this blogger thought roughly the same http://www.cnblogs.com/Kenfly/archive/2011/03/30/2000364.html but, feel there is a problem, because fear will appear a, B can be to C Although a to C costs a lot, but a can be a short time, because this time has an effect on the back, a may later win the comeback? Feel such a bad deal, Baidu but can not find the answer, finally own figured out, since the state of the same, then spend the same time, such doubts suddenly did not * * * #include <iostream> #include <cstdio># include<cstring> #include <algorithm> #include <cmath> #include <queue> #include <stack> #include <vector> #include <set> #include <map> #define L (x) (x<<1) #define R (x) (x<<1|1) # Define MID (x, y) ((x+y) >>1) #define BUG printf ("hihi\n") #define EPS 1e-8typedef __int64 ll;using namespace std;# Define INF 0x3f3f3f3f#define N 16struct stud{int pre,time;//The current state is from which point, current state time, int score;//current deduction score number}dp[1<<16];st  Ruct ha{string name; int D,len;}    Home[n];int n;void Show (int st) {if (st==0) return;    Show (st^ (1<<dp[st].pre)); Cout<





Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

HDU 1074 Doing Homework (pressure DP)

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.