UberOA #38
Find Top Two Teams
Estimated EasyJudge-ready
Topics (AI-labelled)In-place Arrays
A team's points are 3×wins+draws; ties in points are broken by goal difference (goals scored minus goals conceded), in descending order. Output the indices of the top two distinct teams. If points and goal difference are exactly equal, the statement imposes no further ordering, and any valid tie order is accepted.
This site has made the standard input and output explicit.
Input
The first line contains n, followed by 4 lines giving, in order, the n win counts, draw counts, goals scored, and goals conceded. On this site 2≤n≤100000 and every value is in 0..10⁹.
Output
Output two distinct 0-based indices: first place, then second place.
Example 1
Input:
3
2 1 2
0 3 0
5 5 4
1 2 0
Output:
2 0
Example 2
Input:
2
0 0
0 0
0 0
0 0
Output:
1 0
Example 3
Input:
3
1 0 0
0 2 1
0 100 100
0 0 0
Output:
0 1
Example notes
Example 1: all three teams have 6 points; 0 and 2 tie for the lead with a goal difference of 4, so either 0 2 or 2 0 is accepted. Example 2: the two teams are identical, so both 0 1 and 1 0 are correct. Example 3: points 3, 2, 1 decide the ranking, and more goals cannot overcome points, so output 0 1.
Editorial
Loading solution…