Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace HeroGame
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- string[] input = Console.ReadLine().Split(' ');
- int[] safehouses = new int[input.Length];
- for (int i = 0; i < input.Length; i++)
- {
- safehouses[i] = int.Parse(input[i]);
- }
- int greatestDistance = 0;
- for (int i = 0; i < n; i++)
- {
- int minDistance = int.MaxValue;
- for (int j = 0; j < safehouses.Length; j++)
- {
- int distance = Math.Abs(i - safehouses[j]);
- if (distance < minDistance)
- {
- minDistance = distance;
- }
- }
- if (minDistance > greatestDistance)
- {
- greatestDistance = minDistance;
- }
- }
- Console.WriteLine(greatestDistance);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement