topcoder

BestHotel

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
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值