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

1 Answer

0 like 0 dislike
Problem Statement
Somewhere, at some point of time, there was/will be a vehicular traveling system where 1 Kilometre is the basic unit of traversal, that is a vehicle can either stay at rest or can travel distance which is multiple of 1 Km i. e., 2, 3, 4, 10, 35 Km are valid but 2.5, 6.34, 0.25 Km are invalid.
During the age of this system, there is a traffic policeman who stands at the intersection of 4 roads. Due to Development in the City, there are a few barriers placed on some of the roads at some distance from the intersection point.
Measurements are according to the cartesian coordinates, each unit representing a kilometer. You enter into the system and are provided with a coordinate of the Intersection point and the maximum north distance a vehicle can cover, the maximum eastern distance a vehicle can cover and the coordinates of the barrier.
You have to tell the sum of the total kilometers in which the policeman has the vicinity.

Example:
The Coordinate of Intersection point: 4, 3
The maximum north distance = 8Km
The maximum East distance = 8Km
Coordinates of barrier = (1, 3); (4, 6); (5, 3).

Input
First- line contains 2 integers denoting maximum north and east distance.
Second- line contains 2 integers denoting the coordinate of the intersection.
the third line contains an integer ‘k’ denoting the number of barriers
next line contains the coordinate of barriers.

Constraints:-
1<=north distance, east distance<=10000
(0, 0) <=coordinates of intersection<= (10000, 10000)
1<=number of barriers<=1000
(0, 0) <=coordinates of barriers<= (10000, 10000)

Output
An integer denoting the sum of the kilometers in which the police officer has his vicinity.

Example
Sample Input:
8 8
4 3
3
1 3 4 6 5 3

Sample output:
6
by Expert (34,270 points)