Advertisement
Guest User

Untitled

a guest
Dec 20th, 2014
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.08 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Threading;
  7.  
  8. // (づ°ω°)づミ★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
  9. public class Solver
  10. {
  11.     public object Solve()
  12.     {
  13.         int n = ReadInt();
  14.         int l = ReadInt();
  15.         var a = ReadIntArray();
  16.         Array.Sort(a);
  17.  
  18.         var b = new List<int> { -a[0] };
  19.         b.AddRange(a);
  20.         b.Add(2 * l - a[n - 1]);
  21.  
  22.         int ans = 0;
  23.         for (int i = 1; i < n + 2; i++)
  24.             ans = Math.Max(ans, b[i] - b[i - 1]);
  25.  
  26.         return (ans / 2.0).ToString(CultureInfo.InvariantCulture);
  27.  
  28.         return null;
  29.     }
  30.  
  31.     #region Main
  32.  
  33.     protected static TextReader reader;
  34.     protected static TextWriter writer;
  35.  
  36.     static void Main()
  37.     {
  38. #if DEBUG
  39.         reader = new StreamReader("..\\..\\input.txt");
  40.         writer = Console.Out;
  41.         //writer = new StreamWriter("..\\..\\output.txt");
  42. #else
  43.         reader = new StreamReader(Console.OpenStandardInput());
  44.         writer = new StreamWriter(Console.OpenStandardOutput());
  45.         //reader = new StreamReader("numbers.in");
  46.         //writer = new StreamWriter("numbers.out");
  47. #endif
  48.         try
  49.         {
  50.             object result = new Solver().Solve();
  51.             if (result != null)
  52.                 writer.WriteLine(result);
  53.         }
  54.         catch (Exception ex)
  55.         {
  56. #if DEBUG
  57.             Console.WriteLine(ex);
  58. #else
  59.             Console.WriteLine(ex);
  60.             throw;
  61. #endif
  62.         }
  63.         reader.Close();
  64.         writer.Close();
  65.     }
  66.  
  67.     #endregion
  68.  
  69.     #region Read / Write
  70.  
  71.     private static Queue<string> currentLineTokens = new Queue<string>();
  72.  
  73.     private static string[] ReadAndSplitLine()
  74.     {
  75.         return reader.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
  76.     }
  77.  
  78.     public static string ReadToken()
  79.     {
  80.         while (currentLineTokens.Count == 0)
  81.             currentLineTokens = new Queue<string>(ReadAndSplitLine());
  82.         return currentLineTokens.Dequeue();
  83.     }
  84.  
  85.     public static int ReadInt()
  86.     {
  87.         return int.Parse(ReadToken());
  88.     }
  89.  
  90.     public static long ReadLong()
  91.     {
  92.         return long.Parse(ReadToken());
  93.     }
  94.  
  95.     public static double ReadDouble()
  96.     {
  97.         return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
  98.     }
  99.  
  100.     public static int[] ReadIntArray()
  101.     {
  102.         return ReadAndSplitLine().Select(int.Parse).ToArray();
  103.     }
  104.  
  105.     public static long[] ReadLongArray()
  106.     {
  107.         return ReadAndSplitLine().Select(long.Parse).ToArray();
  108.     }
  109.  
  110.     public static double[] ReadDoubleArray()
  111.     {
  112.         return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();
  113.     }
  114.  
  115.     public static int[][] ReadIntMatrix(int numberOfRows)
  116.     {
  117.         int[][] matrix = new int[numberOfRows][];
  118.         for (int i = 0; i < numberOfRows; i++)
  119.             matrix[i] = ReadIntArray();
  120.         return matrix;
  121.     }
  122.  
  123.     public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
  124.     {
  125.         int[][] matrix = ReadIntMatrix(numberOfRows);
  126.         int[][] ret = new int[matrix[0].Length][];
  127.         for (int i = 0; i < ret.Length; i++)
  128.         {
  129.             ret[i] = new int[numberOfRows];
  130.             for (int j = 0; j < numberOfRows; j++)
  131.                 ret[i][j] = matrix[j][i];
  132.         }
  133.         return ret;
  134.     }
  135.  
  136.     public static string[] ReadLines(int quantity)
  137.     {
  138.         string[] lines = new string[quantity];
  139.         for (int i = 0; i < quantity; i++)
  140.             lines[i] = reader.ReadLine().Trim();
  141.         return lines;
  142.     }
  143.  
  144.     public static void WriteArray<T>(IEnumerable<T> array)
  145.     {
  146.         writer.WriteLine(string.Join(" ", array));
  147.     }
  148.  
  149.     public static void Write<T>(params T[] array)
  150.     {
  151.         WriteArray(array);
  152.     }
  153.  
  154.     public static void WriteLines<T>(IEnumerable<T> array)
  155.     {
  156.         foreach (var a in array)
  157.             writer.WriteLine(a);
  158.     }
  159.  
  160.     #endregion
  161. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement