SHARE
TWEET

Untitled

a guest Feb 20th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. static void Main(string[] args) {
  2.         TextWriter textWriter = new StreamWriter(@System.Environment.GetEnvironmentVariable("OUTPUT_PATH"), true);
  3.         int n = Convert.ToInt32(Console.ReadLine());
  4.        
  5.         string colors = Console.ReadLine();
  6.         string[] ar_colors = colors.Split(' ');
  7.  
  8.         List<int> tmp = new List<int>();
  9.         foreach (string color in ar_colors) {
  10.             if (!string.IsNullOrEmpty(color)) {
  11.                 tmp.Add(Convert.ToInt32(color));
  12.             }
  13.         }
  14.  
  15.         int[] ar = tmp.ToArray();
  16.        
  17.         // Input includes a space too much, giving error with Convert.ToInt32.
  18.         // The below is therefore commented out and solved with the very bad code above.
  19.         /*
  20.         int n = Convert.ToInt32(Console.ReadLine());
  21.  
  22.         int[] ar = Array.ConvertAll(Console.ReadLine().Split(' '), arTemp => Convert.ToInt32(arTemp));
  23.         */
  24.        
  25.         int result = sockMerchant(n, ar);
  26.  
  27.         textWriter.WriteLine(result);
  28.  
  29.         textWriter.Flush();
  30.         textWriter.Close();
  31.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top