fork(2) download
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace ConsoleApp17
  5. {
  6. internal class Program
  7. {
  8. private static void Main(string[] args)
  9. {
  10. int n = Convert.ToInt32((Console.ReadLine()));
  11.  
  12. int k;
  13.  
  14. int val = 0;
  15.  
  16. int[] arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
  17. k = Convert.ToInt32((Console.ReadLine()));
  18.  
  19. for (int i = 0; i < n - k + 1; i++)
  20. {
  21. val = arr[i];
  22. for (int j = i; j < i + k; j++)
  23. {
  24. if (val < arr[j])
  25. {
  26. val = arr[j];
  27. }
  28. }
  29.  
  30. Console.Write(val + " ");
  31. }
  32. }
  33. }
  34. }
Success #stdin #stdout 0.03s 23908KB
stdin
9
1 2 3 1 4 5 2 3 6
3
stdout
3 3 4 5 5 5 6