← 返回 meta 的题目列表Maximize Affordability Index
类型:online_judge
Given two arrays: prices and ratings (ranging from 1 to 5), define 'affordability index' as ratings[i] / prices[i]. Return the index of the product with the highest affordability index. If there are multiple products with the same index, return the smallest index.
Input Format:
prices: An integer array representing the price of each product.
ratings: An integer array representing the rating of each product.
Output Format:
An integer representing the index of the product with the highest affordability.
Example:
prices = [10, 20, 30]
ratings = [5, 4, 3]
Output: 0
Constraints:
The length of the arrays does not exceed 1000.
Prices are between 1 and 1000.
Ratings are between 1 and 5.
Example
Input
10
20
30
5
4
3