Woburn Challenge 2016-17 Round 2 - Senior Division

Having run low on dilithium, the Enterprise has stopped at an isolated
space station to refuel. The station is inhabited by
humanoids of various races. Unfortunately, it seems that their
differences have been creating an increasingly heated conflict. In
particular, there are constant debates over the station's artificial
environmental settings! Some species prefer a warmer environment than
others, or one with a stronger gravitational force. Though this might
seem like a trivial matter, the frequent changing back and forth of the
environmental settings appears to pose a serious threat to the state of
tentative peace aboard the station, with threats of violent conflict in
the air.
As a neutral third party, it'll be up to the crew of the Enterprise to step in and make a fair decision. The Enterprise's ambassador, Neelex, has been entrusted with selecting environmental settings in a neutral fashion, with the space station's residents agreeing to abide by his decision. However, if he makes a poor decision, there could still be serious trouble!
Two aspects of the space station's environmental settings may be set -
its temperature (in degrees Celsius) and its gravity (in
). Each of these values may be set to any positive
integer. The
humanoid aboard the station would like the
temperature to be anywhere between
and
, inclusive, and the gravity to be anywhere
between
and
, inclusive.
They'll only be content if both the temperature and the gravity lie
within their requested ranges (they don't care if only one of their
requests is satisfied).
Neelex may not be able to choose a set of environmental settings to leave everyone happy, but he'd like to get as close to that as possible, in order to minimize the chance of a dispute. What's the maximum number of humanoids that can be satisfied by any possible choice of temperature and gravity settings?
In test cases worth of the points,
,
,
and
.
In test cases worth another of the points,
.
In test cases worth another of the points,
.
Input Specification
The first line of input consists of a single integer .
lines follow, the
of which consists of four space-separated
integers
,
,
, and
(for
).
Output Specification
Output a single integer - the maximum number of humanoids that can be simultaneously satisfied.
Sample Input
4
64 100 35 55
100 200 10 40
111 190 39 69
12 120 38 38
Sample Output
3
Sample Explanation
The first, second, and fourth humanoids will all be satisfied if the
temperature is set to and the gravity is set to
. Any other
configuration results in at most two humanoids being satisfied.
Comments