F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Problem Buyer

Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 911    Accepted Submission(s): 279


Problem Description
TopSetter is an organization that creates problems. They¡¯ve prepared N problems with estimated difficulty score in range [ $A_i , B_i$ ]. TopHoster would like to host a contest consisting of M problems.
The $i^{th}$ problem should be of difficulty score $C_i$. The $i^{th}$ problem from TopSetter can be used in the contest if and only if its estimated difficulty score range $[A_i, B_i]$ covers the difficulty score c of its target problem in the contest, i.e. $A_i ¡Ü c ¡Ü B_i$ . Hosting a contest with M problems needs tohave M distinct problems which satisfy the required difficulty scores for each problem.
Unfortunately, TopSetter doesn¡¯t provide a service to buy specific problems. You can only request a problem set containing K problems and they will give you K distinct problems from all the N problems, but you don¡¯t know which problems will be given.
As TopSetter is the only problem provider for TopHoster, TopHoster would like to know the least number K of problems they need to buy to make sure they can host a contest.
 

Input
The first line of the input gives the number of test cases, T. T test cases follow. Each test case starts with 2 integers, N and M. Then N lines follow, each line consists of 2 integers representing the difficulty score range of the $i^{th}$ problem, $A_i and B_i$ . The last line of each test case consists of M integers representing the target difficulty scores of the M problems $C_i$ .
 

Output
For each test case, output one line containing ¡°Case #x: y¡±, where x is the test case number (starting from 1) and y is the least number of problems which the TopHoster needs to buy.
Output ¡°IMPOSSIBLE!¡± if it¡¯s impossible.

limits


$\bullet 1 ¡Ü T ¡Ü 100.$
$\bullet 1 ¡Ü N, M ¡Ü 10^5.$
$\bullet 1 ¡Ü A_i ¡Ü B_i ¡Ü 10^9.$
$\bullet 1 ¡Ü C_i ¡Ü 10^9.$
 

Sample Input
3 3 1 1 4 2 3 5 6 3 3 2 1 10 3 4 7 9 4 8 3 3 1 2 5 6 8 9 1 5 10
 

Sample Output
Case #1: 2 Case #2: 2 Case #3: IMPOSSIBLE!
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-01 18:01:03, Gzip enabled