Fox235's blog

By Fox235, 13 years ago, In Russian

Здравствуйте Всем.
Решил порешать задачки из "Архива" и завис на задачке 2A "Победитель". Написал код на C# , проверил разные варианты. При отправке выдает, что ошибка в 6 тесте. Никак не могу понять в чем ошибка. Помогите, пожалуйста. Код ниже:

struct stNumberAndPoints
    {
        public String sPlayerName;
        public int iPlayerPoints;
    }

    class Program
    {
        static void Main()
        {
            int iCountRounds = Convert.ToInt32(Console.ReadLine());
            List<stNumberAndPoints> lstData = new List<stNumberAndPoints>();
            stNumberAndPoints stnapCurrentPlayer;
            String[] sCurrentLine;
            for (int i = 0; i < iCountRounds; i++)
            {
                sCurrentLine = Console.ReadLine().Split(' ');
                if (sCurrentLine.Count() == 2)
                {
                    stnapCurrentPlayer.sPlayerName = sCurrentLine[0].Trim().ToLower();
                    int iCount = lstData.Where(it => it.sPlayerName == stnapCurrentPlayer.sPlayerName).Count();
                    if (iCount > 0)
                    {
                        stnapCurrentPlayer.iPlayerPoints = Convert.ToInt32(sCurrentLine[1].Trim()) + lstData.Where(it => it.sPlayerName == stnapCurrentPlayer.sPlayerName).LastOrDefault().iPlayerPoints;
                        if (Convert.ToInt32(sCurrentLine[1].Trim()) != 0)
                        {
                            lstData.Remove(lstData.Where(it => it.sPlayerName == stnapCurrentPlayer.sPlayerName).FirstOrDefault());
                            lstData.Add(stnapCurrentPlayer);
                        }
                    }
                    else
                    {
                        stnapCurrentPlayer.iPlayerPoints = Convert.ToInt32(sCurrentLine[1].Trim());
                        lstData.Add(stnapCurrentPlayer);
                    }
                }
            }

            Console.WriteLine(lstData.Where(it => it.iPlayerPoints == lstData.Max(it1 => it1.iPlayerPoints)).FirstOrDefault().sPlayerName);
        }
    }

  • Vote: I like it
  • +1
  • Vote: I do not like it