Computer Science, asked by sbhavana1997, 16 days ago

F7 Championship
The fictional World Championship of Formula 7 Drivers 2019 was characterized by exciting races and frequent shifts of driver positions on the leaderboard. Pradeep has missed most of it because he was training for olympiads in informatics. Now, looking at the leaderboard, Pradeep has a simple question for you: "How many drivers participating in this Championship still had a chance to become Formula 7 World Champion at the start of the final race?” The World Champion is, of course, the driver with the largest point total at the end (after the final race).
There are N drivers participating in the Championship. They are all assigned points after each race, including the final one. The winner of the race is awarded N points, the runner-up gets N - 1 points, and so on until the last driver, who gets 1 point. Two drivers cannot finish a race in the same spot.
Write a program to calculate, based on the total number of points that each driver has earned before the final race, how many drivers still have a chance to have the largest total after the final race and thus win the Championship. If more than one driver has the same maximum point total, they are all awarded the World Champion title
Input Format:
The first line of input contains the positive integer N, the number of drivers participating in the Championship.
Each of the following N lines contains a single integer Bi, the number of points that a driver has before the final race.

Constraints:
3 ≤ N ≤ 300000
0 ≤ Bi ≤ 2000000 (i = 1, ..., N)

Output Format:
The first and only line of output should contain the requested number of drivers that can still win

Sample Input 1:
3
8
10
9

Sample Output 1:
3

Sample Input 2:
5
15
14
15
12
14

Sample Output 2:
4

Answers

Answered by Yadavsabh
0

Answer:

plz mark me brilliant

Explanation:

I required it to move next level

Answered by AadilAhluwalia
0

Solution:

Algorithm:

Read input values N and Bi (the number of points that a driver has before the final race) for each driver.

Find the maximum number of points any driver has before the final race, say it is max_points.

Count the number of drivers who have max points or are one point behind it.

Print the count as output.

Let's implement this algorithm in Python:

n = int(input())

points = []

for i in range(n):

   points.append(int(input()))

max_points = max(points)

print(count)

In this code, we first read the input values N and Bi for each driver and store them in the list of 'points'.

We then find the maximum number of points using the max() function and count the number of drivers who have max_points or are one point behind it using the count() method.

Finally, we print the count as output.

Therefore, this solution should work efficiently for the given constraints.

#SPJ3

Similar questions