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 1910. Titan Ruins: Hidden Entrance

тест 6
Posted by SamGTU7_Kareva Nadezhda Vladimirovna 26 May 2013 19:04
Please help pass the test 6. It is very necessary.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _1910
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int n = int.Parse(str);
            string[] mas = Console.ReadLine().Split(' ');
            int[] a=new int[n];
            for (int i=0; i<n; i++)
                a[i]=int.Parse(mas[i]);
            int sum=0, j=0, maxsum=0;
            if (n >= 3)
            {
                for (int i = 0; i < n - 2; i++)
                {
                    if ((a[i] == a[i + 1]) && (a[i] == a[i + 2]))
                    {
                        sum = a[i]*3;
                        j = i + 2;
                    }
                    if (sum > maxsum)
                    {
                        maxsum = sum;
                        sum = 0;
                    }
                }
            }
            Console.WriteLine(maxsum + " " + j);
        }
    }
}