Untitled
unknown
python
2 years ago
630 B
11
Indexable
def getMeanRankCount(rank):
"""
This function takes the ranks of the students as input and returns an array
containing the number of groups with a mean rank of i for each i in the range [1, n].
Args:
rank: The ranks of the students.
Returns:
An array containing the number of groups with a mean rank of i for each i in the range [1, n].
"""
n = len(rank)
count = [0] * n
for i in range(n):
sum = 0
cnt = 1
for j in range(i, n):
if rank[j] <= rank[i]:
sum += rank[j]
cnt += 1
else:
break
avg = sum / float(cnt)
count[int(avg)] += 1
return countEditor is loading...