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

answer c#
Posted by >OWL< 17 Jan 2016 15:37
using System;
using System.Linq;

class Program {
    static void Main() {
        int n = int.Parse(Console.ReadLine());
        string[] a = Console.ReadLine().Split(' ');

        int[] a_sum = new int[a.Length - 2];

        for(int i = 0; i < a_sum.Length; i++) {
            a_sum[i] = int.Parse(a[i]) + int.Parse(a[i + 1]) + int.Parse(a[i + 2]);
        }

        for(int i = 0; i < a_sum.Length; i++) {
            if(a_sum[i] == a_sum.Max()) {
                Console.WriteLine("{0} {1}", a_sum.Max(), i + 2);
            }
        }
    }
}