using System; using System.Globalization; using System.Linq; class Program { public static void Main(string[] args) { int x = int.Parse(Console.ReadLine()); int y = int.Parse(Console.ReadLine()); int k = int.Parse(Console.ReadLine()); int count = 0; if (x != 0) { count++; } if (y < 0) { count++; } if (x != 0) { count += Math.Abs(x)/k; if (Math.Abs(x)%k != 0) { count++; } } if (y != 0) { count += Math.Abs(y) / k; if (Math.Abs(y) % k != 0) { count++; } } Console.WriteLine(count.ToString(CultureInfo.InvariantCulture)); } } class Program54 { public static void Main54(string[] args) { int n = int.Parse(Console.ReadLine()); Tuple[] valueAndThresholds = new Tuple[n]; for (int i = 0; i < n; i++) { var line = Console.ReadLine().Split(' ').Select(element => int.Parse(element)).ToArray(); valueAndThresholds[i] = new Tuple(line[0], line[1]); } Array.Sort(valueAndThresholds, (tuple, tuple1) => (tuple.Item2 + tuple.Item1).CompareTo(tuple1.Item2 + tuple1.Item1)); var size = valueAndThresholds.Sum(element => element.Item1); var dp = new int[size + 1]; for (int i = 0; i < dp.Length; i++) { dp[i] = int.MinValue; } dp[0] = 0; for (int index = 0; index < n; index++) { var current = valueAndThresholds[index]; var threshold = current.Item2; var value = current.Item1; for (int j = 0; j < threshold; j++) { if (j + value < size + 1) { if (dp[j] != int.MinValue) { dp[j + value] = Math.Max(dp[j + value], dp[j] + value); } } } } int max = 0; for (int i = 0; i < dp.Length; i++) { max = Math.Max(max, dp[i]); } Console.WriteLine(max.ToString(CultureInfo.InvariantCulture)); } }