Message on Whatsapp 8879355057 for DSA(OA + Interview) + Fullstack Dev Training + 1-1 Personalized Mentoring to get 10+LPA Job
0 like 0 dislike
3,069 views
in Online Assessments by Expert (111,330 points) | 3,069 views

1 Answer

0 like 0 dislike
Max has a special vanishing pencil that helps vanish line segments on X-axis. For example , if one line segment is from (1,0) to (4,0) and another one is from (3,0) to (7,0) , Max can touch his pencil on either (3,0) or (4,0) to vanish these two lines- so only 1 try is enough.

 

Input :
first line gives how many line segments
next line starting points of line segments
next line ending points of line segments

 

Output:
how many attempts to remove all the line segments/points

 

Example:
4
0 2 4 -8
4 5 6 -9

 

Expected Ouput
2

 

Explanation :

 

On putting the pencil on 4 , first three line segments will disappear. Remaining point -8,-9 will be removed in next trial.
by Expert (111,330 points)