05. Teamwork projects 83/100 [ C# ]

Здравейте! Някой ако може да помогне с решението. 

Това е задачата:

https://judge.softuni.bg/Contests/Practice/Index/1215#4

using System;
using System.Collections.Generic;
using System.Linq;

namespace _05.TeamworkProjects
{
    class Program
    {
        static void Main()
        {
            int numOfTeams = int.Parse(Console.ReadLine());

            List<Team> teams = new List<Team>(CreateTeams(numOfTeams));



            string[] command = Console.ReadLine().Split("->", StringSplitOptions.RemoveEmptyEntries);

            while (command[0] != "end of assignment")
            {
                string member = command[0];
                string team = command[1];

                if (IsTeamExist(teams, team) && IsNotMemberJoined(teams, member))
                {
                    foreach (var teaaam in teams)
                    {
                        if (teaaam.TeamName == team)
                        {
                            teaaam.Member.Add(member);
                        }
                    }
                }

                command = Console.ReadLine().Split("->", StringSplitOptions.RemoveEmptyEntries);
            }

            var teamsToDisband = teams.OrderBy(x => x.TeamName).Where(x => x.Member.Count == 0).ToList();
            var fullTeams = teams.Where(x => x.Member.Count > 0).OrderByDescending(x => x.Member.Count).ThenBy(x => x.TeamName).ToList();
            foreach (var team in fullTeams)
            {
                Console.WriteLine($"{team.TeamName}");
                Console.WriteLine($"- {team.Creator}");
                foreach (var member in team.Member.OrderBy(x => x))
                {
                    Console.WriteLine($"-- {member}");
                }
            }

            Console.WriteLine("Teams to disband:");
            foreach (var item in teamsToDisband)
            {
                Console.WriteLine(item.TeamName);
            }
        }

        private static bool IsNotMemberJoined(List<Team> teams, string member)
        {
            for (int i = 0; i < teams.Count; i++)
            {
                if (teams[i].Creator == member)
                {
                    Console.WriteLine($"Member {member} cannot join team {teams[i].TeamName}!");
                    return false;
                }
                if (teams[i].Member.Count > 0)
                {
                    if (teams[i].Member.Contains(member))
                    {
                        Console.WriteLine($"Member {member} cannot join team {teams[i].TeamName}!");
                        return false;
                    }

                    continue;
                }

            }
            return true;
        }
        private static bool IsTeamExist(List<Team> teams, string team)
        {
            for (int i = 0; i < teams.Count; i++)
            {
                if (teams[i].TeamName == team)
                {
                    return true;

                }
            }
            Console.WriteLine($"Team {team} does not exist!");
            return false;
        }

        private static List<Team> CreateTeams(int numOfTeams)
        {
            List<Team> teams = new List<Team>();

            for (int i = 0; i < numOfTeams; i++)
            {
                string[] input = Console.ReadLine().Split('-', StringSplitOptions.RemoveEmptyEntries);

                if (IsValidTeam(teams, input, i))
                {
                    List<string> list = new List<string> ();

                    Team team = new Team()
                    {
                        TeamName = input[1],
                        Creator = input[0],
                        Member = list
                    };

                    teams.Add(team);
                    Console.WriteLine(team.ToString());
                }

            }

            return teams;
        }

        private static bool IsValidTeam(List<Team> teams, string[] input, int i)
        {
            if (i > 0)
            {
                for (int j = 0; j < teams.Count; j++)
                {
                    if (teams[j].TeamName == input[1])
                    {
                        Console.WriteLine($"Team {teams[j].TeamName} was already created!");
                        return false;
                    }
                    else if (teams[j].Creator == input[0])
                    {
                        Console.WriteLine($"{teams[j].Creator} cannot create another team!");
                        return false;
                    }
                }
            }
            return true;
        }
    }

    class Team
    {
        public string TeamName { get; set; }
        public string Creator { get; set; }
        public List<string> Member { get; set; }

        public override string ToString()
        {
            return $"Team {TeamName} has been created by {Creator}!";
        }
    }

}