Examples [code] [code] ----- [code] [code]
- User
Examples
input5 vasya 100 vasya 200 artem 100 kolya 200 igor 250output4 artem noob igor pro kolya random vasya random
input3 vasya 200 kolya 1000 vasya 1000output2 kolya pro vasya pro Assistant
5
vasya 100
vasya 200
artem 100
kolya 200
igor 250
4
artem noob
igor pro
kolya random
vasya random
3
vasya 200
kolya 1000
vasya 1000
2
kolya pro
vasya pro
Key insight: - Players' maximum scores: vasya=200, artem=100, kolya=200, igor=250
This appears to involve: sort
Working through the approach: Looking at this problem, I need to understand the logic from the examples.
Example 1 Analysis:
Example 2 Analysis:
Inferred Rules:
Solution:
n = int(input())
player_scores = {}
Track maximum score for each player
for _ in range(n):
name, score = input().split()
score = int(score)
if name in player_scores:
player_scores[name] = max(player_scores[name], score)
else:
player_scores[name] = score
Find min and max of all unique max scores
all_scores = set(player_scores.values())
min_score = min(all_scores)
max_score = max(all_scores)
Assign ranks
result = []
for name, score in player_scores.items():
if score == max_score:
rank = "pro"
elif score == min_score:
rank = "noob"
else:
rank = "random"
result.append((name, rank))
Sort alphabetically and output
result.sort(key=lambda x: x[0])
print(len(result))
for name, rank in result:
print(f"{name} {rank}")
Verification with Example 1:
Verification with Example 2:
I should verify this approach against the given examples to make sure it works.
Looking at this problem, I need to understand the logic from the examples.
Example 1 Analysis:
Example 2 Analysis:
Inferred Rules:
Solution:
n = int(input())
player_scores = {}
# Track maximum score for each player
for _ in range(n):
name, score = input().split()
score = int(score)
if name in player_scores:
player_scores[name] = max(player_scores[name], score)
else:
player_scores[name] = score
# Find min and max of all unique max scores
all_scores = set(player_scores.values())
min_score = min(all_scores)
max_score = max(all_scores)
# Assign ranks
result = []
for name, score in player_scores.items():
if score == max_score:
rank = "pro"
elif score == min_score:
rank = "noob"
else:
rank = "random"
result.append((name, rank))
# Sort alphabetically and output
result.sort(key=lambda x: x[0])
print(len(result))
for name, rank in result:
print(f"{name} {rank}")
Verification with Example 1:
Verification with Example 2: