Exemplo n.º 1
0
        static void Main(string[] args)
        {
            if (args.Length != 2)
            {
                return;
            }
            Env env = new Env();

            try
            {
                env.srd = new StreamReader(
                    args[0], Encoding.GetEncoding("Shift_JIS"));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            try
            {
                env.swr = new StreamWriter(
                    args[1], false, Encoding.GetEncoding("Shift_JIS"));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            sol_prob_a.probLoop(env);

            env.srd.Close();
            env.swr.Close();
        }
Exemplo n.º 2
0
        static int[] readArray(int length, Env env)
        {
            int[] array = new int[length];
            string line = env.srd.ReadLine();
            string[] parts = line.Split(Env.delim, StringSplitOptions.None);

            // 読み出し
            for (int i = 0; i < length; i++)
            {
                array[i] = Int32.Parse(parts[i]);
            }

            return array;
        }
Exemplo n.º 3
0
        static void probCore(long T, Env env)
        {
            Console.WriteLine("start#{0}", T);

            string line = env.srd.ReadLine();
            string[] parts = line.Split(Env.delim, StringSplitOptions.None);
            int A = Int32.Parse(parts[0]);
            int N = Int32.Parse(parts[1]);
            int[] moteSize = readArray(N, env);
            Array.Sort(moteSize);
            Console.WriteLine("N[{0}] = {1}", N-1, moteSize[N-1]);
            int result = solve(A, N, moteSize);
            env.swr.WriteLine("Case #{0}: {1}", T, result);
        }
Exemplo n.º 4
0
 public static void probLoop(Env env)
 {
     string line = env.srd.ReadLine();
     Stopwatch sw = new Stopwatch();
     sw.Start();
     long t = Int64.Parse(line);
     for (long i = 1; i <= t; i++)
     {
         probCore(i, env);
     }
     sw.Stop();
     long millisec = sw.ElapsedMilliseconds;
     Console.WriteLine("used:{0}[ms]", millisec);
 }
Exemplo n.º 5
0
        static void probCore(long T, Env env)
        {
            Console.WriteLine("start#{0}", T);

            string line = env.srd.ReadLine();
            string[] parts = line.Split(Env.delim, StringSplitOptions.None);
            string name = parts[0];
            int n = Int32.Parse(parts[1]);
            int result = solve(name, n);
            env.swr.WriteLine("Case #{0}: {1}", T, result);
        }