11917 - Do Your Own Homework

来源:互联网 发布:linux卸载iso 编辑:程序博客网 时间:2024/06/09 15:11


 Do Your Own Homework! 

These days Soha is so busy that he doesn't have time to do his own homework. But this is not a big problem since he has got many friends who are willing to help. One if his friend's name is Sparrow.Whenever Soha is assigned any homework, he turns to Sparrow for her help.

\epsfbox{p11917.eps}

Sparrow has given a list of subjects that she is comfortable with along with the number of days it will take her to complete an assignment for each subject. Soha has got onlyD days to complete his next assignment. However, the professor of this subject is a little flexible and allows late submissions up to 5 days. That means he will not accept any submission that is afterD + 5 days from now. Will Sparrow be able to do it for Soha this time?

Input 

First line of input is a positive integer T (T le100) that determines the number of test cases. Each case starts with a line containing an integerN that represents the number of subjects Sparrow is comfortable with. Each of the nextN lines contain the name of a subject followed by the number of days it will take Sparrow to complete an assignment of that subject. All these subject names will be distinct. The next line contains an integerD. The meaning of D is described above. The following line contains the name of the subject whose homework is due. All the subjects' names consist of lowercase letters and the length of each is at least 1 and at most 20. All the integer inputs are positive in the range [1,100].

Output 

For each case, first output the case number first starting from 1. If Sparrow doesn't take more thanD days to completelythe assignment, output `Yesss'; if she takes more thanD days but not more than D + 5, output `Late'; if she takes more thanD + 5 days or if she isn't comfortable with the subject, output `Do your own homework!'.Quotes are for clarify only and don't need to be part of the output. Look at the samples for more details. Be careful about the spelling.

Sample Input 

33compiler 4cplusplus 1java 85compiler2algorithm 3math 94math2java 8ai 36calculus

Sample Output 

Case 1: YesssCase 2: LateCase 3: Do your own homework!
#include<stdio.h>#include<string.h>int main(){int t,count=1;scanf("%d",&t);while(t--){int n,d,i,a[500],b[500],f=0;char buf[500][25];char due[25];scanf("%d",&n);for(i=0;i<n;i++)scanf("%s%d",buf[i],&a[i]);scanf("%d",&d);scanf("%s",due);printf("Case %d: ",count++);for(i=0;i<n;i++)if(strcmp(due,buf[i])==0)if(a[i]<=d) {puts("Yesss");f=1;}else if(a[i]<=d+5&&a[i]>d) {puts("Late");f=1;}if(!f)puts("Do your own homework!");}return 0;}