ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1005. Stone Pile

1005. Куча камней
Posted by akron 18 Feb 2012 20:39
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Program a = new Program();
            a.run();
        }

        void run()
        {
           // System.IO.StreamReader file = new System.IO.StreamReader(@"input.txt");
            byte n = Convert.ToByte(Console.ReadLine());
            string[] str = Console.ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
            List<int> l = new List<int>();
            for (byte i = 0; i < n; i++) l.Add(Convert.ToInt32(str[i]));
            int k1=0, k2=0;
            for (byte i = 0; i < n; i++)
            {
                if (k1 >= k2)
                {
                    k2 += l.Max();
                    l.Remove(l.Max());
                }
                else
                {
                    k1 += l.Max();
                    l.Remove(l.Max());
                }
            }
            Console.WriteLine(Math.Abs(k1-k2).ToString());
            Console.ReadKey();
        }
    }
}

пишет что Crash, на компе компилится... в чём может быть проблема?