Question bank › Greedy
Dsa Greedy Easy

Balanced Scoreboard

You are given a scoreboard with scores from multiple players. Your task is to adjust the scores such that the total score of the players is balanced according to a specific ratio. Each player can either increase or decrease their score by 1, but the total number of adjustments should be minimized. Write a function that takes as input the target ratio, a list of scores, and outputs the minimum number of adjustments required to achieve the balanced total score. Input: - The first line contains two integers, `target_ratio` and `n` (1 <= n <= 100), where `target_ratio` indicates the desired ratio of scores between the highest and lowest player. - The second line contains `n` space-separated integers (scores) representing each player's score. Output: - An integer representing the minimum number of adjustments needed to achieve the balanced scoreboard according to the target ratio, or -1 if not possible to achieve within bounds. Example: Input: 2 4 10 20 10 40 Output: 10 In this case, it would take 10 adjustments to make the highest score twice the lowest score.

Key concepts

greedysortingarray

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.