static void Main() { int n = NextInt; int t = NextInt; int a = NextInt; (NextIntCollection.MinIndex(x => Abs(t - x * 0.006 - a)) + 1).WriteLine(); }
static void Main() { int n = NextInt; int a = NextInt; int b = NextInt; int[] p = NextIntCollection.ToArray(); (Min(Min(p.Count(x => x <= a), p.Count(x => a < x && x <= b)), p.Count(x => b < x))).WriteLine(); }
static void Main() { int n = NextInt; int[] h = NextIntCollection.ToArray(); int[] cost = new int[n]; cost[1] = Abs(h[1] - h[0]); for (int i = 2; i < h.Length; i++) { cost[i] = Min(cost[i - 2] + Abs(h[i - 2] - h[i]), cost[i - 1] + Abs(h[i - 1] - h[i])); } cost.Last().WriteLine(); }
static void Main() { int n = NextInt; int k = NextInt; int[] h = NextIntCollection.ToArray(); int[] cost = Enumerable.Repeat(int.MaxValue, n).ToArray(); cost[0] = 0; for (int i = 0; i < n; i++) { for (int j = 0; j <= Min(i, k); j++) { cost[i] = Min(cost[i], cost[i - j] + Abs(h[i] - h[i - j])); } } cost.Last().WriteLine(); }