← 返回 bloomberg 的题目列表Total Friend Requests Based on Age
类型:online_judge
Given an array of ages, calculate the total number of friend requests that meet certain age conditions. The specific conditions are: for any age pair (A, B), if B meets the range condition (0.5 * A + 7, A] and A ≥ B, compute the requests.
Input Description:
An array of n positive integers representing ages; 1 ≤ n ≤ 2000.
Output Description:
The total number of friend requests that satisfy the conditions.
Example:
Input: [16, 16]
Output: 2
Input: [16, 17, 18]
Output: 2
Note:
Exclude cases where the same age requests itself.
Example
Input
[16, 16, 18]