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 1869. New Year Cruise

where is mistake?
Posted by Vadim_Egorov 4 Jun 2014 08:54
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _1869_2
{
    class Program
    {
        static void Main(string[] args)
        {
            Random random = new Random();
            int rand;
            int i, j, k, max;



            int N = int.Parse(Console.ReadLine());
            int[,] A = new int[100, 100];

            for (i = 0; i <N; ++i)
                for (j = 0; j <N; ++j)
                {
                    if (i == j)
                        A[i, j] = 0;
                    else
                    {
                        rand = random.Next(0, 1000);
                        A[i, j] = rand;
                    }
                }
            for (i = 0; i < N; i++)
                for (j = 0; j < N; j++)
                {
                    if (A[i,j] == 0)
                        continue;

                    // Vladi -> Moscow
                    if (i < j && j - i > 1)
                    {
                        for (k = i; k < j; k++)
                        {
                            A[k,k + 1] += A[i,j];
                        }
                    }
                    // Moscow -> Vladi
                    else if (i > j && i - j > 1)
                    {
                        for (k = i; k > j; k--)
                        {
                            A[k,k - 1] += A[i,j];
                        }
                    }
                };

            // get maximum for each pair of stations
            max = 0;
            for (i = 0; i < N - 1; i++)
            {
                if (Math.Max(A[i,i + 1], A[i + 1,i]) > max)
                {
                    max = Math.Max(A[i, i + 1], A[i + 1, i]);
                }
            }
            if (max % 36 == 0)
            {
                max /= 36;
                Console.WriteLine(max);
            }
            else
            {
                max /= 36;
                max = max + 1;
                Console.WriteLine(max);
            }

            //Console.ReadKey();

        }
    }
}