title: How Can I reduce execution time in SPOJ problem?
body: <p>I am trying to solve the problem on SPOJ.COM and although the answer is good it shows that the time limit has been exceeded. How can I correct it so that the task will be completed?
  This is problem to solve on SPOJ: <a href="https://www.spoj.com/problems/ARRAYSUB/" rel="nofollow noreferrer">https://www.spoj.com/problems/ARRAYSUB/</a></p>
  <pre><code>using System;
  using System.Linq;
  
  public class Test
  {
      public static void Main()
      {
              int n = Convert.ToInt32(Console.ReadLine());
  
              int k;
              int m = 0;
  
               int[] a = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
  
              k = Convert.ToInt32((Console.ReadLine()));
  
              for (int i = 0; i &lt;=n - k ; i++)
              {
                  m = a[i];
                  for (int j = 1; j &lt;  k; j++)
                  {
                     if (a[i + j] &gt; m)
                          {
  
                              m = a[i + j];
                          }
                  }
  
                  Console.Write(m);
                  Console.Write(&quot; &quot;);
              }
      }
  }
  </code></pre>