using System; using System.Collections.Generic;

namespace P1135 { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); Student[] students = new Student[n];

        for (int i = 0; i < n; i++)
        {
            string[] input = Console.ReadLine().Split(' ');
            students[i] = new Student(input[0], input[1], int.Parse(input[2]), int.Parse(input[3]));
        }

        Dictionary<string, Student> maxStudents = new Dictionary<string, Student>();

        foreach (Student student in students)
        {
            if (!maxStudents.ContainsKey(student.Sid))
            {
                maxStudents[student.Sid] = student;
            }
            else if (maxStudents[student.Sid].Height < student.Height)
            {
                maxStudents[student.Sid] = student;
            }
        }

        List<Student> result = new List<Student>();
        foreach (Student maxStudent in maxStudents.Values)
        {
            result.Add(maxStudent);
        }
        result.Sort((a, b) => string.Compare(a.Sid, b.Sid));

        foreach (Student student in result)
        {
            student.Display();
        }
    }
}

class Student
{
    public string Sid { get; }
    public string Name { get; }
    public int Height { get; }
    public int Weight { get; }

    public Student(string sid, string name, int height, int weight)
    {
        Sid = sid;
        Name = name;
        Height = height;
        Weight = weight;
    }

    public void Display()
    {
        Console.WriteLine($"{Sid} {Name} {Height} {Weight}");
    }
}

原文地址: https://www.cveoy.top/t/topic/fcld 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录