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

Please help. Why wrong answer 1? (C#)
Posted by Arty 25 Jan 2011 19:39
My programm:
static void Main(string[] args)
        {
            int d = new int();
            int n = new int();
            int k = new int();
            int k1= new int();
            int k2 = new int();
            do
            {
                Console.WriteLine("Kolichestvo N:");
                n = Convert.ToInt32(Console.ReadLine());
            }
            while (n < 1 || n > 20);
            int[] q = new int[n];
            Console.WriteLine("Vedite masiv:");
            string[] str = Console.ReadLine().Split(new char[] { ' ', '\n', '\t' }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < (n < str.Length ? n : str.Length); i++)
            {
                d = Convert.ToInt32(str[i]);
                if (d >= 1 & d <= 100000)
                    q[i] = d;
            }
            Array.Sort(q);
            Array.Reverse(q);
            k1 = q[0];
            k2 = q[1];
            for (int i = 2; i <q.Length; i++)
            {
                if (k1 > k2)
                    k2 = k2 + q[i];
                else k1 = k1 + q[i];
            }
            if (k1 > k2)
                k = k1 - k2;
            else
                k = k2 - k1;
            Console.WriteLine(k);
Re: Please help. Why wrong answer 1? (C#)
Posted by esenin.kazan 6 Feb 2011 19:33
Maybe because you write text before typing =)
Re: Please help. Why wrong answer 1? (C#)
Posted by daco 11 Mar 2011 02:04
Read FAQ.