TopCoder problem "BestHotel" used in TCHS SRM 37 (Division I Level One)



Problem Statement

    Next month you are going to a conference about new trends in programming. It is time to choose a hotel in which you will stay for this time. There are several hotels in a city, all available for you. You are given a int[] price, where the i-th element is the price of the i-th hotel. Similarly, you are given a int[] quality, where the i-th element is the quality of the i-th hotel. Lower prices are better, and higher quality values are better. We say that hotel X is disadvantageous if there is a hotel Y whose price and quality are both at least as good as hotel X, and whose price or quality (or both) is strictly better than hotel X. Return the number of disadvantageous hotels in the city.
 

Definition

    
Class:BestHotel
Method:numberOfDisadvantageous
Parameters:int[], int[]
Returns:int
Method signature:int numberOfDisadvantageous(int[] price, int[] quality)
(be sure your method is public)
    
 

Constraints

-price will contain between 1 and 50 elements, inclusive.
-quality will contain between 1 and 50 elements, inclusive.
-price and quality will contain the same number of elements.
-Each element of price will be between 1 and 1000, inclusive.
-Each element of quality will be between 1 and 1000, inclusive.
 

Examples

0)
    
{100,200}
{2,3}
Returns: 0
The second hotel is more expensive, but it has a higher quality as well. There are no disadvantageous hotels.
1)
    
{100,200}
{3,3}
Returns: 1
2)
    
{100,200,300}
{4,3,5}
Returns: 1
The second hotel is disadvantageous.
3)
    
{100,200,300}
{5,4,3}
Returns: 2
The first hotel is the cheapest and has also the greatest quality. The other two are disadvantageous.
4)
    
{200,300,100,500,100,100,200}
{7,7,4,8,4,3,6}
Returns: 3

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=7850

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=10776&pm=7850

Writer:

Janq

Testers:

PabloGilberto , brett1479 , Olexiy , ivan_metelsky

Problem categories:

Sorting