Milly and pens
Practice
3.6 (507 votes)
Implementation
Ready
Hash function
Easy
Data structures
Problem
39% Success 3937 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code
Milly and Pranjul together want to buy N unique pens. Each pen has a unique id. Pranjul can buy P pens and Milly can buy M pens at a time. Your task is to print “They can” if they can buy those N unique pens at least one each else print “They can’t”.
Input
- First line of the input will contain T (No. of test cases).
- For each test case, first line will contain three space separated integers denoting N, P and M. Then next line will contain P space separated integers denoting the ids of pen that Pranjul can buy and the next line will contain M space separated integers denoting the ids of pen that Milly can buy.
Output
- For every test case, print the required answer in a new line.
Constraints
- 1 ≤ T ≤ 10
- 1 ≤ N ≤ 104
- 1 ≤ P, M ≤ 105
- 1 ≤ Pen id ≤ N
Explanation
Test case #2: Then can’t buy the pen with id = 3.
Code Editor
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Submissions
Please login to view your submissions
Similar Problems
Points:10
169 votes
Tags:
ImplementationBasic ProgrammingVery-EasyReadyMathematicsApproved
Points:30
4 votes
Tags:
Dynamic Programming2D dynamic programmingAlgorithms
Points:50
Tags:
Advanced Data StructuresApprovedData StructuresGrammar-VerifiedHardReadyRecruitSegment Trees
Editorial
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor