@@ -0,0 +1,1187 @@
+package titanRuinsHiddenEntrance;%0A%0Aimport java.util.Scanner;%0A%0A// Timus 1910%0Apublic class TitanRuinsHiddenEntrance %7B%0A%09%0A%09public static int sumByMiddleIndex(int%5B%5D walls, int index) %7B%0A%09%09if(index %3E 0 && index %3C walls.length)%0A%09%09%09return walls%5Bindex - 1%5D + walls%5Bindex%5D + walls%5Bindex + 1%5D;%0A%09%09throw new RuntimeException(%22Index is incorrect!%22);%0A%09%7D%0A%09%0A%09public static int findMaxWallSegmentMiddleIndex( int%5B%5D walls) %7B%0A%09%09int max = sumByMiddleIndex(walls, 1), index = 1;%0A%09%09for(int i = 2; i %3C walls.length - 1; ++i) %7B%0A%09%09%09if(max %3C sumByMiddleIndex(walls, i)) %7B%0A%09%09%09%09max = sumByMiddleIndex(walls, i);%0A%09%09%09%09index = i;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09return index;%0A%09%7D%0A%09%0A%09public static int findMaxWallSegment(int%5B%5D walls) %7B%0A%09%09int indexForMaxSegment = findMaxWallSegmentMiddleIndex(walls);%0A%09%09return sumByMiddleIndex(walls, indexForMaxSegment);%0A%09%7D%0A%09%0A%09public static void main(String... args) %7B%0A%09%09Scanner scanner = new Scanner(System.in);%0A%09%09int numberOfWalls = scanner.nextInt();%0A%09%09int%5B%5D walls = new int%5BnumberOfWalls%5D;%0A%09%09for( int i = 0; i %3C numberOfWalls; ++i) %7B%0A%09%09%09walls%5Bi%5D = scanner.nextInt();%0A%09%09%7D%0A%09%09System.out.println(findMaxWallSegment(walls) + %22 %22 + %0A%09%09%09%09%09%09   (findMaxWallSegmentMiddleIndex(walls) + 1));%0A%09%09scanner.close();%0A%09%7D%0A%7D%0A

Add problem #1910, Timus