示例#1
0
        static void Main(string[] args)
        {
            Kattio.Scanner io      = new Kattio.Scanner();
            int            numRows = io.NextInt();
            int            numCols = io.NextInt();

            List <int[]> values = new List <int[]>();

            for (int i = numRows - 1; i >= 0; i--)
            {
                values.Add(getRow(numCols, io));
            }
            values.Reverse();
            //maxValue(values, numRows, 0,-1,5);
            int max = int.MinValue;

            for (int i = 0; i < numCols; i++)
            {
                int temp = maxValue(values, numRows - 1, i);
                if (temp > max)
                {
                    max = temp;
                }
            }
            Console.WriteLine(max);
        }
示例#2
0
        //static Tuple<int, int, float> getEdge()
        //{

        //    string n = Console.ReadLine();
        //    string[] values = n.Split(" ");
        //    int v1 = int.Parse(values[0]);
        //    int v2 = int.Parse(values[1]);
        //    float weight = float.Parse(values[2]);
        //    var toReturn = Tuple.Create(v1, v2, weight);
        //    return toReturn;
        //}
        static void Main(string[] args)
        {
            //List<float> reports = new List<float>();
            //StringBuilder sb = new StringBuilder("2 15000\n");
            //Random r = new Random();
            //for (int i = 0; i < 15000; i++)
            //{
            //    int v1 = r.Next(0, 9999);
            //    sb.Append(v1);
            //    sb.Append(" ");
            //    int v2 = r.Next(0, 9999);
            //    while(v2 == v1)
            //        v2 = r.Next(0, 9999);
            //    sb.Append(v2);
            //    sb.Append(" ");
            //    double weight = r.NextDouble();
            //    sb.Append(weight.ToString("0.0000"));
            //    sb.Append("\n");
            //}
            //sb.Append("0 0");
            //string test = sb.ToString();
            Kattio.Scanner io = new Kattio.Scanner();
            while (true)
            {
                //string n = Console.ReadLine();
                //string[] values = n.Split(" ");
                int numIntersections = io.NextInt();
                int numCorridors     = io.NextInt();
                if (numIntersections == 0 && numCorridors == 0)
                {
                    break;
                }
                else
                {
                    Graph dungeon = new Graph(numIntersections);
                    for (int i = 0; i < numCorridors; i++)
                    {
                        //string s = Console.ReadLine();
                        //string[] edgeValues = s.Split(" ");
                        int   v1     = io.NextInt();
                        int   v2     = io.NextInt();
                        float weight = io.NextFloat();
                        //int v1 = edgeData.Item1;
                        //int v2 = edgeData.Item2;
                        //float weight = edgeData.Item3;
                        dungeon.addEdge(v1, v2, weight);
                    }
                    //reports.Add(dungeon.findMaxSize());
                    Console.WriteLine(dungeon.findMaxSize().ToString("0.0000"));
                }
            }
            //for(int i = 0; i < reports.Count; i++)
            //{
            //    Console.WriteLine(reports[i].ToString("0.0000"));
            //}

            //Console.Write(map.toDOT());
            //Console.Read();
        }
示例#3
0
 static int[] getRow(int numCols, Kattio.Scanner io)
 {
     int[] toReturn = new int[numCols];
     for (int i = 0; i < numCols; i++)
     {
         toReturn[i] = io.NextInt();
     }
     return(toReturn);
 }
示例#4
0
        static void Main(string[] args)
        {
            Kattio.Scanner io = new Kattio.Scanner();
            int            n  = io.NextInt();

            int[] distance = new int[n + 1];

            for (int i = 0; i < n + 1; i++)
            {
                distance[i] = io.NextInt();
            }
            Console.WriteLine(penalty(distance));
        }
示例#5
0
        static void Main(string[] args)
        {
            Kattio.Scanner io         = new Kattio.Scanner();
            int            numRows    = io.NextInt();
            int            numToClose = io.NextInt();

            int[,] values = new int[numRows, 2];

            for (int i = 0; i < numRows; i++)
            {
                values[i, 0] = io.NextInt();
                values[i, 1] = io.NextInt();
            }
            //maxValue(values, numRows, 0,-1,5);
            Console.WriteLine(maxValue(values, numRows, 0, -1, numToClose));
        }
示例#6
0
        static void Main(string[] args)
        {
            pathCache = new Dictionary <Tuple <int, int, int>, int>();
            Kattio.Scanner io         = new Kattio.Scanner();
            int            xGridCoord = io.NextInt() + 1000;
            int            yGridCoord = io.NextInt() + 1000;

            a = io.NextInt();
            b = io.NextInt();
            c = io.NextInt();
            d = io.NextInt();

            int timeConstraint = io.NextInt();

            int numBorg = io.NextInt();

            grid = new bool[2001, 2001];

            for (int x = 0; x < 2001; x++)
            {
                for (int y = 0; y < 2001; y++)
                {
                    grid[x, y] = false;
                }
            }

            for (int i = 0; i < numBorg; i++)
            {
                grid[io.NextInt() + 1000, io.NextInt() + 1000] = true;
            }

            int result = minPath(xGridCoord, yGridCoord, timeConstraint, 1);

            if (result > timeConstraint)
            {
                Console.WriteLine("You will be assimilated! Resistance is futile!");
            }
            else
            {
                Console.WriteLine("I had " + (timeConstraint - result) + " to spare! Beam me up Scotty!");
            }
        }
示例#7
0
        static void Main(string[] args)
        {
            Kattio.Scanner io = new Kattio.Scanner();
            int            n  = io.NextInt();
            int            t  = io.NextInt();

            OptimalQueue q = new OptimalQueue(t);

            for (int i = 0; i < n; i++)
            {
                int cash = io.NextInt();
                int ttl  = io.NextInt();
                q.Enqueue(cash, ttl);
            }

            //Kattio.BufferedStdoutWriter writer = new Kattio.BufferedStdoutWriter();

            Console.WriteLine(q.MaxCash());
            //Console.ReadLine();
        }