hdu 2257 Bob’s trouble待解决[解题报告]C++

2016-03-12 10:30:33来源:[db:出处]作者:[db:作者]人点击

Bob’s trouble

问题描述 :

Bob is a journalist, nowadays,he has a trouble. You know ,the Olympic Games is around the corner, as a fan of athletic sports, he certainly wants to see the Olympic Games, but as a journalist, the Olympic Games seems to be the busiest time,because Bob needs to report so many games.Fortunately , he has a kind boss.He gives Bob a target, as long as Bob meets the requirement, he can go home to see the Olympic Games. Now,the boss gives every competition a value, which represents the importance of the competition.As long as the sum of the competitions’ value that Bob reported is not less than the target, he can go home.Although there are a lot of competitions every day,some competitions may take at the same time, so Bob can only choose some competitions to report.Now the problem is what’s the earliest time that Bob can go home? To finish his work more easily, Bob gets some information about the competition.He finds every day is divided into 24 parts and every competition takes up at most 2 parts.There are 3 kinds of competitions:the first one only takes up 1 part of a day;the second one takes up two successional parts of a day,it means the competition will hold at the p day’s q and (q+1) part;the third one is special,it is held at two successional days,it means the competition will hold at the p and p+1 days’ q part(ie.If a competition is held at the 2 day’s 3 part, it will also take up the 3 day’s 3 part.)Meanwhile Bob finds two competitions’ first parts will not coincide,and two competitions’ second parts will not coincide .

输入:

The first line contains the number of cases.For each case, there are several lines represent the information of the competitions (The number of competitions will not exceed 1150).Each line includes p : the start day of the competition (0 <= p <50); q : the start part of the competition (0 <= q <23) ; a string s represents the form of the competition ( "first" or "second" or "third" as recorded above ) ) the last one is the value of the competition m (0 输出:

The first line contains the number of cases.For each case, there are several lines represent the information of the competitions (The number of competitions will not exceed 1150).Each line includes p : the start day of the competition (0 <= p <50); q : the start part of the competition (0 <= q <23) ; a string s represents the form of the competition ( "first" or "second" or "third" as recorded above ) ) the last one is the value of the competition m (0 样例输入:

20 17 third 999-19900 1 second 900 2 first 900 -1990

样例输出:

1what a pity!Hint For the first case, the form of the competition is "third",so it will hold at the 0 day's 17 and the 1 day's 17. so it takes Bob 2 days to finish the report. For the second case, the first competion holds at the 0 day's 1 and 2,the second competition holds at the 0 day's 2,so Bob can only choose one of them.The value he can get is 900,so he can't go home.

微信扫一扫

第七城市微信公众平台