시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
20 초 (추가 시간 없음) | 1024 MB | 1 | 1 | 1 | 100.000% |
Umon is a foodie coder. Do you know what two activities that he loves the most? Of course, coding and eating! He always spends the whole day doing only those two activities. However, he thinks that some times of the day are better spent coding, and others are better spent eating.
To illustrate this problem, Umon divides his day into S time slots. During the i-th time slot, if Umon codes 100% of the time, he will achieve Ci units of coding. On the other hand, if he eats 100% of the time, he will achieve Ei units of eating. But of course, Umon can also use only a fraction of the time for coding, and the remaining for eating. Formally, he will choose a real number f (0 ≤ f ≤ 1), code for f of the time, and use the remaining (1 - f) time to eat. This way, he will achieve f × Ci units of coding and (1 - f) × Ei units of eating. The total amount of coding Umon achieves for the day is simply the sum of all units of coding he achieved in each of the time slots. The total amount of eating is calculated in a similar way.
Umon needs to plan his schedule for the next D days. On the i-th day, he needs to achieve at least a total amount of Ai units of coding and Bi units of eating. For each day, determine whether there is a way for Umon to achieve his target.
The first line of input gives the number of test cases, T. T test cases follow. Each test case begins with a line containing two integers D and S, the number of days and the number of time slots in a day, respectively.
Then S lines follow, each describing a time slot. The i-th line contains two integers Ci and Ei, the amount of coding units achieved if Umon codes for 100% of the time slot, and the amount of eating units achieved if he eats for 100% of the time slot, respectively.
Then D lines follow, each describing a day. The i-th line contains two integers Ai and Bi, the minimal total amount of coding and eating that needs to be achieved on that day.
For each test case, output one line containing Case #x: y
, where x
is the test case number (starting from 1) and y
is a string with D characters, where the i-th character is Y
if there exists a schedule that can fulfill the target for the i-th day, otherwise it should be N
.
For at least 90% of the test cases:
For all test cases:
2 4 2 3 8 6 10 0 18 3 13 10 0 7 3 1 2 4 4 4 4 0 0
Case #1: YYNY Case #2: Y
In the first sample case, there are 4 days and 2 time slots for each day.
Thus, the answer should be YYNY.
In the second sample case, note that the value of characteristics for the time slots may not necessarily be different from each other.
Contest > Google > Kick Start > Google Kick Start 2019 > Round E B번