编程介的小学生 2019-08-04 21:59 采纳率: 20.5%
浏览 195

这个到达的计算的问题如何实现输出,用C语言的办法

Problem Description
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 .

Input
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 <m <1000). Separate line with -1 means the end of the competition. Then a line with a num, need (0 <= need <2000000), means the boss's target.

Output
For every case ,output the earliest day that Bob can go home.If it is impossible,output "what a pity!"

Sample Input
2
0 17 third 999
-1
990
0 1 second 90
0 2 first 900
-1
990

Sample Output
1
what a pity!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 iqoo11 如何下载安装工程模式
    • ¥15 本题的答案是不是有问题
    • ¥15 关于#r语言#的问题:(svydesign)为什么在一个大的数据集中抽取了一个小数据集
    • ¥15 C++使用Gunplot
    • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
    • ¥15 matlab数字图像处理频率域滤波
    • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
    • ¥15 ELGamal和paillier计算效率谁快?
    • ¥15 蓝桥杯单片机第十三届第一场,整点继电器吸合,5s后断开出现了问题
    • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?