buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
change_count
int64
0
100
using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics.Contracts; using System.IO; using System.Linq; using System.Numerics; using System.Xml.Schema; using System.Threading; using System.Diagnostics.CodeAnalysis; using System.Security.Cryptography; namespace AtCoder { public static class Ex { public static List<string> FastSort(this List<string> s) { s.Sort(StringComparer.OrdinalIgnoreCase); return s.ToList(); } public static void yesno(this bool b) { Console.WriteLine(b ? "yes" : "no"); } public static void YesNo(this bool b) { Console.WriteLine(b ? "Yes" : "No"); } public static void YESNO(this bool b) { Console.WriteLine(b ? "YES" : "NO"); } public static int BuildBitCount(this int bits) { bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555); bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333); bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f); bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff); return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff); } } partial class AtCoder { public string GetStr() { return Console.ReadLine().Trim(); } public char GetChar() { return Console.ReadLine().Trim()[0]; } public int GetInt() { return int.Parse(Console.ReadLine().Trim()); } public long GetLong() { return long.Parse(Console.ReadLine().Trim()); } public double GetDouble() { return double.Parse(Console.ReadLine().Trim()); } public string[] GetStrArray() { return Console.ReadLine().Trim().Split(' '); } public int[] GetIntArray() { return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray(); } public long[] GetLongArray() { return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray(); } public char[] GetCharArray() { return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray(); } public double[] GetDoubleArray() { return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray(); } public T[][] CreateJaggedArray<T>(int H, int W, T value) { return Enumerable.Repeat(0, H) .Select(s => Enumerable.Repeat(value, W).ToArray()) .ToArray(); } public int[][] GetIntJaggedArray(int N) { return Enumerable.Repeat(0, N) .Select(s => GetIntArray().ToArray()) .ToArray(); } public long[][] GetLongJaggedArray(int N) { return Enumerable.Repeat(0, N) .Select(s => GetLongArray().ToArray()) .ToArray(); } public char[][] GetCharJaggedArray(int N) { return Enumerable.Repeat(0, N) .Select(s => GetStr().ToCharArray()) .ToArray(); } public double[][] GetDoubleJaggedArray(int N) { return Enumerable.Repeat(0, N).Select(s => GetDoubleArray()).ToArray(); } Dictionary<int, List<int>> GetUnweightedAdjacencyList(int N, int M, bool isDirected, bool isNode_0indexed) { var dic = new Dictionary<int, List<int>>(); foreach (var e in Enumerable.Range(0, N)) { dic.Add(e, new List<int>()); } for (int i = 0; i < M; i++) { var input = GetIntArray(); var a = isNode_0indexed ? input[0] : input[0] - 1; var b = isNode_0indexed ? input[1] : input[1] - 1; dic[a].Add(b); if (isDirected == false) dic[b].Add(a); } return dic; } Dictionary<int, List<Edge>> GetWeightedAdjacencyList(int N, int M, bool isDirected, bool isNode_0indexed) { var dic = new Dictionary<int, List<Edge>>(); foreach (var e in Enumerable.Range(0, N)) { dic.Add(e, new List<Edge>()); } for (int i = 0; i < M; i++) { var input = GetIntArray(); var a = isNode_0indexed ? input[0] : input[0] - 1; var b = isNode_0indexed ? input[1] : input[1] - 1; var c = input[2]; dic[a].Add(new Edge(b, c)); if (isDirected == false) dic[b].Add(new Edge(a, c)); } return dic; } bool eq<T, U>() => typeof(T).Equals(typeof(U)); T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T)); T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s)) : eq<T, long>() ? ct<T, long>(long.Parse(s)) : eq<T, double>() ? ct<T, double>(double.Parse(s)) : eq<T, char>() ? ct<T, char>(s[0]) : ct<T, string>(s); void Multi<T>(out T a) => a = cv<T>(GetStr()); void Multi<T, U>(out T a, out U b) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); } void Multi<T, U, V>(out T a, out U b, out V c) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); } void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); } void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); } void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e, out Y f) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); f = cv<Y>(ar[5]); } } class Edge { public Edge(int to, long length) { To = to; Length = length; } public int To { get; set; } public long Length { get; set; } } partial class Program { static void Main() { Console.SetOut( new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }); new AtCoder().Solve(); Console.Out.Flush(); Console.Read(); } } public partial class AtCoder { public void Solve() { var N = GetLong(); long cnt = 0; for (long i = 1; i * i < N; i++) { if (N % i == 0) cnt += N / i - 1; } Console.WriteLine(cnt); } } }
using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics.Contracts; using System.IO; using System.Linq; using System.Numerics; using System.Xml.Schema; using System.Threading; using System.Diagnostics.CodeAnalysis; using System.Security.Cryptography; namespace AtCoder { public static class Ex { public static List<string> FastSort(this List<string> s) { s.Sort(StringComparer.OrdinalIgnoreCase); return s.ToList(); } public static void yesno(this bool b) { Console.WriteLine(b ? "yes" : "no"); } public static void YesNo(this bool b) { Console.WriteLine(b ? "Yes" : "No"); } public static void YESNO(this bool b) { Console.WriteLine(b ? "YES" : "NO"); } public static int BuildBitCount(this int bits) { bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555); bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333); bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f); bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff); return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff); } } partial class AtCoder { public string GetStr() { return Console.ReadLine().Trim(); } public char GetChar() { return Console.ReadLine().Trim()[0]; } public int GetInt() { return int.Parse(Console.ReadLine().Trim()); } public long GetLong() { return long.Parse(Console.ReadLine().Trim()); } public double GetDouble() { return double.Parse(Console.ReadLine().Trim()); } public string[] GetStrArray() { return Console.ReadLine().Trim().Split(' '); } public int[] GetIntArray() { return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray(); } public long[] GetLongArray() { return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray(); } public char[] GetCharArray() { return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray(); } public double[] GetDoubleArray() { return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray(); } public T[][] CreateJaggedArray<T>(int H, int W, T value) { return Enumerable.Repeat(0, H) .Select(s => Enumerable.Repeat(value, W).ToArray()) .ToArray(); } public int[][] GetIntJaggedArray(int N) { return Enumerable.Repeat(0, N) .Select(s => GetIntArray().ToArray()) .ToArray(); } public long[][] GetLongJaggedArray(int N) { return Enumerable.Repeat(0, N) .Select(s => GetLongArray().ToArray()) .ToArray(); } public char[][] GetCharJaggedArray(int N) { return Enumerable.Repeat(0, N) .Select(s => GetStr().ToCharArray()) .ToArray(); } public double[][] GetDoubleJaggedArray(int N) { return Enumerable.Repeat(0, N).Select(s => GetDoubleArray()).ToArray(); } Dictionary<int, List<int>> GetUnweightedAdjacencyList(int N, int M, bool isDirected, bool isNode_0indexed) { var dic = new Dictionary<int, List<int>>(); foreach (var e in Enumerable.Range(0, N)) { dic.Add(e, new List<int>()); } for (int i = 0; i < M; i++) { var input = GetIntArray(); var a = isNode_0indexed ? input[0] : input[0] - 1; var b = isNode_0indexed ? input[1] : input[1] - 1; dic[a].Add(b); if (isDirected == false) dic[b].Add(a); } return dic; } Dictionary<int, List<Edge>> GetWeightedAdjacencyList(int N, int M, bool isDirected, bool isNode_0indexed) { var dic = new Dictionary<int, List<Edge>>(); foreach (var e in Enumerable.Range(0, N)) { dic.Add(e, new List<Edge>()); } for (int i = 0; i < M; i++) { var input = GetIntArray(); var a = isNode_0indexed ? input[0] : input[0] - 1; var b = isNode_0indexed ? input[1] : input[1] - 1; var c = input[2]; dic[a].Add(new Edge(b, c)); if (isDirected == false) dic[b].Add(new Edge(a, c)); } return dic; } bool eq<T, U>() => typeof(T).Equals(typeof(U)); T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T)); T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s)) : eq<T, long>() ? ct<T, long>(long.Parse(s)) : eq<T, double>() ? ct<T, double>(double.Parse(s)) : eq<T, char>() ? ct<T, char>(s[0]) : ct<T, string>(s); void Multi<T>(out T a) => a = cv<T>(GetStr()); void Multi<T, U>(out T a, out U b) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); } void Multi<T, U, V>(out T a, out U b, out V c) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); } void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); } void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); } void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e, out Y f) { var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); f = cv<Y>(ar[5]); } } class Edge { public Edge(int to, long length) { To = to; Length = length; } public int To { get; set; } public long Length { get; set; } } partial class Program { static void Main() { Console.SetOut( new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }); new AtCoder().Solve(); Console.Out.Flush(); Console.Read(); } } public partial class AtCoder { public void Solve() { var N = GetLong(); long sum = 0; for (long a = 1; (a + 1) * a < N; a++) { if (N % a != 0) continue; var m = N / a - 1; if (m > a) sum += m; } Console.WriteLine(sum); } } }
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["-", 8, 196, 0, 7, 15, 16, 31, 16, 31, 22], ["+", 0, 7, 15, 16, 31, 16, 31, 23, 0, 24], ["+", 15, 16, 31, 16, 31, 23, 0, 16, 31, 22], ["+", 15, 16, 31, 16, 31, 23, 0, 16, 17, 72], ["+", 15, 16, 31, 16, 31, 23, 0, 16, 12, 203], ["+", 0, 7, 15, 16, 31, 16, 31, 23, 0, 25], ["-", 8, 196, 0, 7, 15, 16, 31, 16, 12, 22], ["+", 8, 196, 0, 7, 15, 16, 31, 16, 12, 22], ["-", 0, 195, 8, 196, 0, 7, 26, 223, 0, 22], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 22], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 79], ["-", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["-", 0, 57, 64, 1, 0, 11, 0, 202, 0, 107], ["+", 0, 7, 8, 196, 0, 57, 64, 116, 0, 117], ["+", 0, 7, 8, 196, 0, 57, 64, 116, 0, 35], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 64, 1, 0, 11, 12, 16, 31, 16, 12, 22], ["+", 0, 200, 0, 212, 0, 16, 31, 16, 12, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 107], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 12, 22], ["+", 0, 7, 8, 196, 0, 57, 64, 1, 0, 35], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
8
1,906
39
using System; using System.Collections.Generic; namespace D2019PC { class C { static void Main(string[] args) { long N = long.Parse(Console.ReadLine()); List<long> list = new List<long>(); for (long i = 1; i < Math.Sqrt(N); i++) { if (N % i == 0) { list.Add((N / i) - 1); } } long count = 0; foreach (var i in list) { count += i; } Console.WriteLine(count); } } }
using System; using System.Collections.Generic; namespace D2019PC { class C { static void Main(string[] args) { long N = long.Parse(Console.ReadLine()); List<long> list = new List<long>(); for (long i = 1; i < Math.Sqrt(N); i++) { if (N % i == 0) { list.Add((N / i) - 1); } } long count = 0; foreach (var i in list) { if (N % i != 0) count += i; } Console.WriteLine(count); } } }
[["+", 8, 196, 0, 210, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 210, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 0, 210, 8, 196, 0, 57, 15, 16, 17, 79], ["+", 0, 210, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 210, 8, 196, 0, 57, 0, 25]]
8
126
8
using System; using System.Linq; using System.Collections.Generic; class Program { static void Main(string[] args) { var N = long.Parse(Console.ReadLine()); var max = Math.Sqrt(N); var sum = 0L; // N = m * r + r = r(m+1) // r <= m であることに注意する for (long r = (long)max; r >= 1; r--) { var A = N / r; if (N % r == 0) { var m = A - 1; if (r <= m) sum += m; } } Console.WriteLine(sum); } }
using System; using System.Linq; using System.Collections.Generic; class Program { static void Main(string[] args) { var N = long.Parse(Console.ReadLine()); var max = Math.Sqrt(N); var sum = 0L; // N = m * r + r = r(m+1) // r <= m であることに注意する for (long r = (long)max; r >= 1; r--) { if (N % r != 0) continue; var A = N / r; var m = A - 1; if (r < m) sum += m; } Console.WriteLine(sum); } }
[["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 85], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["-", 8, 196, 0, 7, 8, 196, 0, 197, 0, 35], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 79], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 7, 8, 196, 0, 57, 64, 116, 0, 117], ["+", 0, 7, 8, 196, 0, 57, 64, 116, 0, 35], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 85], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 197, 0, 35], ["-", 0, 57, 64, 196, 0, 57, 15, 16, 17, 19], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 18], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
8
121
22
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace diverta_D { class Program { static void Main(string[] args) { var n = long.Parse(Console.ReadLine()); long otpt = 0; var z = Math.Sqrt((n)); long m = (long)(Math.Floor(z)); int count = 0; bool finish = false; int i = 0; do { i++; if (n % i == 0) { if (n / i > m) { otpt = otpt + n / i - 1; count++; } } if (i > m) { finish = true; } } while (finish == false); Console.WriteLine(Convert.ToString(otpt)); Console.ReadKey(); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace diverta_D { class Program { static void Main(string[] args) { var n = long.Parse(Console.ReadLine()); long otpt = 0; var z = Math.Sqrt((n)); long m = (long)(Math.Ceiling(z)); bool finish = false; int i = 0; do { i++; if (n % i == 0) { if (n / i > m) { otpt = otpt + n / i - 1; } } if (i > m) { finish = true; } } while (finish == false); Console.WriteLine(Convert.ToString(otpt)); Console.ReadKey(); } } }
[["-", 0, 74, 51, 23, 0, 213, 63, 214, 141, 22], ["+", 0, 74, 51, 23, 0, 213, 63, 214, 141, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 64, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 0, 57, 64, 196, 0, 1, 0, 223, 0, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 223, 0, 29]]
8
183
10
using System; using System.Collections.Generic; using System.Linq; using static Input; public class Hello { public static void Main() { long N = NextLong(); // Nの約数列挙 List<long> A = new List<long>(); long ans = 0; long M = (long)Math.Ceiling(Math.Sqrt(N)); for (long i = 1; i < M; i++) if (N % i == 0) { ans += (N / i) - 1; } Console.WriteLine(ans); } } public class Input { private static Queue<string> queue = new Queue<string>(); private static void Confirm() { if (queue.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) queue.Enqueue(s); } public static int NextInt() { Confirm(); return int.Parse(queue.Dequeue()); } public static long NextLong() { Confirm(); return long.Parse(queue.Dequeue()); } public static string NextString() { Confirm(); return queue.Dequeue(); } public static double NextDouble() { Confirm(); return double.Parse(queue.Dequeue()); } public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); } public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); } public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); } public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); } }
using System; using System.Collections.Generic; using System.Linq; using static Input; public class Hello { public static void Main() { long N = NextLong(); // Nの約数列挙 List<long> A = new List<long>(); long ans = 0; long M = (long)Math.Ceiling(Math.Sqrt(N)); for (long i = 1; i < M; i++) if (N % i == 0) { long L = (N / i) - 1; if (N / L == N % L) ans += L; } Console.WriteLine(ans); } } public class Input { private static Queue<string> queue = new Queue<string>(); private static void Confirm() { if (queue.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) queue.Enqueue(s); } public static int NextInt() { Confirm(); return int.Parse(queue.Dequeue()); } public static long NextLong() { Confirm(); return long.Parse(queue.Dequeue()); } public static string NextString() { Confirm(); return queue.Dequeue(); } public static double NextDouble() { Confirm(); return double.Parse(queue.Dequeue()); } public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); } public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); } public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); } public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); } }
[["-", 8, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 8, 57, 64, 196, 0, 197, 0, 198, 39, 199], ["+", 64, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 7, 8, 57, 64, 196, 0, 197, 0, 35], ["+", 0, 7, 8, 57, 64, 196, 0, 57, 0, 121], ["+", 0, 7, 8, 57, 64, 196, 0, 57, 0, 24], ["+", 64, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 64, 196, 0, 57, 15, 16, 31, 16, 17, 85], ["+", 64, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 8, 57, 64, 196, 0, 57, 15, 16, 17, 60], ["+", 64, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 64, 196, 0, 57, 15, 16, 12, 16, 17, 109], ["+", 64, 196, 0, 57, 15, 16, 12, 16, 12, 22], ["+", 0, 7, 8, 57, 64, 196, 0, 57, 0, 25], ["+", 64, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 107], ["+", 64, 196, 0, 57, 64, 1, 0, 11, 12, 22]]
8
404
19
using System; using System.Collections.Generic; public class CSharp { public static void Main() { Kyopuro chokudai = new Kyopuro(); chokudai.AtCoder(); } } public class Kyopuro { public void AtCoder() { string[] input; input = Console.ReadLine().Split(' '); long n; n = long.Parse(input[0]); long ans = 0; for (long i = 1; i * i < n; i++) { if (n % i == 0) ans += n / i - 1; } Console.WriteLine(ans); } public static void DebugWL(object x) { System.Diagnostics.Debug.WriteLine(x); } }
using System; using System.Collections.Generic; public class CSharp { public static void Main() { Kyopuro chokudai = new Kyopuro(); chokudai.AtCoder(); } } public class Kyopuro { public void AtCoder() { string[] input; input = Console.ReadLine().Split(' '); long n; n = long.Parse(input[0]); long ans = 0; for (long i = 1; i * i < n; i++) { if (n % i == 0 && n / i - 1 > i) ans += n / i - 1; } Console.WriteLine(ans); } public static void DebugWL(object x) { System.Diagnostics.Debug.WriteLine(x); } }
[["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 15, 16, 12, 16, 31, 16, 31, 16, 31, 22], ["+", 15, 16, 12, 16, 31, 16, 31, 16, 17, 85], ["+", 15, 16, 12, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 57, 15, 16, 12, 16, 31, 16, 17, 33], ["+", 0, 57, 15, 16, 12, 16, 31, 16, 12, 203], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 47], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 22]]
8
151
8
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Diagnostics; namespace AtCoder { class Program { private static string Read() { return Console.ReadLine(); } private static int ReadInt() { return int.Parse(Read()); } private static long ReadLong() { return long.Parse(Read()); } private static double ReadDouble() { return double.Parse(Read()); } private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); } private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); } private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); } static long Solve(long N) { long sum = 0; var dividor = new List<long>(); for (long i = 1; i * i < N; ++i) { if ((N - i) % i == 0) { sum += (N - i) / i; } } return sum; } static void Main(string[] args) { Console.WriteLine(Solve(ReadLong())); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Diagnostics; namespace AtCoder { class Program { private static string Read() { return Console.ReadLine(); } private static int ReadInt() { return int.Parse(Read()); } private static long ReadLong() { return long.Parse(Read()); } private static double ReadDouble() { return double.Parse(Read()); } private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); } private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); } private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); } static long Solve(long N) { long sum = 0; for (long i = 1; i * i < N - i; ++i) { if ((N - i) % i == 0) { sum += (N - i) / i; } } return sum; } static void Main(string[] args) { Console.WriteLine(Solve(ReadLong())); } } }
[["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 198, 0, 200, 0, 212, 0, 230, 0, 228], ["-", 0, 200, 0, 212, 0, 230, 39, 236, 141, 22], ["-", 0, 212, 0, 230, 39, 236, 237, 238, 0, 18], ["-", 0, 212, 0, 230, 39, 236, 237, 238, 0, 199], ["-", 0, 212, 0, 230, 39, 236, 237, 238, 0, 47], ["-", 0, 200, 0, 212, 0, 230, 3, 4, 0, 24], ["-", 0, 200, 0, 212, 0, 230, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 22]]
8
279
13
using System; using System.Collections.Generic; using System.Collections; using System.Collections.Specialized; using System.Linq; using System.Text; using System.IO; static class Program { const int mod = (int)1e9 + 7; static void Main() { Sc sc = new Sc(); long n = sc.L; long ans = 0; double d = Math.Sqrt(n); for (int i = 1; i < d; i++) { if (n % i == 0) { ans += n / i - 1; // ans++; } } Console.WriteLine("{0}", ans); } } public class Sc { private string[] a; private int n = -1, m = 0; public int I { get { if (n == -1 || n == a.Length - 1) { n = -1; a = Console.ReadLine().Split(); } n++; return int.Parse(a[n]); } } public long L { get { if (n == -1 || n == a.Length - 1) { n = -1; a = Console.ReadLine().Split(); } n++; return long.Parse(a[n]); } } public double D { get { if (n == -1 || n == a.Length - 1) { n = -1; a = Console.ReadLine().Split(); } n++; return double.Parse(a[n]); } } public string S { get { if (n == -1 || n == a.Length - 1) { n = -1; a = Console.ReadLine().Split(); } n++; return a[n]; } } public int[] Ia { get { if (n != -1 && n != a.Length - 1) { m = n; n = -1; return Array.ConvertAll(a.Skip(m + 1).ToArray(), int.Parse); } return Array.ConvertAll(Console.ReadLine().Split(), int.Parse); } } public int[] Ia2 { get { return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(), int.Parse); } } public long[] La { get { return Array.ConvertAll(Console.ReadLine().Split(), long.Parse); } } public long[] La2 { get { return Array.ConvertAll(("0 " + Console.ReadLine()).Split(), long.Parse); } } public double[] Da { get { return Array.ConvertAll(Console.ReadLine().Split(), double.Parse); } } public string[] Sa { get { return Console.ReadLine().Split(); } } }
using System; using System.Collections.Generic; using System.Collections; using System.Collections.Specialized; using System.Linq; using System.Text; using System.IO; static class Program { const int mod = (int)1e9 + 7; static void Main() { Sc sc = new Sc(); long n = sc.L; long ans = 0; double d = Math.Sqrt(n); for (int i = 1; i < d; i++) { if (n % i == 0 && n / i - 1 != i) { ans += n / i - 1; // ans++; } } Console.WriteLine("{0}", ans); } } public class Sc { private string[] a; private int n = -1, m = 0; public int I { get { if (n == -1 || n == a.Length - 1) { n = -1; a = Console.ReadLine().Split(); } n++; return int.Parse(a[n]); } } public long L { get { if (n == -1 || n == a.Length - 1) { n = -1; a = Console.ReadLine().Split(); } n++; return long.Parse(a[n]); } } public double D { get { if (n == -1 || n == a.Length - 1) { n = -1; a = Console.ReadLine().Split(); } n++; return double.Parse(a[n]); } } public string S { get { if (n == -1 || n == a.Length - 1) { n = -1; a = Console.ReadLine().Split(); } n++; return a[n]; } } public int[] Ia { get { if (n != -1 && n != a.Length - 1) { m = n; n = -1; return Array.ConvertAll(a.Skip(m + 1).ToArray(), int.Parse); } return Array.ConvertAll(Console.ReadLine().Split(), int.Parse); } } public int[] Ia2 { get { return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(), int.Parse); } } public long[] La { get { return Array.ConvertAll(Console.ReadLine().Split(), long.Parse); } } public long[] La2 { get { return Array.ConvertAll(("0 " + Console.ReadLine()).Split(), long.Parse); } } public double[] Da { get { return Array.ConvertAll(Console.ReadLine().Split(), double.Parse); } } public string[] Sa { get { return Console.ReadLine().Split(); } } }
[["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 15, 16, 12, 16, 31, 16, 31, 16, 31, 22], ["+", 15, 16, 12, 16, 31, 16, 31, 16, 17, 85], ["+", 15, 16, 12, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 57, 15, 16, 12, 16, 31, 16, 17, 33], ["+", 0, 57, 15, 16, 12, 16, 31, 16, 12, 203], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 79], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 22]]
8
613
8
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Diagnostics; public class Program { public static readonly int Mod = 1000000007; public static void Main(string[] args) { long N = Scanner.Long; long ans = 0; for (long i = 1; i * i < N; i++) { if (N % i == 0) { ans += ((N / i) - 1); } } Console.WriteLine(ans); Console.ReadLine(); } } /// <summary> /// スキャナ /// </summary> public static class Scanner { public static char[] separator = new char[] { ' ' }; private static IEnumerator<string> enumerator = Enumerator(); private static IEnumerator<string> Enumerator() { while (true) { foreach (string s in Console.ReadLine().Split(separator)) { yield return s; } } } public static string[] StringArray(int N) { string[] ret = new string[N]; for (int i = 0; i < N; i++) { ret[i] = Scanner.String; } return ret; } public static int[] IntArray(int N) { int[] ret = new int[N]; for (int i = 0; i < N; i++) { ret[i] = Scanner.Int; } return ret; } public static long[] LongArray(int N) { long[] ret = new long[N]; for (int i = 0; i < N; i++) { ret[i] = Scanner.Long; } return ret; } public static double[] DoubleArray(int N) { double[] ret = new double[N]; for (int i = 0; i < N; i++) { ret[i] = Scanner.Double; } return ret; } public static char[] CharArray(int N) { char[] ret = new char[N]; for (int i = 0; i < N; i++) { ret[i] = Scanner.Char; } return ret; } public static Tuple<int, int>[] IntTupleArray(int N) { Tuple<int, int>[] ret = new Tuple<int, int>[N]; for (int i = 0; i < N; i++) { ret[i] = Scanner.IntTuple; } return ret; } public static bool[] BoolArray(int N, Func<string, bool> parser) { bool[] ret = new bool[N]; for (int i = 0; i < N; i++) { ret[i] = Scanner.Bool(parser); } return ret; } public static string String { get { return enumerator.Next(); } } public static int Int { get { return String.Int(); } } public static long Long { get { return String.Long(); } } public static double Double { get { return String.Double(); } } public static char Char { get { return char.Parse(String); } } public static bool Bool(Func<string, bool> parser) { return parser(Scanner.String); } public static Tuple<int, int> IntTuple { get { return new Tuple<int, int>(Int, Int); } } } public class SegmentTree<T> { private Node root; private Func<T, T, T> solver; public SegmentTree(IList<T> data, Func<T, T, T> solver) { this.solver = solver; this.root = new Node(data, this, 0, data.Count); } public T Get(int left, int right) { return root.Get(left, right); } public T Get(params Tuple<int, int>[] ranges) { bool first = true; T value = default(T); foreach (Tuple<int, int> range in ranges) { if (range.Item2 - range.Item1 > 0) { if (first) { value = root.Get(range.Item1, range.Item2); first = true; } else { value = solver(value, root.Get(range.Item1, range.Item2)); } } } return value; } private class Node { private Node left; private Node right; private SegmentTree<T> segmentTree; private T value; private int start; private int end; private int mid { get { return this.start + ((this.end - this.start) / 2); } } public Node(IList<T> data, SegmentTree<T> segmentTree, int start, int end) { this.segmentTree = segmentTree; this.start = start; this.end = end; int length = end - start; if (length == 1) { value = data[start]; } else if (length == 2) { this.left = new Node(data, segmentTree, start, start + 1); this.right = new Node(data, segmentTree, start + 1, start + 2); this.value = this.segmentTree.solver(left.value, right.value); } else { int mid = start + (length / 2); this.left = new Node(data, segmentTree, start, mid); this.right = new Node(data, segmentTree, mid, end); this.value = this.segmentTree.solver(left.value, right.value); } } public T Get(int start, int end) { if (this.start == start && this.end == end) return value; int mid = this.mid; // 右のみ if (start >= mid) { return right.Get(start, end); } // 左のみ else if (end <= mid) { return left.Get(start, end); } // 両方 else { T l = left.Get(start, mid); T r = right.Get(mid, end); return segmentTree.solver(l, r); } } } } public static class LinqExtension { /* public static IEnumerable<Tuple<T, int>> GroupCount<T>(this IEnumerable<T> self) { return self.GroupBy(a => a).Select(g => new Tuple<T, int>(g.Key, g.Count())); } */ public static SegmentTree<T> ToSegmentTree<T>(this IEnumerable<T> self, Func<T, T, T> solver) { return new SegmentTree<T>(self.ToArray(), solver); } public static T LeftBinarySearch<T>(this IEnumerable<T> self, Func<T, bool> solve, T min = default(T), T max = default(T)) { int index = self.LeftBinarySearchIndex(solve); return self.Get(index, min, max); } public static T RightBinarySearch<T>(this IEnumerable<T> self, Func<T, bool> solve, T min = default(T), T max = default(T)) { int index = self.RightBinarySearchIndex(solve); return self.Get(index, min, max); } public static int LeftBinarySearchIndex<T>(this IEnumerable<T> self, Func<T, bool> solve) { int ng = -1; int ok = self.Count(); while (Math.Abs(ok - ng) > 1) { int mid = (ok + ng) / 2; if (solve(self.ElementAt(mid))) { ok = mid; } else { ng = mid; } } return ok; } public static int RightBinarySearchIndex<T>(this IEnumerable<T> self, Func<T, bool> solve) { int ng = self.Count(); int ok = -1; while (Math.Abs(ok - ng) > 1) { int mid = (ok + ng) / 2; if (solve(self.ElementAt(mid))) { ok = mid; } else { ng = mid; } } return ok; } public static T Get<T>(this IEnumerable<T> self, int index, T min, T max) { if (index < 0) return min; if (index >= self.Count()) return max; return self.ElementAt(index); } public static IList<T> Fill<T>(this IList<T> self, Func<int, T> func) { for (int i = 0; i < self.Count; i++) { self[i] = func(i); } return self; } public static IList<T> Fill<T>(this IList<T> self, T value) { for (int i = 0; i < self.Count; i++) { self[i] = value; } return self; } public static T[] Fill<T>(this T[] self, T value) { for (int i = 0; i < self.Length; i++) { self[i] = value; } return self; } public static T Next<T>(this IEnumerator<T> self) { self.MoveNext(); return self.Current; } public static void Write(this IEnumerable<bool> self) { StringBuilder sb = new StringBuilder(); foreach (bool b in self) { sb.Append(b ? "□" : "■"); } Console.WriteLine(sb.ToString()); } public static U[] SelectArray<T, U>(this IEnumerable<T> self, Func<T, U> func) { U[] array = new U[self.Count()]; int i = 0; foreach (T t in self) { array[i] = func(t); i++; } return array; } public static List<U> SelectList<T, U>(this IEnumerable<T> self, Func<T, U> func) { List<U> list = new List<U>(self.Count()); foreach (T t in self) { list.Add(func(t)); } return list; } } public static class IntExtensiton { public static long C(this int self, int n) { return Factorial(self) / Factorial(n); } public static long Factorial(this int self) { int ret = self; for (int i = self - 1; i >= 1; i--) { ret *= i; } return ret; } public static long Factorial(this int self, int c) { int ret = self; for (int i = self - 1; i >= Math.Max(1, self - c - 1); i--) { ret *= i; } return ret; } public static int BitCount(this int bit, int digit = 32) { int count = 0; for (int i = (digit - 1); i >= 0; i--) { if (bit.GetBit(i)) count++; } return count; } public static bool GetBit(this int bit, int digit) { int mask = (1 << digit); return (bit & mask) == mask; } public static int SetBit(this int bit, int digit) { return (bit | (1 << digit)); } public static string BitToString(this int bit, int digit = 32) { StringBuilder sb = new StringBuilder(); for (int i = (digit - 1); i >= 0; i--) { sb.Append(bit.GetBit(i) ? "1" : "0"); } return sb.ToString(); } public static bool IsDivisor(this int self, int target) { return self % target == 0; } public static IEnumerable<int> Divisors(this int self) { for (int i = 1; i * i <= self; i++) { if (self % i == 0) { yield return i; if (i * i != self) yield return self / i; } } } public static IEnumerable<int> PrimeFactors(this int self) { int i = 2; int tmp = self; while (i * i <= self) { if (tmp % i == 0) { tmp /= i; yield return i; } else { i++; } } if (tmp != 1) yield return tmp; } public static bool NeighboringBit(this int self, int digit = 32) { if (digit < 2) return false; return Enumerable.Range(0, digit - 1) .Where(j => self.GetBit(j) && self.GetBit(j + 1)) .Any(); } } public static class LongExtensition { public static long BitCount(this long bit, int digit = 64) { long count = 0; for (int i = (digit - 1); i >= 0; i--) { if (bit.GetBit(i)) count++; } return count; } public static bool GetBit(this long bit, int digit) { long mask = (1L << digit); return (bit & mask) == mask; } public static long SetBit(this long bit, int digit) { return bit | (1L << digit); } public static string BitToString(this long bit, int digit = 64) { StringBuilder sb = new StringBuilder(); for (int i = (digit - 1); i >= 0; i--) { sb.Append(bit.GetBit(i) ? "1" : "0"); } return sb.ToString(); } public static bool IsDivisor(this long self, int target) { return self % target == 0; } } public static class StringExtensiton { public static void Print(this string str) => Console.WriteLine(str); public static int Int(this string str) => int.Parse(str); public static long Long(this string str) => long.Parse(str); public static double Double(this string str) => double.Parse(str); } public class F { public static bool ChMax<T>(ref T x, T y) where T : IComparable { if (x.CompareTo(y) < 0) { x = y; return true; } return false; } public static bool ChMin<T>(ref T x, T y) where T : IComparable { if (x.CompareTo(y) > 0) { x = y; return true; } return false; } public static void Swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; } public static int Gcd(int a, int b) { if (a < b) return Gcd(b, a); while (b != 0) { var remainder = a % b; a = b; b = remainder; } return a; } public static long Gcd(long a, long b) { if (a < b) return Gcd(b, a); while (b != 0) { var remainder = a % b; a = b; b = remainder; } return a; } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Diagnostics; public class Program { public static readonly int Mod = 1000000007; public static void Main(string[] args) { long N = Scanner.Long; long ans = 0; for (long i = 1; i * i < N; i++) { if (N % i == 0) { long tmp = (N / i) - 1; if (tmp != i) ans += tmp; } } Console.WriteLine(ans); Console.ReadLine(); } } /// <summary> /// スキャナ /// </summary> public static class Scanner { public static char[] separator = new char[] { ' ' }; private static IEnumerator<string> enumerator = Enumerator(); private static IEnumerator<string> Enumerator() { while (true) { foreach (string s in Console.ReadLine().Split(separator)) { yield return s; } } } public static string[] StringArray(int N) { string[] ret = new string[N]; for (int i = 0; i < N; i++) { ret[i] = Scanner.String; } return ret; } public static int[] IntArray(int N) { int[] ret = new int[N]; for (int i = 0; i < N; i++) { ret[i] = Scanner.Int; } return ret; } public static long[] LongArray(int N) { long[] ret = new long[N]; for (int i = 0; i < N; i++) { ret[i] = Scanner.Long; } return ret; } public static double[] DoubleArray(int N) { double[] ret = new double[N]; for (int i = 0; i < N; i++) { ret[i] = Scanner.Double; } return ret; } public static char[] CharArray(int N) { char[] ret = new char[N]; for (int i = 0; i < N; i++) { ret[i] = Scanner.Char; } return ret; } public static Tuple<int, int>[] IntTupleArray(int N) { Tuple<int, int>[] ret = new Tuple<int, int>[N]; for (int i = 0; i < N; i++) { ret[i] = Scanner.IntTuple; } return ret; } public static bool[] BoolArray(int N, Func<string, bool> parser) { bool[] ret = new bool[N]; for (int i = 0; i < N; i++) { ret[i] = Scanner.Bool(parser); } return ret; } public static string String { get { return enumerator.Next(); } } public static int Int { get { return String.Int(); } } public static long Long { get { return String.Long(); } } public static double Double { get { return String.Double(); } } public static char Char { get { return char.Parse(String); } } public static bool Bool(Func<string, bool> parser) { return parser(Scanner.String); } public static Tuple<int, int> IntTuple { get { return new Tuple<int, int>(Int, Int); } } } public class SegmentTree<T> { private Node root; private Func<T, T, T> solver; public SegmentTree(IList<T> data, Func<T, T, T> solver) { this.solver = solver; this.root = new Node(data, this, 0, data.Count); } public T Get(int left, int right) { return root.Get(left, right); } public T Get(params Tuple<int, int>[] ranges) { bool first = true; T value = default(T); foreach (Tuple<int, int> range in ranges) { if (range.Item2 - range.Item1 > 0) { if (first) { value = root.Get(range.Item1, range.Item2); first = true; } else { value = solver(value, root.Get(range.Item1, range.Item2)); } } } return value; } private class Node { private Node left; private Node right; private SegmentTree<T> segmentTree; private T value; private int start; private int end; private int mid { get { return this.start + ((this.end - this.start) / 2); } } public Node(IList<T> data, SegmentTree<T> segmentTree, int start, int end) { this.segmentTree = segmentTree; this.start = start; this.end = end; int length = end - start; if (length == 1) { value = data[start]; } else if (length == 2) { this.left = new Node(data, segmentTree, start, start + 1); this.right = new Node(data, segmentTree, start + 1, start + 2); this.value = this.segmentTree.solver(left.value, right.value); } else { int mid = start + (length / 2); this.left = new Node(data, segmentTree, start, mid); this.right = new Node(data, segmentTree, mid, end); this.value = this.segmentTree.solver(left.value, right.value); } } public T Get(int start, int end) { if (this.start == start && this.end == end) return value; int mid = this.mid; // 右のみ if (start >= mid) { return right.Get(start, end); } // 左のみ else if (end <= mid) { return left.Get(start, end); } // 両方 else { T l = left.Get(start, mid); T r = right.Get(mid, end); return segmentTree.solver(l, r); } } } } public static class LinqExtension { /* public static IEnumerable<Tuple<T, int>> GroupCount<T>(this IEnumerable<T> self) { return self.GroupBy(a => a).Select(g => new Tuple<T, int>(g.Key, g.Count())); } */ public static SegmentTree<T> ToSegmentTree<T>(this IEnumerable<T> self, Func<T, T, T> solver) { return new SegmentTree<T>(self.ToArray(), solver); } public static T LeftBinarySearch<T>(this IEnumerable<T> self, Func<T, bool> solve, T min = default(T), T max = default(T)) { int index = self.LeftBinarySearchIndex(solve); return self.Get(index, min, max); } public static T RightBinarySearch<T>(this IEnumerable<T> self, Func<T, bool> solve, T min = default(T), T max = default(T)) { int index = self.RightBinarySearchIndex(solve); return self.Get(index, min, max); } public static int LeftBinarySearchIndex<T>(this IEnumerable<T> self, Func<T, bool> solve) { int ng = -1; int ok = self.Count(); while (Math.Abs(ok - ng) > 1) { int mid = (ok + ng) / 2; if (solve(self.ElementAt(mid))) { ok = mid; } else { ng = mid; } } return ok; } public static int RightBinarySearchIndex<T>(this IEnumerable<T> self, Func<T, bool> solve) { int ng = self.Count(); int ok = -1; while (Math.Abs(ok - ng) > 1) { int mid = (ok + ng) / 2; if (solve(self.ElementAt(mid))) { ok = mid; } else { ng = mid; } } return ok; } public static T Get<T>(this IEnumerable<T> self, int index, T min, T max) { if (index < 0) return min; if (index >= self.Count()) return max; return self.ElementAt(index); } public static IList<T> Fill<T>(this IList<T> self, Func<int, T> func) { for (int i = 0; i < self.Count; i++) { self[i] = func(i); } return self; } public static IList<T> Fill<T>(this IList<T> self, T value) { for (int i = 0; i < self.Count; i++) { self[i] = value; } return self; } public static T[] Fill<T>(this T[] self, T value) { for (int i = 0; i < self.Length; i++) { self[i] = value; } return self; } public static T Next<T>(this IEnumerator<T> self) { self.MoveNext(); return self.Current; } public static void Write(this IEnumerable<bool> self) { StringBuilder sb = new StringBuilder(); foreach (bool b in self) { sb.Append(b ? "□" : "■"); } Console.WriteLine(sb.ToString()); } public static U[] SelectArray<T, U>(this IEnumerable<T> self, Func<T, U> func) { U[] array = new U[self.Count()]; int i = 0; foreach (T t in self) { array[i] = func(t); i++; } return array; } public static List<U> SelectList<T, U>(this IEnumerable<T> self, Func<T, U> func) { List<U> list = new List<U>(self.Count()); foreach (T t in self) { list.Add(func(t)); } return list; } } public static class IntExtensiton { public static long C(this int self, int n) { return Factorial(self) / Factorial(n); } public static long Factorial(this int self) { int ret = self; for (int i = self - 1; i >= 1; i--) { ret *= i; } return ret; } public static long Factorial(this int self, int c) { int ret = self; for (int i = self - 1; i >= Math.Max(1, self - c - 1); i--) { ret *= i; } return ret; } public static int BitCount(this int bit, int digit = 32) { int count = 0; for (int i = (digit - 1); i >= 0; i--) { if (bit.GetBit(i)) count++; } return count; } public static bool GetBit(this int bit, int digit) { int mask = (1 << digit); return (bit & mask) == mask; } public static int SetBit(this int bit, int digit) { return (bit | (1 << digit)); } public static string BitToString(this int bit, int digit = 32) { StringBuilder sb = new StringBuilder(); for (int i = (digit - 1); i >= 0; i--) { sb.Append(bit.GetBit(i) ? "1" : "0"); } return sb.ToString(); } public static bool IsDivisor(this int self, int target) { return self % target == 0; } public static IEnumerable<int> Divisors(this int self) { for (int i = 1; i * i <= self; i++) { if (self % i == 0) { yield return i; if (i * i != self) yield return self / i; } } } public static IEnumerable<int> PrimeFactors(this int self) { int i = 2; int tmp = self; while (i * i <= self) { if (tmp % i == 0) { tmp /= i; yield return i; } else { i++; } } if (tmp != 1) yield return tmp; } public static bool NeighboringBit(this int self, int digit = 32) { if (digit < 2) return false; return Enumerable.Range(0, digit - 1) .Where(j => self.GetBit(j) && self.GetBit(j + 1)) .Any(); } } public static class LongExtensition { public static long BitCount(this long bit, int digit = 64) { long count = 0; for (int i = (digit - 1); i >= 0; i--) { if (bit.GetBit(i)) count++; } return count; } public static bool GetBit(this long bit, int digit) { long mask = (1L << digit); return (bit & mask) == mask; } public static long SetBit(this long bit, int digit) { return bit | (1L << digit); } public static string BitToString(this long bit, int digit = 64) { StringBuilder sb = new StringBuilder(); for (int i = (digit - 1); i >= 0; i--) { sb.Append(bit.GetBit(i) ? "1" : "0"); } return sb.ToString(); } public static bool IsDivisor(this long self, int target) { return self % target == 0; } } public static class StringExtensiton { public static void Print(this string str) => Console.WriteLine(str); public static int Int(this string str) => int.Parse(str); public static long Long(this string str) => long.Parse(str); public static double Double(this string str) => double.Parse(str); } public class F { public static bool ChMax<T>(ref T x, T y) where T : IComparable { if (x.CompareTo(y) < 0) { x = y; return true; } return false; } public static bool ChMin<T>(ref T x, T y) where T : IComparable { if (x.CompareTo(y) > 0) { x = y; return true; } return false; } public static void Swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; } public static int Gcd(int a, int b) { if (a < b) return Gcd(b, a); while (b != 0) { var remainder = a % b; a = b; b = remainder; } return a; } public static long Gcd(long a, long b) { if (a < b) return Gcd(b, a); while (b != 0) { var remainder = a % b; a = b; b = remainder; } return a; } }
[["-", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["-", 64, 196, 0, 1, 0, 11, 12, 23, 0, 24], ["+", 0, 57, 64, 196, 0, 197, 0, 198, 39, 199], ["+", 64, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 8, 196, 0, 57, 64, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 79], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 22], ["+", 64, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 107], ["+", 64, 196, 0, 57, 64, 1, 0, 11, 12, 22]]
8
3,126
15
using System; using System.Collections.Generic; class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); long[] A = new long[N]; long[] S = new long[N + 1]; long[] S0 = new long[N + 1]; long mod = 1000000007; string[] str = Console.ReadLine().Split(); for (var i = 0; i < N; i++) { A[i] = long.Parse(str[i]); } for (var i = 0; i < N; i++) { long c = 1; for (var j = 0; j < 22; j++) { if (A[i] / c % 2 + S[i] / c % 2 == 1) { S[i + 1] += c; } S0[i + 1] = S0[i]; if (S[i + 1] == 0) { S0[i + 1]++; } c *= 2; } } long ans = 0; if (S[N] == 0) { long[] D0 = new long[4000000]; long[] DX = new long[4000000]; long[] DL = new long[4000000]; D0[0] = 1; for (var i = 1; i < N; i++) { D0[i] = 1; } for (var i = 1; i < N; i++) { if (S[i] > 0) { // if(DX[S[i]]==0){ // DX[S[i]] = 1; //} else { D0[S[i]] = (D0[S[i]] + DX[S[i]] * (S0[i] - DL[S[i]])) % mod; DX[S[i]] = (DX[S[i]] + D0[S[i]]) % mod; //} DL[S[i]] = S0[i]; } else { D0[0] = D0[0] * 2 % mod; } } for (var i = 1; i < 4000000; i++) { D0[i] = DX[i]; } for (var i = 0; i < 4000000; i++) { ans = (ans + D0[i]) % mod; } } else { long D0 = 1; long DX = 0; for (var i = 1; i < N; i++) { if (S[i] == S[N]) { DX = (D0 + DX) % mod; } else if (S[i] == 0) { D0 = (D0 + DX) % mod; } } ans = D0; } Console.WriteLine(ans); } }
using System; using System.Collections.Generic; class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); long[] A = new long[N]; long[] S = new long[N + 1]; long[] S0 = new long[N + 1]; long mod = 1000000007; string[] str = Console.ReadLine().Split(); for (var i = 0; i < N; i++) { A[i] = long.Parse(str[i]); } for (var i = 0; i < N; i++) { long c = 1; for (var j = 0; j < 22; j++) { if (A[i] / c % 2 + S[i] / c % 2 == 1) { S[i + 1] += c; } S0[i + 1] = S0[i]; if (S[i + 1] == 0) { S0[i + 1]++; } c *= 2; } } long ans = 0; if (S[N] == 0) { long[] D0 = new long[4000000]; long[] DX = new long[4000000]; long[] DL = new long[4000000]; for (var i = 0; i < 4000000; i++) { D0[i] = 1; } for (var i = 1; i < N; i++) { if (S[i] > 0) { D0[S[i]] = (D0[S[i]] + DX[S[i]] * (S0[i] - DL[S[i]])) % mod; DX[S[i]] = (DX[S[i]] + D0[S[i]]) % mod; DL[S[i]] = S0[i]; } else { D0[0] = D0[0] * 2 % mod; } } for (var i = 1; i < 4000000; i++) { D0[i] = DX[i]; } for (var i = 0; i < 4000000; i++) { ans = (ans + D0[i]) % mod; } } else { long D0 = 1; long DX = 0; for (var i = 1; i < N; i++) { if (S[i] == S[N]) { DX = (D0 + DX) % mod; } else if (S[i] == 0) { D0 = (D0 + DX) % mod; } } ans = D0; } Console.WriteLine(ans); } }
[["-", 64, 196, 0, 1, 0, 11, 31, 204, 205, 22], ["-", 0, 1, 0, 11, 31, 204, 206, 207, 0, 70], ["-", 0, 11, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 1, 0, 11, 31, 204, 206, 207, 0, 73], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 57, 64, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 57, 64, 196, 0, 7, 15, 16, 12, 203]]
8
586
11
using System; using System.Collections.Generic; using System.Linq; using static System.Console; class Z { static void Main() => new K(); } class K { int[] G => ReadLine().Split().Select(int.Parse).ToArray(); static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; } static T[] Recurse<T>(int n, T a0, Func<int, T, T> f) { var a = new T[n]; a[0] = a0; for (var i = 1; i < n; i++) a[i] = f(i, a[i - 1]); return a; } static T[] Accumulate<T>(IList<T> a, T zero, Func<T, T, T> f) { var s = new T[a.Count + 1]; s[0] = zero; for (var i = 0; i < a.Count; i++) s[i + 1] = f(s[i], a[i]); return s; } static int[] Accumulate(IList<int> a) { var s = new int[a.Count + 1]; for (var i = 0; i < a.Count; i++) s[i + 1] = s[i] + a[i]; return s; } const int MOD = 1000000007; public K() { var N = G[0]; var A = G; var sum = Accumulate(A, 0, (a, b) => a ^ b); var zero = Accumulate(sum.Select(t => t == 0 ? 1 : 0).ToList()); Func<IList<int>, int[]> getZero = l => MakeArray(l.Count - 1, i => zero[l[i + 1]] - zero[l[i]]); var dic = Indexes(sum); if (sum[N] != 0) WriteLine(DP(getZero(dic[-1])).Last()); else { var ans = Pow(2, zero[N + 1] - 2, MOD); foreach (var t in dic) if (t.Key != 0) ans = (ans + DP(getZero(t.Value)).Sum()) % MOD; WriteLine(ans % MOD); } } static Dictionary<int, List<int>> Indexes(IList<int> x) { var dic = new Dictionary<int, List<int>>(); for (var i = 0; i < x.Count; i++) { if (!dic.ContainsKey(x[i])) dic[x[i]] = new List<int>(); dic[x[i]].Add(i); } return dic; } static long[] DP(IList<int> zs) { var L = zs.Count; var dp = new long[L + 1]; dp[0] = 1; var sum = 1L; for (var j = 0; j < L; j++) { dp[j + 1] = (dp[j] + zs[j] * sum % MOD) % MOD; sum = (sum + dp[j + 1]) % MOD; } return dp; } public static long Pow(long a, long b, long mod) { long p = 1L, x = a; while (b > 0) { if ((b & 1L) == 1L) p = p * x % mod; b >>= 1; x = x * x % mod; } return p; } }
using System; using System.Collections.Generic; using System.Linq; using static System.Console; class Z { static void Main() => new K(); } class K { int[] G => ReadLine().Split().Select(int.Parse).ToArray(); static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; } static T[] Recurse<T>(int n, T a0, Func<int, T, T> f) { var a = new T[n]; a[0] = a0; for (var i = 1; i < n; i++) a[i] = f(i, a[i - 1]); return a; } static T[] Accumulate<T>(IList<T> a, T zero, Func<T, T, T> f) { var s = new T[a.Count + 1]; s[0] = zero; for (var i = 0; i < a.Count; i++) s[i + 1] = f(s[i], a[i]); return s; } static int[] Accumulate(IList<int> a) { var s = new int[a.Count + 1]; for (var i = 0; i < a.Count; i++) s[i + 1] = s[i] + a[i]; return s; } const int MOD = 1000000007; public K() { var N = G[0]; var A = G; var sum = Accumulate(A, 0, (a, b) => a ^ b); var zero = Accumulate(sum.Select(t => t == 0 ? 1 : 0).ToList()); Func<IList<int>, int[]> getZero = l => MakeArray(l.Count - 1, i => zero[l[i + 1]] - zero[l[i]]); var dic = Indexes(sum); if (sum[N] != 0) WriteLine(DP(getZero(dic[sum[N]])).Last()); else WriteLine( (Pow(2, zero[N + 1] - 2, MOD) + dic.Where(t => t.Key != 0).Sum(t => DP(getZero(t.Value)).Sum())) % MOD); } static Dictionary<int, List<int>> Indexes(IList<int> x) { var dic = new Dictionary<int, List<int>>(); for (var i = 0; i < x.Count; i++) { if (!dic.ContainsKey(x[i])) dic[x[i]] = new List<int>(); dic[x[i]].Add(i); } return dic; } static long[] DP(IList<int> zs) { var L = zs.Count; var dp = new long[L + 1]; dp[0] = 1; var sum = 1L; for (var j = 0; j < L; j++) { dp[j + 1] = (dp[j] + zs[j] * sum % MOD) % MOD; sum = (sum + dp[j + 1]) % MOD; } return dp; } public static long Pow(long a, long b, long mod) { long p = 1L, x = a; while (b > 0) { if ((b & 1L) == 1L) p = p * x % mod; b >>= 1; x = x * x % mod; } return p; } }
[["-", 0, 204, 206, 207, 0, 28, 0, 241, 0, 33], ["-", 0, 204, 206, 207, 0, 28, 0, 241, 0, 203], ["+", 0, 204, 206, 207, 0, 28, 0, 204, 205, 22], ["+", 206, 207, 0, 28, 0, 204, 206, 207, 0, 70], ["+", 0, 28, 0, 204, 206, 207, 0, 28, 0, 22], ["+", 206, 207, 0, 28, 0, 204, 206, 207, 0, 73], ["-", 0, 263, 8, 196, 0, 57, 75, 196, 0, 45], ["-", 75, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 75, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 8, 196, 0, 57, 75, 1, 0, 213, 63, 22], ["+", 0, 57, 75, 1, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 24], ["-", 8, 196, 0, 57, 75, 196, 0, 197, 0, 35], ["-", 8, 196, 0, 57, 75, 196, 0, 210, 0, 266], ["-", 8, 196, 0, 57, 75, 196, 0, 210, 0, 24], ["-", 0, 57, 75, 196, 0, 210, 39, 216, 0, 217], ["-", 8, 196, 0, 57, 75, 196, 0, 210, 31, 22], ["-", 8, 196, 0, 57, 75, 196, 0, 210, 0, 267], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 17, 72], ["-", 8, 196, 0, 57, 75, 196, 0, 210, 0, 25], ["-", 0, 57, 75, 196, 0, 210, 8, 57, 0, 121], ["+", 12, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["+", 12, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 205, 213, 3, 4, 0, 28, 0, 218, 0, 221], ["+", 0, 28, 0, 218, 8, 16, 31, 214, 205, 22], ["-", 0, 210, 8, 57, 64, 1, 0, 11, 31, 22], ["-", 8, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 31, 23, 0, 16, 12, 213, 63, 214, 0, 131], ["+", 31, 23, 0, 16, 12, 213, 63, 214, 141, 22], ["-", 0, 11, 12, 16, 31, 23, 0, 16, 31, 22], ["-", 0, 11, 12, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["+", 12, 213, 3, 4, 0, 28, 0, 218, 0, 221], ["-", 8, 57, 64, 1, 0, 11, 12, 16, 17, 109], ["-", 8, 57, 64, 1, 0, 11, 12, 16, 12, 22], ["-", 75, 196, 0, 210, 8, 57, 64, 1, 0, 35], ["-", 0, 57, 75, 196, 0, 1, 0, 213, 63, 22], ["-", 75, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 25], ["-", 0, 263, 8, 196, 0, 57, 75, 196, 0, 46]]
8
835
6
using System; using System.IO; using System.Linq; using System.Collections; using System.Collections.Generic; using System.Text; using System.Numerics; using System.Threading.Tasks; using System.Text.RegularExpressions; using Debug = System.Diagnostics.Debug; using System.Runtime.CompilerServices; using static System.Math; using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions; using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute; static class P { static void Main() { int n = int.Parse(Console.ReadLine()); var a = Console.ReadLine().Split().Select(int.Parse).ToArray(); //仕切りを最初は全ての0の後に入れておく //仕切りを取り払う(=一つ前のセクションとマージする)か、仕切りを入れる //とりあえず、全ての0セクション内に仕切りを入れる場合を考える //全てのセクションについてある数を含んでいる場合は //今そこで仕切れるよ っていう情報 // dp[目標とする美しさ][現在の目標(0:0 or 1:目標)] // 0が来た時は遅延評価で良い?最後に来た0の時間をメモしておいて、どの0を採用するかで掛ける //[目標までのXOR]仕切りを入れる/入れない int accumXor = 0; int zeroCount = 0; ModInt[] count = new ModInt[1 << 20]; //このまま最後まで伸びるとした場合のそれ ModInt[] eachRes = new ModInt[1 << 20]; ModInt[] dp = new ModInt[1 << 20]; int[] lastZero = new int[1 << 20]; int[] sameRegionCount = new int[1 << 20]; //一個前からの経過 + 一個前をabortして今そこで区切る for (int i = 0; i < a.Length; i++) { accumXor ^= a[i]; if (accumXor == 0) { zeroCount++; continue; } //前回からの区切りの数 var possibleSeparateCount = lastZero[accumXor] - zeroCount; lastZero[accumXor] = zeroCount; dp[accumXor] += eachRes[accumXor] * possibleSeparateCount + new ModInt(1); eachRes[accumXor] += dp[accumXor]; } if (accumXor == 0) { ModInt res = 0; // 0セクションのみを加算 var zeroSectionOnly = Power(2, zeroCount - 1); res += zeroSectionOnly; for (int i = 1; i < dp.Length; i++) res += eachRes[i]; Console.WriteLine(res); } else { Console.WriteLine(dp[accumXor]); } } static ModInt Power(ModInt n, long m) { ModInt pow = n; ModInt res = 1; while (m > 0) { if ((m & 1) == 1) res *= pow; pow *= pow; m >>= 1; } return res; } } struct ModInt { const int MOD = 1000000007; long Data; [MethodImpl(MethodImplOptions.AggressiveInlining)] public ModInt(long data) { if ((Data = data % MOD) < 0) Data += MOD; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static implicit operator long(ModInt modInt) => modInt.Data; [MethodImpl(MethodImplOptions.AggressiveInlining)] public static implicit operator ModInt(long val) => new ModInt(val); [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ModInt operator +(ModInt a, ModInt b) { long res = a.Data + b.Data; return new ModInt() { Data = res >= MOD ? res - MOD : res }; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ModInt operator +(ModInt a, long b) => a.Data + b; [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ModInt operator -(ModInt a, ModInt b) { long res = a.Data - b.Data; return new ModInt() { Data = res < 0 ? res + MOD : res }; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ModInt operator -(ModInt a, long b) => a.Data - b; [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ModInt operator *(ModInt a, ModInt b) => new ModInt() { Data = a.Data * b.Data % MOD }; [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ModInt operator /(ModInt a, ModInt b) => a.Data * GetInverse(b); [MethodImpl(MethodImplOptions.AggressiveInlining)] public override string ToString() => Data.ToString(); [MethodImpl(MethodImplOptions.AggressiveInlining)] static long GetInverse(long a) { long div; long p = MOD; long x1 = 1, y1 = 0, x2 = 0, y2 = 1; while (true) { if (p == 1) return x2; div = a / p; x1 -= x2 * div; y1 -= y2 * div; a %= p; if (a == 1) return x1; div = p / a; x2 -= x1 * div; y2 -= y1 * div; p %= a; } } }
using System; using System.IO; using System.Linq; using System.Collections; using System.Collections.Generic; using System.Text; using System.Numerics; using System.Threading.Tasks; using System.Text.RegularExpressions; using Debug = System.Diagnostics.Debug; using System.Runtime.CompilerServices; using static System.Math; using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions; using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute; static class P { static void Main() { int n = int.Parse(Console.ReadLine()); var a = Console.ReadLine().Split().Select(int.Parse).ToArray(); //仕切りを最初は全ての0の後に入れておく //仕切りを取り払う(=一つ前のセクションとマージする)か、仕切りを入れる //とりあえず、全ての0セクション内に仕切りを入れる場合を考える //全てのセクションについてある数を含んでいる場合は //今そこで仕切れるよ っていう情報 // dp[目標とする美しさ][現在の目標(0:0 or 1:目標)] // 0が来た時は遅延評価で良い?最後に来た0の時間をメモしておいて、どの0を採用するかで掛ける //[目標までのXOR]仕切りを入れる/入れない int accumXor = 0; int zeroCount = 0; //このまま最後まで伸びるとした場合のそれ ModInt[] eachRes = new ModInt[1 << 20]; ModInt[] dp = Enumerable.Repeat(new ModInt(1), 1 << 20).ToArray(); int[] lastZero = new int[1 << 20]; int[] sameRegionCount = new int[1 << 20]; //一個前からの経過 + 一個前をabortして今そこで区切る for (int i = 0; i < a.Length; i++) { accumXor ^= a[i]; if (accumXor == 0) { zeroCount++; continue; } //前回からの区切りの数 var possibleSeparateCount = zeroCount - lastZero[accumXor]; lastZero[accumXor] = zeroCount; dp[accumXor] += eachRes[accumXor] * possibleSeparateCount; eachRes[accumXor] += dp[accumXor]; } if (accumXor == 0) { ModInt res = 0; // 0セクションのみを加算 var zeroSectionOnly = Power(2, zeroCount - 1); res += zeroSectionOnly; for (int i = 1; i < dp.Length; i++) res += eachRes[i]; Console.WriteLine(res); } else { Console.WriteLine(dp[accumXor]); } } static ModInt Power(ModInt n, long m) { ModInt pow = n; ModInt res = 1; while (m > 0) { if ((m & 1) == 1) res *= pow; pow *= pow; m >>= 1; } return res; } } struct ModInt { const int MOD = 1000000007; long Data; [MethodImpl(MethodImplOptions.AggressiveInlining)] public ModInt(long data) { if ((Data = data % MOD) < 0) Data += MOD; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static implicit operator long(ModInt modInt) => modInt.Data; [MethodImpl(MethodImplOptions.AggressiveInlining)] public static implicit operator ModInt(long val) => new ModInt(val); [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ModInt operator +(ModInt a, ModInt b) { long res = a.Data + b.Data; return new ModInt() { Data = res >= MOD ? res - MOD : res }; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ModInt operator +(ModInt a, long b) => a.Data + b; [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ModInt operator -(ModInt a, ModInt b) { long res = a.Data - b.Data; return new ModInt() { Data = res < 0 ? res + MOD : res }; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ModInt operator -(ModInt a, long b) => a.Data - b; [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ModInt operator *(ModInt a, ModInt b) => new ModInt() { Data = a.Data * b.Data % MOD }; [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ModInt operator /(ModInt a, ModInt b) => a.Data * GetInverse(b); [MethodImpl(MethodImplOptions.AggressiveInlining)] public override string ToString() => Data.ToString(); [MethodImpl(MethodImplOptions.AggressiveInlining)] static long GetInverse(long a) { long div; long p = MOD; long x1 = 1, y1 = 0, x2 = 0, y2 = 1; while (true) { if (p == 1) return x2; div = a / p; x1 -= x2 * div; y1 -= y2 * div; a %= p; if (a == 1) return x1; div = p / a; x2 -= x1 * div; y2 -= y1 * div; p %= a; } } }
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 198, 0, 200, 0, 212, 0, 227, 0, 228], ["-", 0, 200, 0, 212, 0, 227, 39, 224, 39, 22], ["-", 0, 212, 0, 227, 39, 224, 225, 226, 0, 70], ["-", 0, 227, 39, 224, 225, 226, 0, 16, 31, 203], ["-", 0, 227, 39, 224, 225, 226, 0, 16, 17, 151], ["-", 0, 227, 39, 224, 225, 226, 0, 16, 12, 203], ["-", 0, 212, 0, 227, 39, 224, 225, 226, 0, 73], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 22], ["-", 0, 197, 0, 198, 39, 224, 225, 226, 0, 70], ["-", 0, 197, 0, 198, 39, 224, 225, 226, 0, 73], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 205, 22], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 230, 3, 4, 0, 24], ["+", 0, 28, 0, 230, 3, 4, 0, 28, 0, 203], ["+", 3, 4, 0, 28, 0, 230, 3, 4, 0, 25], ["+", 0, 213, 63, 214, 205, 213, 3, 4, 0, 21], ["+", 0, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 33], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 33], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["-", 0, 1, 0, 11, 12, 16, 12, 230, 0, 228], ["-", 0, 1, 0, 11, 12, 16, 12, 230, 39, 22], ["-", 0, 11, 12, 16, 12, 230, 3, 4, 0, 24], ["-", 12, 16, 12, 230, 3, 4, 0, 28, 0, 203], ["-", 0, 11, 12, 16, 12, 230, 3, 4, 0, 25]]
8
889
38
using System; using System.Collections.Generic; using System.Linq; namespace agc033_a { class MainClass { public static void Main(string[] args) { var ins = new Problem(); ins.solve(); } } class Problem { public void solve() { Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray(); int[] v = read(); int H = v[0]; int W = v[1]; int[,] dist = new int[H, W]; var q = new Queue<Tuple<int, int>>(); for (int i = 0; i < H; i++) { var S = Console.ReadLine().Trim(); for (int j = 0; j < W; j++) { dist[i, j] = -1; if (S[j] == '#') { q.Enqueue(Tuple.Create(j, i)); } } } var answer = BFS(q, dist, H, W); Console.WriteLine(answer); } public int BFS(Queue<Tuple<int, int>> q, int[,] dist, int h, int w) { var dx = new int[] { -1, 1, 0, 0 }; var dy = new int[] { 0, 0, -1, 1 }; while (q.Count != 0) { var item = q.Dequeue(); int x = item.Item1; int y = item.Item2; for (int i = 0; i < 4; i++) { int px = x + dx[i]; int py = y + dy[i]; if (!(0 <= py && py < h && 0 <= px && px < w)) { continue; } if (dist[py, px] == -1) { q.Enqueue(Tuple.Create(px, py)); dist[py, px] = dist[y, x] + 1; } } } var ans = 0; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { ans = Math.Max(ans, dist[i, j]); } } return ans; } } }
using System; using System.Collections.Generic; using System.Linq; namespace agc033_a { class MainClass { public static void Main(string[] args) { var ins = new Problem(); ins.solve(); } } class Problem { public void solve() { Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray(); int[] v = read(); int H = v[0]; int W = v[1]; int[,] dist = new int[H, W]; var q = new Queue<Tuple<int, int>>(); for (int i = 0; i < H; i++) { var S = Console.ReadLine().Trim(); for (int j = 0; j < W; j++) { dist[i, j] = -1; if (S[j] == '#') { q.Enqueue(Tuple.Create(j, i)); dist[i, j] = 0; } } } var answer = BFS(q, dist, H, W); Console.WriteLine(answer); } public int BFS(Queue<Tuple<int, int>> q, int[,] dist, int h, int w) { var dx = new int[] { -1, 1, 0, 0 }; var dy = new int[] { 0, 0, -1, 1 }; while (q.Count != 0) { var item = q.Dequeue(); int x = item.Item1; int y = item.Item2; for (int i = 0; i < 4; i++) { int px = x + dx[i]; int py = y + dy[i]; if (!(0 <= py && py < h && 0 <= px && px < w)) { continue; } if (dist[py, px] == -1) { q.Enqueue(Tuple.Create(px, py)); dist[py, px] = dist[y, x] + 1; } } } var ans = 0; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { ans = Math.Max(ans, dist[i, j]); } } return ans; } } }
[["+", 64, 196, 0, 1, 0, 11, 31, 204, 205, 22], ["+", 0, 1, 0, 11, 31, 204, 206, 207, 0, 70], ["+", 0, 11, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 1, 0, 11, 31, 204, 206, 207, 0, 21], ["+", 0, 1, 0, 11, 31, 204, 206, 207, 0, 73], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35]]
8
509
9
using System; using System.Collections.Generic; using System.Linq; using System.IO; using SB = System.Text.StringBuilder; // using System.Threading.Tasks; // using System.Text.RegularExpressions; // using System.Globalization; // using System.Diagnostics; using static System.Console; using System.Numerics; using static System.Math; using pair = Pair<int, int>; class Program { static void Main() { SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false }); new Program().solve(); Out.Flush(); } readonly Scanner cin = new Scanner(); readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑ readonly int mod = 1000000007; readonly int dom = 998244353; bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; } bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } return false; } void solve() { int H = cin.nextint; int W = cin.nextint; var A = new string[H]; var L = new List<int>(); for (int i = 0; i < H; i++) { A[i] = ReadLine(); for (int j = 0; j < W; j++) { if (A[i][j] == '#') { L.Add(i * W + j); } } } int[] dist; var far = new TwoD_BFS().BFS(H, W, L[0], out dist, L); WriteLine(dist[far]); } } class TwoD_BFS { readonly int[] dy = { 0, 1, 0, -1 }; //→↓←↑ readonly int[] dx = { 1, 0, -1, 0 }; int H, W; int idx(int y, int x) => y * W + x; bool ok(int y, int x) => 0 <= y && y < H && 0 <= x && x < W; public int BFS(int h, int w, int s, out int[] dist, IEnumerable<int> multi = null) { H = h; W = w; dist = new int[H * W]; for (int i = 0; i < dist.Length; i++) dist[i] = -1; var Q = new Queue<int>(); if (multi == null) { Q.Enqueue(s); dist[s] = 0; } else foreach (var v in multi) { Q.Enqueue(v); dist[v] = 0; } int id = s; while (Q.Count > 0) { var u = Q.Dequeue(); int ty = u / H; int tx = u % H; int before = idx(ty, tx); for (int r = 0; r < dx.Length; r++) { int y = ty + dy[r]; int x = tx + dx[r]; int now = idx(y, x); if (!ok(y, x) || dist[now] >= 0) continue; dist[now] = dist[before] + 1; id = now; Q.Enqueue(now); } } return id; } } static class Ex { public static void join<T>(this IEnumerable<T> values, string sep = " ") => WriteLine(string.Join(sep, values)); public static string concat<T>(this IEnumerable<T> values) => string.Concat(values); public static string reverse(this string s) { var t = s.ToCharArray(); Array.Reverse(t); return t.concat(); } public static int lower_bound<T>(this IList<T> arr, T val) where T : IComparable<T> { int low = 0, high = arr.Count; int mid; while (low < high) { mid = ((high - low) >> 1) + low; if (arr[mid].CompareTo(val) < 0) low = mid + 1; else high = mid; } return low; } public static int upper_bound<T>(this IList<T> arr, T val) where T : IComparable<T> { int low = 0, high = arr.Count; int mid; while (low < high) { mid = ((high - low) >> 1) + low; if (arr[mid].CompareTo(val) <= 0) low = mid + 1; else high = mid; } return low; } } class Pair<T, U> : IComparable<Pair<T, U>> where T : IComparable<T> where U : IComparable<U> { public T f; public U s; public Pair(T f, U s) { this.f = f; this.s = s; } public int CompareTo(Pair<T, U> a) => f.CompareTo(a.f) != 0 ? f.CompareTo(a.f) : s.CompareTo(a.s); public override string ToString() => $"{f} {s}"; } class Scanner { string[] s; int i; readonly char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string[] scan => ReadLine().Split(); public int[] scanint => Array.ConvertAll(scan, int.Parse); public long[] scanlong => Array.ConvertAll(scan, long.Parse); public double[] scandouble => Array.ConvertAll(scan, double.Parse); public string next { get { if (i < s.Length) return s[i++]; string st = ReadLine(); while (st == "") st = ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); i = 0; return next; } } public int nextint => int.Parse(next); public long nextlong => long.Parse(next); public double nextdouble => double.Parse(next); }
using System; using System.Collections.Generic; using System.Linq; using System.IO; using SB = System.Text.StringBuilder; // using System.Threading.Tasks; // using System.Text.RegularExpressions; // using System.Globalization; // using System.Diagnostics; using static System.Console; using System.Numerics; using static System.Math; using pair = Pair<int, int>; class Program { static void Main() { SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false }); new Program().solve(); Out.Flush(); } readonly Scanner cin = new Scanner(); readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑ readonly int mod = 1000000007; readonly int dom = 998244353; bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; } bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } return false; } void solve() { int H = cin.nextint; int W = cin.nextint; var L = new List<int>(); for (int i = 0; i < H; i++) { var A = ReadLine(); for (int j = 0; j < W; j++) { if (A[j] == '#') { L.Add(i * W + j); } } } int[] dist; var far = new TwoD_BFS().BFS(H, W, L[0], out dist, L); WriteLine(dist[far]); } } class TwoD_BFS { readonly int[] dy = { 0, 1, 0, -1 }; //→↓←↑ readonly int[] dx = { 1, 0, -1, 0 }; int H, W; int idx(int y, int x) => y * W + x; bool ok(int y, int x) => 0 <= y && y < H && 0 <= x && x < W; public int BFS(int h, int w, int s, out int[] dist, IEnumerable<int> multi = null) { H = h; W = w; dist = new int[H * W]; for (int i = 0; i < dist.Length; i++) dist[i] = -1; var Q = new Queue<int>(); if (multi == null) { Q.Enqueue(s); dist[s] = 0; } else foreach (var v in multi) { Q.Enqueue(v); dist[v] = 0; } int id = s; while (Q.Count > 0) { var u = Q.Dequeue(); int ty = u / W; int tx = u % W; int before = dist[u]; for (int r = 0; r < dx.Length; r++) { int y = ty + dy[r]; int x = tx + dx[r]; int now = idx(y, x); if (!ok(y, x) || dist[now] >= 0) continue; dist[now] = before + 1; id = now; Q.Enqueue(now); } } return id; } } static class Ex { public static void join<T>(this IEnumerable<T> values, string sep = " ") => WriteLine(string.Join(sep, values)); public static string concat<T>(this IEnumerable<T> values) => string.Concat(values); public static string reverse(this string s) { var t = s.ToCharArray(); Array.Reverse(t); return t.concat(); } public static int lower_bound<T>(this IList<T> arr, T val) where T : IComparable<T> { int low = 0, high = arr.Count; int mid; while (low < high) { mid = ((high - low) >> 1) + low; if (arr[mid].CompareTo(val) < 0) low = mid + 1; else high = mid; } return low; } public static int upper_bound<T>(this IList<T> arr, T val) where T : IComparable<T> { int low = 0, high = arr.Count; int mid; while (low < high) { mid = ((high - low) >> 1) + low; if (arr[mid].CompareTo(val) <= 0) low = mid + 1; else high = mid; } return low; } } class Pair<T, U> : IComparable<Pair<T, U>> where T : IComparable<T> where U : IComparable<U> { public T f; public U s; public Pair(T f, U s) { this.f = f; this.s = s; } public int CompareTo(Pair<T, U> a) => f.CompareTo(a.f) != 0 ? f.CompareTo(a.f) : s.CompareTo(a.s); public override string ToString() => $"{f} {s}"; } class Scanner { string[] s; int i; readonly char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string[] scan => ReadLine().Split(); public int[] scanint => Array.ConvertAll(scan, int.Parse); public long[] scanlong => Array.ConvertAll(scan, long.Parse); public double[] scandouble => Array.ConvertAll(scan, double.Parse); public string next { get { if (i < s.Length) return s[i++]; string st = ReadLine(); while (st == "") st = ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); i = 0; return next; } } public int nextint => int.Parse(next); public long nextlong => long.Parse(next); public double nextdouble => double.Parse(next); }
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 198, 0, 200, 0, 212, 0, 227, 0, 228], ["-", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["-", 0, 212, 0, 227, 39, 224, 225, 226, 0, 70], ["-", 0, 212, 0, 227, 39, 224, 225, 226, 0, 22], ["-", 0, 212, 0, 227, 39, 224, 225, 226, 0, 73], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 0, 1, 0, 11, 31, 204, 206, 207, 0, 70], ["-", 0, 11, 31, 204, 206, 207, 0, 28, 0, 22], ["-", 0, 1, 0, 11, 31, 204, 206, 207, 0, 73], ["-", 31, 204, 205, 204, 206, 207, 0, 28, 0, 22], ["-", 15, 16, 31, 204, 205, 204, 206, 207, 0, 73], ["-", 0, 57, 15, 16, 31, 204, 206, 207, 0, 70], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["-", 0, 198, 0, 200, 0, 212, 0, 213, 63, 22], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["-", 0, 212, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 21], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["+", 0, 198, 0, 200, 0, 212, 0, 204, 205, 22], ["+", 0, 200, 0, 212, 0, 204, 206, 207, 0, 70], ["+", 0, 212, 0, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 200, 0, 212, 0, 204, 206, 207, 0, 73], ["-", 0, 1, 0, 11, 12, 16, 31, 204, 205, 22], ["-", 0, 11, 12, 16, 31, 204, 206, 207, 0, 70], ["-", 0, 11, 12, 16, 31, 204, 206, 207, 0, 73]]
8
1,343
33
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AGC033A7 { class Program { static int black = 0; static int[] dp; static int max; public struct pos { public int x; public int y; } public static List<pos> C_list = new List<pos>(); static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); //スペース区切りの入力を受け取る int h = int.Parse(input[0]); //1文字目を数値化してhに代入する int w = int.Parse(input[1]); //2文字目を数値化してwに代入する dp = new int[h * w]; max = h + w - 1; //答えの最大値+1 最大の答えは(h-1)+(w-1) for (int i = 0; i < h; i++) { var tmp = Console.ReadLine(); for (int j = 0; j < w; j++) { var tmp2 = tmp.Substring(j, 1); if (tmp2 == "#") { dp[i * h + j] = black; pos p = new pos(); p.x = i; p.y = j; C_list.Add(p); //黒コマの場所をリストにする } else { dp[i * h + j] = max; } } } /*端っこの一つだけが黒コマの場合 in06.txtをACできた if (C_list.Count == 1 && (C_list[0].x == 0 && (C_list[0].y == 0 || C_list[0].y == w - 1))) { Console.WriteLine(max - 1); } else if (C_list.Count == 1 && C_list[0].x == h - 1 && (C_list[0].y == 0 || C_list[0].y == w - 1)) { Console.WriteLine(max - 1); } else { */ while (C_list.Count > 0) { List<pos> C2_list = new List<pos>(C_list); C_list.Clear(); foreach (var item in C2_list) { seek(item.x, item.y, h, w); //周囲をチェック } C2_list.Clear(); /* for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { Console.Write(dp[i*h+j] + " "); } Console.WriteLine(); } Console.WriteLine(); */ } Console.WriteLine(dp.Max()); //} } static void seek(int i, int j, int h, int w) { pos p = new pos(); if (i > 0 && dp[(i - 1) * h + j] == max) { dp[(i - 1) * h + j] = dp[i * h + j] + 1; p.x = i - 1; p.y = j; C_list.Add(p); } if (i < h - 1 && dp[(i + 1) * h + j] == max) { dp[(i + 1) * h + j] = dp[i * h + j] + 1; p.x = i + 1; p.y = j; C_list.Add(p); } if (j > 0 && dp[i * h + j - 1] == max) { dp[i * h + j - 1] = dp[i * h + j] + 1; p.x = i; p.y = j - 1; C_list.Add(p); } if (j < w - 1 && dp[i * h + j + 1] == max) { dp[i * h + j + 1] = dp[i * h + j] + 1; p.x = i; p.y = j + 1; C_list.Add(p); } } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AGC033A8OLD { class Program { static int black = 0; static int[] dp; static int max; // static int ans = 0; public struct pos { public int x; public int y; } public static List<pos> C_list = new List<pos>(); static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); int h = int.Parse(input[0]); int w = int.Parse(input[1]); dp = new int[h * w]; max = h + w - 1; //答えの最大値+1 最大の答えは(h-1)+(w-1) for (int i = 0; i < h; i++) { var tmp = Console.ReadLine(); for (int j = 0; j < w; j++) { var tmp2 = tmp.Substring(j, 1); if (tmp2 == "#") { dp[i * w + j] = black; pos p = new pos(); p.x = i; p.y = j; C_list.Add(p); //黒コマの場所をリストにする } else { dp[i * w + j] = max; } } } while (C_list.Count > 0) { List<pos> C2_list = new List<pos>(C_list); C_list.Clear(); foreach (var item in C2_list) { seek(item.x, item.y, h, w); //周囲をチェック } C2_list.Clear(); /* for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { Console.Write(dp[i * h + j] + " "); } Console.WriteLine(); } Console.WriteLine(); */ } Console.WriteLine(dp.Max()); } static void seek(int i, int j, int h, int w) { pos p = new pos(); if (i > 0 && dp[(i - 1) * w + j] == max) { dp[(i - 1) * w + j] = dp[i * w + j] + 1; p.x = i - 1; p.y = j; // ans = Math.Max(ans, dp[(i - 1) * w + j]); C_list.Add(p); } if (i < h - 1 && dp[(i + 1) * w + j] == max) { dp[(i + 1) * w + j] = dp[i * w + j] + 1; p.x = i + 1; p.y = j; // ans = Math.Max(ans, dp[(i + 1) * w + j]); C_list.Add(p); } if (j > 0 && dp[i * w + j - 1] == max) { dp[i * w + j - 1] = dp[i * w + j] + 1; p.x = i; p.y = j - 1; // ans = Math.Max(ans, dp[i * w + j - 1]); C_list.Add(p); } if (j < w - 1 && dp[i * w + j + 1] == max) { dp[i * w + j + 1] = dp[i * w + j] + 1; p.x = i; p.y = j + 1; // ans = Math.Max(ans, dp[i * w + j + 1]); C_list.Add(p); } } } }
[["-", 36, 36, 36, 36, 0, 208, 0, 209, 141, 22], ["+", 36, 36, 36, 36, 0, 208, 0, 209, 141, 22], ["-", 206, 207, 0, 28, 0, 16, 31, 16, 12, 22], ["+", 206, 207, 0, 28, 0, 16, 31, 16, 12, 22], ["-", 0, 28, 0, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 28, 0, 16, 31, 16, 31, 16, 12, 22]]
8
643
30
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AGC033A8OLD { class Program { static int black = 0; static int[] dp; static int max; static int ans = 0; public struct pos { public int x; public int y; } public static List<pos> C_list = new List<pos>(); static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); int h = int.Parse(input[0]); int w = int.Parse(input[1]); dp = new int[h * w]; max = h + w - 1; //答えの最大値+1 最大の答えは(h-1)+(w-1) for (int i = 0; i < h; i++) { var tmp = Console.ReadLine(); for (int j = 0; j < w; j++) { var tmp2 = tmp.Substring(j, 1); if (tmp2 == "#") { dp[i * h + j] = black; pos p = new pos(); p.x = i; p.y = j; C_list.Add(p); //黒コマの場所をリストにする } else { dp[i * h + j] = max; } } } while (C_list.Count > 0) { List<pos> C2_list = new List<pos>(C_list); C_list.Clear(); foreach (var item in C2_list) { seek(item.x, item.y, h, w); //周囲をチェック } C2_list.Clear(); /* for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { Console.Write(dp[i * h + j] + " "); } Console.WriteLine(); } Console.WriteLine(); */ } Console.WriteLine(ans); } static void seek(int i, int j, int h, int w) { pos p = new pos(); if (i > 0 && dp[(i - 1) * h + j] == max) { dp[(i - 1) * h + j] = dp[i * h + j] + 1; p.x = i - 1; p.y = j; ans = Math.Max(ans, dp[(i - 1) * h + j]); C_list.Add(p); } if (i < h - 1 && dp[(i + 1) * h + j] == max) { dp[(i + 1) * h + j] = dp[i * h + j] + 1; p.x = i + 1; p.y = j; ans = Math.Max(ans, dp[(i + 1) * h + j]); C_list.Add(p); } if (j > 0 && dp[i * h + j - 1] == max) { dp[i * h + j - 1] = dp[i * h + j] + 1; p.x = i; p.y = j - 1; ans = Math.Max(ans, dp[i * h + j - 1]); C_list.Add(p); } if (j < w - 1 && dp[i * h + j + 1] == max) { dp[i * h + j + 1] = dp[i * h + j] + 1; p.x = i; p.y = j + 1; ans = Math.Max(ans, dp[i * h + j + 1]); C_list.Add(p); } } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AGC033A8OLD { class Program { static int black = 0; static int[] dp; static int max; static int ans = 0; public struct pos { public int x; public int y; } public static List<pos> C_list = new List<pos>(); static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); int h = int.Parse(input[0]); int w = int.Parse(input[1]); dp = new int[h * w]; max = h + w - 1; //答えの最大値+1 最大の答えは(h-1)+(w-1) for (int i = 0; i < h; i++) { var tmp = Console.ReadLine(); for (int j = 0; j < w; j++) { var tmp2 = tmp.Substring(j, 1); if (tmp2 == "#") { dp[i * w + j] = black; pos p = new pos(); p.x = i; p.y = j; C_list.Add(p); //黒コマの場所をリストにする } else { dp[i * w + j] = max; } } } while (C_list.Count > 0) { List<pos> C2_list = new List<pos>(C_list); C_list.Clear(); foreach (var item in C2_list) { seek(item.x, item.y, h, w); //周囲をチェック } C2_list.Clear(); /* for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { Console.Write(dp[i * h + j] + " "); } Console.WriteLine(); } Console.WriteLine(); */ } Console.WriteLine(ans); } static void seek(int i, int j, int h, int w) { pos p = new pos(); if (i > 0 && dp[(i - 1) * w + j] == max) { dp[(i - 1) * w + j] = dp[i * w + j] + 1; p.x = i - 1; p.y = j; ans = Math.Max(ans, dp[(i - 1) * w + j]); C_list.Add(p); } if (i < h - 1 && dp[(i + 1) * w + j] == max) { dp[(i + 1) * w + j] = dp[i * w + j] + 1; p.x = i + 1; p.y = j; ans = Math.Max(ans, dp[(i + 1) * w + j]); C_list.Add(p); } if (j > 0 && dp[i * w + j - 1] == max) { dp[i * w + j - 1] = dp[i * w + j] + 1; p.x = i; p.y = j - 1; ans = Math.Max(ans, dp[i * w + j - 1]); C_list.Add(p); } if (j < w - 1 && dp[i * w + j + 1] == max) { dp[i * w + j + 1] = dp[i * w + j] + 1; p.x = i; p.y = j + 1; ans = Math.Max(ans, dp[i * w + j + 1]); C_list.Add(p); } } } }
[["-", 206, 207, 0, 28, 0, 16, 31, 16, 12, 22], ["+", 206, 207, 0, 28, 0, 16, 31, 16, 12, 22], ["-", 0, 28, 0, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 28, 0, 16, 31, 16, 31, 16, 12, 22]]
8
724
36
using System; using System.Collections.Generic; using System.Linq; public static partial class Program { public static void Main() { var hw = CRL().ArrayInts(); var h = hw[0]; var w = hw[1]; var map = new int[h, w]; for (int i = 0; i < h; i++) { var str = CRL(); for (int j = 0; j < w; j++) { if (str[j] == '#') { map[i, j] = 1; } } } var queue = new Queue<KeyValuePair<int, int>>(); //最初の一回目 for (int row = 0; row < h; row++) { for (int col = 0; col < w; col++) { if (map[row, col] == 1) { queue.Enqueue(new KeyValuePair<int, int>(row, col)); } } } var cnt = 0; while (true) { var bufq = new Queue<KeyValuePair<int, int>>(); while (queue.Count != 0) { var q = queue.Dequeue(); // 4方向 for (int i = 0; i < 4; i++) { var y = q.Key + dy[i]; var x = q.Value + dx[i]; if (x < 0 || x >= h || y < 0 || y >= w) { continue; } if (map[y, x] == 0) { map[y, x] = 1; bufq.Enqueue(new KeyValuePair<int, int>(y, x)); } } } queue = bufq; if (queue.Count == 0) { CWL(cnt); return; } cnt++; } } } public static partial class Program { //テンプレここから public static int ToInt(this string str) => int.Parse(str); public static long ToLong(this string str) => long.Parse(str); public static long[] ToLong(this IEnumerable<string> strs) => strs.Select(x => x.ToLong()).ToArray(); public static int[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray(); public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToLong(); public static int[] ArrayInts(this string str, char opr = ' ') => str.Split(opr).ToInt(); public static string CRL() => Console.ReadLine(); public static void CWL(object obj) => Console.WriteLine(obj); public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b)); public static long Sign(this long i) => Math.Sign(i); public static bool IsEven(this long i) => i % 2 == 0; public static bool IsEven(this int i) => i % 2 == 0; public static int[] dx = new[] { 0, -1, 0, 1 }; public static int[] dy = new[] { -1, 0, 1, 0 }; public static long mod = 1000000007; public static string alphabet = "abcdefghijklmnopqrstuvwxyz"; public static long ToLong(this char c) => c.ToString().ToInt(); public static long[] Sort(this long[] array) => array.OrderBy(x => x).ToArray(); public static int[] Sort(this int[] array) => array.OrderBy(x => x).ToArray(); public static long[] DSort(this long[] array) => array.OrderByDescending(x => x).ToArray(); public static int[] DSort(this int[] array) => array.OrderByDescending(x => x).ToArray(); public static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b); public static long LCM(long a, long b) => a * b / GCD(a, b); //テンプレここまで }
using System; using System.Collections.Generic; using System.Linq; public static partial class Program { public static void Main() { var hw = CRL().ArrayInts(); var h = hw[0]; var w = hw[1]; var map = new int[h, w]; for (int i = 0; i < h; i++) { var str = CRL(); for (int j = 0; j < w; j++) { if (str[j] == '#') { map[i, j] = 1; } } } var queue = new Queue<KeyValuePair<int, int>>(); //最初の一回目 for (int row = 0; row < h; row++) { for (int col = 0; col < w; col++) { if (map[row, col] == 1) { queue.Enqueue(new KeyValuePair<int, int>(row, col)); } } } var cnt = 0; while (true) { var bufq = new Queue<KeyValuePair<int, int>>(); while (queue.Count != 0) { var q = queue.Dequeue(); // 4方向 for (int i = 0; i < 4; i++) { var y = q.Key + dy[i]; var x = q.Value + dx[i]; if (y < 0 || y >= h || x < 0 || x >= w) { continue; } if (map[y, x] == 0) { map[y, x] = 1; bufq.Enqueue(new KeyValuePair<int, int>(y, x)); } } } queue = bufq; if (queue.Count == 0) { CWL(cnt); return; } cnt++; } } } public static partial class Program { //テンプレここから public static int ToInt(this string str) => int.Parse(str); public static long ToLong(this string str) => long.Parse(str); public static long[] ToLong(this IEnumerable<string> strs) => strs.Select(x => x.ToLong()).ToArray(); public static int[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray(); public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToLong(); public static int[] ArrayInts(this string str, char opr = ' ') => str.Split(opr).ToInt(); public static string CRL() => Console.ReadLine(); public static void CWL(object obj) => Console.WriteLine(obj); public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b)); public static long Sign(this long i) => Math.Sign(i); public static bool IsEven(this long i) => i % 2 == 0; public static bool IsEven(this int i) => i % 2 == 0; public static int[] dx = new[] { 0, -1, 0, 1 }; public static int[] dy = new[] { -1, 0, 1, 0 }; public static long mod = 1000000007; public static string alphabet = "abcdefghijklmnopqrstuvwxyz"; public static long ToLong(this char c) => c.ToString().ToInt(); public static long[] Sort(this long[] array) => array.OrderBy(x => x).ToArray(); public static int[] Sort(this int[] array) => array.OrderBy(x => x).ToArray(); public static long[] DSort(this long[] array) => array.OrderByDescending(x => x).ToArray(); public static int[] DSort(this int[] array) => array.OrderByDescending(x => x).ToArray(); public static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b); public static long LCM(long a, long b) => a * b / GCD(a, b); //テンプレここまで }
[["-", 15, 16, 31, 16, 31, 16, 31, 16, 31, 22], ["+", 15, 16, 31, 16, 31, 16, 31, 16, 31, 22], ["-", 15, 16, 31, 16, 31, 16, 12, 16, 31, 22], ["+", 15, 16, 31, 16, 31, 16, 12, 16, 31, 22], ["-", 0, 57, 15, 16, 31, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 16, 31, 16, 12, 16, 31, 22], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22]]
8
898
8
using System; using System.Linq; using System.Collections.Generic; class Mondai { static void Main() { var hw = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray(); ; var H = hw[0]; var W = hw[1]; var isBlack = new bool[H, W]; var que = new Queue<int[]>(); for (int i = 0; i < H; ++i) { var A = Console.ReadLine().ToCharArray(); for (int j = 0; j < W; ++j) { if (A[j] == '#') { isBlack[i, j] = true; que.Enqueue(new int[3] { i, j, 0 }); } else isBlack[i, j] = false; } } var ans = 0; var X = new int[] { -1, 0, 1, 0 }; var Y = new int[] { 0, -1, 0, 1 }; while (que.Any()) { var info = que.Dequeue(); var y = info[0]; var x = info[1]; var time = info[2] + 1; for (int i = 0; i < 4; ++i) { var nextX = x + X[i]; var nextY = y + Y[i]; if (nextX < 0 || W <= nextX || nextY < 0 || H <= nextY || isBlack[nextX, nextY]) continue; isBlack[nextX, nextY] = true; que.Enqueue(new int[3] { nextY, nextX, time }); if (ans < time) ans = time; } } Console.WriteLine(ans); } }
using System; using System.Linq; using System.Collections.Generic; class Mondai { static void Main() { var hw = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray(); ; var H = hw[0]; var W = hw[1]; var isBlack = new bool[H, W]; var que = new Queue<int[]>(); for (int i = 0; i < H; ++i) { var A = Console.ReadLine().ToCharArray(); for (int j = 0; j < W; ++j) { if (A[j] == '#') { isBlack[i, j] = true; que.Enqueue(new int[3] { i, j, 0 }); } else isBlack[i, j] = false; } } var ans = 0; var X = new int[] { -1, 0, 1, 0 }; var Y = new int[] { 0, -1, 0, 1 }; while (que.Any()) { var info = que.Dequeue(); var y = info[0]; var x = info[1]; var time = info[2] + 1; for (int i = 0; i < 4; ++i) { var nextX = x + X[i]; var nextY = y + Y[i]; if (nextX < 0 || W <= nextX || nextY < 0 || H <= nextY || isBlack[nextY, nextX]) continue; isBlack[nextY, nextX] = true; que.Enqueue(new int[3] { nextY, nextX, time }); if (ans < time) ans = time; } } Console.WriteLine(ans); } }
[["-", 15, 16, 12, 204, 206, 207, 0, 28, 0, 22], ["-", 0, 57, 15, 16, 12, 204, 206, 207, 0, 21], ["+", 0, 57, 15, 16, 12, 204, 206, 207, 0, 21], ["+", 15, 16, 12, 204, 206, 207, 0, 28, 0, 22], ["-", 0, 11, 31, 204, 206, 207, 0, 28, 0, 22], ["-", 0, 1, 0, 11, 31, 204, 206, 207, 0, 21], ["+", 0, 1, 0, 11, 31, 204, 206, 207, 0, 21], ["+", 0, 11, 31, 204, 206, 207, 0, 28, 0, 22]]
8
387
8
using System; using System.Collections.Generic; using System.Linq; using static Input; public class Prog { private const int INF = 1000000007; private const long INFINITY = 9223372036854775807; private struct Pair { public int x, y; public Pair(int xx, int yy) { x = xx; y = yy; } } private static int[] dx = { 1, 0, -1, 0 }; private static int[] dy = { 0, -1, 0, 1 }; public static void Main() { int H = NextInt(); int W = NextInt(); int[,] map = new int[H, W]; for (int i = 0; i < H; i++) { string box = NextString(); // string box = ""; // for (int j = 0; j < W; j++) box += "."; for (int j = 0; j < W; j++) map[i, j] = (box[j] == '#' ? 1 : 0); } // BFSの気持ち Queue<Pair> Black = new Queue<Pair>(); for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) if (map[i, j] == 1) Black.Enqueue(new Pair(j, i)); Queue<Pair> nextBlack = Fac(Black, ref map, H, W); int ans = 0; while (nextBlack.Count() != 0) { nextBlack = Fac(nextBlack, ref map, H, W); ans++; } Console.WriteLine(ans); } private static Queue<Pair> Fac(Queue<Pair> Black, ref int[,] map, int H, int W) { Queue<Pair> nextBlack = new Queue<Pair>(); while (Black.Count() != 0) { Pair pos = Black.Dequeue(); for (int i = 0; i < 4; i++) { if (pos.x + dx[i] < 0 || W <= pos.x + dx[i] || pos.y + dy[i] < 0 || H <= pos.y + dy[i]) continue; if (map[pos.y + dy[i], pos.x + dx[i]] == 0) { nextBlack.Enqueue(new Pair(pos.y + dy[i], pos.x + dx[i])); map[pos.y + dy[i], pos.x + dx[i]] = 1; } } } return nextBlack; } } public class Input { private static Queue<string> q = new Queue<string>(); private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); } public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); } public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); } public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); } public static string NextString() { Confirm(); return q.Dequeue(); } public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); } public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); } public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); } public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); } public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); } }
using System; using System.Collections.Generic; using System.Linq; using static Input; public class Prog { private const int INF = 1000000007; private const long INFINITY = 9223372036854775807; private struct Pair { public int x, y; public Pair(int xx, int yy) { x = xx; y = yy; } } private static int[] dx = { 1, 0, -1, 0 }; private static int[] dy = { 0, -1, 0, 1 }; public static void Main() { int H = NextInt(); int W = NextInt(); int[,] map = new int[H, W]; for (int i = 0; i < H; i++) { string box = NextString(); // string box = ""; // for (int j = 0; j < W; j++) box += "."; for (int j = 0; j < W; j++) map[i, j] = (box[j] == '#' ? 1 : 0); } // BFSの気持ち Queue<Pair> Black = new Queue<Pair>(); for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) if (map[i, j] == 1) Black.Enqueue(new Pair(j, i)); if (Black.Count() == H * W) { Console.WriteLine(0); return; } Queue<Pair> nextBlack = Fac(Black, ref map, H, W); int ans = 1; while (nextBlack.Count() != 0) { nextBlack = Fac(nextBlack, ref map, H, W); if (nextBlack.Count() == 0) break; ans++; } Console.WriteLine(ans); } private static Queue<Pair> Fac(Queue<Pair> Black, ref int[,] map, int H, int W) { Queue<Pair> nextBlack = new Queue<Pair>(); while (Black.Count() != 0) { Pair pos = Black.Dequeue(); for (int i = 0; i < 4; i++) { if (pos.x + dx[i] < 0 || W <= pos.x + dx[i] || pos.y + dy[i] < 0 || H <= pos.y + dy[i]) continue; if (map[pos.y + dy[i], pos.x + dx[i]] == 0) { nextBlack.Enqueue(new Pair(pos.x + dx[i], pos.y + dy[i])); map[pos.y + dy[i], pos.x + dx[i]] = 1; } } } return nextBlack; } } public class Input { private static Queue<string> q = new Queue<string>(); private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); } public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); } public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); } public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); } public static string NextString() { Confirm(); return q.Dequeue(); } public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); } public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); } public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); } public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); } public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 57, 15, 16, 31, 213, 63, 214, 205, 22], ["+", 0, 57, 15, 16, 31, 213, 63, 214, 0, 131], ["+", 0, 57, 15, 16, 31, 213, 63, 214, 141, 22], ["+", 0, 57, 15, 16, 31, 213, 3, 4, 0, 24], ["+", 0, 57, 15, 16, 31, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 48], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 24], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 52, 8, 196, 0, 57, 64, 93, 0, 94], ["-", 3, 4, 0, 28, 0, 16, 31, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 16, 31, 214, 141, 22], ["-", 3, 4, 0, 28, 0, 16, 12, 204, 205, 22], ["+", 3, 4, 0, 28, 0, 16, 12, 204, 205, 22]]
8
845
45
using System; using System.Collections.Generic; using System.Diagnostics; using System.Text; using System.Linq; using static System.Math; class Program { static int n; static int k; static string s; static RSQ1 rsq; static bool f; //先頭が立っているか static void Main() { string[] input = Console.ReadLine().Split(); n = int.Parse(input[0]); k = int.Parse(input[1]); s = Console.ReadLine(); f = s[0] == '0'; List<int> ls = new List<int>(); if (f) ls.Add(0); int count = 0; for (int i = 0; i < n; i++) { count++; if (i == n - 1 || s[i] != s[i + 1]) { ls.Add(count); count = 0; } } int lsc = ls.Count(); if (lsc / 2 <= k) { Console.WriteLine(n); return; } rsq = new RSQ1(lsc); for (int i = 0; i < lsc; i++) rsq[i] = ls[i]; long ans = 0; for (int i = 0; i + 2 * k < lsc; i += 2) ans = Max(ans, rsq.Query(i, i + 1 + 2 * k)); Console.WriteLine(ans); } } struct RSQ1 { private int n; private long[] dat; public int Length { get; private set; } public long this[int i] { get { if (i < 0 || i >= this.Length) throw new IndexOutOfRangeException(); return dat[i + n - 1]; } set { this.Update(i, value); } } /* nを要素数として、すべて0で初期化 */ public RSQ1(int n) { Length = n; this.n = 1; while (this.n < n) this.n *= 2; dat = new long[2 * this.n]; } /* k番目(0-indexed)をaに変更 */ public void Update(int k, long a) { k += n - 1; dat[k] = a; while (k > 0) { k = (k - 1) / 2; dat[k] = dat[k * 2 + 1] + dat[k * 2 + 2]; } } private long Query_(int a, int b, int k, int l, int r) { if (r <= a || b <= l) return 0; if (a <= l && r <= b) return dat[k]; long v1 = Query_(a, b, k * 2 + 1, l, (l + r) / 2); long v2 = Query_(a, b, k * 2 + 2, (l + r) / 2, r); return v1 + v2; } /* [a,b)の和を求める */ public long Query(int a, int b) { return Query_(a, b, 0, 0, n); } }
using System; using System.Collections.Generic; using System.Diagnostics; using System.Text; using System.Linq; using static System.Math; class Program { static int n; static int k; static string s; static RSQ1 rsq; static bool f; //先頭が立っているか static void Main() { string[] input = Console.ReadLine().Split(); n = int.Parse(input[0]); k = int.Parse(input[1]); s = Console.ReadLine(); f = s[0] == '0'; List<int> ls = new List<int>(); if (f) ls.Add(0); int count = 0; for (int i = 0; i < n; i++) { count++; if (i == n - 1 || s[i] != s[i + 1]) { ls.Add(count); count = 0; } } int lsc = ls.Count(); if (lsc / 2 <= k) { Console.WriteLine(n); return; } rsq = new RSQ1(lsc); for (int i = 0; i < lsc; i++) rsq[i] = ls[i]; long ans = 0; for (int i = 0; i < lsc; i += 2) ans = Max(ans, rsq.Query(i, Min(i + 1 + 2 * k, lsc))); Console.WriteLine(ans); } } struct RSQ1 { private int n; private long[] dat; public int Length { get; private set; } public long this[int i] { get { if (i < 0 || i >= this.Length) throw new IndexOutOfRangeException(); return dat[i + n - 1]; } set { this.Update(i, value); } } /* nを要素数として、すべて0で初期化 */ public RSQ1(int n) { Length = n; this.n = 1; while (this.n < n) this.n *= 2; dat = new long[2 * this.n]; } /* k番目(0-indexed)をaに変更 */ public void Update(int k, long a) { k += n - 1; dat[k] = a; while (k > 0) { k = (k - 1) / 2; dat[k] = dat[k * 2 + 1] + dat[k * 2 + 2]; } } private long Query_(int a, int b, int k, int l, int r) { if (r <= a || b <= l) return 0; if (a <= l && r <= b) return dat[k]; long v1 = Query_(a, b, k * 2 + 1, l, (l + r) / 2); long v2 = Query_(a, b, k * 2 + 2, (l + r) / 2, r); return v1 + v2; } /* [a,b)の和を求める */ public long Query(int a, int b) { return Query_(a, b, 0, 0, n); } }
[["-", 8, 196, 0, 7, 15, 16, 31, 16, 17, 72], ["-", 0, 7, 15, 16, 31, 16, 12, 16, 31, 203], ["-", 0, 7, 15, 16, 31, 16, 12, 16, 17, 48], ["-", 0, 7, 15, 16, 31, 16, 12, 16, 12, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 213, 63, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 21], ["+", 0, 28, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25]]
8
638
9
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Beg124D { class Program { public static int N; static void Main(string[] args) { var read = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); N = read[0]; var K = read[1]; var S = Console.ReadLine().ToArray(); var start1 = S[0] == '1'; var end1 = S[S.Length - 1] == '1'; var S_Count = new List<int>(); var count = 1; if (S.Length == 1) Console.WriteLine(K > 0 ? 1 : 0); if (!start1) S_Count.Add(0); for (int i = 0; i < S.Length - 1; i++) { if (S[i] == '0' && S[i + 1] == '1') { S_Count.Add(-count); count = 1; if (i == S.Length - 2) S_Count.Add(1); } else if (S[i] == '1' && S[i + 1] == '0') { S_Count.Add(count); count = 1; if (i == S.Length - 2) S_Count.Add(-1); } else { count++; if (i == S.Length - 2) S_Count.Add(S[i] == '1' ? count : -count); } } if (!end1) S_Count.Add(0); var ret = new List<int>(); S_Count = S_Count.Select(x => Math.Abs(x)).ToList(); var beginTarget = 0; var endTarget = 2 * K + 1 - 1; var sumNum = S_Count.Where((x, i) => i <= endTarget).Sum(); ret.Add(sumNum); if (endTarget >= S_Count.Count()) Console.WriteLine(N); for (int i = endTarget; i < S_Count.Count() - 2; i += 2) { sumNum -= S_Count[beginTarget] + S_Count[beginTarget + 1]; sumNum += S_Count[endTarget + 1] + S_Count[endTarget + 2]; beginTarget += 2; endTarget += 2; ret.Add(sumNum); } Console.WriteLine(ret.Max()); } public static int MaxHandStandNum(int K, List<int> S_Count, int preIndex) { if (K == 0) return S_Count.Max(); else if (S_Count.Count() == 1) return Math.Max(S_Count[0], 1); var ret = new List<int>(); var tempS_Count = new List<int>(S_Count); if (preIndex == 0) { var combine = tempS_Count[0] - tempS_Count[1]; tempS_Count[0] = combine; tempS_Count.RemoveAt(1); return MaxHandStandNum(K - 1, tempS_Count, 0); } else if (preIndex == S_Count.Count() - 1) { var combine = -tempS_Count[S_Count.Count() - 2] + tempS_Count[S_Count.Count() - 1]; tempS_Count[preIndex] = combine; tempS_Count.RemoveAt(preIndex - 1); return MaxHandStandNum(K - 1, tempS_Count, preIndex - 1); } else { var combine = tempS_Count[preIndex - 2] - tempS_Count[preIndex - 1] + tempS_Count[preIndex]; tempS_Count[preIndex - 2] = combine; tempS_Count.RemoveAt(preIndex); tempS_Count.RemoveAt(preIndex - 1); ret.Add(MaxHandStandNum(K - 1, tempS_Count, preIndex - 2)); tempS_Count = new List<int>(S_Count); combine = tempS_Count[preIndex] - tempS_Count[preIndex + 1] + tempS_Count[preIndex + 2]; tempS_Count[preIndex] = combine; tempS_Count.RemoveAt(preIndex + 2); tempS_Count.RemoveAt(preIndex + 1); ret.Add(MaxHandStandNum(K - 1, tempS_Count, preIndex)); return ret.Max(); } } public static int MaxHandStandNum(int K, List<int> S_Count) { if (K == 0) return S_Count.Max(); else if (S_Count.Count() == 1) return Math.Max(S_Count[0], 1); var ret = new List<int>(); var tempS_Count = new List<int>(); for (int i = 0; i < S_Count.Count(); i++) { if (S_Count[i] < 0) { tempS_Count = new List<int>(S_Count); if (i == 0) { var combine = -tempS_Count[0] + tempS_Count[1]; tempS_Count[0] = combine; tempS_Count.RemoveAt(1); ret.Add(MaxHandStandNum(K - 1, tempS_Count)); } else if (i == S_Count.Count() - 1) { var combine = tempS_Count[i - 1] - tempS_Count[i]; tempS_Count[i - 1] = combine; tempS_Count.RemoveAt(i); ret.Add(MaxHandStandNum(K - 1, tempS_Count)); } else { var combine = S_Count[i - 1] - S_Count[i] + S_Count[i + 1]; tempS_Count[i] = combine; tempS_Count.RemoveAt(i + 1); tempS_Count.RemoveAt(i - 1); ret.Add(MaxHandStandNum(K - 1, tempS_Count)); } } } return ret.Max(); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Beg124D { class Program { public static int N; static void Main(string[] args) { var read = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); N = read[0]; var K = read[1]; var S = Console.ReadLine().ToArray(); var start1 = S[0] == '1'; var end1 = S[S.Length - 1] == '1'; var S_Count = new List<int>(); var count = 1; if (S.Length == 1) { Console.WriteLine(K > 0 ? 1 : 0); } if (!start1) S_Count.Add(0); for (int i = 0; i < S.Length - 1; i++) { if (S[i] == '0' && S[i + 1] == '1') { S_Count.Add(-count); count = 1; if (i == S.Length - 2) S_Count.Add(1); } else if (S[i] == '1' && S[i + 1] == '0') { S_Count.Add(count); count = 1; if (i == S.Length - 2) S_Count.Add(-1); } else { count++; if (i == S.Length - 2) S_Count.Add(S[i] == '1' ? count : -count); } } if (!end1) S_Count.Add(0); var ret = new List<int>(); S_Count = S_Count.Select(x => Math.Abs(x)).ToList(); var beginTarget = 0; var endTarget = 2 * K + 1 - 1; var sumNum = S_Count.Where((x, i) => i <= endTarget).Sum(); ret.Add(sumNum); if (endTarget >= S_Count.Count() && S.Count() != 1) Console.WriteLine(N); for (int i = endTarget; i < S_Count.Count() - 2; i += 2) { sumNum -= S_Count[beginTarget] + S_Count[beginTarget + 1]; sumNum += S_Count[endTarget + 1] + S_Count[endTarget + 2]; beginTarget += 2; endTarget += 2; ret.Add(sumNum); } if (endTarget < S_Count.Count() && S.Count() != 1) Console.WriteLine(ret.Max()); } public static int MaxHandStandNum(int K, List<int> S_Count, int preIndex) { if (K == 0) return S_Count.Max(); else if (S_Count.Count() == 1) return Math.Max(S_Count[0], 1); var ret = new List<int>(); var tempS_Count = new List<int>(S_Count); if (preIndex == 0) { var combine = tempS_Count[0] - tempS_Count[1]; tempS_Count[0] = combine; tempS_Count.RemoveAt(1); return MaxHandStandNum(K - 1, tempS_Count, 0); } else if (preIndex == S_Count.Count() - 1) { var combine = -tempS_Count[S_Count.Count() - 2] + tempS_Count[S_Count.Count() - 1]; tempS_Count[preIndex] = combine; tempS_Count.RemoveAt(preIndex - 1); return MaxHandStandNum(K - 1, tempS_Count, preIndex - 1); } else { var combine = tempS_Count[preIndex - 2] - tempS_Count[preIndex - 1] + tempS_Count[preIndex]; tempS_Count[preIndex - 2] = combine; tempS_Count.RemoveAt(preIndex); tempS_Count.RemoveAt(preIndex - 1); ret.Add(MaxHandStandNum(K - 1, tempS_Count, preIndex - 2)); tempS_Count = new List<int>(S_Count); combine = tempS_Count[preIndex] - tempS_Count[preIndex + 1] + tempS_Count[preIndex + 2]; tempS_Count[preIndex] = combine; tempS_Count.RemoveAt(preIndex + 2); tempS_Count.RemoveAt(preIndex + 1); ret.Add(MaxHandStandNum(K - 1, tempS_Count, preIndex)); return ret.Max(); } } public static int MaxHandStandNum(int K, List<int> S_Count) { if (K == 0) return S_Count.Max(); else if (S_Count.Count() == 1) return Math.Max(S_Count[0], 1); var ret = new List<int>(); var tempS_Count = new List<int>(); for (int i = 0; i < S_Count.Count(); i++) { if (S_Count[i] < 0) { tempS_Count = new List<int>(S_Count); if (i == 0) { var combine = -tempS_Count[0] + tempS_Count[1]; tempS_Count[0] = combine; tempS_Count.RemoveAt(1); ret.Add(MaxHandStandNum(K - 1, tempS_Count)); } else if (i == S_Count.Count() - 1) { var combine = tempS_Count[i - 1] - tempS_Count[i]; tempS_Count[i - 1] = combine; tempS_Count.RemoveAt(i); ret.Add(MaxHandStandNum(K - 1, tempS_Count)); } else { var combine = S_Count[i - 1] - S_Count[i] + S_Count[i + 1]; tempS_Count[i] = combine; tempS_Count.RemoveAt(i + 1); tempS_Count.RemoveAt(i - 1); ret.Add(MaxHandStandNum(K - 1, tempS_Count)); } } } return ret.Max(); } } }
[["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 15, 16, 31, 16, 12, 213, 63, 214, 0, 131], ["+", 15, 16, 31, 16, 12, 213, 63, 214, 141, 22], ["+", 15, 16, 31, 16, 12, 213, 3, 4, 0, 24], ["+", 15, 16, 31, 16, 12, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 15, 16, 12, 16, 31, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 79], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 18], ["+", 15, 16, 31, 16, 12, 213, 63, 214, 205, 22], ["+", 15, 16, 12, 16, 31, 213, 63, 214, 0, 131], ["+", 15, 16, 12, 16, 31, 213, 63, 214, 141, 22], ["+", 15, 16, 12, 16, 31, 213, 3, 4, 0, 24], ["+", 15, 16, 12, 16, 31, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25]]
8
1,177
28
using System; using System.Collections.Generic; using System.Linq; using static Input; public class Prog { private const int INF = 1000000007; private const long INFINITY = 9223372036854775807; private struct Pair { public int x, y; } public static void Main() { int N = NextInt(); int K = NextInt(); string S = NextString(); List<int> memo = new List<int>(); int count = 0; bool flag = true; for (int i = 0; i < N; i++) { if (!flag && S[i] == '0') { count++; } else if (!flag && S[i] == '1') { memo.Add(count); count = 1; flag = true; } else if (flag && S[i] == '1') { count++; } else if (flag && S[i] == '0') { memo.Add(count); count = 1; flag = false; } } memo.Add(count); if (S[N - 1] == '0') memo.Add(0); long ans = 0; long box = 0; count = 0; for (int i = 0; i < memo.Count(); i += 2) { if (count <= K) { box += memo[i]; if (i != 0) box += memo[i - 1]; } else { box += memo[i] + memo[i - 1]; box -= (memo[i / 2 - K - 1] + memo[i / 2 - K]); } ans = Math.Max(ans, box); count++; } Console.WriteLine(ans); } } public class Input { private static Queue<string> q = new Queue<string>(); private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); } public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); } public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); } public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); } public static string NextString() { Confirm(); return q.Dequeue(); } public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); } public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); } public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); } public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); } public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); } }
using System; using System.Collections.Generic; using System.Linq; using static Input; public class Prog { private const int INF = 1000000007; private const long INFINITY = 9223372036854775807; private struct Pair { public int x, y; } public static void Main() { int N = NextInt(); int K = NextInt(); string S = NextString(); List<int> memo = new List<int>(); int count = 0; bool flag = true; for (int i = 0; i < N; i++) { if (!flag && S[i] == '0') { count++; } else if (!flag && S[i] == '1') { memo.Add(count); count = 1; flag = true; } else if (flag && S[i] == '1') { count++; } else if (flag && S[i] == '0') { memo.Add(count); count = 1; flag = false; } } memo.Add(count); if (S[N - 1] == '0') memo.Add(0); long ans = memo[0]; long box = memo[0]; count = 0; for (int i = 1; i < memo.Count(); i += 2) { count++; if (count <= K) { box += memo[i]; if (i + 1 != memo.Count()) box += memo[i + 1]; } else { box += memo[i] + memo[i + 1]; box -= (memo[i - K * 2] + memo[i - K * 2 - 1]); } ans = Math.Max(ans, box); // count++; } Console.WriteLine(ans); } } public class Input { private static Queue<string> q = new Queue<string>(); private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); } public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); } public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); } public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); } public static string NextString() { Confirm(); return q.Dequeue(); } public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); } public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); } public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); } public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); } public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); } }
[["+", 0, 198, 0, 200, 0, 212, 0, 204, 205, 22], ["+", 0, 200, 0, 212, 0, 204, 206, 207, 0, 70], ["+", 0, 200, 0, 212, 0, 204, 206, 207, 0, 73], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 8, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 223, 0, 29], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["+", 64, 196, 0, 57, 15, 16, 31, 16, 17, 72], ["+", 64, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["-", 0, 57, 64, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 57, 15, 16, 12, 213, 63, 214, 205, 22], ["+", 0, 57, 15, 16, 12, 213, 63, 214, 0, 131], ["+", 0, 57, 15, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 57, 15, 16, 12, 213, 3, 4, 0, 24], ["+", 0, 57, 15, 16, 12, 213, 3, 4, 0, 25], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 17, 72], ["-", 0, 28, 0, 16, 31, 16, 31, 16, 17, 85], ["-", 0, 28, 0, 16, 31, 16, 31, 16, 12, 203], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 206, 207, 0, 28, 0, 16, 12, 16, 17, 48], ["+", 206, 207, 0, 28, 0, 16, 12, 16, 12, 203], ["-", 206, 207, 0, 28, 0, 16, 31, 16, 17, 85], ["-", 206, 207, 0, 28, 0, 16, 31, 16, 12, 203], ["+", 0, 28, 0, 16, 31, 16, 12, 16, 17, 48], ["+", 0, 28, 0, 16, 31, 16, 12, 16, 12, 203], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["-", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["-", 0, 7, 8, 196, 0, 1, 0, 223, 0, 22], ["-", 0, 7, 8, 196, 0, 1, 0, 223, 0, 29]]
8
683
38
using System; using System.Text; using System.Linq; using System.Collections; using System.Collections.Generic; using static System.Console; using static System.Math; namespace AtCoder { public class Program { public static void Main(string[] args) { new Program().Solve(new ConsoleInput(Console.In, ' ')); } public void Solve(ConsoleInput cin) { // 解答はココに書く var n = cin.ReadInt; var k = cin.ReadInt; var s = cin.ReadLine; var list = new List<int>(); var charList = new List<char>(); var sum = 0; var bef = '9'; list.Add(sum); charList.Add(bef); foreach (var temps in s) { sum++; if (temps != bef) { if (bef != '9') list.Add(sum); charList.Add(temps); } bef = temps; } list.Add(sum); var count = 0; var l = list.Count(); for (var i = 0; i < l; i++) { var now = charList[i]; if (now == '9') continue; var len = now == '0' ? k * 2 : k * 2 + 1; var to = Min(i + len, l) - 1; var temp = list[to] - list[i - 1]; if (temp > count) { count = temp; } } WriteLine(count); } private double MultipleCeil(double value, double multiple) { return Math.Ceiling(value / multiple) * multiple; } } public class ConsoleInput { private readonly System.IO.TextReader _stream; private char _separator = ' '; private Queue<string> inputStream; public ConsoleInput(System.IO.TextReader stream, char separator = ' ') { this._separator = separator; this._stream = stream; inputStream = new Queue<string>(); } public string Read { get { if (inputStream.Count != 0) return inputStream.Dequeue(); string[] tmp = _stream.ReadLine().Split(_separator); for (int i = 0; i < tmp.Length; ++i) inputStream.Enqueue(tmp[i]); return inputStream.Dequeue(); } } public string ReadLine { get { return _stream.ReadLine(); } } public int ReadInt { get { return int.Parse(Read); } } public long ReadLong { get { return long.Parse(Read); } } public double ReadDouble { get { return double.Parse(Read); } } public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; } public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; } public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; } } }
using System; using System.Text; using System.Linq; using System.Collections; using System.Collections.Generic; using static System.Console; using static System.Math; namespace AtCoder { public class Program { public static void Main(string[] args) { new Program().Solve(new ConsoleInput(Console.In, ' ')); } public void Solve(ConsoleInput cin) { // 解答はココに書く var n = cin.ReadInt; var k = cin.ReadInt; var s = cin.ReadLine; var list = new List<int>(); var charList = new List<char>(); var sum = 0; var bef = '9'; list.Add(sum); charList.Add(bef); foreach (var temps in s) { if (temps != bef) { if (bef != '9') list.Add(sum); charList.Add(temps); } bef = temps; if (temps != '9') sum++; } list.Add(sum); var count = 0; var l = list.Count(); for (var i = 0; i < l; i++) { var now = charList[i]; if (now == '9') continue; var len = now == '0' ? k * 2 : k * 2 + 1; var to = Min(i + len, l) - 1; var temp = list[to] - list[i - 1]; if (temp > count) { count = temp; } } WriteLine(count); } private double MultipleCeil(double value, double multiple) { return Math.Ceiling(value / multiple) * multiple; } } public class ConsoleInput { private readonly System.IO.TextReader _stream; private char _separator = ' '; private Queue<string> inputStream; public ConsoleInput(System.IO.TextReader stream, char separator = ' ') { this._separator = separator; this._stream = stream; inputStream = new Queue<string>(); } public string Read { get { if (inputStream.Count != 0) return inputStream.Dequeue(); string[] tmp = _stream.ReadLine().Split(_separator); for (int i = 0; i < tmp.Length; ++i) inputStream.Enqueue(tmp[i]); return inputStream.Dequeue(); } } public string ReadLine { get { return _stream.ReadLine(); } } public int ReadInt { get { return int.Parse(Read); } } public long ReadLong { get { return long.Parse(Read); } } public double ReadDouble { get { return double.Parse(Read); } } public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; } public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; } public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; } } }
[["-", 0, 210, 8, 196, 0, 1, 0, 223, 0, 22], ["-", 0, 210, 8, 196, 0, 1, 0, 223, 0, 29], ["-", 8, 196, 0, 210, 8, 196, 0, 1, 0, 35], ["+", 0, 210, 8, 196, 0, 1, 0, 11, 12, 22], ["+", 8, 196, 0, 210, 8, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 210, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 210, 8, 196, 0, 57, 0, 24], ["+", 0, 210, 8, 196, 0, 57, 15, 16, 17, 79], ["+", 8, 196, 0, 57, 15, 16, 12, 252, 0, 104], ["+", 8, 196, 0, 57, 15, 16, 12, 252, 0, 253], ["+", 8, 196, 0, 210, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 223, 0, 22], ["+", 8, 196, 0, 57, 64, 1, 0, 223, 0, 29]]
8
684
14
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp1 { class Program4 { static void Main(string[] args) { var nk = Console.ReadLine().Split(' '); var s = Console.ReadLine(); List<KeyValuePair<int, int>> numlist = new List<KeyValuePair<int, int>>(); int k = int.Parse(nk[1]); int addk = 0; int max = 0; int ans = 0; int num = 0; for (int i = 0; i < s.Length; i++) { num++; bool b = true; if (s[i].Equals('1')) { b = true; } else { b = false; } if (i + 1 < s.Length && s[i].Equals(s[i + 1])) { continue; } // これは1が続いた if (b) { numlist.Add(new KeyValuePair<int, int>(1, num)); ans += num; if (ans > max) { max = ans; } } // ここは0が続いた else { // 0が続いた場合はkを使って裏返す if (addk < k) { addk++; numlist.Add(new KeyValuePair<int, int>(0, num)); ans += num; if (ans > max) { max = ans; } } else { numlist.Add(new KeyValuePair<int, int>(0, num)); ans += num; // 既にk回裏返している場合はnumlistから0を削除する必要がある if (numlist[0].Key == 0) { ans -= numlist[0].Value; numlist.RemoveAt(0); } else { ans -= numlist[0].Value; ans -= numlist[1].Value; numlist.RemoveAt(0); numlist.RemoveAt(0); } } } num = 0; } Console.Write(max.ToString() + "\n"); // Console.ReadLine(); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp1 { class Program4 { static void Main(string[] args) { var nk = Console.ReadLine().Split(' '); var s = Console.ReadLine(); List<KeyValuePair<int, int>> numlist = new List<KeyValuePair<int, int>>(); int k = int.Parse(nk[1]); int addk = 0; int max = 0; int ans = 0; int num = 0; for (int i = 0; i < s.Length; i++) { num++; bool b = true; if (s[i].Equals('1')) { b = true; } else { b = false; } if (i + 1 < s.Length && s[i].Equals(s[i + 1])) { continue; } // これは1が続いた if (b) { numlist.Add(new KeyValuePair<int, int>(1, num)); ans += num; if (ans > max) { max = ans; } } // ここは0が続いた else { // 0が続いた場合はkを使って裏返す if (addk < k) { addk++; numlist.Add(new KeyValuePair<int, int>(0, num)); ans += num; if (ans > max) { max = ans; } } else { numlist.Add(new KeyValuePair<int, int>(0, num)); ans += num; // 既にk回裏返している場合はnumlistから0を削除する必要がある if (numlist[0].Key == 0) { ans -= numlist[0].Value; numlist.RemoveAt(0); } else { ans -= numlist[0].Value; ans -= numlist[1].Value; numlist.RemoveAt(0); numlist.RemoveAt(0); } if (ans > max) { max = ans; } } } num = 0; } Console.Write(max.ToString() + "\n"); // Console.ReadLine(); } } }
[["+", 75, 196, 0, 57, 75, 196, 0, 57, 0, 121], ["+", 75, 196, 0, 57, 75, 196, 0, 57, 0, 24], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 12, 22], ["+", 75, 196, 0, 57, 75, 196, 0, 57, 0, 25], ["+", 0, 57, 75, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["+", 75, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 57, 75, 196, 0, 57, 64, 196, 0, 46]]
8
411
12
using System; using System.Linq; using System.Collections; using System.Collections.Generic; namespace AtCoder124 { class Program { public static void Main(string[] args) { string[] s = Console.ReadLine().Split(' '); int N = int.Parse(s[0]); int K = int.Parse(s[1]); string S = Console.ReadLine(); int ressize = 0; int[] resblacks = new int[100001]; int[] black = new int[100001]; int[] white = new int[100001]; int blackcount = 0; int whitecount = 0; int startidx = 0; int finishidx = 0; char bef = S[0]; if (S[0] == '0') { black[blackcount] = 0; resblacks[blackcount] = 0; blackcount++; } for (int i = 0; i < N; i++) { if (S[i] == bef) { finishidx = i; } else { if (bef == '0') { white[whitecount] = finishidx - startidx + 1; whitecount++; } else { black[blackcount] = finishidx - startidx + 1; resblacks[blackcount] = finishidx - startidx + 1; blackcount++; } startidx = i; finishidx = i; bef = S[i]; } } if (bef == '0') { white[whitecount] = finishidx - startidx + 1; whitecount++; black[blackcount] = 0; resblacks[blackcount] = 0; blackcount++; } else { black[blackcount] = finishidx - startidx + 1; resblacks[blackcount] = finishidx - startidx + 1; blackcount++; } ressize = blackcount; int res = black[0]; for (int i = 0; i < Math.Min(whitecount, K); i++) res += black[i + 1] + white[i]; int resbef = res; for (int i = K; i < blackcount; i++) { int restemp = resbef - black[i - 1] - white[i - 1] + white[i] + black[i + 1]; res = Math.Max(res, restemp); } Console.WriteLine(res); } } }
using System; using System.Linq; using System.Collections; using System.Collections.Generic; namespace AtCoder124 { class Program { public static void Main(string[] args) { string[] s = Console.ReadLine().Split(' '); int N = int.Parse(s[0]); int K = int.Parse(s[1]); string S = Console.ReadLine(); int[] resblacks = new int[100001]; int[] black = new int[100001]; int[] white = new int[100001]; int blackcount = 0; int whitecount = 0; int startidx = 0; int finishidx = 0; char bef = S[0]; if (S[0] == '0') { black[blackcount] = 0; resblacks[blackcount] = 0; blackcount++; } for (int i = 0; i < N; i++) { if (S[i] == bef) { finishidx = i; } else { if (bef == '0') { white[whitecount] = finishidx - startidx + 1; whitecount++; } else { black[blackcount] = finishidx - startidx + 1; resblacks[blackcount] = finishidx - startidx + 1; blackcount++; } startidx = i; finishidx = i; bef = S[i]; } } if (bef == '0') { white[whitecount] = finishidx - startidx + 1; whitecount++; black[blackcount] = 0; resblacks[blackcount] = 0; blackcount++; } else { black[blackcount] = finishidx - startidx + 1; resblacks[blackcount] = finishidx - startidx + 1; blackcount++; } int res = black[0]; for (int i = 0; i < Math.Min(whitecount, K); i++) res += black[i + 1] + white[i]; int resbef = res; int firsti = 0; for (int i = K; i < blackcount - 1; i++) { int restemp = resbef - black[firsti] - white[firsti] + white[i] + black[i + 1]; firsti++; resbef = restemp; res = Math.Max(res, restemp); } Console.WriteLine(res); } } }
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 0, 195, 8, 196, 0, 1, 0, 11, 12, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 31, 16, 12, 204, 206, 207, 0, 28, 0, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 197, 0, 35], ["+", 0, 7, 8, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 223, 0, 29], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 12, 22]]
8
476
31
using System; using System.Collections.Generic; using System.Linq; public class AtCoder { public static int[] ReadArray() { return Array.ConvertAll(Console.ReadLine().Split(' '), m => Convert.ToInt32(m)); } public static int ReadInt() { return Convert.ToInt32(Console.ReadLine()); } public static string ReadStr() { return Console.ReadLine(); } public static long ReadLong() { return Convert.ToInt64(Console.ReadLine()); } public static long[] ReadLongArray() { return Array.ConvertAll(Console.ReadLine().Split(' '), m => Convert.ToInt64(m)); } public static void Main() { var T = ReadArray(); var arr = ReadStr(); int n = T[0], k = T[1]; int i = 0; var q = new Queue<int>(); int ans = 0; for (int j = 0; j < n; j++) { if (arr[j] == '0') { q.Enqueue(j); } if (q.Count > k) { i = q.Dequeue(); while (i < n && arr[i] == '0') i++; } while (j < n && arr[j] == '0') { j++; } ans = Math.Max(ans, j - i + 1); } Console.WriteLine(ans); } }
using System; using System.Collections.Generic; using System.Linq; public class AtCoder { public static int[] ReadArray() { return Array.ConvertAll(Console.ReadLine().Split(' '), m => Convert.ToInt32(m)); } public static int ReadInt() { return Convert.ToInt32(Console.ReadLine()); } public static string ReadStr() { return Console.ReadLine(); } public static long ReadLong() { return Convert.ToInt64(Console.ReadLine()); } public static long[] ReadLongArray() { return Array.ConvertAll(Console.ReadLine().Split(' '), m => Convert.ToInt64(m)); } public static void Main() { var T = ReadArray(); var arr = ReadStr(); int n = T[0], k = T[1]; int i = 0; var q = new Queue<int>(); int ans = 0; for (int j = 0; j < n; j++) { if (arr[j] == '0') { q.Enqueue(j); } if (q.Count > k) { i = q.Dequeue(); while (i < n && arr[i] == '0') i++; } while (j < n && arr[j] == '0') { j++; } if (j == n) ans = Math.Max(ans, j - i); else ans = Math.Max(ans, j - i + 1); } Console.WriteLine(ans); } }
[["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 64, 1, 0, 11, 12, 213, 63, 214, 205, 22], ["+", 64, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["+", 64, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 64, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["+", 64, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["+", 64, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 1, 0, 35], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["+", 8, 196, 0, 57, 75, 1, 0, 11, 31, 22]]
8
323
20
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCorder { public class Program { static void Main(string[] args) { D(); } public static void D() { Scanner cin = new Scanner(); int n = cin.NextInt(); int k = cin.NextInt(); string s = cin.Next(); List<int> nums = new List<int>(); char value = s[0]; int count = 0; for (int i = 0; i < n; ++i) { if (s[i] == value) { ++count; } else { nums.Add(count); value = s[i]; count = 1; } if (i == n - 1) { nums.Add(count); } } if (s[0] == '0') { nums.Insert(0, 0); } if (s[n - 1] == '0') { nums.Add(0); } int l = k * 2 + 1; if (nums.Count <= l) { Console.WriteLine(n); } else { long initial = 0; for (int i = 0; i < l; ++i) { initial += nums[i]; } long last = initial; long max = initial; for (int i = 2; i < nums.Count - l; i += 2) { long num = last - nums[i - 1] + nums[i + l - 1]; if (num > max) { max = num; } last = num; } Console.WriteLine(max); } } } public class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string Next() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return Next(); i = 0; return s[i++]; } public int NextInt() { return int.Parse(Next()); } public int[] ArrayInt(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = NextInt() + add; } return Array; } public long NextLong() { return long.Parse(Next()); } public long[] ArrayLong(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = NextLong() + add; } return Array; } public double NextDouble() { return double.Parse(Next()); } public double[] ArrayDouble(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = NextDouble() + add; } return Array; } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCorder { public class Program { static void Main(string[] args) { D(); } public static void D() { Scanner cin = new Scanner(); int n = cin.NextInt(); int k = cin.NextInt(); string s = cin.Next(); List<int> nums = new List<int>(); char value = s[0]; int count = 0; for (int i = 0; i < n; ++i) { if (s[i] == value) { ++count; } else { nums.Add(count); value = s[i]; count = 1; } if (i == n - 1) { nums.Add(count); } } if (s[0] == '0') { nums.Insert(0, 0); } if (s[n - 1] == '0') { nums.Add(0); } int l = k * 2 + 1; if (nums.Count <= l) { Console.WriteLine(n); } else { long initial = 0; for (int i = 0; i < l; ++i) { initial += nums[i]; } long last = initial; long max = initial; for (int i = 2; i <= nums.Count - l; i += 2) { long num = last - nums[i - 1] - nums[i - 2] + nums[i + l - 1] + nums[i + l - 2]; if (num > max) { max = num; } last = num; } Console.WriteLine(max); } } } public class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string Next() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return Next(); i = 0; return s[i++]; } public int NextInt() { return int.Parse(Next()); } public int[] ArrayInt(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = NextInt() + add; } return Array; } public long NextLong() { return long.Parse(Next()); } public long[] ArrayLong(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = NextLong() + add; } return Array; } public double NextDouble() { return double.Parse(Next()); } public double[] ArrayDouble(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = NextDouble() + add; } return Array; } } }
[["-", 0, 57, 75, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 57, 75, 196, 0, 7, 15, 16, 17, 19], ["+", 31, 16, 31, 16, 12, 204, 206, 207, 0, 73], ["+", 0, 212, 0, 16, 31, 16, 31, 16, 17, 33], ["+", 0, 16, 31, 16, 31, 16, 12, 204, 205, 22], ["+", 31, 16, 31, 16, 12, 204, 206, 207, 0, 70], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 0, 16, 31, 16, 12, 204, 206, 207, 0, 73], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["+", 0, 200, 0, 212, 0, 16, 12, 204, 205, 22], ["+", 0, 212, 0, 16, 12, 204, 206, 207, 0, 70], ["+", 206, 207, 0, 28, 0, 16, 31, 16, 31, 22], ["+", 206, 207, 0, 28, 0, 16, 31, 16, 17, 72], ["+", 206, 207, 0, 28, 0, 16, 31, 16, 12, 22]]
8
716
18
using System; using System.Collections.Generic; namespace CSsample { class Program { static void Main(string[] args) { string input = Console.ReadLine(); var x = input.Split(); int N = int.Parse(x[0]); int K = int.Parse(x[1]); string S = Console.ReadLine(); var ind = new List<int>(); var len = new List<int>(); int A = S.IndexOf('0'); while (A != -1) { ind.Add(A); int B = S.IndexOf('1', A + 1); if (B == -1) { len.Add(S.Length - A); A = -1; } else { len.Add(B - A); A = S.IndexOf('0', B + 1); } } int num = ind.Count; if (K >= num) { Console.WriteLine(S.Length); } else { int con = num - K + 1; int leng = 0; int max = 0; for (int i = 0; i < con; i++) { if (i == 0) { leng = ind[K]; if (S[0] == '1') { leng++; } max = leng; } else { int indx = 0; if (K + i >= num) { indx = S.Length; } else { indx = ind[K + i]; } leng = indx - (ind[i] + len[i]); max = Math.Max(max, leng); } } Console.WriteLine(max); } } } }
using System; using System.Collections.Generic; namespace CSsample { class Program { static void Main(string[] args) { string input = Console.ReadLine(); var x = input.Split(); int N = int.Parse(x[0]); int K = int.Parse(x[1]); string S = Console.ReadLine(); var ind = new List<int>(); var len = new List<int>(); int A = S.IndexOf('0'); while (A != -1) { ind.Add(A); int B = S.IndexOf('1', A + 1); if (B == -1) { len.Add(S.Length - A); A = -1; } else { len.Add(B - A); A = S.IndexOf('0', B + 1); } } int num = ind.Count; if (K >= num) { Console.WriteLine(S.Length); } else { int con = num - K + 1; int leng = 0; int max = 0; for (int i = 0; i < con; i++) { if (i == 0) { leng = ind[K]; max = leng; } else { int indx = 0; if (K + i >= num) { indx = S.Length; } else { indx = ind[K + i]; } leng = indx - (ind[i - 1] + len[i - 1]); max = Math.Max(max, leng); } } Console.WriteLine(max); } } } }
[["-", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["-", 64, 196, 0, 57, 15, 16, 31, 204, 205, 22], ["-", 0, 57, 15, 16, 31, 204, 206, 207, 0, 70], ["-", 15, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 57, 15, 16, 31, 204, 206, 207, 0, 73], ["-", 0, 57, 64, 196, 0, 57, 15, 16, 17, 60], ["-", 64, 196, 0, 57, 15, 16, 12, 252, 0, 104], ["-", 64, 196, 0, 57, 15, 16, 12, 252, 0, 253], ["-", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["-", 0, 57, 64, 196, 0, 57, 64, 196, 0, 45], ["-", 0, 57, 64, 196, 0, 1, 0, 223, 0, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 223, 0, 29], ["-", 64, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203]]
8
367
20
using System; using System.Collections.Generic; using System.Linq; using static System.Console; using static System.Convert; using static System.Math; using Pair = System.Tuple<int, int>; using Edge = System.Tuple<int, int, long>; // using Debug; // using static System.Globalization.CultureInfo; class Program { static void Main(string[] args) { Solve(); // WriteLine(Solve()); } static void Solve() { var nk = Input.ar; var str = ReadLine(); var len1 = new List<int>(); var len0 = new List<int>(); var ct = 1; for (var i = 1; i < nk[0]; i++) { if (str[i - 1] == str[i]) ct++; else { if (str[i - 1] == '0') len0.Add(ct); else len1.Add(ct); ct = 1; } } if (str[nk[0] - 1] == '0') len0.Add(ct); else len1.Add(ct); var sum1 = new int[len1.Count + 2]; for (var i = 1; i <= len1.Count; i++) sum1[i] = sum1[i - 1] + len1[i - 1]; sum1[len1.Count + 1] = sum1[len1.Count]; var sum0 = new int[len0.Count + 1]; for (var i = 1; i <= len0.Count; i++) sum0[i] = sum0[i - 1] + len0[i - 1]; var res = 0; for (var i = 0; i < len0.Count - nk[1] + 1; i++) { var calc = sum0[i + nk[1]] - sum0[i]; if (str[0] == '0') { if (i == 0) calc += sum1[i + nk[1]] - sum1[i]; else calc += sum1[i + nk[1]] - sum1[i - 1]; } else { calc += sum1[i + nk[1] + 1] - sum1[i]; } res = Max(res, calc); } if (len1.Count == 1) res = Max(len1[0], res); WriteLine(res); } } public class Input { public static string read => ReadLine(); public static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse); public static int num => ToInt32(read); public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse); public static long numL => ToInt64(read); public static char[][] gred(int h) => Enumerable.Repeat(0, h).Select(v => read.ToCharArray()).ToArray(); public static int[][] ar2D(int num) => Enumerable.Repeat(0, num).Select(v => ar).ToArray(); public static long[][] arL2D(int num) => Enumerable.Repeat(0, num).Select(v => arL).ToArray(); public const long Inf = (long)1e18; public const double eps = 1e-6; public const string Alfa = "abcdefghijklmnopqrstuvwxyz"; public const int MOD = 1000000007; }
using System; using System.Collections.Generic; using System.Linq; using static System.Console; using static System.Convert; using static System.Math; using Pair = System.Tuple<int, int>; using Edge = System.Tuple<int, int, long>; // using Debug; // using static System.Globalization.CultureInfo; class Program { static void Main(string[] args) { Solve(); // WriteLine(Solve()); } static void Solve() { var nk = Input.ar; var str = ReadLine(); var len1 = new List<int>(); var len0 = new List<int>(); var ct = 1; for (var i = 1; i < nk[0]; i++) { if (str[i - 1] == str[i]) ct++; else { if (str[i - 1] == '0') len0.Add(ct); else len1.Add(ct); ct = 1; } } if (str[nk[0] - 1] == '0') len0.Add(ct); else len1.Add(ct); var sum1 = new int[len1.Count + 2]; for (var i = 1; i <= len1.Count; i++) sum1[i] = sum1[i - 1] + len1[i - 1]; sum1[len1.Count + 1] = sum1[len1.Count]; var sum0 = new int[len0.Count + 1]; for (var i = 1; i <= len0.Count; i++) sum0[i] = sum0[i - 1] + len0[i - 1]; var res = 0; if (len0.Count < nk[1]) { res = str.Length; } for (var i = 0; i < len0.Count - nk[1] + 1; i++) { var calc = sum0[i + nk[1]] - sum0[i]; if (str[0] == '0') { if (i == 0) calc += sum1[i + nk[1]] - sum1[i]; else calc += sum1[i + nk[1]] - sum1[i - 1]; } else { calc += sum1[i + nk[1] + 1] - sum1[i]; } res = Max(res, calc); } if (len1.Count == 1) res = Max(len1[0], res); WriteLine(res); } } public class Input { public static string read => ReadLine(); public static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse); public static int num => ToInt32(read); public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse); public static long numL => ToInt64(read); public static char[][] gred(int h) => Enumerable.Repeat(0, h).Select(v => read.ToCharArray()).ToArray(); public static int[][] ar2D(int num) => Enumerable.Repeat(0, num).Select(v => ar).ToArray(); public static long[][] arL2D(int num) => Enumerable.Repeat(0, num).Select(v => arL).ToArray(); public const long Inf = (long)1e18; public const double eps = 1e-6; public const string Alfa = "abcdefghijklmnopqrstuvwxyz"; public const int MOD = 1000000007; }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 205, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 0, 131], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 141, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 8, 196, 0, 57, 15, 16, 12, 204, 205, 22], ["+", 0, 57, 15, 16, 12, 204, 206, 207, 0, 70], ["+", 15, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 57, 15, 16, 12, 204, 206, 207, 0, 73], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 64, 196, 0, 1, 0, 11, 12, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 11, 12, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 11, 12, 214, 141, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
8
723
19
using System; using System.Collections.Generic; using System.Linq; using System.Text; using static System.Console; using static System.Math; namespace AtTest.ABC_124 { class D { static void Main(string[] args) { Method(args); } static void Method(string[] args) { int[] nk = ReadInts(); int n = nk[0]; int k = nk[1]; string s = Read(); List<int> cnts = new List<int>(); if (s[0] == '0') cnts.Add(0); cnts.Add(1); for (int i = 1; i < n; i++) { if (s[i] == s[i - 1]) { cnts[cnts.Count - 1]++; } else { cnts.Add(1); } } if (s[s.Length - 1] == '0') cnts.Add(0); int sum = 0; if (cnts.Count / 2 <= k) { for (int i = 0; i < cnts.Count; i++) { sum += cnts[i]; } WriteLine(sum); return; } for (int i = 0; i < 2 * k + 1; i++) { sum += cnts[i]; } int res = sum; for (int i = 2; i + 2 * k < cnts.Count; i += 2) { sum -= cnts[i - 2] + cnts[i - 1]; sum += cnts[i + 2 * k - 1] + cnts[i + 2 * k]; res = Max(res, sum); } WriteLine(sum); } private static string Read() { return ReadLine(); } private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); } private static int ReadInt() { return int.Parse(Read()); } private static long ReadLong() { return long.Parse(Read()); } private static double ReadDouble() { return double.Parse(Read()); } private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); } private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); } private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using static System.Console; using static System.Math; namespace AtTest.ABC_124 { class D { static void Main(string[] args) { Method(args); } static void Method(string[] args) { int[] nk = ReadInts(); int n = nk[0]; int k = nk[1]; string s = Read(); List<int> cnts = new List<int>(); if (s[0] == '0') cnts.Add(0); cnts.Add(1); for (int i = 1; i < n; i++) { if (s[i] == s[i - 1]) { cnts[cnts.Count - 1]++; } else { cnts.Add(1); } } if (s[n - 1] == '0') cnts.Add(0); int sum = 0; if (cnts.Count <= 2 * k + 1) { for (int i = 0; i < cnts.Count; i++) { sum += cnts[i]; } WriteLine(sum); return; } for (int i = 0; i < 2 * k + 1; i++) { sum += cnts[i]; } int res = sum; for (int i = 2; i + 2 * k < cnts.Count; i += 2) { sum -= cnts[i - 2] + cnts[i - 1]; sum += cnts[i + 2 * k - 1] + cnts[i + 2 * k]; res = Max(res, sum); } WriteLine(res); } private static string Read() { return ReadLine(); } private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); } private static int ReadInt() { return int.Parse(Read()); } private static long ReadLong() { return long.Parse(Read()); } private static double ReadDouble() { return double.Parse(Read()); } private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); } private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); } private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); } } }
[["-", 206, 207, 0, 28, 0, 16, 31, 214, 205, 22], ["-", 206, 207, 0, 28, 0, 16, 31, 214, 0, 131], ["-", 206, 207, 0, 28, 0, 16, 31, 214, 141, 22], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 85], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 57, 15, 16, 12, 16, 31, 16, 31, 203], ["+", 0, 57, 15, 16, 12, 16, 31, 16, 17, 48], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 72], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
8
552
12
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp1 { class Program { static void Main(string[] args) { int[] a = new int[5]; for (int i = 0; i < a.Length; ++i) // a.Length は配列 a の長さ。これの例では5。 { a[i] = int.Parse(Console.ReadLine()); } int k = int.Parse(Console.ReadLine()); int check = 0; for (int j = 0; j < a.Length - 1; ++j) { for (int dif = j + 1; dif < a.Length - 1; ++dif) { if (a[dif] - a[j] > k) { check = 1; } } } if (check == 1) { Console.WriteLine(":("); } else { Console.WriteLine("Yay!"); } Console.Read(); } } }
using System; namespace ConsoleApp1 { class Program { static void Main(string[] args) { int[] a = new int[5]; for (int i = 0; i < a.Length; ++i) // a.Length は配列 a の長さ。これの例では5。 { a[i] = int.Parse(Console.ReadLine()); } int k = int.Parse(Console.ReadLine()); int check = 0; for (int j = 0; j < a.Length; ++j) { for (int dif = j + 1; dif < a.Length; ++dif) { if (a[dif] - a[j] > k) { check = 1; } } } if (check == 1) { Console.WriteLine(":("); } else { Console.WriteLine("Yay!"); } Console.Read(); } } }
[["-", 36, 36, 36, 36, 0, 208, 0, 231, 0, 233], ["-", 0, 208, 0, 231, 141, 232, 234, 232, 234, 22], ["-", 0, 208, 0, 231, 141, 232, 234, 232, 0, 131], ["-", 0, 208, 0, 231, 141, 232, 234, 232, 141, 22], ["-", 36, 36, 0, 208, 0, 231, 141, 232, 0, 131], ["-", 36, 36, 0, 208, 0, 231, 141, 232, 141, 22], ["-", 36, 36, 36, 36, 0, 208, 0, 231, 0, 35], ["-", 36, 36, 0, 208, 0, 231, 141, 232, 234, 22], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203]]
8
208
28
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace abc123_a { class Program { static void Main(string[] args) { int a = int.Parse(Console.ReadLine()); int b = int.Parse(Console.ReadLine()); int c = int.Parse(Console.ReadLine()); int d = int.Parse(Console.ReadLine()); int e = int.Parse(Console.ReadLine()); int k = int.Parse(Console.ReadLine()); if (b - a > k && c - a > k && d - a > k && e - a > k && c - b > k && d - b > k && e - b > k && d - c > k && e - c > k && e - d > k) { Console.WriteLine(":("); } else { Console.WriteLine("Yay!"); } Console.ReadLine(); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace abc123_a { class Program { static void Main(string[] args) { int a = int.Parse(Console.ReadLine()); int b = int.Parse(Console.ReadLine()); int c = int.Parse(Console.ReadLine()); int d = int.Parse(Console.ReadLine()); int e = int.Parse(Console.ReadLine()); int k = int.Parse(Console.ReadLine()); if (b - a > k || c - a > k || d - a > k || e - a > k || c - b > k || d - b > k || e - b > k || d - c > k || e - c > k || e - d > k) { Console.WriteLine(":("); } else { Console.WriteLine("Yay!"); } Console.ReadLine(); } } }
[["-", 31, 16, 31, 16, 31, 16, 31, 16, 17, 98], ["+", 31, 16, 31, 16, 31, 16, 31, 16, 17, 106], ["-", 15, 16, 31, 16, 31, 16, 31, 16, 17, 98], ["+", 15, 16, 31, 16, 31, 16, 31, 16, 17, 106], ["-", 0, 57, 15, 16, 31, 16, 31, 16, 17, 98], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 17, 106], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 98], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 106], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106]]
8
221
18
using System; using System.Linq; public class Program { public static void Main() { var xs = Console.In.ReadToEnd().Split().Select(int.Parse).ToArray(); int k = xs[xs.Length - 1]; int min = xs[0]; int max = xs[xs.Length - 2]; Console.WriteLine(max - min <= k ? "Yay!" : ":("); } }
using System; using System.Linq; class Program { static void Main() { var xs = Console.In.ReadToEnd() .Trim('\n') .Split() .Select(n => int.Parse(n)) .ToArray(); int k = xs[xs.Length - 1]; int min = xs[0]; int max = xs[xs.Length - 2]; Console.WriteLine(max - min <= k ? "Yay!" : ":("); } }
[["-", 36, 36, 0, 208, 0, 235, 0, 251, 0, 259], ["-", 0, 235, 8, 201, 0, 195, 0, 251, 0, 259], ["+", 205, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["+", 205, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["+", 205, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 205, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["+", 205, 213, 3, 4, 0, 28, 0, 252, 0, 104], ["+", 205, 213, 3, 4, 0, 28, 0, 252, 0, 44], ["+", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["+", 205, 213, 3, 4, 0, 28, 0, 218, 0, 221], ["+", 0, 28, 0, 218, 8, 213, 3, 4, 0, 24], ["+", 0, 218, 8, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 28, 0, 218, 8, 213, 3, 4, 0, 25]]
8
98
14
using System; namespace abc123 { class A { static void Main(string[] args) { int a = int.Parse(Console.ReadLine()); int b = int.Parse(Console.ReadLine()); int c = int.Parse(Console.ReadLine()); int d = int.Parse(Console.ReadLine()); int e = int.Parse(Console.ReadLine()); int k = int.Parse(Console.ReadLine()); if (e - a < k) { Console.WriteLine("Yay!"); } else { Console.WriteLine(":("); } } } }
using System; namespace abc123 { class A { static void Main(string[] args) { int a = int.Parse(Console.ReadLine()); int b = int.Parse(Console.ReadLine()); int c = int.Parse(Console.ReadLine()); int d = int.Parse(Console.ReadLine()); int e = int.Parse(Console.ReadLine()); int k = int.Parse(Console.ReadLine()); if (e - a > k) { Console.WriteLine(":("); return; } Console.WriteLine("Yay!"); } } }
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["-", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["-", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
8
137
11
using System; using System.Linq; using System.Collections; using System.Collections.Generic; using static System.Console; class Program { static void Main() { //入力 // int n = 100; int[] input = new int[5]; for (int a = 0; a < 5; a++) { input[a] = int.Parse(Console.ReadLine()); } int max = int.Parse(Console.ReadLine()); // int[] input = "5 100".Split().Select(i=>int.Parse(i)).ToArray(); bool f = true; for (int a = 0; a < 5; a++) { for (int b = 0; b < 5; b++) { if (Math.Abs(input[b] - input[a]) > max) { Console.WriteLine(":("); f = false; } } } /* int n = input[0]; int q = input[1]; //int seed = Environment.TickCount; */ Console.WriteLine(f ? "Yay!" : ":("); /* //処理速度計測 var sw = new System.Diagnostics.Stopwatch(); sw.Start(); //解法 //処理速度表示 sw.Stop(); TimeSpan ts = sw.Elapsed; Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms"); */ Console.ReadLine(); } }
using System; using System.Linq; using System.Collections; using System.Collections.Generic; using static System.Console; class Program { static void Main() { //入力 // int n = 100; int[] input = new int[5]; for (int a = 0; a < 5; a++) { input[a] = int.Parse(Console.ReadLine()); } int max = int.Parse(Console.ReadLine()); // int[] input = "5 100".Split().Select(i=>int.Parse(i)).ToArray(); bool f = true; for (int a = 0; a < 5; a++) { for (int b = a + 1; b < 5; b++) { if (Math.Abs(input[b] - input[a]) > max) { f = false; } } } /* int n = input[0]; int q = input[1]; //int seed = Environment.TickCount; */ Console.WriteLine(f ? "Yay!" : ":("); /* //処理速度計測 var sw = new System.Diagnostics.Stopwatch(); sw.Start(); //解法 //処理速度表示 sw.Stop(); TimeSpan ts = sw.Elapsed; Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms"); */ Console.ReadLine(); } }
[["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 10, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["+", 10, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["+", 10, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["-", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35]]
8
191
13
using System; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int a = int.Parse(Console.ReadLine()); int b = int.Parse(Console.ReadLine()); int c = int.Parse(Console.ReadLine()); int d = int.Parse(Console.ReadLine()); int e = int.Parse(Console.ReadLine()); int k = int.Parse(Console.ReadLine()); string answer = "Yay!"; int[] antena = new int[] { a, b, c, d, e }; for (int i = 0; i < antena.Length; i++) { for (int j = i + 1; j < antena.Length - 1; j++) { if (Math.Abs(antena[j] - antena[i]) > k) { answer = ":("; break; } } } Console.WriteLine(answer); } } }
using System; class Program { static void Main(string[] args) { int a = int.Parse(Console.ReadLine()); int b = int.Parse(Console.ReadLine()); int c = int.Parse(Console.ReadLine()); int d = int.Parse(Console.ReadLine()); int e = int.Parse(Console.ReadLine()); int k = int.Parse(Console.ReadLine()); string answer = "Yay!"; int[] antena = new int[] { a, b, c, d, e }; for (int i = 0; i < antena.Length; i++) { for (int j = i + 1; j < antena.Length; j++) { if ((antena[j] - antena[i]) > k) { answer = ":("; break; } } } Console.WriteLine(answer); } }
[["-", 36, 36, 36, 36, 0, 208, 0, 209, 0, 256], ["-", 36, 36, 36, 36, 0, 208, 0, 209, 141, 22], ["-", 36, 36, 0, 208, 0, 209, 8, 201, 0, 45], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["-", 0, 57, 15, 16, 31, 213, 63, 214, 205, 22], ["-", 0, 57, 15, 16, 31, 213, 63, 214, 0, 131], ["-", 0, 57, 15, 16, 31, 213, 63, 214, 141, 22], ["-", 0, 235, 8, 201, 0, 195, 8, 196, 0, 46]]
8
210
9
using System; using System.Collections.Generic; using System.Linq; using static System.Math; using static AtCoderTemplate.MyExtensions; using static AtCoderTemplate.MyInputOutputs; using static AtCoderTemplate.MyNumericFunctions; namespace AtCoderTemplate { class Program { static void Main(string[] args) { var aTOe = ReadIntColumns(5)[0]; var k = ReadInt(); PrintIf(Enumerable.Range(0, 4) .SelectMany(p => Enumerable.Range(p, 4 - p).Select( q => aTOe[q] - aTOe[p])) .All(d => d <= k), "Yay!", ":("); } } static class MyInputOutputs { /* Input & Output*/ public static int ReadInt() { return int.Parse(Console.ReadLine()); } public static long ReadLong() { return long.Parse(Console.ReadLine()); } public static List<int> ReadInts() { return Console.ReadLine().Split(' ').Select(c => int.Parse(c)).ToList(); } public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(c => long.Parse(c)).ToList(); } public static List<List<int>> ReadIntColumns(int n) { /* 入力例 A1 B1 A2 B2 ... An Bn 出力例 [[A1,A2,...,An], [B1,B2,...,Bn]] */ var rows = Enumerable.Range(0, n).Select(i => ReadInts()).ToList(); var m = rows.FirstOrDefault()?.Count() ?? 0; return Enumerable.Range(0, m) .Select(i => rows.Select(items => items[i]).ToList()) .ToList(); } public static List<List<long>> ReadLongColumns(int n) { /* 入力例 A1 B1 A2 B2 ... An Bn 出力例 [[A1,A2,...,An], [B1,B2,...,Bn]] */ var rows = Enumerable.Range(0, n).Select(i => ReadLongs()).ToList(); var m = rows.FirstOrDefault()?.Count() ?? 0; return Enumerable.Range(0, m) .Select(i => rows.Select(items => items[i]).ToList()) .ToList(); } public static void PrintRow<T>(IEnumerable<T> list) { /* 横ベクトルで表示 A B C D ... */ if (!list.IsEmpty()) { Console.Write(list.First()); foreach (var item in list.Skip(1)) { Console.Write($" {item}"); } } Console.Write("\n"); } public static void PrintColomn<T>(IEnumerable<T> list) { /* 縦ベクトルで表示 A B C D ... */ foreach (var item in list) { Console.WriteLine(item); } } public static void Print2DArray<T>(IEnumerable<IEnumerable<T>> sources) { foreach (var row in sources) { PrintRow(row); } } public static void PrintIf<T1, T2>(bool condition, T1 trueResult, T2 falseResult) { if (condition) { Console.WriteLine(trueResult); } else { Console.WriteLine(falseResult); } } } static class MyNumericFunctions { public static int Fact(int n) { return Enumerable.Range(1, n).Aggregate(1, ((i, k) => i * k)); } public static int PermNum(int n, int m) { if (m > n) { return 0; } return Enumerable.Range(n - m, m + 1).Aggregate(1, ((i, k) => i * k)); } public static int CombNum(int n, int m) { return PermNum(n, m) / Fact(m); } // 最大公約数 (m ≧ n) public static int GCD(int m, int n) { if (n == 0) { return m; } else { return GCD(n, m % n); } } // 最小公倍数 (m ≧ n) public static int LCM(int m, int n) { return GCD(m, n) / (m * n); } } static class MyExtensions { public static bool IsEmpty<T>(this IEnumerable<T> source) { return source.Count() == 0; } /// <summary> /// 一つ前の値との差を得る /// O(N * log(N)) /// </summary> public static IEnumerable<int> Diff(this IEnumerable<int> source) { var list = source.ToList(); return Enumerable.Range(1, list.Count - 1) .Select(i => list[i] - list[i - 1]); } /// <summary> /// 累積和を得る /// O(N * log(N)) /// </summary> public static IEnumerable<int> CumSum(this IEnumerable<int> source) { var list = source.ToList(); var result = new List<int> { list[0] }; foreach (var i in Enumerable.Range(1, source.Count() - 1)) { result.Add(result[i - 1] + list[i]); } return result; } /// <summary> /// 昇順にソートしたインデックスを得る /// </summary> public static IEnumerable<int> SortIndex<T>(this IEnumerable<T> source) { return source.Select((item, i) => new { Item = item, Index = i }) .OrderBy(x => x.Item) .Select(x => x.Index); } } }
using System; using System.Collections.Generic; using System.Linq; using static System.Math; using static AtCoderTemplate.MyExtensions; using static AtCoderTemplate.MyInputOutputs; using static AtCoderTemplate.MyNumericFunctions; namespace AtCoderTemplate { class Program { static void Main(string[] args) { var aTOe = ReadIntColumns(5)[0]; var k = ReadInt(); PrintIf(Enumerable.Range(0, 5) .SelectMany(p => Enumerable.Range(0, 5).Select( q => Abs(aTOe[q] - aTOe[p]))) .All(d => d <= k), "Yay!", ":("); } } static class MyInputOutputs { /* Input & Output*/ public static int ReadInt() { return int.Parse(Console.ReadLine()); } public static long ReadLong() { return long.Parse(Console.ReadLine()); } public static List<int> ReadInts() { return Console.ReadLine().Split(' ').Select(c => int.Parse(c)).ToList(); } public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(c => long.Parse(c)).ToList(); } public static List<List<int>> ReadIntColumns(int n) { /* 入力例 A1 B1 A2 B2 ... An Bn 出力例 [[A1,A2,...,An], [B1,B2,...,Bn]] */ var rows = Enumerable.Range(0, n).Select(i => ReadInts()).ToList(); var m = rows.FirstOrDefault()?.Count() ?? 0; return Enumerable.Range(0, m) .Select(i => rows.Select(items => items[i]).ToList()) .ToList(); } public static List<List<long>> ReadLongColumns(int n) { /* 入力例 A1 B1 A2 B2 ... An Bn 出力例 [[A1,A2,...,An], [B1,B2,...,Bn]] */ var rows = Enumerable.Range(0, n).Select(i => ReadLongs()).ToList(); var m = rows.FirstOrDefault()?.Count() ?? 0; return Enumerable.Range(0, m) .Select(i => rows.Select(items => items[i]).ToList()) .ToList(); } public static void PrintRow<T>(IEnumerable<T> list) { /* 横ベクトルで表示 A B C D ... */ if (!list.IsEmpty()) { Console.Write(list.First()); foreach (var item in list.Skip(1)) { Console.Write($" {item}"); } } Console.Write("\n"); } public static void PrintColomn<T>(IEnumerable<T> list) { /* 縦ベクトルで表示 A B C D ... */ foreach (var item in list) { Console.WriteLine(item); } } public static void Print2DArray<T>(IEnumerable<IEnumerable<T>> sources) { foreach (var row in sources) { PrintRow(row); } } public static void PrintIf<T1, T2>(bool condition, T1 trueResult, T2 falseResult) { if (condition) { Console.WriteLine(trueResult); } else { Console.WriteLine(falseResult); } } } static class MyNumericFunctions { public static int Fact(int n) { return Enumerable.Range(1, n).Aggregate(1, ((i, k) => i * k)); } public static int PermNum(int n, int m) { if (m > n) { return 0; } return Enumerable.Range(n - m, m + 1).Aggregate(1, ((i, k) => i * k)); } public static int CombNum(int n, int m) { return PermNum(n, m) / Fact(m); } // 最大公約数 (m ≧ n) public static int GCD(int m, int n) { if (n == 0) { return m; } else { return GCD(n, m % n); } } // 最小公倍数 (m ≧ n) public static int LCM(int m, int n) { return GCD(m, n) / (m * n); } } static class MyExtensions { public static bool IsEmpty<T>(this IEnumerable<T> source) { return source.Count() == 0; } /// <summary> /// 一つ前の値との差を得る /// O(N * log(N)) /// </summary> public static IEnumerable<int> Diff(this IEnumerable<int> source) { var list = source.ToList(); return Enumerable.Range(1, list.Count - 1) .Select(i => list[i] - list[i - 1]); } /// <summary> /// 累積和を得る /// O(N * log(N)) /// </summary> public static IEnumerable<int> CumSum(this IEnumerable<int> source) { var list = source.ToList(); var result = new List<int> { list[0] }; foreach (var i in Enumerable.Range(1, source.Count() - 1)) { result.Add(result[i - 1] + list[i]); } return result; } /// <summary> /// 昇順にソートしたインデックスを得る /// </summary> public static IEnumerable<int> SortIndex<T>(this IEnumerable<T> source) { return source.Select((item, i) => new { Item = item, Index = i }) .OrderBy(x => x.Item) .Select(x => x.Index); } } }
[["-", 63, 214, 205, 213, 3, 4, 0, 28, 0, 203], ["+", 63, 214, 205, 213, 3, 4, 0, 28, 0, 203], ["-", 63, 214, 205, 213, 3, 4, 0, 28, 0, 22], ["-", 205, 213, 3, 4, 0, 28, 0, 16, 31, 203], ["-", 205, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["-", 205, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["+", 3, 4, 0, 28, 0, 218, 8, 213, 63, 22], ["+", 0, 28, 0, 218, 8, 213, 3, 4, 0, 24], ["+", 0, 28, 0, 218, 8, 213, 3, 4, 0, 25]]
8
1,066
11
using System; using System.Collections.Generic; using System.Linq; class ABC123B { public static void Main() { var a = int.Parse(Console.ReadLine()); Console.ReadLine(); Console.ReadLine(); Console.ReadLine(); var e = int.Parse(Console.ReadLine()); var k = int.Parse(Console.ReadLine()); if (((a - e) ^ 2) > (k ^ 2)) Console.WriteLine(":("); else Console.WriteLine("Yay!"); } }
using System; using System.Collections.Generic; using System.Linq; class ABC123B { public static void Main() { var a = int.Parse(Console.ReadLine()); Console.ReadLine(); Console.ReadLine(); Console.ReadLine(); var e = int.Parse(Console.ReadLine()); var k = int.Parse(Console.ReadLine()); if (e - a > k) Console.WriteLine(":("); else Console.WriteLine("Yay!"); } }
[["-", 8, 196, 0, 57, 15, 16, 31, 23, 0, 24], ["-", 15, 16, 31, 23, 0, 16, 31, 23, 0, 24], ["-", 31, 23, 0, 16, 31, 23, 0, 16, 31, 22], ["-", 31, 23, 0, 16, 31, 23, 0, 16, 17, 33], ["-", 15, 16, 31, 23, 0, 16, 31, 23, 0, 25], ["-", 0, 57, 15, 16, 31, 23, 0, 16, 17, 140], ["-", 0, 57, 15, 16, 31, 23, 0, 16, 12, 203], ["-", 8, 196, 0, 57, 15, 16, 31, 23, 0, 25], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 33], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["-", 8, 196, 0, 57, 15, 16, 12, 23, 0, 24], ["-", 0, 57, 15, 16, 12, 23, 0, 16, 17, 140], ["-", 0, 57, 15, 16, 12, 23, 0, 16, 12, 203], ["-", 8, 196, 0, 57, 15, 16, 12, 23, 0, 25]]
8
124
14
using System; using System.Collections; using System.Collections.Generic; class FiveAntennas { static void Main(string[] args) { var antena = new int[5]; for (int i = 0; i < 5; i++) { antena[i] = int.Parse(Console.ReadLine()); } var k = int.Parse(Console.ReadLine()); bool isYes = true; for (int i = 0; i < antena.Length - 1; i++) { if (antena[i + 1] - antena[i] > k) { isYes = false; } } if (isYes) { Console.WriteLine("Yay!"); } else { Console.WriteLine(":("); } } }
using System; using System.Collections; using System.Collections.Generic; class FiveAntennas { static void Main(string[] args) { var antena = new int[5]; for (int i = 0; i < 5; i++) { antena[i] = int.Parse(Console.ReadLine()); } var k = int.Parse(Console.ReadLine()); bool isYes = true; for (int i = 0; i < antena.Length; i++) { for (int j = 0; j < antena.Length; j++) { if (antena[j] - antena[i] > k) { isYes = false; } } } if (isYes) { Console.WriteLine("Yay!"); } else { Console.WriteLine(":("); } } }
[["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 29], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 25], ["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 45], ["+", 8, 196, 0, 7, 8, 196, 0, 7, 0, 88], ["+", 8, 196, 0, 7, 8, 196, 0, 7, 0, 24], ["+", 0, 7, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 7, 0, 35], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 8, 196, 0, 7, 15, 16, 12, 214, 205, 22], ["+", 8, 196, 0, 7, 15, 16, 12, 214, 0, 131], ["+", 8, 196, 0, 7, 15, 16, 12, 214, 141, 22], ["+", 0, 7, 8, 196, 0, 7, 26, 223, 0, 22], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 17, 72], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 31, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
8
159
24
using System; namespace abc123A { class MainClass { public static void Main(string[] args) { int a = Int32.Parse(Console.ReadLine()); int b = Int32.Parse(Console.ReadLine()); int c = Int32.Parse(Console.ReadLine()); int d = Int32.Parse(Console.ReadLine()); int e = Int32.Parse(Console.ReadLine()); int k = Int32.Parse(Console.ReadLine()); int f = b - a; int g = c - a; int h = d - a; int i = e - a; int j = c - b; int l = d - b; int m = e - b; int n = d - c; int o = e - c; int p = e - d; if (k > f && k > g && k > h && k > i && k > j && k > l && k > m && k > n && k > o && k > p) Console.WriteLine("Yay!"); else Console.WriteLine(":("); } } }
using System; namespace abc123A { class MainClass { public static void Main(string[] args) { int a = Int32.Parse(Console.ReadLine()); int b = Int32.Parse(Console.ReadLine()); int c = Int32.Parse(Console.ReadLine()); int d = Int32.Parse(Console.ReadLine()); int e = Int32.Parse(Console.ReadLine()); int k = Int32.Parse(Console.ReadLine()); int f = b - a; int g = c - a; int h = d - a; int i = e - a; int j = c - b; int l = d - b; int m = e - b; int n = d - c; int o = e - c; int p = e - d; if (k >= f && k >= g && k >= h && k >= i && k >= j && k >= l && k >= m && k >= n && k >= o && k >= p) Console.WriteLine("Yay!"); else Console.WriteLine(":("); } } }
[["-", 31, 16, 31, 16, 31, 16, 31, 16, 17, 47], ["+", 31, 16, 31, 16, 31, 16, 31, 16, 17, 20], ["-", 31, 16, 31, 16, 31, 16, 12, 16, 17, 47], ["+", 31, 16, 31, 16, 31, 16, 12, 16, 17, 20], ["-", 15, 16, 31, 16, 31, 16, 12, 16, 17, 47], ["+", 15, 16, 31, 16, 31, 16, 12, 16, 17, 20], ["-", 0, 57, 15, 16, 31, 16, 12, 16, 17, 47], ["+", 0, 57, 15, 16, 31, 16, 12, 16, 17, 20], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 47], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 20]]
8
238
20
using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { string input = Console.ReadLine(); int a = int.Parse(input); input = Console.ReadLine(); int b = int.Parse(input); input = Console.ReadLine(); int c = int.Parse(input); input = Console.ReadLine(); int d = int.Parse(input); input = Console.ReadLine(); int e = int.Parse(input); input = Console.ReadLine(); int k = int.Parse(input); if (Math.Abs(a - b) < k && Math.Abs(a - b) < k && Math.Abs(a - c) < k && Math.Abs(a - d) < k && Math.Abs(a - e) < k && Math.Abs(c - b) < k && Math.Abs(b - d) < k && Math.Abs(e - b) < k && Math.Abs(c - d) < k && Math.Abs(c - e) < k && Math.Abs(d - e) < k) { Console.WriteLine("Yay!"); } else { Console.WriteLine(":("); } } }
using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { string input = Console.ReadLine(); int a = int.Parse(input); input = Console.ReadLine(); int b = int.Parse(input); input = Console.ReadLine(); int c = int.Parse(input); input = Console.ReadLine(); int d = int.Parse(input); input = Console.ReadLine(); int e = int.Parse(input); input = Console.ReadLine(); int k = int.Parse(input); if (Math.Abs(a - b) <= k && Math.Abs(a - b) <= k && Math.Abs(a - c) <= k && Math.Abs(a - d) <= k && Math.Abs(a - e) <= k && Math.Abs(c - b) <= k && Math.Abs(b - d) <= k && Math.Abs(e - b) <= k && Math.Abs(c - d) <= k && Math.Abs(c - e) <= k && Math.Abs(d - e) <= k) { Console.WriteLine("Yay!"); } else { Console.WriteLine(":("); } } }
[["-", 31, 16, 31, 16, 31, 16, 31, 16, 17, 18], ["+", 31, 16, 31, 16, 31, 16, 31, 16, 17, 19], ["-", 31, 16, 31, 16, 31, 16, 12, 16, 17, 18], ["+", 31, 16, 31, 16, 31, 16, 12, 16, 17, 19], ["-", 15, 16, 31, 16, 31, 16, 12, 16, 17, 18], ["+", 15, 16, 31, 16, 31, 16, 12, 16, 17, 19], ["-", 0, 57, 15, 16, 31, 16, 12, 16, 17, 18], ["+", 0, 57, 15, 16, 31, 16, 12, 16, 17, 19], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 18], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 19]]
8
285
22
using System; using System.IO; using System.Linq; class Program { static void Solve() { var max = int.MaxValue; var min = 0; for (var i = 0; i < 5; i++) { var a = ReadInt(); if (a > max) max = a; if (a < min) min = a; } var k = ReadInt(); Console.WriteLine(max - min <= k ? "Yay!" : ":("); } static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); Solve(); Console.Out.Flush(); } public static string Read() { return Console.ReadLine(); } public static int ReadInt() { return int.Parse(Read()); } public static long ReadLong() { return long.Parse(Read()); } public static double ReadDouble() { return double.Parse(Read()); } public static string[] Reads() { return Console.ReadLine().Split(' '); } public static int[] ReadInts() { return Reads().Select(_ => int.Parse(_)).ToArray(); } public static long[] ReadLongs() { return Reads().Select(_ => long.Parse(_)).ToArray(); } public static double[] ReadDoubles() { return Reads().Select(_ => double.Parse(_)).ToArray(); } }
using System; using System.IO; using System.Linq; class Program { static void Solve() { var max = 0; var min = 123; for (var i = 0; i < 5; i++) { var antenna = ReadInt(); if (antenna > max) max = antenna; if (antenna < min) min = antenna; } var k = ReadInt(); Console.WriteLine(max - min <= k ? "Yay!" : ":("); } static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); Solve(); Console.Out.Flush(); } public static string Read() { return Console.ReadLine(); } public static int ReadInt() { return int.Parse(Read()); } public static long ReadLong() { return long.Parse(Read()); } public static double ReadDouble() { return double.Parse(Read()); } public static string[] Reads() { return Console.ReadLine().Split(' '); } public static int[] ReadInts() { return Reads().Select(_ => int.Parse(_)).ToArray(); } public static long[] ReadLongs() { return Reads().Select(_ => long.Parse(_)).ToArray(); } public static double[] ReadDoubles() { return Reads().Select(_ => double.Parse(_)).ToArray(); } }
[["-", 0, 198, 0, 200, 0, 212, 0, 214, 205, 199], ["-", 0, 198, 0, 200, 0, 212, 0, 214, 0, 131], ["-", 0, 198, 0, 200, 0, 212, 0, 214, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 8, 196, 0, 57, 64, 1, 0, 11, 12, 22], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 12, 22]]
8
339
16
using System; using System.Collections; using System.Collections.Generic; using static System.Console; using static System.Math; namespace AtCoder { public class Program { public static void Main(string[] args) { new Program().Solve(new ConsoleInput(Console.In, ' ')); } public void Solve(ConsoleInput cin) { var n = cin.ReadIntArray(5); bool f = false; int k = cin.ReadInt; for (int i = 0; i < 4; i++) { if (n[i + 1] - n[i] > k) { f = true; break; } } Console.WriteLine((f) ? ":(" : "Yay!"); } } public class ConsoleInput { private readonly System.IO.TextReader _stream; private char _separator = ' '; private Queue<string> inputStream; public ConsoleInput(System.IO.TextReader stream, char separator = ' ') { this._separator = separator; this._stream = stream; inputStream = new Queue<string>(); } public string Read { get { if (inputStream.Count != 0) return inputStream.Dequeue(); string[] tmp = _stream.ReadLine().Split(_separator); for (int i = 0; i < tmp.Length; ++i) inputStream.Enqueue(tmp[i]); return inputStream.Dequeue(); } } public string ReadLine { get { return _stream.ReadLine(); } } public int ReadInt { get { return int.Parse(Read); } } public long ReadLong { get { return long.Parse(Read); } } public double ReadDouble { get { return double.Parse(Read); } } public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; } public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; } public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; } public double[] ReadDoubleArray(long N) { var ret = new double[N]; for (long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; } } }
using System; using System.Collections; using System.Collections.Generic; using static System.Console; using static System.Math; namespace AtCoder { public class Program { public static void Main(string[] args) { new Program().Solve(new ConsoleInput(Console.In, ' ')); } public void Solve(ConsoleInput cin) { var n = cin.ReadIntArray(5); int k = cin.ReadInt; bool f = (n[4] - n[0] > k); Console.WriteLine((f) ? ":(" : "Yay!"); } } public class ConsoleInput { private readonly System.IO.TextReader _stream; private char _separator = ' '; private Queue<string> inputStream; public ConsoleInput(System.IO.TextReader stream, char separator = ' ') { this._separator = separator; this._stream = stream; inputStream = new Queue<string>(); } public string Read { get { if (inputStream.Count != 0) return inputStream.Dequeue(); string[] tmp = _stream.ReadLine().Split(_separator); for (int i = 0; i < tmp.Length; ++i) inputStream.Enqueue(tmp[i]); return inputStream.Dequeue(); } } public string ReadLine { get { return _stream.ReadLine(); } } public int ReadInt { get { return int.Parse(Read); } } public long ReadLong { get { return long.Parse(Read); } } public double ReadDouble { get { return double.Parse(Read); } } public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; } public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; } public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; } public double[] ReadDoubleArray(long N) { var ret = new double[N]; for (long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; } } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 198, 0, 200, 0, 212, 0, 211, 0, 147], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 8, 201, 0, 195, 8, 196, 0, 7, 0, 88], ["-", 8, 201, 0, 195, 8, 196, 0, 7, 0, 24], ["-", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["-", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 7, 0, 35], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["-", 0, 195, 8, 196, 0, 7, 26, 223, 0, 22], ["-", 0, 195, 8, 196, 0, 7, 26, 223, 0, 29], ["-", 8, 201, 0, 195, 8, 196, 0, 7, 0, 25], ["-", 0, 195, 8, 196, 0, 7, 8, 196, 0, 45], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 17, 72], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 31, 16, 12, 204, 206, 207, 0, 28, 0, 22], ["+", 31, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 64, 196, 0, 1, 0, 11, 12, 211, 0, 146], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46]]
8
537
36
using System; class ABC_123_A { static void Main(string[] args) { int a = int.Parse(Console.ReadLine()); int b = int.Parse(Console.ReadLine()); int c = int.Parse(Console.ReadLine()); int d = int.Parse(Console.ReadLine()); int e = int.Parse(Console.ReadLine()); int k = int.Parse(Console.ReadLine()); bool result = true; if (b - a >= k) result = false; if (c - a >= k) result = false; if (d - a >= k) result = false; if (e - a >= k) result = false; if (c - b >= k) result = false; if (d - b >= k) result = false; if (e - b >= k) result = false; if (d - c >= k) result = false; if (e - c >= k) result = false; if (e - d >= k) result = false; if (result) { Console.WriteLine("Yay!"); } else { Console.WriteLine(":("); } } }
using System; class ABC_123_A { static void Main(string[] args) { int a = int.Parse(Console.ReadLine()); int b = int.Parse(Console.ReadLine()); int c = int.Parse(Console.ReadLine()); int d = int.Parse(Console.ReadLine()); int e = int.Parse(Console.ReadLine()); int k = int.Parse(Console.ReadLine()); bool result = true; if (b - a > k) result = false; if (c - a > k) result = false; if (d - a > k) result = false; if (e - a > k) result = false; if (c - b > k) result = false; if (d - b > k) result = false; if (e - b > k) result = false; if (d - c > k) result = false; if (e - c > k) result = false; if (e - d > k) result = false; if (result) { Console.WriteLine("Yay!"); } else { Console.WriteLine(":("); } } }
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 20], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47]]
8
254
20
using System; using System.Collections.Generic; namespace AtCoder_ { class Program { static void Main(string[] args) { int[] array = { 0, 0, 0, 0, 0 }; array[0] = int.Parse(Console.ReadLine()); array[1] = int.Parse(Console.ReadLine()); array[2] = int.Parse(Console.ReadLine()); array[3] = int.Parse(Console.ReadLine()); array[4] = int.Parse(Console.ReadLine()); int k = int.Parse(Console.ReadLine()); for (int i = 1; i < 5; i++) { int di = Math.Abs(array[i - 1] - array[i]); if (di > k) { Console.WriteLine(":("); return; } } Console.WriteLine("Yay!"); } static void MainStream() {} } }
using System; using System.Collections.Generic; namespace AtCoder_ { class Program { static void Main(string[] args) { int[] array = { 0, 0, 0, 0, 0 }; array[0] = int.Parse(Console.ReadLine()); array[1] = int.Parse(Console.ReadLine()); array[2] = int.Parse(Console.ReadLine()); array[3] = int.Parse(Console.ReadLine()); array[4] = int.Parse(Console.ReadLine()); int k = int.Parse(Console.ReadLine()); int di = Math.Abs(array[0] - array[4]); if (di > k) { Console.WriteLine(":("); } else { Console.WriteLine("Yay!"); } } static void MainStream() {} } }
[["-", 8, 201, 0, 195, 8, 196, 0, 7, 0, 88], ["-", 8, 201, 0, 195, 8, 196, 0, 7, 0, 24], ["-", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 7, 0, 35], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["-", 0, 195, 8, 196, 0, 7, 26, 223, 0, 22], ["-", 0, 195, 8, 196, 0, 7, 26, 223, 0, 29], ["-", 8, 201, 0, 195, 8, 196, 0, 7, 0, 25], ["-", 0, 195, 8, 196, 0, 7, 8, 196, 0, 45], ["-", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 0, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 16, 12, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["-", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["-", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
8
211
27
using System; using System.Collections.Generic; public class B { public static void Main() { long[] time = new long[5]; for (int i = 0; i < 5; i++) time[i] = Int64.Parse(Console.ReadLine()); long muda = 9; long result = 0; for (int i = 0; i < 5; i++) { if ((time[i] % 10) == 0) { result += time[i]; } else { result += ((time[i] + 10) / 10) * 10; muda = Math.Min(muda, time[i] % 10); } } result -= (10 - muda); Console.WriteLine(result); } }
using System; using System.Collections.Generic; public class B { public static void Main() { long[] time = new long[5]; for (int i = 0; i < 5; i++) time[i] = Int64.Parse(Console.ReadLine()); long muda = 9; long result = 0; bool just = true; for (int i = 0; i < 5; i++) { if ((time[i] % 10) == 0) { result += time[i]; } else { just = false; result += ((time[i] + 10) / 10) * 10; muda = Math.Min(muda, time[i] % 10); } } if (!just) result -= (10 - muda); Console.WriteLine(result); } }
[["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 211, 0, 146], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 75, 196, 0, 1, 0, 11, 12, 211, 0, 147], ["+", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 241, 0, 111], ["+", 0, 195, 8, 196, 0, 57, 15, 241, 0, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25]]
8
163
14
using System; using System.Collections.Generic; using System.Linq; using System.Text; public class AtCoderB { static void Main() { var sc = new Scanner(); int[] n = new int[] { sc.NextInt(), sc.NextInt(), sc.NextInt(), sc.NextInt(), sc.NextInt() }; int answer = 0; int minMod = int.MaxValue; for (int i = 0; i < 5; i++) { int mod = n[i] % 10; if (mod == 0) { mod = 10; } answer += 10 * (n[i] / 10) + mod % 10; } answer = answer - 10 + minMod; Console.WriteLine(answer); } class Scanner { private string[] _line; private int _index; private const char Separator = ' '; public Scanner() { _line = new string[0]; _index = 0; } public string Next() { while (_index >= _line.Length) { _line = Console.ReadLine().Split(Separator); _index = 0; } return _line[_index++]; } public int NextInt() => int.Parse(Next()); public long NextLong() => long.Parse(Next()); public double NextDouble() => double.Parse(Next()); public decimal NextDecimal() => decimal.Parse(Next()); public char NextChar() => Next()[0]; public char[] NextCharArray() => Next().ToCharArray(); public string[] Array() { _line = Console.ReadLine().Split(Separator); _index = _line.Length; return _line; } public int[] IntArray() => Array().Select(int.Parse).ToArray(); public long[] LongArray() => Array().Select(long.Parse).ToArray(); public double[] DoubleArray() => Array().Select(double.Parse).ToArray(); public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray(); } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; public class AtCoderB { static void Main() { var sc = new Scanner(); int[] n = new int[] { sc.NextInt(), sc.NextInt(), sc.NextInt(), sc.NextInt(), sc.NextInt() }; int answer = 0; int minMod = int.MaxValue; for (int i = 0; i < 5; i++) { int mod = n[i] % 10; if (mod == 0) { mod = 10; } minMod = Math.Min(minMod, mod); answer += 10 * ((n[i] + 9) / 10); } answer = answer - 10 + minMod; Console.WriteLine(answer); } class Scanner { private string[] _line; private int _index; private const char Separator = ' '; public Scanner() { _line = new string[0]; _index = 0; } public string Next() { while (_index >= _line.Length) { _line = Console.ReadLine().Split(Separator); _index = 0; } return _line[_index++]; } public int NextInt() => int.Parse(Next()); public long NextLong() => long.Parse(Next()); public double NextDouble() => double.Parse(Next()); public decimal NextDecimal() => decimal.Parse(Next()); public char NextChar() => Next()[0]; public char[] NextCharArray() => Next().ToCharArray(); public string[] Array() { _line = Console.ReadLine().Split(Separator); _index = _line.Length; return _line; } public int[] IntArray() => Array().Select(int.Parse).ToArray(); public long[] LongArray() => Array().Select(long.Parse).ToArray(); public double[] DoubleArray() => Array().Select(double.Parse).ToArray(); public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray(); } }
[["+", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 205, 22], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["+", 0, 11, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 24], ["+", 12, 23, 0, 16, 31, 23, 0, 16, 17, 72], ["+", 12, 23, 0, 16, 31, 23, 0, 16, 12, 203], ["+", 12, 16, 12, 23, 0, 16, 31, 23, 0, 25], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["-", 0, 1, 0, 11, 12, 16, 12, 16, 31, 22], ["-", 0, 1, 0, 11, 12, 16, 12, 16, 17, 109], ["-", 0, 1, 0, 11, 12, 16, 12, 16, 12, 203]]
8
457
19
using System; using System.Collections.Generic; using System.Numerics; using System.Linq; namespace AtCoderTemplate { class Program { static void Main(string[] args) { var a = Scanner.rescanint(5); var b = a.Where(x => x[0] % 10 == 0).ToArray(); var c = a.Where(x => x[0] % 10 != 0) .OrderByDescending(x => x[0] % 10) .ToArray(); var res = 0; for (var i = 0; i < c.Length - 1; i++) res += c[i][0] + (10 - c[i][0] % 10); for (var i = 0; i < b.Length; i++) res += b[i][0]; Console.WriteLine(res + c[c.Length - 1][0]); } } public class Scanner { public static string[] scan => Console.ReadLine().Split(' '); public static int[] scanint => Array.ConvertAll(scan, int.Parse); public static long[] scanlong => Array.ConvertAll(scan, long.Parse); public static string[][] rescan(int n) => Enumerable.Repeat(0, n).Select(_ => scan).ToArray(); public static int[][] rescanint(int n) => Enumerable.Repeat(0, n).Select(_ => scanint).ToArray(); public static long[][] rescanlong(int n) => Enumerable.Repeat(0, n).Select(_ => scanlong).ToArray(); } public class Ex { public static int[] subarr(int[] arr, int begin, int n) { int[] a = new int[arr.Length]; Array.Copy(arr, begin, a, 0, n); return a; } } }
using System; using System.Collections.Generic; using System.Numerics; using System.Linq; namespace AtCoderTemplate { class Program { static void Main(string[] args) { var a = Scanner.rescanint(5); var b = a.Where(x => x[0] % 10 == 0).ToArray(); var c = a.Where(x => x[0] % 10 != 0) .OrderByDescending(x => x[0] % 10) .ToArray(); var res = 0; for (var i = 0; i < c.Length - 1; i++) res += c[i][0] + (10 - c[i][0] % 10); for (var i = 0; i < b.Length; i++) res += b[i][0]; if (c.Length != 0) Console.WriteLine(res + c[c.Length - 1][0]); else Console.WriteLine(res); } } public class Scanner { public static string[] scan => Console.ReadLine().Split(' '); public static int[] scanint => Array.ConvertAll(scan, int.Parse); public static long[] scanlong => Array.ConvertAll(scan, long.Parse); public static string[][] rescan(int n) => Enumerable.Repeat(0, n).Select(_ => scan).ToArray(); public static int[][] rescanint(int n) => Enumerable.Repeat(0, n).Select(_ => scanint).ToArray(); public static long[][] rescanlong(int n) => Enumerable.Repeat(0, n).Select(_ => scanlong).ToArray(); } public class Ex { public static int[] subarr(int[] arr, int begin, int n) { int[] a = new int[arr.Length]; Array.Copy(arr, begin, a, 0, n); return a; } } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 205, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 0, 131], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 141, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 79], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 57, 75, 1, 0, 213, 63, 214, 205, 22], ["+", 0, 57, 75, 1, 0, 213, 63, 214, 0, 131], ["+", 0, 57, 75, 1, 0, 213, 63, 214, 141, 22], ["+", 0, 57, 75, 1, 0, 213, 3, 4, 0, 24], ["+", 75, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
8
415
16
using System; namespace ABC123 { class B { static void Main(string[] args) { int res = 0; int max = 10; int ll = 0; int l = 0; for (int i = 0; i < 5; i++) { ll = int.Parse(Console.ReadLine()); l = ll % 10; if (0 < l) { max = Math.Min(max, l); } res += ll + (10 - l); } Console.WriteLine(res - (10 - max)); } } }
using System; namespace ABC123 { class B { static void Main(string[] args) { int res = 0; int max = 10; int ll = 0; int l = 0; for (int i = 0; i < 5; i++) { ll = int.Parse(Console.ReadLine()); l = ll % 10; if (0 < l) { max = Math.Min(max, l); res += ll + (10 - l); } else { res += ll; } } Console.WriteLine(res - (10 - max)); } } }
[["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 12, 22], ["+", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 46]]
8
119
9
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace AtCoder { public class Program { static void Main(string[] args) { int[] dishes = new int[5]; for (int i = 0; i < 5; i++) { dishes[i] = int.Parse(Console.ReadLine()); } int ans = 0; int min = 0; for (int i = 0; i < 5; i++) { int m = dishes[i] % 10; ans += dishes[i]; if (m > 0) { ans += 10 - m; if (min == 0 || min > m) { min = m; } } } ans = ans - (10 - min); Console.WriteLine(ans); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace AtCoder { public class Program { static void Main(string[] args) { int[] dishes = new int[5]; for (int i = 0; i < 5; i++) { dishes[i] = int.Parse(Console.ReadLine()); } int ans = 0; int min = 0; for (int i = 0; i < 5; i++) { int m = dishes[i] % 10; ans += dishes[i]; if (m > 0) { ans += 10 - m; if (min == 0 || min > m) { min = m; } } } if (min > 0) { ans -= (10 - min); } Console.WriteLine(ans); } } }
[["-", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 110], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
8
173
12
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Text.RegularExpressions; namespace AIZUproject07 { class Program { // static string T; /*static void Main() { int count = 0; bool flag = false; string In = Console.ReadLine(); string[] s = Console.ReadLine().Split(); int[] aa = s.Select(int.Parse).ToArray(); while (true) { for (int i = 0; i < aa.Length; i++) { if (aa[i] % 2 != 0) { flag = true; } } aa = aa.Select(n => n / 2).ToArray(); if (flag == true) break; count++; } Console.WriteLine(count); }*/ /*static void Main() { int sum = 0; int count = 0; string A = Console.ReadLine(); string B = Console.ReadLine(); string C = Console.ReadLine(); string D = Console.ReadLine(); int AA = int.Parse(A); int BB = int.Parse(B); int CC = int.Parse(C); int DD = int.Parse(D); for(int i = 0;i<=AA;i++) { for (int j=0;j<=BB;j++) { for (int k =0;k<=CC;k++) { sum = i * 500 + j * 100 + k * 50; if (sum == DD) count++; } } } Console.WriteLine(count); }*/ /*static void Main() { int ans1 = 0; int ans2 = 0; string[] s = Console.ReadLine().Split(); int[] intArray = s.Select(int.Parse).ToArray(); for (int i = 1;i<=intArray[0];i++) { ans1 = 0; if (i >= 10 && i <100) { var aaa = i % 10; var bbb = i / 10; ans1 = aaa + bbb; if (intArray[1] <= ans1 && ans1 <= intArray[2]) { ans2 += i; } } if (i >= 100 && i<1000) { var aaa = i % 10; var bbb = i / 10; var ccc = bbb % 10; var ddd = bbb / 10; ans1 = aaa + ccc + ddd; if (intArray[1] <= ans1 && ans1 <= intArray[2]) { ans2 += i; } } if (i >= 1000 && i <10000) { var aaa = i % 10;//4 var bbb = i / 10; var ccc = bbb % 10;//3 var ddd = bbb / 10; var eee = ddd % 10;//2 var fff = ddd / 10;//1 ans1 = aaa + ccc + eee + fff; if (intArray[1] <= ans1 && ans1 <= intArray[2]) { ans2 += i; } } if (i == 10000) { ans1 = 1; if (intArray[1] <= ans1 && ans1 <= intArray[2]) { ans2 += i; } } if (i < 10) { ans1 = i; if (intArray[1] <= ans1 && ans1 <= intArray[2]) { ans2 += i; } } } Console.WriteLine(ans2); }*/ /*static void Main() { int sum = 0; bool test = false; string[] aa = Console.ReadLine().Split(); int N = int.Parse(aa[0]); int Y = int.Parse(aa[1]); int Yukichi = Y / 10000; int Ichiyo = Y / 5000; int Hideyo = Y / 1000; int x = 0; int y = 0; int z = 0; for (int i = 0;i<=Yukichi;i++) { for (int j =0;j<=Ichiyo;j++) { for (int k =0;k<=Hideyo;k++) { sum = 10000 * i + 5000 * j + 1000 * k; if (sum == Y && i+j+k < N) { x = i; y = j; z = k; //Console.WriteLine(i + " " + j + " " + k); test = true; } } } } if (test == true) { Console.WriteLine(x + " " + y + " " + z); } if (test == false) { Console.WriteLine("-1 -1 -1"); } }*/ /*static void Main() { string[] aa = Console.ReadLine().Split(); int N = int.Parse(aa[0]); int Y = int.Parse(aa[1]); int X = 0; int Z = 0; int b = 0; int d = 0; X = Y / 10000; var a = Y - (X*10000); if (a != 0 || Y < 10000) { b = a / 5000; var cc = a - (b * 5000); if (cc != 0 || a < 5000) { d = cc / 1000; var gg = cc - (d * 1000); if (gg != 0 || cc<1000) { Console.WriteLine("-1 -1 -1"); } else if (X + b + d <= N) { Console.WriteLine(X + " " + b + " " + d); } else if (X + b + d > N) { Console.WriteLine("-1 -1 -1"); } } else if (X + b <= N) { Console.WriteLine(X +" "+ b +" "+"0"); } else if (X + b > N) { Console.WriteLine("-1 -1 -1"); } } else if (X <= N) { Console.WriteLine(X +" "+0+" "+0); } else if (X>N) { Console.WriteLine("-1 -1 -1"); } }*/ /*static void Main() { string s = Console.ReadLine(); var Ans = s.Replace("eraser", "").Replace("dreamer", "").Replace("dreamer", "").Replace("erase", "").ToString(); if (Ans == null) Console.WriteLine("YES"); else Console.WriteLine("NO");*/ // List<string> str = new List<string>(); || s.Substring(5, 1) == "" // string NN = new string(s); || s.Substring(5,1) == "" /*while (true) { while (true) { if (s.StartsWith("dream") && (s.Substring(5,2) != "er" )) { count++; var f = s.Remove(0, 5); s = f; break; } if (s.StartsWith("dreamer")) { var n = s.Remove(0, 7); s = n; break; } if (s.StartsWith("erase") || (s.Substring(5,1) != "r" )) { count2++; var f1 = s.Remove(0, 5); s = f1; break; } if (s.StartsWith("eraser")) { var f2 = s.Remove(0, 6); s = f2; break; } else { tt = true; break; } } if (s.Length == 0) { Console.WriteLine("YES"); break; } if (tt) { Console.WriteLine("NO"); break; } }*/ // Console.WriteLine(count+","+count2); //} // 86C /*static void Main() { /*string aa = Console.ReadLine(); List<int[]> nn = new List<int[]>(); for (int i = 0;i<aa.Length;i++) { string[] str = Console.ReadLine().Split(); int[] intstr = str.Select(int.Parse).ToArray(); nn.Add(intstr); } var a1 = Console.ReadLine().Split().Select(int.Parse).ToArray(); var num = a1[0]; var list = new List<int[]>(num); for (int i=0;i<num;i++) { } }*/ /*static void Main(string[] args) { var input = Console.ReadLine().Split(' '); var array = input.Select(int.Parse).ToArray(); int num = array[0] * 100 + array[1] * 10 + array[2] * 1; if (num % 4 == 0) { Console.WriteLine("YES"); } else { Console.WriteLine("NO"); } }*/ /*static void Main() { var input = Console.ReadLine(); var a = Console.ReadLine(); int N = int.Parse(input); int A = int.Parse(a); bool flag = false; for (int i = 0;i <= A;i++ ) { var Ans = N - i; if (Ans % 500 == 0) { Console.WriteLine("Yes"); flag = true; break; } } if (flag == false) { Console.WriteLine("No"); } }*/ /*static void Main() { var a = Console.ReadLine().Split(); double[] integer = a.Select(double.Parse).ToArray(); double ans = (integer[0] + integer[1]) / 2; Console.WriteLine(Math.Ceiling(ans)); }*/ /*static void Main() { int count = 0; string str = Console.ReadLine(); //var cross = str.Select(n => n != '×'); //var circle = str.Select(n => n != 'o'); //Console.WriteLine(cross); //Console.WriteLine(circle); /*Console.WriteLine(str.Length); while (true) { Match match1 = Regex.Match(str, "o"); if (match1 != null) { count++; } str = str.Substring(match1.Index+1, str.Length); if (match1.Index == str.Length) { break; } } var Ans = 700 + count * 100; Console.WriteLine(Ans);*/ // Console.WriteLine(match.Value); /*or (int i =0;i<str.Length;i++) { if (Regex.Match(str[i], "o")) { } } count = str.Length - str.Replace("o", "").Length; var Ans = 700 + count * 100; Console.WriteLine(Ans); }*/ /*static void Main() { var str = Console.ReadLine(); var Ans = str.Replace("2017","2018"); Console.WriteLine(Ans); }*/ /*static void Main() { var str = Console.ReadLine(); //str.Substring(0, 1) + Console.WriteLine(str.Substring(0, 1) + (str.Length-2) + str.Substring(str.Length-1)); }*/ // 82B /*static void Main() { var s = Console.ReadLine(); var t = Console.ReadLine(); char[] S = s.ToArray(); char[] T = t.ToArray(); Array.Sort(S); Array.Sort(T);Array.Reverse(T); string ss = new string(S); string ts = new string(T); if (ss.CompareTo(ts) < 0) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); }*/ // sに関してソート /*for (int i = 0; i < s.Length; i++) { }*/ // var hoge = s.OrderByDescending((x) => x.Value); /*List<int> array = new List<int>(); int[] rank = new int[s.Length]; for (int i = 0; i < s.Length; i++) { rank[i] = 0; } for (int i = 0; i < s.Length; i++) { for (int j = 0; j < s.Length; j++) { if (s[i] > s[j]) { rank[i]++; } } } for (int i=0;i<s.Length;i++) { for (int j =0;j<s.Length;j++) { if (i == rank[j]) { array.Add(s[i]); } } } for (int i = 0; i < s.Length; i++) { Console.Write(array[i]); } }*/ /*static void Main() { int count; int temp = 0; var N = int.Parse(Console.ReadLine()); List<int> aa = new List<int>(); for (int i = 1; i <= N; i++) { count = 0; temp = i; while (true) { var Ans = temp / 2; var Ans2 = temp % 2; if (Ans2 == 0) { count++; temp = Ans; } else { break; } } aa.Add(count); } //Program program = new Program(); //program.Max(aa, temp); var max = aa.IndexOf(aa.Max()); Console.WriteLine(max+1); } public void Max(List<int> array,int num) { var Ans3 = array.Max(); }*/ /*static void Main() { List<int> array = new List<int>(); var N = Console.ReadLine(); int[] A = Console.ReadLine().Split().Select(int.Parse).ToArray(); for (int i = 0;i<A.Length;i++) { for (int j = 0; j< A.Length; j++) { var ans = A[i] - A[j]; if (ans < 0) { ans = Math.Abs(ans); } //Console.Write(ans); array.Add(ans); } //Console.WriteLine(); } Console.WriteLine(array.Max()); }*/ /*static void Main() { var N = Console.ReadLine(); int[] temperture = Console.ReadLine().Split().Select(int.Parse).ToArray(); int[] height = Console.ReadLine().Split().Select(int.Parse).ToArray(); int T = temperture[0]; int A = temperture[1]; List<double> aa = new List<double>(); List<double> bb = new List<double>(); for (int i = 0;i<height.Length;i++) { var temp = T - height[i] * 0.006; aa.Add(temp); } for (int i =0;i<height.Length;i++) { var temp = A - aa[i]; if (temp < 0) { temp = Math.Abs(temp); } bb.Add(temp); } Console.WriteLine(bb.IndexOf(bb.Min())+1); }*/ /*static void Main() { string a = Console.ReadLine(); char[] charArray = a.ToArray(); List<char> aa = new List<char>(); for (int i = 0;i<charArray.Length;i++) { if ((i+1)%2 == 1) { aa.Add(charArray[i]); } } var str = string.Join("",aa); Console.WriteLine(str); }*/ // 053B /*static void Main() { var str = Console.ReadLine(); var start = str.IndexOf("A"); var goal = str.IndexOf("Z",start); string temp = new string(str.Substring(goal).ToArray()); int goalpoint = 0; List<int> kk = new List<int>(); while (true) { if (temp.Contains("Z")) { goalpoint = temp.IndexOf("Z") +1; temp = temp.Replace("Z", ""); } if (temp.Contains("Z") == false) { break; } if(temp.Contains("Z")) { Console.WriteLine(); } } for (int i = 0;i<temp.Length;i++) { if (temp[i] == 'Z') { goalpoint = i; } } var ans = str.Substring(start, goal-start).Length + 1 + goalpoint; Console.WriteLine(ans); }*/ // 095B /*static void Main() { var a = Console.ReadLine().Split().Select(int.Parse).ToArray(); int N = a[0]; int X = a[1]; List<int> listarray = new List<int>(); int Ans = 0; for (int i =0;i < N;i++) { var temp = Console.ReadLine(); int temp1 = int.Parse(temp); listarray.Add(temp1); } for (int i =0;i< N;i++) { X = X - listarray[i]; if (X >= 0) { Ans++; } } if (X > 0) { while (true) { X = X - listarray.Min(); if (X < 0) { break; } Ans++; } } Console.WriteLine(Ans); }*/ // 105B /*static void Main() { int dunats = 7; int cake = 4; int sum = 0; bool flag = false; int N = int.Parse(Console.ReadLine()); if (N > 3) { for (int i = 0; i <= N / cake; i++) { for (int j=0; j<=N/dunats;j++) { sum = dunats * j + cake * i; if (sum == N) { flag = true; } if (flag == true) { break; } } if (flag == true) { break; } } } if (flag == true) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } }*/ // 004A /*static void Main() { List<double> Ans = new List<double>(); List<int[]> array = new List<int[]>(); int N = int.Parse(Console.ReadLine()); for (int i = 0; i < N; i++) { int[] aa = Console.ReadLine().Split().Select(int.Parse).ToArray(); array.Add(aa); } for (int i=0;i<N;i++) { for (int j = 0;j<N;j++) { var X = array[i][0] - array[j][0]; var Y = array[i][1] - array[j][1]; var resultX = Math.Pow(X, 2); var resultY = Math.Pow(Y, 2); var ans = Math.Sqrt(resultX + resultY); Ans.Add(ans); } } var finalresult = Ans.Max(); Console.WriteLine(finalresult); }*/ // 51B /*static void Main() { int count = 0; int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray(); int K = input[0]; int S = input[1]; for (int x =0;x<= K;x++) { for (int y = 0; y <= K; y++) { var z = S - x - y; if ( 0 <= z && z <= K) { count++; } } } Console.WriteLine(count); }*/ // 80B /*static void Main() { int Ans = 0; string x = Console.ReadLine(); int X = int.Parse(x); for (int i =0;i<x.Length;i++) { var temp = Convert.ToInt32(x[i].ToString()); Ans += temp; } if (X % Ans == 0) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } }*/ // 90B /*static void Main() { int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray(); int A = input[0]; int B = input[1]; int aaa = 0; int count = 1; int ko = 0; string ans =""; StringBuilder sb = new StringBuilder(); while(true) { string X = A.ToString(); count = 1; ans = ""; //Console.WriteLine(X[X.Length - count]); while (true) { //sb = null; sb.Append(X[X.Length - count]); if (X.Length - count == 0) { ans = sb.ToString(); break; } count++; } sb.Remove(0,X.Length); aaa = int.Parse(ans); //Console.WriteLine(aaa); if (A == aaa) { ko++; } if (A == B) { break; } A++; } Console.WriteLine(ko); }*/ // 25A /*static void Main() { int ansA = 0; int ansB = 0; int N = int.Parse(Console.ReadLine()); List<int> Ans = new List<int>(); for (int A = 1;A<N;A++) { int B = N - A; List<int> la = new List<int>(); List<int> lb = new List<int>(); ansA = 0; ansB = 0; string a = A.ToString(); string b = B.ToString(); for (int i =0;i<a.Length;i++) { char ca = a[i]; int intca = Convert.ToInt32(ca.ToString()); la.Add(intca); } for (int i=0;i<b.Length;i++) { char cb = b[i]; int intcb = Convert.ToInt32(cb.ToString()); lb.Add(intcb); } foreach(int n in la) { ansA += n; } foreach (int n in lb) { ansB += n; } Ans.Add(ansA + ansB); } Console.WriteLine(Ans.Min()); }*/ // 67B /*static void Main() { int Ans = 0; List<int> array = new List<int>(); int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray(); int N = input[0]; int K = input[1]; int[] length = Console.ReadLine().Split().Select(int.Parse).ToArray(); //int[] newone = new int[length.Length]; Array.Sort(length); Array.Reverse(length); for (int i = 0;i<K;i++) { array.Add(length[i]); Ans += length[i]; } Console.WriteLine(Ans); }*/ // 42B /*static void Main() { int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray(); int N = input[0]; int L = input[1]; string[] str = new string[N]; for (int i=0;i<N;i++) { var a = Console.ReadLine(); str[i] = a; } StringComparer cmp = StringComparer.OrdinalIgnoreCase; Array.Sort(str,cmp); List<string> Ans = new List<string>(); for (int i = 0;i<N;i++) { Ans.Add(string.Concat(str[i])); } StringBuilder sb = new StringBuilder(); for (int i = 0;i<N;i++) { sb.Append(Ans[i]); sb.Append(string.Concat(str[i])); } Console.WriteLine(sb); }*/ // 27A /*static void Main() { int count = 0; int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray(); int N = input[0]; int x = input[1]; var a = Console.ReadLine().Split().Select(int.Parse).ToArray(); foreach (int i in a.OrderBy(nn => nn)) { x -= i; if (x >= 0) { count++; } if(x < 0) { break; } } if (x > 0) { count--; } Console.WriteLine(count); }*/ // 12A /*static void Main() { int Ans = 0; int N = int.Parse(Console.ReadLine()); int[] Aarray = Console.ReadLine().Split().Select(int.Parse).ToArray(); Array.Sort(Aarray); Array.Reverse(Aarray); Array.Clear(Aarray, 0, N); for (int i = N;i< 2*N; i++) { Ans += Aarray[i]; } Console.WriteLine(Ans); }*/ /*static void Main() { int o = 0; string Ans; string input = Console.ReadLine(); string alphabet = "abcdefghijklmnopqrstuvwxyz"; for (int i = 0;i< input.Length;i++) { char temp = input[i]; string ans = string.Join("", temp); if (alphabet.Contains(ans)) { alphabet = alphabet.Replace(ans,""); //o = alphabet.Length - alphabet.Replace(ans, "").Length; } } if (alphabet == "") { Console.WriteLine("None"); } else { Console.WriteLine(alphabet.Min()); //alphabet.Min() } }*/ // 61B /*static void Main() { int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray(); int N = input[0]; int M = input[1]; List<int[]> map = new List<int[]>(); for (int i =0;i<M;i++) { int[] road = Console.ReadLine().Split().Select(int.Parse).ToArray(); map.Add(road); } List<int> ans = new List<int>(); for (int i = 0;i< N;i++) { ans.Add(0); } for (int i = 0; i<N;i++) { var ff = i+1; foreach (int[] n in map) { for (int j = 0; j < 2; j++) { if (n[j] == ff) { ans[i]++; } } } } for (int i=0;i<N; i++) { Console.WriteLine(ans[i]); } }*/ // 47B /*static void Main() { int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray(); int X = input[0]; int Y = input[1]; int N = input[2]; int[,] map = new int[X+1,Y+1]; for (int i =0;i<N;i++) { int[] input2 = Console.ReadLine().Split().Select(int.Parse).ToArray(); int x = input2[0]; int y = input2[1]; int a = input2[2]; switch (a) { case 1: for (int ty =0;ty<Y;ty++) { for (int j = 0; j <x; j++) { map[j, ty] += 1; } } break; case 2: for (int ty = 0; ty < Y; ty++) { for (int j = x; j < X; j++) { map[j, ty] += 1; } } break; case 3: for (int tx = 0; tx < X; tx++) { for (int j = 0; j < y; j++) { map[tx, j] += 1; } } break; case 4: for (int tx = 0; tx < X; tx++) { for (int j = y; j < Y; j++) { map[tx, j] += 1; } } break; } } int count = 0; for (int i = 0;i<X;i++) { for (int j = 0;j<Y;j++) { if (map[i,j] == 0) { count++; } } } Console.WriteLine(count); }*/ // 91B /*static void Main() { bool ji = false; int N = int.Parse(Console.ReadLine()); List<string> bluewords = new List<string>(); List<string> redwords = new List<string>(); for (int i = 0; i < N;i++) { var temp = Console.ReadLine(); bluewords.Add(temp); } int M = int.Parse(Console.ReadLine()); for (int i = 0; i < M; i++) { var temp = Console.ReadLine(); redwords.Add(temp); } List<KeyValuePair<int,string>> countBlue = new List<KeyValuePair<int, string>>(); int a = 0; foreach (string n in bluewords) { foreach (string l in bluewords) { if (n == l) { a++; } } KeyValuePair<int, string> tempKey = new KeyValuePair<int, string>(a,n); countBlue.Add(tempKey); a = 0; } countBlue.Sort((w, x) => x.Key - w.Key); List<KeyValuePair<int, string>> countRed = new List<KeyValuePair<int, string>>(); int b = 0; foreach (string n in redwords) { foreach (string l in redwords) { if (n == l) { b++; } } KeyValuePair<int, string> tempKey1 = new KeyValuePair<int, string>(b, n); countRed.Add(tempKey1); b = 0; } countRed.Sort((w, x) => x.Key - w.Key); List<int> ans = new List<int>(); int countt = 0; foreach (var blue in countBlue) { foreach (var red in countRed) { countt = 0; var andss = new List<bool>(countRed.Select(d => d.Value == blue.Value)); foreach (var tt in andss) { var ee = tt; if (ee == false) { countt++; } } if (blue.Value == red.Value) { var Ans = blue.Key - red.Key; ans.Add(Ans); break; } else if(countt == andss.Count) { var Ans = blue.Key; ans.Add(Ans); } } } if (ans.Max() <= 0) { Console.WriteLine("0"); } else { Console.WriteLine(ans.Max()); } }*/ // 130コンテスト /*static void Main() { int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray(); int X = input[0]; int A = input[1]; if (X < A) { Console.WriteLine("0"); } else { Console.WriteLine("10"); } }*/ // 130B /*static void Main() { int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray(); int[] Xarray = Console.ReadLine().Split().Select(int.Parse).ToArray(); int N = input[0]; int X = input[1]; List<int> Ans = new List<int>(); List<int> Ans1 = new List<int>(); int ans = 0; Ans.Add(ans); for (int i = 0; i < Xarray.Length; i++) { ans += Xarray[i]; Ans.Add(ans); } foreach (int a in Ans) { if (a <= X) { Ans1.Add(a); } } Console.WriteLine(Ans1.Count); }*/ // 130C /*static void Main() { double[] input = Console.ReadLine().Split().Select(double.Parse).ToArray(); double W = input[0]; double H = input[1]; double x = input[2]; double y = input[3]; double temp1 = W * H/2; var ans = temp1; int ans2 = 0; if (x == W/2 && y== H/2) { ans2 = 1; } else { ans2 = 0; } Console.WriteLine(ans+" "+ans2); }*/ // 130D /*static void Main() { int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray(); int N = input[0]; int K = input[1]; int[] Aarray = Console.ReadLine().Split().Select(int.Parse).ToArray(); int Answer = 0; int AnsCount = 0; for (int i = 0;i< N;i++) { Answer += Aarray[i]; for (int j = i+1;j<N;j++) { Answer += Aarray[j]; if (Answer >= K) { AnsCount++; AnsCount+=Aarray.Length - j; //AnsCount += N - Answer + 1; break; } } Answer = 0; } Console.WriteLine(AnsCount); }*/ // 129B /*static void Main() { int N = int.Parse(Console.ReadLine()); int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray(); int Answer = 0; int Answer2 = 0; List<int> Ans = new List<int>(); for (int i=0;i<array.Length;i++) { Answer += array[i]; for (int j=i+1;j<array.Length;j++) { Answer2 += array[j]; }/* Ans.Add(Math.Abs(Answer - Answer2)); Answer2 = 0; } Console.WriteLine(Ans.Min()); }*/ // 128B /*static void Main() { List<KeyValuePair<string,int>> KeyList = new List<KeyValuePair<string,int>>(); int N = int.Parse(Console.ReadLine()); for (int i =0;i< N;i++) { string[] temp = Console.ReadLine().Split(' '); var mm = new KeyValuePair<string, int>(temp[0],int.Parse(temp[1])); KeyList.Add(mm); } }*/ // 123B static void Main() { List<int> time = new List<int>(); List<int> sample = new List<int>(); List<int> sss = new List<int>(); int[] aa = new int[5]; int[] bb = new int[5]; for (int i = 0; i < 5; i++) { int dish = int.Parse(Console.ReadLine()); time.Add(dish); } time.CopyTo(aa); int ans = 0; foreach (int a in time) { var temp = a % 10; sample.Add(temp); } var count = 0; foreach (int ji in sample) { if (ji != 0) { sss.Add(ji); } else if (ji == 0) { count++; } } if (count == sample.Count) { sss.Add(0); } var jj = sample.IndexOf(sss.Min()); time.RemoveAt(jj); time.Add(aa[jj]); foreach (int n in time) { ans += n; if (ans % 10 != 0) { ans += 10 - (ans % 10); } } ans = ans - (10 - sss.Min()); Console.WriteLine(ans); } } // 128B /*public class Data { public int ID; public string Name; public int Evaluation; public Data(int ID,string Name, int Evaluation) { this.ID = ID; this.Name = Name; this.Evaluation = Evaluation; } } public class Atcoder { static void Main() { int N = int.Parse(Console.ReadLine()); for (int i = 0; i < N; i++) { List<Data> Console.ReadLine(); } List<Data> DataList() { List<Data> Datalist = new List<Data>() { new Data(Name:Console.ReadLine().Split()[0][0],Evaluation:) }; return Datalist; } } }*/ }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Text.RegularExpressions; namespace AIZUproject07 { class Program { // static string T; /*static void Main() { int count = 0; bool flag = false; string In = Console.ReadLine(); string[] s = Console.ReadLine().Split(); int[] aa = s.Select(int.Parse).ToArray(); while (true) { for (int i = 0; i < aa.Length; i++) { if (aa[i] % 2 != 0) { flag = true; } } aa = aa.Select(n => n / 2).ToArray(); if (flag == true) break; count++; } Console.WriteLine(count); }*/ /*static void Main() { int sum = 0; int count = 0; string A = Console.ReadLine(); string B = Console.ReadLine(); string C = Console.ReadLine(); string D = Console.ReadLine(); int AA = int.Parse(A); int BB = int.Parse(B); int CC = int.Parse(C); int DD = int.Parse(D); for(int i = 0;i<=AA;i++) { for (int j=0;j<=BB;j++) { for (int k =0;k<=CC;k++) { sum = i * 500 + j * 100 + k * 50; if (sum == DD) count++; } } } Console.WriteLine(count); }*/ /*static void Main() { int ans1 = 0; int ans2 = 0; string[] s = Console.ReadLine().Split(); int[] intArray = s.Select(int.Parse).ToArray(); for (int i = 1;i<=intArray[0];i++) { ans1 = 0; if (i >= 10 && i <100) { var aaa = i % 10; var bbb = i / 10; ans1 = aaa + bbb; if (intArray[1] <= ans1 && ans1 <= intArray[2]) { ans2 += i; } } if (i >= 100 && i<1000) { var aaa = i % 10; var bbb = i / 10; var ccc = bbb % 10; var ddd = bbb / 10; ans1 = aaa + ccc + ddd; if (intArray[1] <= ans1 && ans1 <= intArray[2]) { ans2 += i; } } if (i >= 1000 && i <10000) { var aaa = i % 10;//4 var bbb = i / 10; var ccc = bbb % 10;//3 var ddd = bbb / 10; var eee = ddd % 10;//2 var fff = ddd / 10;//1 ans1 = aaa + ccc + eee + fff; if (intArray[1] <= ans1 && ans1 <= intArray[2]) { ans2 += i; } } if (i == 10000) { ans1 = 1; if (intArray[1] <= ans1 && ans1 <= intArray[2]) { ans2 += i; } } if (i < 10) { ans1 = i; if (intArray[1] <= ans1 && ans1 <= intArray[2]) { ans2 += i; } } } Console.WriteLine(ans2); }*/ /*static void Main() { int sum = 0; bool test = false; string[] aa = Console.ReadLine().Split(); int N = int.Parse(aa[0]); int Y = int.Parse(aa[1]); int Yukichi = Y / 10000; int Ichiyo = Y / 5000; int Hideyo = Y / 1000; int x = 0; int y = 0; int z = 0; for (int i = 0;i<=Yukichi;i++) { for (int j =0;j<=Ichiyo;j++) { for (int k =0;k<=Hideyo;k++) { sum = 10000 * i + 5000 * j + 1000 * k; if (sum == Y && i+j+k < N) { x = i; y = j; z = k; //Console.WriteLine(i + " " + j + " " + k); test = true; } } } } if (test == true) { Console.WriteLine(x + " " + y + " " + z); } if (test == false) { Console.WriteLine("-1 -1 -1"); } }*/ /*static void Main() { string[] aa = Console.ReadLine().Split(); int N = int.Parse(aa[0]); int Y = int.Parse(aa[1]); int X = 0; int Z = 0; int b = 0; int d = 0; X = Y / 10000; var a = Y - (X*10000); if (a != 0 || Y < 10000) { b = a / 5000; var cc = a - (b * 5000); if (cc != 0 || a < 5000) { d = cc / 1000; var gg = cc - (d * 1000); if (gg != 0 || cc<1000) { Console.WriteLine("-1 -1 -1"); } else if (X + b + d <= N) { Console.WriteLine(X + " " + b + " " + d); } else if (X + b + d > N) { Console.WriteLine("-1 -1 -1"); } } else if (X + b <= N) { Console.WriteLine(X +" "+ b +" "+"0"); } else if (X + b > N) { Console.WriteLine("-1 -1 -1"); } } else if (X <= N) { Console.WriteLine(X +" "+0+" "+0); } else if (X>N) { Console.WriteLine("-1 -1 -1"); } }*/ /*static void Main() { string s = Console.ReadLine(); var Ans = s.Replace("eraser", "").Replace("dreamer", "").Replace("dreamer", "").Replace("erase", "").ToString(); if (Ans == null) Console.WriteLine("YES"); else Console.WriteLine("NO");*/ // List<string> str = new List<string>(); || s.Substring(5, 1) == "" // string NN = new string(s); || s.Substring(5,1) == "" /*while (true) { while (true) { if (s.StartsWith("dream") && (s.Substring(5,2) != "er" )) { count++; var f = s.Remove(0, 5); s = f; break; } if (s.StartsWith("dreamer")) { var n = s.Remove(0, 7); s = n; break; } if (s.StartsWith("erase") || (s.Substring(5,1) != "r" )) { count2++; var f1 = s.Remove(0, 5); s = f1; break; } if (s.StartsWith("eraser")) { var f2 = s.Remove(0, 6); s = f2; break; } else { tt = true; break; } } if (s.Length == 0) { Console.WriteLine("YES"); break; } if (tt) { Console.WriteLine("NO"); break; } }*/ // Console.WriteLine(count+","+count2); //} // 86C /*static void Main() { /*string aa = Console.ReadLine(); List<int[]> nn = new List<int[]>(); for (int i = 0;i<aa.Length;i++) { string[] str = Console.ReadLine().Split(); int[] intstr = str.Select(int.Parse).ToArray(); nn.Add(intstr); } var a1 = Console.ReadLine().Split().Select(int.Parse).ToArray(); var num = a1[0]; var list = new List<int[]>(num); for (int i=0;i<num;i++) { } }*/ /*static void Main(string[] args) { var input = Console.ReadLine().Split(' '); var array = input.Select(int.Parse).ToArray(); int num = array[0] * 100 + array[1] * 10 + array[2] * 1; if (num % 4 == 0) { Console.WriteLine("YES"); } else { Console.WriteLine("NO"); } }*/ /*static void Main() { var input = Console.ReadLine(); var a = Console.ReadLine(); int N = int.Parse(input); int A = int.Parse(a); bool flag = false; for (int i = 0;i <= A;i++ ) { var Ans = N - i; if (Ans % 500 == 0) { Console.WriteLine("Yes"); flag = true; break; } } if (flag == false) { Console.WriteLine("No"); } }*/ /*static void Main() { var a = Console.ReadLine().Split(); double[] integer = a.Select(double.Parse).ToArray(); double ans = (integer[0] + integer[1]) / 2; Console.WriteLine(Math.Ceiling(ans)); }*/ /*static void Main() { int count = 0; string str = Console.ReadLine(); //var cross = str.Select(n => n != '×'); //var circle = str.Select(n => n != 'o'); //Console.WriteLine(cross); //Console.WriteLine(circle); /*Console.WriteLine(str.Length); while (true) { Match match1 = Regex.Match(str, "o"); if (match1 != null) { count++; } str = str.Substring(match1.Index+1, str.Length); if (match1.Index == str.Length) { break; } } var Ans = 700 + count * 100; Console.WriteLine(Ans);*/ // Console.WriteLine(match.Value); /*or (int i =0;i<str.Length;i++) { if (Regex.Match(str[i], "o")) { } } count = str.Length - str.Replace("o", "").Length; var Ans = 700 + count * 100; Console.WriteLine(Ans); }*/ /*static void Main() { var str = Console.ReadLine(); var Ans = str.Replace("2017","2018"); Console.WriteLine(Ans); }*/ /*static void Main() { var str = Console.ReadLine(); //str.Substring(0, 1) + Console.WriteLine(str.Substring(0, 1) + (str.Length-2) + str.Substring(str.Length-1)); }*/ // 82B /*static void Main() { var s = Console.ReadLine(); var t = Console.ReadLine(); char[] S = s.ToArray(); char[] T = t.ToArray(); Array.Sort(S); Array.Sort(T);Array.Reverse(T); string ss = new string(S); string ts = new string(T); if (ss.CompareTo(ts) < 0) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); }*/ // sに関してソート /*for (int i = 0; i < s.Length; i++) { }*/ // var hoge = s.OrderByDescending((x) => x.Value); /*List<int> array = new List<int>(); int[] rank = new int[s.Length]; for (int i = 0; i < s.Length; i++) { rank[i] = 0; } for (int i = 0; i < s.Length; i++) { for (int j = 0; j < s.Length; j++) { if (s[i] > s[j]) { rank[i]++; } } } for (int i=0;i<s.Length;i++) { for (int j =0;j<s.Length;j++) { if (i == rank[j]) { array.Add(s[i]); } } } for (int i = 0; i < s.Length; i++) { Console.Write(array[i]); } }*/ /*static void Main() { int count; int temp = 0; var N = int.Parse(Console.ReadLine()); List<int> aa = new List<int>(); for (int i = 1; i <= N; i++) { count = 0; temp = i; while (true) { var Ans = temp / 2; var Ans2 = temp % 2; if (Ans2 == 0) { count++; temp = Ans; } else { break; } } aa.Add(count); } //Program program = new Program(); //program.Max(aa, temp); var max = aa.IndexOf(aa.Max()); Console.WriteLine(max+1); } public void Max(List<int> array,int num) { var Ans3 = array.Max(); }*/ /*static void Main() { List<int> array = new List<int>(); var N = Console.ReadLine(); int[] A = Console.ReadLine().Split().Select(int.Parse).ToArray(); for (int i = 0;i<A.Length;i++) { for (int j = 0; j< A.Length; j++) { var ans = A[i] - A[j]; if (ans < 0) { ans = Math.Abs(ans); } //Console.Write(ans); array.Add(ans); } //Console.WriteLine(); } Console.WriteLine(array.Max()); }*/ /*static void Main() { var N = Console.ReadLine(); int[] temperture = Console.ReadLine().Split().Select(int.Parse).ToArray(); int[] height = Console.ReadLine().Split().Select(int.Parse).ToArray(); int T = temperture[0]; int A = temperture[1]; List<double> aa = new List<double>(); List<double> bb = new List<double>(); for (int i = 0;i<height.Length;i++) { var temp = T - height[i] * 0.006; aa.Add(temp); } for (int i =0;i<height.Length;i++) { var temp = A - aa[i]; if (temp < 0) { temp = Math.Abs(temp); } bb.Add(temp); } Console.WriteLine(bb.IndexOf(bb.Min())+1); }*/ /*static void Main() { string a = Console.ReadLine(); char[] charArray = a.ToArray(); List<char> aa = new List<char>(); for (int i = 0;i<charArray.Length;i++) { if ((i+1)%2 == 1) { aa.Add(charArray[i]); } } var str = string.Join("",aa); Console.WriteLine(str); }*/ // 053B /*static void Main() { var str = Console.ReadLine(); var start = str.IndexOf("A"); var goal = str.IndexOf("Z",start); string temp = new string(str.Substring(goal).ToArray()); int goalpoint = 0; List<int> kk = new List<int>(); while (true) { if (temp.Contains("Z")) { goalpoint = temp.IndexOf("Z") +1; temp = temp.Replace("Z", ""); } if (temp.Contains("Z") == false) { break; } if(temp.Contains("Z")) { Console.WriteLine(); } } for (int i = 0;i<temp.Length;i++) { if (temp[i] == 'Z') { goalpoint = i; } } var ans = str.Substring(start, goal-start).Length + 1 + goalpoint; Console.WriteLine(ans); }*/ // 095B /*static void Main() { var a = Console.ReadLine().Split().Select(int.Parse).ToArray(); int N = a[0]; int X = a[1]; List<int> listarray = new List<int>(); int Ans = 0; for (int i =0;i < N;i++) { var temp = Console.ReadLine(); int temp1 = int.Parse(temp); listarray.Add(temp1); } for (int i =0;i< N;i++) { X = X - listarray[i]; if (X >= 0) { Ans++; } } if (X > 0) { while (true) { X = X - listarray.Min(); if (X < 0) { break; } Ans++; } } Console.WriteLine(Ans); }*/ // 105B /*static void Main() { int dunats = 7; int cake = 4; int sum = 0; bool flag = false; int N = int.Parse(Console.ReadLine()); if (N > 3) { for (int i = 0; i <= N / cake; i++) { for (int j=0; j<=N/dunats;j++) { sum = dunats * j + cake * i; if (sum == N) { flag = true; } if (flag == true) { break; } } if (flag == true) { break; } } } if (flag == true) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } }*/ // 004A /*static void Main() { List<double> Ans = new List<double>(); List<int[]> array = new List<int[]>(); int N = int.Parse(Console.ReadLine()); for (int i = 0; i < N; i++) { int[] aa = Console.ReadLine().Split().Select(int.Parse).ToArray(); array.Add(aa); } for (int i=0;i<N;i++) { for (int j = 0;j<N;j++) { var X = array[i][0] - array[j][0]; var Y = array[i][1] - array[j][1]; var resultX = Math.Pow(X, 2); var resultY = Math.Pow(Y, 2); var ans = Math.Sqrt(resultX + resultY); Ans.Add(ans); } } var finalresult = Ans.Max(); Console.WriteLine(finalresult); }*/ // 51B /*static void Main() { int count = 0; int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray(); int K = input[0]; int S = input[1]; for (int x =0;x<= K;x++) { for (int y = 0; y <= K; y++) { var z = S - x - y; if ( 0 <= z && z <= K) { count++; } } } Console.WriteLine(count); }*/ // 80B /*static void Main() { int Ans = 0; string x = Console.ReadLine(); int X = int.Parse(x); for (int i =0;i<x.Length;i++) { var temp = Convert.ToInt32(x[i].ToString()); Ans += temp; } if (X % Ans == 0) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } }*/ // 90B /*static void Main() { int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray(); int A = input[0]; int B = input[1]; int aaa = 0; int count = 1; int ko = 0; string ans =""; StringBuilder sb = new StringBuilder(); while(true) { string X = A.ToString(); count = 1; ans = ""; //Console.WriteLine(X[X.Length - count]); while (true) { //sb = null; sb.Append(X[X.Length - count]); if (X.Length - count == 0) { ans = sb.ToString(); break; } count++; } sb.Remove(0,X.Length); aaa = int.Parse(ans); //Console.WriteLine(aaa); if (A == aaa) { ko++; } if (A == B) { break; } A++; } Console.WriteLine(ko); }*/ // 25A /*static void Main() { int ansA = 0; int ansB = 0; int N = int.Parse(Console.ReadLine()); List<int> Ans = new List<int>(); for (int A = 1;A<N;A++) { int B = N - A; List<int> la = new List<int>(); List<int> lb = new List<int>(); ansA = 0; ansB = 0; string a = A.ToString(); string b = B.ToString(); for (int i =0;i<a.Length;i++) { char ca = a[i]; int intca = Convert.ToInt32(ca.ToString()); la.Add(intca); } for (int i=0;i<b.Length;i++) { char cb = b[i]; int intcb = Convert.ToInt32(cb.ToString()); lb.Add(intcb); } foreach(int n in la) { ansA += n; } foreach (int n in lb) { ansB += n; } Ans.Add(ansA + ansB); } Console.WriteLine(Ans.Min()); }*/ // 67B /*static void Main() { int Ans = 0; List<int> array = new List<int>(); int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray(); int N = input[0]; int K = input[1]; int[] length = Console.ReadLine().Split().Select(int.Parse).ToArray(); //int[] newone = new int[length.Length]; Array.Sort(length); Array.Reverse(length); for (int i = 0;i<K;i++) { array.Add(length[i]); Ans += length[i]; } Console.WriteLine(Ans); }*/ // 42B /*static void Main() { int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray(); int N = input[0]; int L = input[1]; string[] str = new string[N]; for (int i=0;i<N;i++) { var a = Console.ReadLine(); str[i] = a; } StringComparer cmp = StringComparer.OrdinalIgnoreCase; Array.Sort(str,cmp); List<string> Ans = new List<string>(); for (int i = 0;i<N;i++) { Ans.Add(string.Concat(str[i])); } StringBuilder sb = new StringBuilder(); for (int i = 0;i<N;i++) { sb.Append(Ans[i]); sb.Append(string.Concat(str[i])); } Console.WriteLine(sb); }*/ // 27A /*static void Main() { int count = 0; int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray(); int N = input[0]; int x = input[1]; var a = Console.ReadLine().Split().Select(int.Parse).ToArray(); foreach (int i in a.OrderBy(nn => nn)) { x -= i; if (x >= 0) { count++; } if(x < 0) { break; } } if (x > 0) { count--; } Console.WriteLine(count); }*/ // 12A /*static void Main() { int Ans = 0; int N = int.Parse(Console.ReadLine()); int[] Aarray = Console.ReadLine().Split().Select(int.Parse).ToArray(); Array.Sort(Aarray); Array.Reverse(Aarray); Array.Clear(Aarray, 0, N); for (int i = N;i< 2*N; i++) { Ans += Aarray[i]; } Console.WriteLine(Ans); }*/ /*static void Main() { int o = 0; string Ans; string input = Console.ReadLine(); string alphabet = "abcdefghijklmnopqrstuvwxyz"; for (int i = 0;i< input.Length;i++) { char temp = input[i]; string ans = string.Join("", temp); if (alphabet.Contains(ans)) { alphabet = alphabet.Replace(ans,""); //o = alphabet.Length - alphabet.Replace(ans, "").Length; } } if (alphabet == "") { Console.WriteLine("None"); } else { Console.WriteLine(alphabet.Min()); //alphabet.Min() } }*/ // 61B /*static void Main() { int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray(); int N = input[0]; int M = input[1]; List<int[]> map = new List<int[]>(); for (int i =0;i<M;i++) { int[] road = Console.ReadLine().Split().Select(int.Parse).ToArray(); map.Add(road); } List<int> ans = new List<int>(); for (int i = 0;i< N;i++) { ans.Add(0); } for (int i = 0; i<N;i++) { var ff = i+1; foreach (int[] n in map) { for (int j = 0; j < 2; j++) { if (n[j] == ff) { ans[i]++; } } } } for (int i=0;i<N; i++) { Console.WriteLine(ans[i]); } }*/ // 47B /*static void Main() { int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray(); int X = input[0]; int Y = input[1]; int N = input[2]; int[,] map = new int[X+1,Y+1]; for (int i =0;i<N;i++) { int[] input2 = Console.ReadLine().Split().Select(int.Parse).ToArray(); int x = input2[0]; int y = input2[1]; int a = input2[2]; switch (a) { case 1: for (int ty =0;ty<Y;ty++) { for (int j = 0; j <x; j++) { map[j, ty] += 1; } } break; case 2: for (int ty = 0; ty < Y; ty++) { for (int j = x; j < X; j++) { map[j, ty] += 1; } } break; case 3: for (int tx = 0; tx < X; tx++) { for (int j = 0; j < y; j++) { map[tx, j] += 1; } } break; case 4: for (int tx = 0; tx < X; tx++) { for (int j = y; j < Y; j++) { map[tx, j] += 1; } } break; } } int count = 0; for (int i = 0;i<X;i++) { for (int j = 0;j<Y;j++) { if (map[i,j] == 0) { count++; } } } Console.WriteLine(count); }*/ // 91B /*static void Main() { bool ji = false; int N = int.Parse(Console.ReadLine()); List<string> bluewords = new List<string>(); List<string> redwords = new List<string>(); for (int i = 0; i < N;i++) { var temp = Console.ReadLine(); bluewords.Add(temp); } int M = int.Parse(Console.ReadLine()); for (int i = 0; i < M; i++) { var temp = Console.ReadLine(); redwords.Add(temp); } List<KeyValuePair<int,string>> countBlue = new List<KeyValuePair<int, string>>(); int a = 0; foreach (string n in bluewords) { foreach (string l in bluewords) { if (n == l) { a++; } } KeyValuePair<int, string> tempKey = new KeyValuePair<int, string>(a,n); countBlue.Add(tempKey); a = 0; } countBlue.Sort((w, x) => x.Key - w.Key); List<KeyValuePair<int, string>> countRed = new List<KeyValuePair<int, string>>(); int b = 0; foreach (string n in redwords) { foreach (string l in redwords) { if (n == l) { b++; } } KeyValuePair<int, string> tempKey1 = new KeyValuePair<int, string>(b, n); countRed.Add(tempKey1); b = 0; } countRed.Sort((w, x) => x.Key - w.Key); List<int> ans = new List<int>(); int countt = 0; foreach (var blue in countBlue) { foreach (var red in countRed) { countt = 0; var andss = new List<bool>(countRed.Select(d => d.Value == blue.Value)); foreach (var tt in andss) { var ee = tt; if (ee == false) { countt++; } } if (blue.Value == red.Value) { var Ans = blue.Key - red.Key; ans.Add(Ans); break; } else if(countt == andss.Count) { var Ans = blue.Key; ans.Add(Ans); } } } if (ans.Max() <= 0) { Console.WriteLine("0"); } else { Console.WriteLine(ans.Max()); } }*/ // 130コンテスト /*static void Main() { int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray(); int X = input[0]; int A = input[1]; if (X < A) { Console.WriteLine("0"); } else { Console.WriteLine("10"); } }*/ // 130B /*static void Main() { int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray(); int[] Xarray = Console.ReadLine().Split().Select(int.Parse).ToArray(); int N = input[0]; int X = input[1]; List<int> Ans = new List<int>(); List<int> Ans1 = new List<int>(); int ans = 0; Ans.Add(ans); for (int i = 0; i < Xarray.Length; i++) { ans += Xarray[i]; Ans.Add(ans); } foreach (int a in Ans) { if (a <= X) { Ans1.Add(a); } } Console.WriteLine(Ans1.Count); }*/ // 130C /*static void Main() { double[] input = Console.ReadLine().Split().Select(double.Parse).ToArray(); double W = input[0]; double H = input[1]; double x = input[2]; double y = input[3]; double temp1 = W * H/2; var ans = temp1; int ans2 = 0; if (x == W/2 && y== H/2) { ans2 = 1; } else { ans2 = 0; } Console.WriteLine(ans+" "+ans2); }*/ // 130D /*static void Main() { int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray(); int N = input[0]; int K = input[1]; int[] Aarray = Console.ReadLine().Split().Select(int.Parse).ToArray(); int Answer = 0; int AnsCount = 0; for (int i = 0;i< N;i++) { Answer += Aarray[i]; for (int j = i+1;j<N;j++) { Answer += Aarray[j]; if (Answer >= K) { AnsCount++; AnsCount+=Aarray.Length - j; //AnsCount += N - Answer + 1; break; } } Answer = 0; } Console.WriteLine(AnsCount); }*/ // 129B /*static void Main() { int N = int.Parse(Console.ReadLine()); int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray(); int Answer = 0; int Answer2 = 0; List<int> Ans = new List<int>(); for (int i=0;i<array.Length;i++) { Answer += array[i]; for (int j=i+1;j<array.Length;j++) { Answer2 += array[j]; }/* Ans.Add(Math.Abs(Answer - Answer2)); Answer2 = 0; } Console.WriteLine(Ans.Min()); }*/ // 128B /*static void Main() { List<KeyValuePair<string,int>> KeyList = new List<KeyValuePair<string,int>>(); int N = int.Parse(Console.ReadLine()); for (int i =0;i< N;i++) { string[] temp = Console.ReadLine().Split(' '); var mm = new KeyValuePair<string, int>(temp[0],int.Parse(temp[1])); KeyList.Add(mm); } }*/ // 123B static void Main() { bool flag = false; List<int> time = new List<int>(); List<int> sample = new List<int>(); List<int> sss = new List<int>(); int[] aa = new int[5]; int[] bb = new int[5]; for (int i = 0; i < 5; i++) { int dish = int.Parse(Console.ReadLine()); time.Add(dish); } time.CopyTo(aa); int ans = 0; foreach (int a in time) { var temp = a % 10; sample.Add(temp); } var count = 0; foreach (int ji in sample) { if (ji != 0) { sss.Add(ji); } else if (ji == 0) { count++; } } if (count == sample.Count) { sss.Add(0); flag = true; } var jj = sample.IndexOf(sss.Min()); time.RemoveAt(jj); time.Add(aa[jj]); foreach (int n in time) { ans += n; if (ans % 10 != 0) { ans += 10 - (ans % 10); } } if (flag == false) { ans = ans - (10 - sss.Min()); } Console.WriteLine(ans); } } // 128B /*public class Data { public int ID; public string Name; public int Evaluation; public Data(int ID,string Name, int Evaluation) { this.ID = ID; this.Name = Name; this.Evaluation = Evaluation; } } public class Atcoder { static void Main() { int N = int.Parse(Console.ReadLine()); for (int i = 0; i < N; i++) { List<Data> Console.ReadLine(); } List<Data> DataList() { List<Data> Datalist = new List<Data>() { new Data(Name:Console.ReadLine().Split()[0][0],Evaluation:) }; return Datalist; } } }*/ }
[["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 211, 0, 147], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 64, 196, 0, 1, 0, 11, 12, 211, 0, 146], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 211, 0, 147], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
8
406
17
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp1 { class Program { static void Main(string[] args) { var line = new List<int>(); for (int i = 0; i < 5; i++) { line.Add(int.Parse(Console.ReadLine())); } var minlist = line.Select(i => i % 10).ToList(); if (minlist.All(i => i == 0)) { Console.WriteLine(0); return; } minlist.RemoveAll(i => i == 0); int min = minlist.Min(); var target = line.Where(i => i % 10 == min).ToList(); line.Remove(target[0]); line.Add(target[0]); int time = 0; for (int i = 0; i < 5; i++) { time += line[i]; if (i == 4) break; else if (line[i] % 10 != 0) { time += (10 - (line[i] % 10)); } } Console.WriteLine(time); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp1 { class Program { static void Main(string[] args) { var line = new List<int>(); for (int i = 0; i < 5; i++) { line.Add(int.Parse(Console.ReadLine())); } int time = 0; var minlist = line.Select(i => i % 10).ToList(); if (minlist.All(i => i == 0)) { keisan(line, time); return; } minlist.RemoveAll(i => i == 0); int min = minlist.Min(); var target = line.Where(i => i % 10 == min).ToList(); line.Remove(target[0]); line.Add(target[0]); keisan(line, time); } static void keisan(List<int> line, int time) { for (int i = 0; i < 5; i++) { time += line[i]; if (i == 4) break; else if (line[i] % 10 != 0) { time += (10 - (line[i] % 10)); } } Console.WriteLine(time); } } }
[["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 213, 63, 22], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 21], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 1, 0, 213, 63, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 21], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 0, 235, 8, 201, 0, 195, 8, 196, 0, 46], ["+", 0, 235, 8, 201, 0, 195, 0, 251, 0, 115], ["+", 8, 201, 0, 235, 8, 201, 0, 195, 39, 199], ["+", 8, 201, 0, 235, 8, 201, 0, 195, 141, 22], ["+", 0, 235, 8, 201, 0, 195, 54, 55, 0, 24], ["+", 0, 195, 54, 55, 0, 220, 39, 236, 141, 22], ["+", 54, 55, 0, 220, 39, 236, 237, 238, 0, 18], ["+", 54, 55, 0, 220, 39, 236, 237, 238, 0, 199], ["+", 54, 55, 0, 220, 39, 236, 237, 238, 0, 47], ["+", 8, 201, 0, 195, 54, 55, 0, 220, 141, 22], ["+", 0, 235, 8, 201, 0, 195, 54, 55, 0, 21], ["+", 8, 201, 0, 195, 54, 55, 0, 220, 39, 199], ["+", 0, 235, 8, 201, 0, 195, 54, 55, 0, 25], ["+", 0, 235, 8, 201, 0, 195, 8, 196, 0, 45]]
8
263
36
using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using static System.Math; class Program { public static void Main(string[] args) { var v = Enumerable.Range(0, 5) .Select(_ => int.Parse(Console.ReadLine())) .Select(x => new { V = x, R = ((x + 9) / 10 * 10), A = (x % 10) == 0 ? 0 : (10 - x) }) .ToLookup(x => x.A == 0); int i = 0; int sum = 0; foreach (var item in v[true]) { sum += item.V; i++; } foreach (var item in v[false]) { sum += (i == 4) ? item.V : item.R; i++; } Console.WriteLine(sum); } }
using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using static System.Math; class Program { public static void Main(string[] args) { var v = Enumerable.Range(0, 5) .Select(_ => int.Parse(Console.ReadLine())) .Select(x => new { V = x, R = ((x + 9) / 10 * 10), A = (x % 10) == 0 ? 0 : (10 - x % 10) }) .ToLookup(x => x.A == 0); int i = 0; int sum = 0; foreach (var item in v[true]) { sum += item.V; i++; } foreach (var item in v[false].OrderBy(x => x.A)) { sum += (i == 4) ? item.V : item.R; i++; } Console.WriteLine(sum); } }
[["+", 0, 41, 75, 23, 0, 16, 12, 16, 17, 109], ["+", 0, 41, 75, 23, 0, 16, 12, 16, 12, 203], ["+", 8, 196, 0, 210, 12, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 210, 12, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 210, 12, 213, 3, 4, 0, 24], ["+", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["+", 12, 213, 3, 4, 0, 28, 0, 218, 0, 221], ["+", 3, 4, 0, 28, 0, 218, 8, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 218, 8, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 218, 8, 214, 141, 22], ["+", 8, 196, 0, 210, 12, 213, 3, 4, 0, 25]]
8
196
11
using System; using System.Linq; public class Program { public static void Main() { int[] dishes = new int[5]; for (var i = 0; i < 5; i++) { dishes[i] = int.Parse(Console.ReadLine()); } var min = 0; for (var i = 1; i < 5; i++) { if (dishes[min] % 11 > dishes[i] % 11) { min = i; } } for (var i = 0; i < 5; i++) { if (i != min) { dishes[i] = (int)Math.Ceiling((double)dishes[i] / 10) * 10; } } Console.WriteLine("{0}", dishes.Sum()); } }
using System; using System.Linq; public class Program { public static void Main() { int[] dishes = new int[5]; for (var i = 0; i < 5; i++) { dishes[i] = int.Parse(Console.ReadLine()); } var min = 0; for (var i = 1; i < 5; i++) { if (dishes[i] % 10 != 0 && dishes[min] % 10 > dishes[i] % 10) { min = i; } else if (dishes[min] % 10 == 0) { min = i; } } for (var i = 0; i < 5; i++) { if (i != min) { dishes[i] = (int)Math.Ceiling((double)dishes[i] / 10) * 10; } } Console.WriteLine("{0}", dishes.Sum()); } }
[["+", 31, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 31, 16, 31, 16, 31, 204, 206, 207, 0, 73], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 17, 109], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 12, 203], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 79], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 15, 16, 12, 16, 31, 16, 31, 204, 205, 22], ["+", 12, 16, 31, 16, 31, 204, 206, 207, 0, 70], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 57, 15, 16, 12, 16, 31, 16, 12, 203], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 0, 57, 15, 16, 12, 16, 12, 16, 12, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["+", 0, 7, 8, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 7, 8, 196, 0, 57, 75, 57, 0, 24], ["+", 75, 57, 15, 16, 31, 16, 31, 204, 205, 22], ["+", 15, 16, 31, 16, 31, 204, 206, 207, 0, 70], ["+", 15, 16, 31, 16, 31, 204, 206, 207, 0, 73], ["+", 0, 57, 75, 57, 15, 16, 31, 16, 17, 109], ["+", 0, 57, 75, 57, 15, 16, 31, 16, 12, 203], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 60], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 12, 203]]
8
171
31
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp6 { class Program { static void Main(string[] args) { int[] a = new int[5]; int dup = 0; int sum = 0; for (int i = 0; i < 5; ++i) { a[i] = int.Parse(Console.ReadLine()); //読み込み } int min = 10; //比較対象 int o = 0; //配列番号 for (int j = 0; j < 5; ++j) { int k = a[j] % 10; if (min > k && k != 0) { min = k; o = j; } if (k == 0) { dup++; } } for (int l = 0; l < 5; ++l) { if (o != l) { a[l] = a[l] - a[l] % 10; } } for (int m = 0; m < 5; ++m) { sum = sum + a[m]; } sum = sum + 10 * (4 - dup); Console.WriteLine(sum); Console.ReadKey(); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp6 { class Program { static void Main(string[] args) { int[] a = new int[5]; int dup = 0; int sum = 0; for (int i = 0; i < 5; ++i) { a[i] = int.Parse(Console.ReadLine()); //読み込み } int min = 10; //比較対象 int o = 0; //配列番号 for (int j = 0; j < 5; ++j) { int k = a[j] % 10; if (min > k && k != 0) { min = k; o = j; } if (k == 0) { dup++; } } /* for (int l = 0; l < 5; ++l) { if (o != l) { a[l] = a[l] - a[l] % 10; } } */ for (int l = 0; l < 5; ++l) { a[l] = a[l] - a[l] % 10; } for (int m = 0; m < 5; ++m) { sum = sum + a[m]; } sum = sum + 10 * (4 - dup) + min; Console.WriteLine(sum); Console.ReadKey(); } } }
[["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 79], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 22]]
8
260
10
using System; using System.Diagnostics; using System.Collections.Generic; using System.Linq; class Program { static void Main() { List<int> wait = new List<int>(); int ans = 0; for (int i = 0; i < 5; i++) { int cin = int.Parse(Console.ReadLine()); ans += cin; if (cin % 10 != 0) { ans += 10 - cin % 10; wait.Add(10 - cin % 10); } } Console.WriteLine(ans - wait.Max()); } }
using System; using System.Diagnostics; using System.Collections.Generic; using System.Linq; class Program { static void Main() { List<int> wait = new List<int>(); int ans = 0; for (int i = 0; i < 5; i++) { int cin = int.Parse(Console.ReadLine()); ans += cin; if (cin % 10 != 0) { ans += 10 - cin % 10; wait.Add(10 - cin % 10); } } if (wait.Count != 0) Console.WriteLine(ans - wait.Max()); else Console.WriteLine(ans); } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 205, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 0, 131], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 141, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 79], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 28, 0, 16, 12, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 57, 75, 1, 0, 213, 63, 214, 205, 22], ["+", 0, 57, 75, 1, 0, 213, 63, 214, 0, 131], ["+", 0, 57, 75, 1, 0, 213, 63, 214, 141, 22], ["+", 0, 57, 75, 1, 0, 213, 3, 4, 0, 24], ["+", 75, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
8
126
16
using System.Linq; using static System.Math; using System; public class Hello { public static void Main() { var a = new int[5]; var b = new int[5]; for (int i = 0; i < 5; i++) { a[i] = int.Parse(Console.ReadLine().Trim()); b[i] = a[i] % 10; } var t = 100; for (int i = 0; i < 5; i++) { if (b[i] != 0) t = Min(t, b[i]); } if (t == 100) { Console.WriteLine(a.Sum()); goto exit; } var ans = 0; for (int i = 0; i < 5; i++) { if (b[i] != t) ans += ((a[i] + 9) / 10) * 10; else ans += a[i]; } Console.WriteLine(ans); exit:; } }
using System.Linq; using System; public class Hello { public static void Main() { var a = new int[5]; var b = new int[5]; for (int i = 0; i < 5; i++) { a[i] = int.Parse(Console.ReadLine().Trim()); b[i] = a[i] % 10; } var t = 100; var ti = 0; for (int i = 0; i < 5; i++) { if (b[i] != 0) if (b[i] < t) { ti = i; t = b[i]; } } if (t == 100) { Console.WriteLine(a.Sum()); goto exit; } var ans = 0; for (int i = 0; i < 5; i++) { if (i != ti) ans += ((a[i] + 9) / 10) * 10; else ans += a[i]; } Console.WriteLine(ans); exit:; } }
[["-", 36, 36, 36, 36, 0, 208, 0, 231, 0, 115], ["-", 36, 36, 0, 208, 0, 231, 141, 232, 234, 22], ["-", 36, 36, 0, 208, 0, 231, 141, 232, 0, 131], ["-", 36, 36, 0, 208, 0, 231, 141, 232, 141, 22], ["-", 36, 36, 36, 36, 0, 208, 0, 231, 0, 35], ["-", 36, 36, 36, 36, 0, 208, 0, 231, 0, 233], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 64, 57, 0, 121], ["+", 0, 7, 8, 196, 0, 57, 64, 57, 0, 24], ["+", 0, 57, 64, 57, 15, 16, 31, 204, 205, 22], ["+", 64, 57, 15, 16, 31, 204, 206, 207, 0, 70], ["+", 15, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 64, 57, 15, 16, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 64, 57, 15, 16, 17, 18], ["+", 0, 7, 8, 196, 0, 57, 64, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 57, 64, 196, 0, 45], ["+", 64, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 0, 57, 64, 1, 0, 11, 12, 213, 63, 22], ["-", 64, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["+", 64, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["+", 0, 57, 64, 57, 64, 196, 0, 1, 0, 35], ["-", 64, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 64, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46], ["-", 8, 196, 0, 57, 15, 16, 31, 204, 205, 22], ["-", 0, 57, 15, 16, 31, 204, 206, 207, 0, 70], ["-", 0, 57, 15, 16, 31, 204, 206, 207, 0, 73], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22]]
8
222
34
namespace ABC123_B { using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static void Main(string[] args) { var _list = new List<int>(); for (int i = 0; i < 5; i++) { _list.Add(ReadInput()); } var nlist = _list.Where(x => x % 10 != 0).ToList(); var tlist = _list.Where(x => x % 10 == 0).ToList(); tlist.Sort((a, b) => a % 10 - b % 10); tlist.AddRange(nlist); var total = tlist .Select((x, i) => { if (i < 4) { return x % 10 != 0 ? Math.Ceiling(x / 10.0) * 10 : x; } else { return x; } }) .Sum(); WriteLine(total); } static int ReadInput() { return int.Parse(ReadLine()); } } }
namespace ABC123_B { using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static void Main(string[] args) { var _list = new List<int>(); for (int i = 0; i < 5; i++) { _list.Add(ReadInput()); } var nodivd = _list.Where(x => x % 10 != 0).ToList(); var divd = _list.Where(x => x % 10 == 0).ToList(); nodivd.Sort((a, b) => b % 10 - a % 10); divd.AddRange(nodivd); var total = divd.Select((x, i) => { if (i < 4) { return x % 10 != 0 ? Math.Ceiling(x / 10.0) * 10 : x; } else { return x; } }) .Sum(); WriteLine(total); } static int ReadInput() { return int.Parse(ReadLine()); } } }
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 0, 28, 0, 218, 8, 16, 31, 16, 31, 22], ["+", 0, 28, 0, 218, 8, 16, 31, 16, 31, 22], ["-", 0, 28, 0, 218, 8, 16, 12, 16, 31, 22], ["+", 0, 28, 0, 218, 8, 16, 12, 16, 31, 22], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 205, 22], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 205, 22]]
8
219
16
using System; using System.Linq; using System.Collections; using System.Collections.Generic; using static System.Console; class Program { static void Main() { //入力 // int n = 100; int[] input = new int[5]; for (int a = 0; a < 5; a++) { input[a] = int.Parse(Console.ReadLine()); } // int[] input = "5 100".Split().Select(i=>int.Parse(i)).ToArray(); var sortList = input.OrderBy(i => abc(i)).ToArray(); double total = 0; Console.WriteLine(string.Join(",", sortList)); for (int a = 0; a < 5; a++) { if (a == 4) { total += (double)sortList[a]; } else { total += Math.Ceiling((double)sortList[a] / 10) * 10; } } /* for(int a = 0; a < 5; a++) { for (int b = 0;b < 5; b++) { for (int c = 0; c < 5; c++) { for (int d = 0; d < 5; d++) { for (int e = 0; e < 5; e++) { } } } } } */ /* int n = input[0]; int q = input[1]; //int seed = Environment.TickCount; */ Console.WriteLine((int)total); /* //処理速度計測 var sw = new System.Diagnostics.Stopwatch(); sw.Start(); //解法 //処理速度表示 sw.Stop(); TimeSpan ts = sw.Elapsed; Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms"); */ Console.ReadLine(); } static int abc(int i) { int val = 10 - i % 10; if (val == 10) { val = 0; } return val; } }
using System; using System.Linq; using System.Collections; using System.Collections.Generic; using static System.Console; class Program { static void Main() { //入力 // int n = 100; int[] input = new int[5]; for (int a = 0; a < 5; a++) { input[a] = int.Parse(Console.ReadLine()); } // int[] input = "5 100".Split().Select(i=>int.Parse(i)).ToArray(); var sortList = input.OrderBy(i => abc(i)).ToArray(); double total = 0; // Console.WriteLine(string.Join(",",sortList)); for (int a = 0; a < 5; a++) { if (a == 4) { total += (double)sortList[a]; } else { total += Math.Ceiling((double)sortList[a] / 10) * 10; } } /* for(int a = 0; a < 5; a++) { for (int b = 0;b < 5; b++) { for (int c = 0; c < 5; c++) { for (int d = 0; d < 5; d++) { for (int e = 0; e < 5; e++) { } } } } } */ /* int n = input[0]; int q = input[1]; //int seed = Environment.TickCount; */ Console.WriteLine((int)total); /* //処理速度計測 var sw = new System.Diagnostics.Stopwatch(); sw.Start(); //解法 //処理速度表示 sw.Stop(); TimeSpan ts = sw.Elapsed; Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms"); */ Console.ReadLine(); } static int abc(int i) { int val = 10 - i % 10; if (val == 10) { val = 0; } return val; } }
[["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 205, 199], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["-", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["-", 3, 4, 0, 28, 0, 213, 3, 4, 0, 21], ["-", 0, 28, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
8
231
16
using System; namespace AtCoderABC123B { class Program { static void Main(string[] args) { double[] dishTime = new double[5]; for (int i = 0; i < 5; i++) { string[] line = Console.ReadLine().Split(' '); dishTime[i] = double.Parse(line[0]); } double sum = 0; double min = 123; foreach (double i in dishTime) { sum += Math.Ceiling(i / 10) * 10; if (min > ((Math.Ceiling(i / 10) * 10) - i)) { min = Math.Ceiling(i / 10) * 10 - i; } } Console.Write((int)sum - min); } } }
using System; namespace AtCoderABC123B { class Program { static void Main(string[] args) { double[] dishTime = new double[5]; for (int i = 0; i < 5; i++) { string[] line = Console.ReadLine().Split(' '); dishTime[i] = double.Parse(line[0]); } double sum = 0; double max = 0; foreach (double i in dishTime) { sum += Math.Ceiling(i / 10) * 10; if (((Math.Ceiling(i / 10) * 10) - i) > max) { max = Math.Ceiling(i / 10) * 10 - i; } } Console.Write((int)sum - max); } } }
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 210, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 210, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 210, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 210, 8, 196, 0, 57, 15, 16, 12, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22]]
8
164
12
using System; using System.Linq; using System.Collections.Generic; class Program { static void Main(string[] args) { List<int> list = new List<int>(); List<int> list2 = new List<int>(); for (var i = 0; i < 5; i++) { var a = int.Parse(Console.ReadLine()); if (a % 10 == 0) { list.Add(a); } else { list2.Add(a); } } list2 = list2.OrderByDescending(d => d % 10).ToList(); var sum = 0; for (var i = 0; i < list.Count; i++) { sum += list[i]; } for (var i = 0; i < list2.Count - 1; i++) { sum += list2[i] + (10 - list2[i] % 10); } sum += list2.Last(); Console.WriteLine(sum); } }
using System; using System.Linq; using System.Collections.Generic; class Program { static void Main(string[] args) { List<int> list = new List<int>(); List<int> list2 = new List<int>(); for (var i = 0; i < 5; i++) { var a = int.Parse(Console.ReadLine()); if (a % 10 == 0) { list.Add(a); } else { list2.Add(a); } } list2 = list2.OrderByDescending(d => d % 10).ToList(); var sum = 0; for (var i = 0; i < list.Count; i++) { sum += list[i]; } for (var i = 0; i < list2.Count - 1; i++) { sum += list2[i] + (10 - list2[i] % 10); } if (list2.Count > 0) { sum += list2.Last(); } Console.WriteLine(sum); } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 205, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 0, 131], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 141, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
8
215
10
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; namespace AtCoder { class Program { static void Main() { //ここから List<int> vs = new List<int>(); for (int i = 0; i < 5; i++) { vs.Add(IO.ReadLineToInt()); } int ans = 0; foreach (var item in vs) { if (item % 10 == 0) { ans += item; } } vs.RemoveAll(v => v % 10 == 0); vs = vs.OrderByDescending(v => v % 10).ToList(); foreach (var item in vs) { ans += ((item / 10) + 1) * 10; } ans += -10 + (vs.Last() % 10); Console.WriteLine(ans); Console.ReadKey(); } } class Func { long mod = 1000000007; static public void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; } static public long GCD(int a, int b) { return b != 0 ? GCD(b, a % b) : a; } static public long LCM(int a, int b) { return (long)a * b / GCD(a, b); } static public int Factorial(int a) { return a == 1 ? a : a * Factorial(a - 1); } static public int Conbin(int n, int m) { return Factorial(n) / (Factorial(n - m) * Factorial(m)); } static public void Factoring(long num, ref long[] vs) { if (num == 1) { vs[1]++; } for (long i = 2; i < (long)Math.Sqrt(num); i++) { if (num % i == 0) { vs[i]++; Factoring(num / i, ref vs); } } vs[1]++; } } class IO { static public string ReadLineToString() { return Console.ReadLine(); } static public int ReadLineToInt() { return int.Parse(Console.ReadLine()); } static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); } static public string[] ReadLineToStringArray() { return Console.ReadLine().Split(' ').ToArray(); } static public int[] ReadLineToIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); } static public long[] ReadLineToLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); } static public List<string> ReadLineToStringList() { return Console.ReadLine().Split(' ').ToList(); } static public List<int> ReadLineToIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); } static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; namespace AtCoder { class Program { static void Main() { //ここから List<int> vs = new List<int>(); for (int i = 0; i < 5; i++) { vs.Add(IO.ReadLineToInt()); } int ans = 0; foreach (var item in vs) { if (item % 10 == 0) { ans += item; } } vs.RemoveAll(v => v % 10 == 0); vs = vs.OrderByDescending(v => v % 10).ToList(); if (vs.Count > 0) { foreach (var item in vs) { ans += ((item / 10) + 1) * 10; } ans += -10 + (vs.Last() % 10); } Console.WriteLine(ans); Console.ReadKey(); } } class Func { long mod = 1000000007; static public void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; } static public long GCD(int a, int b) { return b != 0 ? GCD(b, a % b) : a; } static public long LCM(int a, int b) { return (long)a * b / GCD(a, b); } static public int Factorial(int a) { return a == 1 ? a : a * Factorial(a - 1); } static public int Conbin(int n, int m) { return Factorial(n) / (Factorial(n - m) * Factorial(m)); } static public void Factoring(long num, ref long[] vs) { if (num == 1) { vs[1]++; } for (long i = 2; i < (long)Math.Sqrt(num); i++) { if (num % i == 0) { vs[i]++; Factoring(num / i, ref vs); } } vs[1]++; } } class IO { static public string ReadLineToString() { return Console.ReadLine(); } static public int ReadLineToInt() { return int.Parse(Console.ReadLine()); } static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); } static public string[] ReadLineToStringArray() { return Console.ReadLine().Split(' ').ToArray(); } static public int[] ReadLineToIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); } static public long[] ReadLineToLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); } static public List<string> ReadLineToStringList() { return Console.ReadLine().Split(' ').ToList(); } static public List<int> ReadLineToIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); } static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); } } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 205, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 0, 131], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 141, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
8
698
10
using System; using System.Collections.Generic; using System.Linq; namespace ConsoleApp { class Program { static int N = 0; static void Main(string[] args) { var a = new List<int>(); for (int i = 0; i < 5; i++) { a.Add(int.Parse(Console.ReadLine())); } var sum = 0; for (int i = 0; i < a.Count; i++) { if (a[i] % 10 == 0) { sum += a[i]; a.RemoveAt(i); i--; } } var min = 9; var min1Index = -1; for (int i = 0; i < a.Count; i++) { var num1 = a[i] % 10; if (num1 <= min) { min = num1; min1Index = i; } } sum += a[min1Index]; a.RemoveAt(min1Index); while (a.Count > 0) { sum += a[0] + (10 - a[0] % 10); a.RemoveAt(0); } Console.WriteLine(sum); } } }
using System; using System.Collections.Generic; using System.Linq; namespace ConsoleApp { class Program { static int N = 0; static void Main(string[] args) { var a = new List<int>(); for (int i = 0; i < 5; i++) { a.Add(int.Parse(Console.ReadLine())); } var sum = 0; for (int i = 0; i < a.Count; i++) { if (a[i] % 10 == 0) { sum += a[i]; a.RemoveAt(i); i--; } } var min = 9; var min1Index = -1; for (int i = 0; i < a.Count; i++) { var num1 = a[i] % 10; if (num1 <= min) { min = num1; min1Index = i; } } if (min1Index != -1) { sum += a[min1Index]; a.RemoveAt(min1Index); } while (a.Count > 0) { sum += a[0] + (10 - a[0] % 10); a.RemoveAt(0); } Console.WriteLine(sum); } } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 79], ["+", 8, 196, 0, 57, 15, 16, 12, 241, 0, 33], ["+", 8, 196, 0, 57, 15, 16, 12, 241, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
8
247
9
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace B { class Program { static void Main(string[] args) { int[] cookingTimes = new int[5]; for (int i = 0; i < cookingTimes.Length; i++) { cookingTimes[i] = RInt(); } int min = int.MaxValue; foreach (var item in GetPermutation(cookingTimes, 5)) { int[] order = item.ToArray(); int time = 0; for (int i = 0; i < order.Length; i++) { time += order[i]; if (i < 4) { time += order[i] % 10 == 0 ? 0 : 10 - order[i] % 10; } } min = Math.Min(min, time); } Console.WriteLine(min); } /// <summary> /// 配列の順列を列挙する /// </summary> /// <typeparam name="T"></typeparam> /// <param name="items">配列</param> /// <param name="r">取得数</param> /// <returns>配列の組み合わせの列挙</returns> public static IEnumerable<IEnumerable<T>> GetPermutation<T>(IEnumerable<T> items, int r) { if (r == 0) { yield return Enumerable.Empty<T>(); } else { foreach (var x in items) { var xs = items.Where(y => !y.Equals(x)); foreach (var c in GetPermutation(xs, r - 1)) yield return Concat(x, c); } } } public static IEnumerable<T> Concat<T>(T first, IEnumerable<T> items) { yield return first; foreach (var i in items) yield return i; } static string RSt() { return Console.ReadLine(); } static int RInt() { return int.Parse(Console.ReadLine().Trim()); } static long RLong() { return long.Parse(Console.ReadLine().Trim()); } static double RDouble() { return double.Parse(Console.ReadLine()); } static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); } static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); } static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); } static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); } static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace B { class Program { static void Main(string[] args) { int[] cookingTimes = new int[5]; for (int i = 0; i < cookingTimes.Length; i++) { cookingTimes[i] = RInt(); } int min = int.MaxValue; foreach (var idxs in GetPermutation(Enumerable.Range(0, 5), 5)) { int[] order = idxs.ToArray(); int time = 0; for (int i = 0; i < order.Length; i++) { time += cookingTimes[order[i]]; if (i < 4) { time += cookingTimes[order[i]] % 10 == 0 ? 0 : 10 - cookingTimes[order[i]] % 10; } } min = Math.Min(min, time); } Console.WriteLine(min); } /// <summary> /// 配列の順列を列挙する /// </summary> /// <typeparam name="T"></typeparam> /// <param name="items">配列</param> /// <param name="r">取得数</param> /// <returns>配列の組み合わせの列挙</returns> public static IEnumerable<IEnumerable<T>> GetPermutation<T>(IEnumerable<T> items, int r) { if (r == 0) { yield return Enumerable.Empty<T>(); } else { foreach (var x in items) { var xs = items.Where(y => !y.Equals(x)); foreach (var c in GetPermutation(xs, r - 1)) yield return Concat(x, c); } } } public static IEnumerable<T> Concat<T>(T first, IEnumerable<T> items) { yield return first; foreach (var i in items) yield return i; } static string RSt() { return Console.ReadLine(); } static int RInt() { return int.Parse(Console.ReadLine().Trim()); } static long RLong() { return long.Parse(Console.ReadLine().Trim()); } static double RDouble() { return double.Parse(Console.ReadLine()); } static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); } static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); } static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); } static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); } static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); } } }
[["-", 8, 201, 0, 195, 8, 196, 0, 210, 31, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 210, 31, 22], ["-", 0, 210, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 0, 28, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 21], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 204, 205, 22], ["+", 0, 1, 0, 11, 12, 204, 206, 207, 0, 70], ["+", 0, 1, 0, 11, 12, 204, 206, 207, 0, 73], ["+", 12, 41, 15, 16, 31, 16, 31, 204, 205, 22], ["+", 15, 16, 31, 16, 31, 204, 206, 207, 0, 70], ["+", 206, 207, 0, 28, 0, 204, 206, 207, 0, 73], ["+", 12, 41, 75, 16, 12, 16, 31, 204, 205, 22], ["+", 75, 16, 12, 16, 31, 204, 206, 207, 0, 70]]
8
620
22
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Program { const int MOD = 1000000007; const int INF = 1 << 30; static void Main(string[] args) { Solve(); } static long GCD(long x, long y) { if (y == 0) return x; return GCD(y, x % y); } static long LCM(long x, long y) { return x * y / GCD(x, y); } static int keta(int x) { string s = x.ToString(); return s[s.Length - 1] - '0'; } static void Solve() { Scan sc = new Scan(); write wr = new write(); int[] x = new int[5]; x[0] = sc.intarr[0]; x[1] = sc.intarr[0]; x[2] = sc.intarr[0]; x[3] = sc.intarr[0]; x[4] = sc.intarr[0]; int[] x2 = new int[5]; for (int i = 0; i < 5; ++i) { x2[i] = keta(x[i]); } Array.Sort(x2, x); int ans = x[0]; for (int i = 1; i < 5; ++i) { ans += x[i] - keta(x[i]); if (keta(x[i]) != 0) { ans += 10; } } wr.wri(ans); } } class Scan { public string str => Console.ReadLine(); public string[] strarr => str.Split(' '); public long[] longarr => strarr.Select(long.Parse).ToArray(); public int[] intarr => strarr.Select(int.Parse).ToArray(); public char[] chararr => str.ToArray(); } class write { public void wri<Type>(Type x) { Console.WriteLine(x); } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Program { const int MOD = 1000000007; const int INF = 1 << 30; static void Main(string[] args) { Solve(); } static long GCD(long x, long y) { if (y == 0) return x; return GCD(y, x % y); } static long LCM(long x, long y) { return x * y / GCD(x, y); } static int keta(int x) { string s = x.ToString(); return s[s.Length - 1] - '0'; } static void Solve() { Scan sc = new Scan(); write wr = new write(); int[] x = new int[5]; x[0] = sc.intarr[0]; x[1] = sc.intarr[0]; x[2] = sc.intarr[0]; x[3] = sc.intarr[0]; x[4] = sc.intarr[0]; int[] x2 = new int[5]; int xi = 0; for (int i = 0; i < 5; ++i) { x2[i] = keta(x[i]); if (x2[i] == 0) xi++; } if (xi >= 5) xi = 4; Array.Sort(x2, x); int ans = x[xi]; for (int i = 0; i < 5; ++i) { if (i != xi) { ans += x[i] - keta(x[i]); if (keta(x[i]) != 0) { ans += 10; } } } wr.wri(ans); } } class Scan { public string str => Console.ReadLine(); public string[] strarr => str.Split(' '); public long[] longarr => strarr.Select(long.Parse).ToArray(); public int[] intarr => strarr.Select(int.Parse).ToArray(); public char[] chararr => str.ToArray(); } class write { public void wri<Type>(Type x) { Console.WriteLine(x); } }
[["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 204, 205, 22], ["+", 0, 57, 15, 16, 31, 204, 206, 207, 0, 70], ["+", 15, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 57, 15, 16, 31, 204, 206, 207, 0, 73], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 223, 0, 22], ["+", 8, 196, 0, 57, 64, 1, 0, 223, 0, 29], ["+", 0, 7, 8, 196, 0, 57, 64, 1, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 20], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35], ["-", 0, 212, 0, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 212, 0, 204, 206, 207, 0, 28, 0, 22], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 79], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46]]
8
456
39
using System; using System.Linq; using System.Collections; using System.Collections.Generic; namespace AtCoderABC123 { class Program { public static void Main(string[] args) { int[] p = new int[5]; p[0] = int.Parse(Console.ReadLine()); p[1] = int.Parse(Console.ReadLine()); p[2] = int.Parse(Console.ReadLine()); p[3] = int.Parse(Console.ReadLine()); p[4] = int.Parse(Console.ReadLine()); int[] q = p.OrderBy(x => x % 10).ToArray(); int res = 0; int resi = -1; for (int i = 0; i < 5; i++) { if (q[i] % 10 == 0) { res += q[i]; } else { if (resi == -1) { resi = i; } else { res += q[i] - (q[i] % 10) + 10; } } } res += q[resi]; Console.WriteLine(res); } } }
using System; using System.Linq; using System.Collections; using System.Collections.Generic; namespace AtCoderABC123 { class Program { public static void Main(string[] args) { int[] p = new int[5]; p[0] = int.Parse(Console.ReadLine()); p[1] = int.Parse(Console.ReadLine()); p[2] = int.Parse(Console.ReadLine()); p[3] = int.Parse(Console.ReadLine()); p[4] = int.Parse(Console.ReadLine()); int[] q = p.OrderBy(x => x % 10).ToArray(); int res = 0; int resi = -1; for (int i = 0; i < 5; i++) { if (q[i] % 10 == 0) { res += q[i]; } else { if (resi == -1) { resi = i; } else { res += q[i] - (q[i] % 10) + 10; } } } res += (resi == -1) ? 0 : q[resi]; Console.WriteLine(res); } } }
[["+", 0, 1, 0, 11, 12, 41, 15, 23, 0, 24], ["+", 0, 11, 12, 41, 15, 23, 0, 16, 31, 22], ["+", 0, 11, 12, 41, 15, 23, 0, 16, 17, 60], ["+", 12, 41, 15, 23, 0, 16, 12, 241, 0, 33], ["+", 12, 41, 15, 23, 0, 16, 12, 241, 0, 203], ["+", 0, 1, 0, 11, 12, 41, 15, 23, 0, 25], ["+", 8, 196, 0, 1, 0, 11, 12, 41, 0, 101], ["+", 8, 196, 0, 1, 0, 11, 12, 41, 64, 203], ["+", 8, 196, 0, 1, 0, 11, 12, 41, 0, 102]]
8
249
9
using System; namespace Atcoder { class ABC122_A { static void Main(string[] args) { int b = int.Parse(Console.ReadLine()); switch (b) { case 'A': Console.Write('T'); break; case 'T': Console.Write('A'); break; case 'C': Console.Write('G'); break; case 'G': Console.Write('C'); break; } } } }
using System; namespace Atcoder { class ABC122_A { static void Main(string[] args) { string str = Console.ReadLine(); char b = str[0]; switch (b) { case 'A': Console.Write('T'); break; case 'T': Console.Write('A'); break; case 'C': Console.Write('G'); break; case 'G': Console.Write('C'); break; } } } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 204, 205, 22], ["+", 0, 200, 0, 212, 0, 204, 206, 207, 0, 70], ["+", 0, 212, 0, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 200, 0, 212, 0, 204, 206, 207, 0, 73]]
8
106
17
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Atc_0034 { class Program { static void Main(string[] args) { var str = Console.ReadLine(); int Cnt = 0; int result = 0; for (int i = 0; i < str.Length; i++) { if (str.Substring(i, 1) == "A" || str.Substring(i, 1) == "T" || str.Substring(i, 1) == "C" || str.Substring(i, 1) == "G") { Cnt++; } else { if (result <= Cnt) { result = Cnt; } Cnt = 0; } } Console.WriteLine(result); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Atc_0034 { class Program { static void Main(string[] args) { var str = Console.ReadLine(); int Cnt = 0; int result = 0; for (int i = 0; i < str.Length; i++) { if (str.Substring(i, 1) == "A" || str.Substring(i, 1) == "T" || str.Substring(i, 1) == "C" || str.Substring(i, 1) == "G") { Cnt++; if (result <= Cnt) { result = Cnt; } } else { if (result <= Cnt) { result = Cnt; } Cnt = 0; } } Console.WriteLine(result); } } }
[["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 19], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["+", 64, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46]]
8
168
12
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using static System.Console; using static System.Math; using static AtCoderTemplate.MyLibrary; namespace AtCoderTemplate { class Program { static void Main(string[] args) { string S = Console.ReadLine(); int ans = 0; int count = 0; for (int i = 0; i < S.Length; i++) { if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') { count++; } else { ans = Max(ans, count); count = 0; } } Console.WriteLine(ans); } } class MyLibrary { public static int GCD(int a, int b) { if (a % b == 0) return b; return GCD(b, a % b); } } }
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using static System.Console; using static System.Math; using static AtCoderTemplate.MyLibrary; namespace AtCoderTemplate { class Program { static void Main(string[] args) { string S = Console.ReadLine(); int ans = 0; int count = 0; for (int i = 0; i < S.Length; i++) { if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') { count++; } else { ans = Max(ans, count); count = 0; } if (i == S.Length - 1) ans = Max(ans, count); } Console.WriteLine(ans); } } class MyLibrary { public static int GCD(int a, int b) { if (a % b == 0) return b; return GCD(b, a % b); } } }
[["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 57, 15, 16, 12, 16, 31, 214, 205, 22], ["+", 0, 57, 15, 16, 12, 16, 31, 214, 0, 131], ["+", 0, 57, 15, 16, 12, 16, 31, 214, 141, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 33], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 1, 0, 11, 12, 213, 63, 22], ["+", 64, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["+", 0, 11, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 64, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["+", 64, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 1, 0, 35]]
8
203
19
using System; using System.Collections.Generic; using System.Linq; using System.Security.Cryptography; class Program { static void Main(string[] args) { var s = Console.ReadLine().ToCharArray(); var mojis = new char[] { 'A', 'C', 'G', 'T' }; var ls = new List<int>(); var count = 0; for (var i = 0; s.Length > i; i++) { if (mojis.Contains(s[i])) count++; else { ls.Add(count); count = 0; } } Console.WriteLine(ls.Max()); } }
using System; using System.Collections.Generic; using System.Linq; using System.Security.Cryptography; class Program { static void Main(string[] args) { var s = Console.ReadLine().ToCharArray(); var mojis = new List<char>() { 'A', 'C', 'G', 'T' }; var ls = new List<int>(); var count = 0; for (var i = 0; s.Length > i; i++) { if (mojis.Contains(s[i])) count++; else { ls.Add(count); count = 0; } } ls.Add(count); Console.WriteLine(ls.Max()); } }
[["+", 0, 200, 0, 212, 0, 230, 39, 236, 141, 22], ["+", 0, 212, 0, 230, 39, 236, 237, 238, 0, 18], ["-", 0, 212, 0, 227, 39, 224, 225, 226, 0, 70], ["-", 0, 212, 0, 227, 39, 224, 225, 226, 0, 73], ["+", 0, 212, 0, 230, 39, 236, 237, 238, 0, 47], ["+", 0, 200, 0, 212, 0, 230, 3, 4, 0, 24], ["+", 0, 200, 0, 212, 0, 230, 3, 4, 0, 25], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
8
149
14
using System; class Program { static void Main(string[] args) { char[] s = Console.ReadLine().ToCharArray(); int count = 0; int max = 0; for (int i = 0; i < s.Length; i++) { if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') count++; else { if (count > max) max = count; count = 0; } } Console.WriteLine(max); } }
using System; class Program { static void Main(string[] args) { char[] s = Console.ReadLine().ToCharArray(); int count = 0; int max = 0; for (int i = 0; i < s.Length; i++) { if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') count++; else { if (count > max) max = count; count = 0; } } if (count > max) max = count; Console.WriteLine(max); } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35]]
8
126
10
using System; using System.Linq; namespace atcoder { class Program { static void Main(string[] args) { var S = Console.ReadLine(); Console.WriteLine(ACGT(S)); } static int ACGT(string S) { var include = new[] { 'A', 'C', 'G', 'T' }; var len = 0; var count = 0; for (var i = 0; i < S.Length; ++i) { if (include.Contains(S[i])) { count++; } else { len = Math.Max(count, len); count = 0; } } return len; } } }
using System; using System.Linq; namespace atcoder { class Program { static void Main(string[] args) { var S = Console.ReadLine(); Console.WriteLine(ACGT(S)); } static int ACGT(string S) { var include = new[] { 'A', 'C', 'G', 'T' }; var len = 0; var count = 0; for (var i = 0; i < S.Length; ++i) { if (include.Contains(S[i])) { count++; } else { len = Math.Max(count, len); count = 0; } } len = Math.Max(count, len); return len; } } }
[["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 205, 22], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["+", 0, 11, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
8
145
11
using System; using System.IO; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder.Contest.B { static class Program { public static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); var cin = new Scanner(); string s = cin.Next(); int ans = 0; int now = 0; for (int i = 0; i < s.Length; i++) { if (s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C') { now++; } else { ans = Math.Max(now, ans); now = 0; } } Console.WriteLine(ans); Console.Out.Flush(); } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string Next() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return Next(); i = 0; return s[i++]; } public int NextInt() { return int.Parse(Next()); } public int[] ArrayInt(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = NextInt() + add; } return Array; } public long NextLong() { return long.Parse(Next()); } public long[] ArrayLong(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = NextLong() + add; } return Array; } public double NextDouble() { return double.Parse(Next()); } public double[] ArrayDouble(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = NextDouble() + add; } return Array; } } }
using System; using System.IO; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder.Contest.B { static class Program { public static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); var cin = new Scanner(); string s = cin.Next(); int ans = 0; int now = 0; for (int i = 0; i < s.Length; i++) { if (s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C') { now++; } else { now = 0; } ans = Math.Max(now, ans); } Console.WriteLine(ans); Console.Out.Flush(); } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string Next() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return Next(); i = 0; return s[i++]; } public int NextInt() { return int.Parse(Next()); } public int[] ArrayInt(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = NextInt() + add; } return Array; } public long NextLong() { return long.Parse(Next()); } public long[] ArrayLong(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = NextLong() + add; } return Array; } public double NextDouble() { return double.Parse(Next()); } public double[] ArrayDouble(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = NextDouble() + add; } return Array; } } }
[["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 46], ["-", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["-", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["-", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 0, 57, 75, 196, 0, 1, 0, 11, 12, 203], ["-", 0, 7, 8, 196, 0, 57, 75, 196, 0, 46]]
8
553
10
using System; using System.Collections.Generic; namespace cswork { class Program { public Program() {} Scanner cin; void Omame() { cin = new Scanner(); string s = cin.next(); int ans = 0; int tmp = 0; for (int i = 0; i < s.Length; i++) { string ss = s[i].ToString(); if (ss.Equals("A") || ss.Equals("C") || ss.Equals("G") || ss.Equals("T")) { tmp++; } else { if (ans < tmp) { ans = tmp; } tmp = 0; } } Console.WriteLine(ans); } static void Main(string[] args) { new Program().Omame(); } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string next() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); i = 0; return next(); } public int nextInt() { return int.Parse(next()); } public long nextLong() { return long.Parse(next()); } public double nextDouble() { return double.Parse(next()); } } }
using System; using System.Collections.Generic; namespace cswork { class Program { public Program() {} Scanner cin; void Omame() { cin = new Scanner(); string s = cin.next(); int ans = 0; int tmp = 0; for (int i = 0; i < s.Length; i++) { string ss = s[i].ToString(); if (ss.Equals("A") || ss.Equals("C") || ss.Equals("G") || ss.Equals("T")) { tmp++; if (ans < tmp) { ans = tmp; } } else { if (ans < tmp) { ans = tmp; } tmp = 0; } } Console.WriteLine(ans); } static void Main(string[] args) { new Program().Omame(); } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string next() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); i = 0; return next(); } public int nextInt() { return int.Parse(next()); } public long nextLong() { return long.Parse(next()); } public double nextDouble() { return double.Parse(next()); } } }
[["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["+", 64, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46]]
8
342
12
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace AtCoder { class Program { static void Main(string[] args) { var s = Console.ReadLine(); var max = 0; for (var i = 0; i < s.Length; i++) { for (var j = i; j < s.Length; j++) { if (s[j] != 'A' && s[j] != 'C' && s[j] != 'G' && s[j] != 'T') { max = Math.Max(max, j - i); break; } } } Console.WriteLine(max); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace AtCoder { class Program { static void Main(string[] args) { var s = Console.ReadLine(); var max = 0; for (var i = 0; i < s.Length; i++) { var isAcgt = true; for (var j = i; j < s.Length; j++) { if (s[j] != 'A' && s[j] != 'C' && s[j] != 'G' && s[j] != 'T') { max = Math.Max(max, j - i); isAcgt = false; break; } } if (isAcgt) { max = Math.Max(max, s.Length - i); } } Console.WriteLine(max); } } }
[["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 211, 0, 146], ["+", 8, 196, 0, 7, 8, 196, 0, 197, 0, 35], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 64, 196, 0, 1, 0, 11, 12, 211, 0, 147], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 7, 8, 196, 0, 7, 8, 196, 0, 46], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 15, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 205, 22], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["+", 0, 11, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["+", 3, 4, 0, 28, 0, 16, 31, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 16, 31, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 16, 31, 214, 141, 22], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25]]
8
151
30
using System; using System.Linq; namespace Practice { class Program { static void Main(string[] args) { string str = Console.ReadLine(); int temp = 0; int max = 0; for (int i = 0; i < str.Length; i++) { if (str[i] == 'A' || str[i] == 'G' || str[i] == 'C' || str[i] == 'T') { temp++; } else { if (max < temp) max = temp; temp = 0; } } Console.WriteLine(max); } } }
using System; using System.Linq; namespace Practice { class Program { static void Main(string[] args) { string str = Console.ReadLine(); int temp = 0; int max = 0; for (int i = 0; i < str.Length; i++) { if (str[i] == 'A' || str[i] == 'G' || str[i] == 'C' || str[i] == 'T') { temp++; } else { if (max < temp) max = temp; temp = 0; } } if (max < temp) max = temp; Console.WriteLine(max); } } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35]]
8
131
10
using System; using System.Collections.Generic; using System.Linq; public static class Program { public static void Main(string[] args) { var s = Console.ReadLine().Select(x => x.ToString()).ToArray(); string[] vals = { "A", "C", "G", "T" }; var result = 0; var cnt = 0; for (int i = 0; i < s.Length; i++) { if (vals.Contains(s[i])) cnt++; else { result = cnt > result ? cnt : result; cnt = 0; } } Console.WriteLine(result); } }
using System; using System.Collections.Generic; using System.Linq; public static class Program { public static void Main(string[] args) { var s = Console.ReadLine().Select(x => x.ToString()).ToArray(); string[] vals = { "A", "C", "G", "T" }; var result = 0; var cnt = 0; for (int i = 0; i < s.Length; i++) { if (vals.Contains(s[i])) cnt++; else { result = cnt > result ? cnt : result; cnt = 0; } } result = cnt > result ? cnt : result; Console.WriteLine(result); } }
[["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 1, 0, 11, 12, 41, 15, 16, 31, 22], ["+", 0, 1, 0, 11, 12, 41, 15, 16, 17, 47], ["+", 0, 1, 0, 11, 12, 41, 15, 16, 12, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 41, 0, 101], ["+", 8, 196, 0, 1, 0, 11, 12, 41, 64, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 41, 0, 102], ["+", 8, 196, 0, 1, 0, 11, 12, 41, 75, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
8
147
10
using System; using System.Collections.Generic; using System.Linq; namespace kyoupuro { class MainClass { public static void Main() { MainClass mainClass = new MainClass(); mainClass.Start(); } public void Start() { var line = Console.ReadLine(); var tmp = new Char[4] { 'A', 'T', 'G', 'C' }; int sum = 0, tsum = 0; bool start = tmp.Contains(line[0]); for (int i = 0; i < line.Length; i++) { if (!start) { if (tmp.Contains(line[i])) { start = true; tsum = 1; } } else { if (tmp.Contains(line[i])) { tsum++; } else { sum = Math.Max(tsum, sum); tsum = 0; } } } Console.WriteLine(sum); } List<List<int>> IntInit() { int maxindex = int.Parse(Console.ReadLine()); List<List<int>> array = new List<List<int>>(); for (int i = 0; i < maxindex; i++) { array.Add(new List<int>(Console.ReadLine().Split(' ').Select(int.Parse))); } return array; } } }
using System; using System.Collections.Generic; using System.Linq; namespace kyoupuro { class MainClass { public static void Main() { MainClass mainClass = new MainClass(); mainClass.Start(); } public void Start() { var line = Console.ReadLine(); var tmp = new Char[4] { 'A', 'T', 'G', 'C' }; int sum = 0, tsum = 0; bool start = tmp.Contains(line[0]); for (int i = 0; i < line.Length; i++) { if (!start) { if (tmp.Contains(line[i])) { start = true; tsum = 1; } } else { if (tmp.Contains(line[i])) { tsum++; } else { sum = Math.Max(tsum, sum); tsum = 0; } } } sum = Math.Max(tsum, sum); Console.WriteLine(sum); } List<List<int>> IntInit() { int maxindex = int.Parse(Console.ReadLine()); List<List<int>> array = new List<List<int>>(); for (int i = 0; i < maxindex; i++) { array.Add(new List<int>(Console.ReadLine().Split(' ').Select(int.Parse))); } return array; } } }
[["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 205, 22], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["+", 0, 11, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
8
298
11
using System; using System.Collections.Generic; using System.Linq; namespace B___ATCoder { class Program { static void Main(string[] args) { var s = Console.ReadLine(); var a = 0; var b = new List<int> { 0 }; for (var i = 0; i < s.Length; i++) { if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') { a++; } else { if (a != 0) { b.Add(a); } a = 0; } } Console.WriteLine(b.Max()); } } }
using System; using System.Collections.Generic; using System.Linq; namespace B___ATCoder { class Program { static void Main(string[] args) { var s = Console.ReadLine(); var a = 0; var b = new List<int> { 0 }; for (var i = 0; i < s.Length; i++) { if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') { a++; if (i == s.Length - 1) { b.Add(a); } } else { if (a != 0) { b.Add(a); a = 0; } } } Console.WriteLine(b.Max()); } } }
[["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 57, 15, 16, 12, 16, 31, 214, 205, 22], ["+", 0, 57, 15, 16, 12, 16, 31, 214, 0, 131], ["+", 0, 57, 15, 16, 12, 16, 31, 214, 141, 22], ["+", 64, 196, 0, 57, 15, 16, 12, 16, 17, 33], ["+", 64, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 64, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46], ["-", 0, 57, 75, 196, 0, 57, 64, 196, 0, 46], ["+", 0, 57, 75, 196, 0, 57, 64, 196, 0, 46]]
8
154
21
using System; using System.Linq; using System.Collections.Generic; using System.IO; class Program { public static long Read() { return long.Parse(Console.ReadLine()); } public static long[] Reads() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); } public static void Main() { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); var s = Console.ReadLine(); var L = new List<long>(); var count = 0; for (int i = 0; i < s.Length; i++) { if (s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C') { count++; } else { L.Add(count); count = 0; } } Console.WriteLine(L.Max()); Console.Out.Flush(); } }
using System; using System.Linq; using System.Collections.Generic; using System.IO; class Program { public static long Read() { return long.Parse(Console.ReadLine()); } public static long[] Reads() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); } public static void Main() { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); var s = Console.ReadLine(); var L = new List<long>(); var count = 0; for (int i = 0; i < s.Length; i++) { if (s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C') { count++; } else { L.Add(count); count = 0; } } L.Add(count); Console.WriteLine(L.Max()); Console.Out.Flush(); } }
[["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
8
228
7
using System; class Program { static void Main(string[] args) { string S = Console.ReadLine(); int maxLength = 0; int currLength = 0; for (int i = 0; i < S.Length; i++) { if ((S[i] == 'A') || (S[i] == 'C') || (S[i] == 'G') || (S[i] == 'T')) { currLength++; } else { maxLength = (maxLength < currLength) ? currLength : maxLength; currLength = 0; } } Console.WriteLine(maxLength); } }
using System; class Program { static void Main(string[] args) { string S = Console.ReadLine(); int maxLength = 0; int currLength = 0; for (int i = 0; i < S.Length; i++) { if ((S[i] == 'A') || (S[i] == 'C') || (S[i] == 'G') || (S[i] == 'T')) { currLength++; } else { maxLength = (maxLength < currLength) ? currLength : maxLength; currLength = 0; } } maxLength = (maxLength < currLength) ? currLength : maxLength; Console.WriteLine(maxLength); } }
[["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 1, 0, 11, 12, 41, 15, 23, 0, 24], ["+", 0, 11, 12, 41, 15, 23, 0, 16, 31, 22], ["+", 0, 11, 12, 41, 15, 23, 0, 16, 17, 18], ["+", 0, 11, 12, 41, 15, 23, 0, 16, 12, 22], ["+", 0, 1, 0, 11, 12, 41, 15, 23, 0, 25], ["+", 8, 196, 0, 1, 0, 11, 12, 41, 0, 101], ["+", 8, 196, 0, 1, 0, 11, 12, 41, 64, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 41, 0, 102], ["+", 8, 196, 0, 1, 0, 11, 12, 41, 75, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
8
132
12
using System; using System.Collections.Generic; using System.Linq; namespace ConsoleApp1 { class Program { static void Main(string[] args) { var S = Console.ReadLine().Select(x => x.ToString()).ToArray(); List<int> list = new List<int>(); int count = 0; foreach (string s in S) { if (s == "A" || s == "T" || s == "C" || s == "G") { count = count + 1; } else if (count > 0) { list.Add(count); count = 0; } } if (list.Count != 0) { Console.WriteLine(list.Max()); } else { Console.WriteLine(0); } } } }
using System; using System.Collections.Generic; using System.Linq; namespace ConsoleApp1 { class Program { static void Main(string[] args) { var S = Console.ReadLine().Select(x => x.ToString()).ToArray(); List<int> list = new List<int>(); int count = 0; foreach (string s in S) { if (s == "A" || s == "T" || s == "C" || s == "G") { count = count + 1; } else if (count > 0) { list.Add(count); count = 0; } } list.Add(count); if (list.Count != 0) { Console.WriteLine(list.Max()); } else { Console.WriteLine(0); } } } }
[["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
8
171
7
using System; using System.Collections.Generic; using System.Linq; namespace ConsoleApp2 { using static System.Console; using static System.Math; class Program { static void Main(string[] args) { S = ReadLine(); Solve(); } static string S; static void Solve() { var longest = 0; var current = 0; foreach (var c in S) { var before = current; if ("ACGT".Contains(c)) current++; else { if (longest < current) longest = current; current = 0; } } WriteLine(longest); } } }
using System; using System.Collections.Generic; using System.Linq; namespace ConsoleApp2 { using static System.Console; using static System.Math; class Program { static void Main(string[] args) { S = ReadLine(); Solve(); } static string S; static void Solve() { var longest = 0; var current = 0; foreach (var c in S) { var before = current; if ("ACGT".Contains(c)) current++; else { if (longest < current) longest = current; current = 0; } } if (longest < current) longest = current; WriteLine(longest); } } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35]]
8
127
10
using System; namespace abc122_b { class Program { static void Main(string[] args) { int count = 0; int max = 0; string array = Console.ReadLine(); for (int i = 0; i < array.Length; i++) { char ch = array[i]; Console.WriteLine(ch); if (ch == 'A' || ch == 'C' || ch == 'G' || ch == 'T') { count += 1; } else { if (max < count) { max = count; } count = 0; } if (max < count) { max = count; } } Console.WriteLine(max); } } }
using System; namespace abc122_b { class Program { static void Main(string[] args) { int count = 0; int max = 0; string array = Console.ReadLine(); for (int i = 0; i < array.Length; i++) { char ch = array[i]; if (ch == 'A' || ch == 'C' || ch == 'G' || ch == 'T') { count += 1; } else { if (max < count) { max = count; } count = 0; } if (max < count) { max = count; } } Console.WriteLine(max); } } }
[["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35]]
8
144
7
using System; using System.Linq; public class Program { public static void Main(string[] args) { string input = Console.ReadLine(); int max = 0; int stock = 0; foreach (char i in input) if (i == 'A' || i == 'C' || i == 'T' || i == 'G') { stock++; } else { if (max < stock) { max = stock; } stock = 0; } Console.WriteLine(max); } }
using System; using System.Linq; public class Program { public static void Main(string[] args) { string input = Console.ReadLine(); int max = 0; int stock = 0; foreach (char i in input) { if (i == 'A' || i == 'C' || i == 'T' || i == 'G') { stock++; } else { if (max < stock) { max = stock; } stock = 0; } if (max < stock) { max = stock; } } Console.WriteLine(max); } }
[["+", 0, 195, 8, 196, 0, 210, 8, 196, 0, 45], ["+", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["+", 0, 210, 8, 196, 0, 57, 75, 196, 0, 46], ["+", 8, 196, 0, 210, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 210, 8, 196, 0, 57, 0, 24], ["+", 0, 210, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 210, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 210, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 196, 0, 210, 8, 196, 0, 57, 0, 25], ["+", 0, 210, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["+", 0, 210, 8, 196, 0, 57, 64, 196, 0, 46]]
8
108
14
using System; using System.Linq; using System.Collections.Generic; using System.Text; namespace Program { public class ABC122B { static public void Main(string[] args) { var S = NextString; var ans = 0; var tmp = 0; var ACGT = "ACGT"; for (int i = 0; i < S.Length; ++i) { if (ACGT.Contains(S[i])) { ++tmp; } else { ans = Math.Max(ans, tmp); tmp = 0; } } Console.WriteLine(ans); } static class Console_ { private static Queue<string> param = new Queue<string>(); public static string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); } } static int NextInt => int.Parse(Console_.NextString()); static List<int> NextIntList(int N) { var ret = new List<int>(N); for (int i = 0; i < N; ++i) ret.Add(NextInt); return ret; } static long NextLong => long.Parse(Console_.NextString()); static List<long> NextLongList(int N) { var ret = new List<long>(N); for (int i = 0; i < N; ++i) ret.Add(NextLong); return ret; } static string NextString => Console_.NextString(); static void Sort<T>(List<T> l) where T : IComparable => l.Sort(); static void RevSort<T>(List<T> l) where T : IComparable => l.Sort((x, y) => y.CompareTo(x)); static IEnumerable<long> Prime(long x) { if (x < 2) yield break; yield return 2; var halfx = x / 2; var table = new bool[halfx + 1]; var max = (long)(Math.Sqrt(x) / 2); for (long i = 1; i <= max; ++i) { if (table[i]) continue; var add = 2 * i + 1; yield return add; for (long j = 2 * i * (i + 1); j <= halfx; j += add) table[j] = true; } for (long i = max + 1; i <= halfx; ++i) if (!table[i]) yield return 2 * i + 1; } static IEnumerable<long> Divisor(long x) { if (x < 1) yield break; var max = (long)Math.Sqrt(x); for (long i = 1; i < max; ++i) { if (x % i != 0) continue; yield return i; if (i != x / i) yield return x / i; } } static long GCD(long a, long b) { long tmpa = a, tmpb = b; while (tmpb > 0) { var tmp = tmpb; tmpb = tmpa % tmpb; tmpa = tmp; } return tmpa; } class PQ<T> where T : IComparable { private List<T> h; private Comparison<T> c; public PQ(int cap, Comparison<T> c, bool asc = true) { h = new List<T>(cap); this.c = asc ? c : (x, y) => c(y, x); } public PQ(Comparison<T> c, bool asc = true) { h = new List<T>(); this.c = asc ? c : (x, y) => c(y, x); } public PQ(int cap, bool asc = true) : this(cap, (x, y) => x.CompareTo(y), asc) { } public PQ(bool asc = true) : this((x, y) => x.CompareTo(y), asc) { } public void Push(T v) { var i = h.Count; h.Add(v); while (i > 0) { var ni = (i - 1) / 2; if (c(v, h[ni]) >= 0) break; h[i] = h[ni]; i = ni; } h[i] = v; } public T Peek => h[0]; public int Count => h.Count; public T Pop { get { var r = h[0]; var v = h[h.Count - 1]; h.RemoveAt(h.Count - 1); if (h.Count == 0) return r; var i = 0; while (i * 2 + 1 < h.Count) { var i1 = i * 2 + 1; var i2 = i * 2 + 2; if (i2 < h.Count && c(h[i1], h[i2]) > 0) i1 = i2; if (c(v, h[i1]) <= 0) break; h[i] = h[i1]; i = i1; } h[i] = v; return r; } private set { } } } class PQ<TKey, TValue> where TKey : IComparable { private PQ<Tuple<TKey, TValue>> q; public PQ(int cap, Comparison<TKey> c, bool asc = true) { q = new PQ<Tuple<TKey, TValue>>(cap, (x, y) => c(x.Item1, y.Item1), asc); } public PQ(Comparison<TKey> c, bool asc = true) { q = new PQ<Tuple<TKey, TValue>>((x, y) => c(x.Item1, y.Item1), asc); } public PQ(int cap, bool asc = true) : this(cap, (x, y) => x.CompareTo(y), asc) { } public PQ(bool asc = true) : this((x, y) => x.CompareTo(y), asc) { } public void Push(TKey k, TValue v) => q.Push(Tuple.Create(k, v)); public Tuple<TKey, TValue> Peek => q.Peek; public int Count => q.Count; public Tuple<TKey, TValue> Pop => q.Pop; } static class Mod { static public long _mod = 1000000007; static public long Add(long x, long y) => (x + y) % _mod; static public long Sub(long x, long y) => (x - y) % _mod; static public long Multi(long x, long y) => (x * y) % _mod; static public long Div(long x, long y) => (x * Inverse(y)) % _mod; static public long Pow(long x, long y) { var a = 1L; while (y != 0) { if ((y & 1) == 1) a = Mod.Multi(a, x); x = Mod.Multi(x, x); y >>= 1; } return a; } static public long Inverse(long x) { var b = _mod; var r = 1L; var u = 0L; while (b > 0L) { var q = x / b; var t = u; u = r - q * u; r = t; t = b; b = x - q * b; x = t; } return r < 0 ? r + _mod : r; } static private List<long> _fact = new List<long>(); static private List<long> _ifact = new List<long>(); static private void Build(int n) { if (n >= _fact.Count) for (int i = _fact.Count; i <= n; ++i) if (i == 0L) { _fact.Add(1); _ifact.Add(1); } else { _fact.Add(Mod.Multi(_fact[i - 1], i)); _ifact.Add(Mod.Multi(_ifact[i - 1], Mod.Pow(i, _mod - 2))); } } static public long Comb(int n, int k) { Build(n); if (n == 0 && k == 0) return 1; if (n < k || n < 0) return 0; return Mod.Multi(Mod.Multi(_ifact[n - k], _ifact[k]), _fact[n]); } } } }
using System; using System.Linq; using System.Collections.Generic; using System.Text; namespace Program { public class ABC122B { static public void Main(string[] args) { var S = NextString; var ans = 0; var tmp = 0; var ACGT = "ACGT"; for (int i = 0; i < S.Length; ++i) { if (ACGT.Contains(S[i])) { ++tmp; } else { ans = Math.Max(ans, tmp); tmp = 0; } } Console.WriteLine(Math.Max(ans, tmp)); } static class Console_ { private static Queue<string> param = new Queue<string>(); public static string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); } } static int NextInt => int.Parse(Console_.NextString()); static List<int> NextIntList(int N) { var ret = new List<int>(N); for (int i = 0; i < N; ++i) ret.Add(NextInt); return ret; } static long NextLong => long.Parse(Console_.NextString()); static List<long> NextLongList(int N) { var ret = new List<long>(N); for (int i = 0; i < N; ++i) ret.Add(NextLong); return ret; } static string NextString => Console_.NextString(); static void Sort<T>(List<T> l) where T : IComparable => l.Sort(); static void RevSort<T>(List<T> l) where T : IComparable => l.Sort((x, y) => y.CompareTo(x)); static IEnumerable<long> Prime(long x) { if (x < 2) yield break; yield return 2; var halfx = x / 2; var table = new bool[halfx + 1]; var max = (long)(Math.Sqrt(x) / 2); for (long i = 1; i <= max; ++i) { if (table[i]) continue; var add = 2 * i + 1; yield return add; for (long j = 2 * i * (i + 1); j <= halfx; j += add) table[j] = true; } for (long i = max + 1; i <= halfx; ++i) if (!table[i]) yield return 2 * i + 1; } static IEnumerable<long> Divisor(long x) { if (x < 1) yield break; var max = (long)Math.Sqrt(x); for (long i = 1; i < max; ++i) { if (x % i != 0) continue; yield return i; if (i != x / i) yield return x / i; } } static long GCD(long a, long b) { long tmpa = a, tmpb = b; while (tmpb > 0) { var tmp = tmpb; tmpb = tmpa % tmpb; tmpa = tmp; } return tmpa; } class PQ<T> where T : IComparable { private List<T> h; private Comparison<T> c; public PQ(int cap, Comparison<T> c, bool asc = true) { h = new List<T>(cap); this.c = asc ? c : (x, y) => c(y, x); } public PQ(Comparison<T> c, bool asc = true) { h = new List<T>(); this.c = asc ? c : (x, y) => c(y, x); } public PQ(int cap, bool asc = true) : this(cap, (x, y) => x.CompareTo(y), asc) { } public PQ(bool asc = true) : this((x, y) => x.CompareTo(y), asc) { } public void Push(T v) { var i = h.Count; h.Add(v); while (i > 0) { var ni = (i - 1) / 2; if (c(v, h[ni]) >= 0) break; h[i] = h[ni]; i = ni; } h[i] = v; } public T Peek => h[0]; public int Count => h.Count; public T Pop { get { var r = h[0]; var v = h[h.Count - 1]; h.RemoveAt(h.Count - 1); if (h.Count == 0) return r; var i = 0; while (i * 2 + 1 < h.Count) { var i1 = i * 2 + 1; var i2 = i * 2 + 2; if (i2 < h.Count && c(h[i1], h[i2]) > 0) i1 = i2; if (c(v, h[i1]) <= 0) break; h[i] = h[i1]; i = i1; } h[i] = v; return r; } private set { } } } class PQ<TKey, TValue> where TKey : IComparable { private PQ<Tuple<TKey, TValue>> q; public PQ(int cap, Comparison<TKey> c, bool asc = true) { q = new PQ<Tuple<TKey, TValue>>(cap, (x, y) => c(x.Item1, y.Item1), asc); } public PQ(Comparison<TKey> c, bool asc = true) { q = new PQ<Tuple<TKey, TValue>>((x, y) => c(x.Item1, y.Item1), asc); } public PQ(int cap, bool asc = true) : this(cap, (x, y) => x.CompareTo(y), asc) { } public PQ(bool asc = true) : this((x, y) => x.CompareTo(y), asc) { } public void Push(TKey k, TValue v) => q.Push(Tuple.Create(k, v)); public Tuple<TKey, TValue> Peek => q.Peek; public int Count => q.Count; public Tuple<TKey, TValue> Pop => q.Pop; } static class Mod { static public long _mod = 1000000007; static public long Add(long x, long y) => (x + y) % _mod; static public long Sub(long x, long y) => (x - y) % _mod; static public long Multi(long x, long y) => (x * y) % _mod; static public long Div(long x, long y) => (x * Inverse(y)) % _mod; static public long Pow(long x, long y) { var a = 1L; while (y != 0) { if ((y & 1) == 1) a = Mod.Multi(a, x); x = Mod.Multi(x, x); y >>= 1; } return a; } static public long Inverse(long x) { var b = _mod; var r = 1L; var u = 0L; while (b > 0L) { var q = x / b; var t = u; u = r - q * u; r = t; t = b; b = x - q * b; x = t; } return r < 0 ? r + _mod : r; } static private List<long> _fact = new List<long>(); static private List<long> _ifact = new List<long>(); static private void Build(int n) { if (n >= _fact.Count) for (int i = _fact.Count; i <= n; ++i) if (i == 0L) { _fact.Add(1); _ifact.Add(1); } else { _fact.Add(Mod.Multi(_fact[i - 1], i)); _ifact.Add(Mod.Multi(_ifact[i - 1], Mod.Pow(i, _mod - 2))); } } static public long Comb(int n, int k) { Build(n); if (n == 0 && k == 0) return 1; if (n < k || n < 0) return 0; return Mod.Multi(Mod.Multi(_ifact[n - k], _ifact[k]), _fact[n]); } } } }
[["+", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 21], ["+", 0, 28, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25]]
8
1,813
7
using System; using System.Text.RegularExpressions; using System.Linq; class abc122_B { static void Main(string[] args) { var input = Console.ReadLine(); var regex = new Regex(@"([ATCG]+)", RegexOptions.Compiled); var matches = regex.Match(input); var result = matches.Captures.Cast<Capture>() .Select(s => s.Length) .DefaultIfEmpty(0) .Max(); Console.WriteLine(result); } }
using System; using System.Text.RegularExpressions; using System.Linq; class abc122_B { static void Main(string[] args) { var input = Console.ReadLine(); var regex = new Regex(@"([ATCG]+)", RegexOptions.Compiled); var matches = regex.Matches(input); var result = matches.Cast<Match>() .SelectMany(g => g.Captures.Cast<Capture>()) .Select(s => s.Length) .DefaultIfEmpty(0) .Max(); Console.WriteLine(result); } }
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 205, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["+", 63, 214, 205, 213, 63, 214, 141, 236, 141, 22], ["+", 205, 213, 63, 214, 141, 236, 237, 238, 0, 18], ["+", 205, 213, 63, 214, 141, 236, 237, 238, 0, 22], ["+", 205, 213, 63, 214, 141, 236, 237, 238, 0, 47], ["+", 205, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["+", 205, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["+", 205, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["+", 205, 213, 3, 4, 0, 28, 0, 218, 0, 221], ["+", 0, 218, 8, 213, 63, 214, 205, 214, 205, 22], ["+", 0, 218, 8, 213, 63, 214, 205, 214, 0, 131], ["+", 0, 28, 0, 218, 8, 213, 3, 4, 0, 25]]
8
101
16
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using static ABC122.Util; namespace ABC122 { class Program { static void Main(string[] args) { // DoubleHelix(); // 5min AtCoder(); } static void AtCoder() { string agct = "AGCT"; string input = Console.ReadLine(); int len = input.Length; int ans = 0; int cur = 0; for (int i = 0; i < len; i++) { if (agct.Contains(input[i])) { cur++; } else { ans = Math.Max(ans, cur); cur = 0; } } Console.WriteLine(ans); } static void DoubleHelix() { string input = Console.ReadLine(); string ans = string.Empty; if (input == "A") { ans = "T"; } else if (input == "T") { ans = "A"; } else if (input == "C") { ans = "G"; } else if (input == "G") { ans = "C"; } Console.WriteLine(ans); } } public class Util { public static T[] ReverseSort<T>(T[] array) { Array.Sort<T>(array); Array.Reverse(array); return array; } public static int[] ReadBinaryString() { return Console.ReadLine().Select(c => int.Parse(c.ToString())).ToArray(); } public static bool[] ReadBoolArray() { return Console.ReadLine().Select(c => c == '1').ToArray(); } public static long ReadLong() { return long.Parse(Console.ReadLine()); } public static long[] ReadLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); } public static int ReadInt() { return int.Parse(Console.ReadLine()); } public static int[] ReadIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); } } /// <summary> /// EqualsとGetHashCodeを提供します。IEqualityComparer<T>を実装するクラスです。 /// HashSetのコンストラクタに渡すために使います。 /// </summary> /// <typeparam name="T"></typeparam> public class EqualityComparer<T> : IEqualityComparer<T> { private Func<T, T, bool> _equals; private Func<T, int> _getHashCode; public EqualityComparer(Func<T, T, bool> equals, Func<T, int> getHashCode) { _equals = equals; _getHashCode = getHashCode; } public bool Equals(T x, T y) { return _equals(x, y); } public int GetHashCode(T obj) { return _getHashCode(obj); } } public class PriorityQueue<T> where T : IComparable { private Comparison<T> _comparison = null; private int _type = 0; private T[] _heap; private int _sz = 0; private int _count = 0; /// <summary> /// Priority queue /// </summary> /// <param name="maxSize">max size</param> /// <param name="type">0: asc, 1:desc</param> public PriorityQueue(int maxSize, int type = 0) { _heap = new T[maxSize]; _type = type; } public PriorityQueue(int maxSize, Comparison<T> comparison) { _heap = new T[maxSize]; _comparison = comparison; } private int Compare(T x, T y) { if (_comparison != null) return _comparison(x, y); return _type == 0 ? x.CompareTo(y) : y.CompareTo(x); } public void Push(T x) { _count++; // node number var i = _sz++; while (i > 0) { // parent node number var p = (i - 1) / 2; if (Compare(_heap[p], x) <= 0) break; _heap[i] = _heap[p]; i = p; } _heap[i] = x; } public T Pop() { _count--; T ret = _heap[0]; T x = _heap[--_sz]; int i = 0; while (i * 2 + 1 < _sz) { // children int a = i * 2 + 1; int b = i * 2 + 2; if (b < _sz && Compare(_heap[b], _heap[a]) < 0) a = b; if (Compare(_heap[a], x) >= 0) break; _heap[i] = _heap[a]; i = a; } _heap[i] = x; return ret; } public int Count() { return _count; } public T Peek() { return _heap[0]; } public bool Contains(T x) { for (int i = 0; i < _sz; i++) if (x.Equals(_heap[i])) return true; return false; } public void Clear() { while (this.Count() > 0) this.Pop(); } public IEnumerator<T> GetEnumerator() { var ret = new List<T>(); while (this.Count() > 0) { ret.Add(this.Pop()); } foreach (var r in ret) { this.Push(r); yield return r; } } public T[] ToArray() { T[] array = new T[_sz]; int i = 0; foreach (var r in this) { array[i++] = r; } return array; } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using static ABC122.Util; namespace ABC122 { class Program { static void Main(string[] args) { // DoubleHelix(); // 5min AtCoder(); } static void AtCoder() { string agct = "AGCT"; string input = Console.ReadLine(); int len = input.Length; int ans = 0; int cur = 0; for (int i = 0; i < len; i++) { if (agct.Contains(input[i])) { cur++; } else { ans = Math.Max(ans, cur); cur = 0; } } ans = Math.Max(ans, cur); Console.WriteLine(ans); } static void DoubleHelix() { string input = Console.ReadLine(); string ans = string.Empty; if (input == "A") { ans = "T"; } else if (input == "T") { ans = "A"; } else if (input == "C") { ans = "G"; } else if (input == "G") { ans = "C"; } Console.WriteLine(ans); } } public class Util { public static T[] ReverseSort<T>(T[] array) { Array.Sort<T>(array); Array.Reverse(array); return array; } public static int[] ReadBinaryString() { return Console.ReadLine().Select(c => int.Parse(c.ToString())).ToArray(); } public static bool[] ReadBoolArray() { return Console.ReadLine().Select(c => c == '1').ToArray(); } public static long ReadLong() { return long.Parse(Console.ReadLine()); } public static long[] ReadLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); } public static int ReadInt() { return int.Parse(Console.ReadLine()); } public static int[] ReadIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); } } /// <summary> /// EqualsとGetHashCodeを提供します。IEqualityComparer<T>を実装するクラスです。 /// HashSetのコンストラクタに渡すために使います。 /// </summary> /// <typeparam name="T"></typeparam> public class EqualityComparer<T> : IEqualityComparer<T> { private Func<T, T, bool> _equals; private Func<T, int> _getHashCode; public EqualityComparer(Func<T, T, bool> equals, Func<T, int> getHashCode) { _equals = equals; _getHashCode = getHashCode; } public bool Equals(T x, T y) { return _equals(x, y); } public int GetHashCode(T obj) { return _getHashCode(obj); } } public class PriorityQueue<T> where T : IComparable { private Comparison<T> _comparison = null; private int _type = 0; private T[] _heap; private int _sz = 0; private int _count = 0; /// <summary> /// Priority queue /// </summary> /// <param name="maxSize">max size</param> /// <param name="type">0: asc, 1:desc</param> public PriorityQueue(int maxSize, int type = 0) { _heap = new T[maxSize]; _type = type; } public PriorityQueue(int maxSize, Comparison<T> comparison) { _heap = new T[maxSize]; _comparison = comparison; } private int Compare(T x, T y) { if (_comparison != null) return _comparison(x, y); return _type == 0 ? x.CompareTo(y) : y.CompareTo(x); } public void Push(T x) { _count++; // node number var i = _sz++; while (i > 0) { // parent node number var p = (i - 1) / 2; if (Compare(_heap[p], x) <= 0) break; _heap[i] = _heap[p]; i = p; } _heap[i] = x; } public T Pop() { _count--; T ret = _heap[0]; T x = _heap[--_sz]; int i = 0; while (i * 2 + 1 < _sz) { // children int a = i * 2 + 1; int b = i * 2 + 2; if (b < _sz && Compare(_heap[b], _heap[a]) < 0) a = b; if (Compare(_heap[a], x) >= 0) break; _heap[i] = _heap[a]; i = a; } _heap[i] = x; return ret; } public int Count() { return _count; } public T Peek() { return _heap[0]; } public bool Contains(T x) { for (int i = 0; i < _sz; i++) if (x.Equals(_heap[i])) return true; return false; } public void Clear() { while (this.Count() > 0) this.Pop(); } public IEnumerator<T> GetEnumerator() { var ret = new List<T>(); while (this.Count() > 0) { ret.Add(this.Pop()); } foreach (var r in ret) { this.Push(r); yield return r; } } public T[] ToArray() { T[] array = new T[_sz]; int i = 0; foreach (var r in this) { array[i++] = r; } return array; } } }
[["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 205, 22], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["+", 0, 11, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
8
1,123
11
using System; using System.Collections.Generic; using System.Linq; namespace AtC { class Program { static void Main(string[] args) { var S = ReadString(); var list = new List<int>(); int count = 0; var acgt = new[] { 'A', 'C', 'G', 'T' }; foreach (var c in S) { if (acgt.Contains(c)) count++; else { list.Add(count); count = 0; } } Out(list.Max()); } static int[] ReadIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); } static int ReadInt() { return int.Parse(Console.ReadLine()); } static long ReadLong() { return long.Parse(Console.ReadLine()); } static string ReadString() { return Console.ReadLine(); } static void Out(object o) { Console.WriteLine(o); } } static class EnumerableExtension { public delegate void Function<in T>(T val); public static void ForEach<T>(this IEnumerable<T> enumerable, Function<T> function) { foreach (var x in enumerable) { function(x); } } } }
using System; using System.Collections.Generic; using System.Linq; namespace AtC { class Program { static void Main(string[] args) { var S = ReadString(); var list = new List<int>(); int count = 0; var acgt = new char[] { 'A', 'C', 'G', 'T' }; foreach (var c in S) { if (acgt.Contains(c)) count++; else { list.Add(count); count = 0; } } list.Add(count); Out(list.Max()); } static int[] ReadIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); } static int ReadInt() { return int.Parse(Console.ReadLine()); } static long ReadLong() { return long.Parse(Console.ReadLine()); } static string ReadString() { return Console.ReadLine(); } static void Out(object o) { Console.WriteLine(o); } } static class EnumerableExtension { public delegate void Function<in T>(T val); public static void ForEach<T>(this IEnumerable<T> enumerable, Function<T> function) { foreach (var x in enumerable) { function(x); } } } }
[["+", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
8
282
8
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Program { static void Main(string[] args) { var sc = new Scanner(); string s = sc.NextString(); string acgt = "ACGT"; int max = 0; int head = 0; int count = 0; while (head < s.Length) { if (acgt.IndexOf(s[head++]) == -1) { if (count > max) max = count; count = 0; continue; } count++; } Console.WriteLine(max); } } class Scanner { int index = -1; string[] buf; public Scanner() {} public int NextInt() { CheckNext(); return int.Parse(buf[index++]); } public long NextLong() { CheckNext(); return long.Parse(buf[index++]); } public string NextString() { CheckNext(); return buf[index++]; } private void CheckNext() { if (index >= 0 && index < buf.Length) return; buf = Console.ReadLine().Split(' '); index = 0; } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Program { static void Main(string[] args) { var sc = new Scanner(); string s = sc.NextString(); string acgt = "ACGT"; int max = 0; int head = 0; int count = 0; while (head < s.Length) { if (acgt.IndexOf(s[head++]) == -1) { if (count > max) max = count; count = 0; continue; } count++; } Console.WriteLine(Math.Max(max, count)); } } class Scanner { int index = -1; string[] buf; public Scanner() {} public int NextInt() { CheckNext(); return int.Parse(buf[index++]); } public long NextLong() { CheckNext(); return long.Parse(buf[index++]); } public string NextString() { CheckNext(); return buf[index++]; } private void CheckNext() { if (index >= 0 && index < buf.Length) return; buf = Console.ReadLine().Split(' '); index = 0; } }
[["+", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 21], ["+", 0, 28, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25]]
8
260
7
using System; using System.Linq; using System.Collections.Generic; class Program { static void Main(string[] args) { var S = Console.ReadLine(); var hash = new HashSet<char> { 'A', 'C', 'G', 'T' }; int max = 0; for (int i = 0; i < S.Length; i++) { int len = 0; for (int j = i; j < S.Length; j++) { if (hash.Contains(S[j])) { len++; } else { max = Math.Max(max, len); len = 0; } } } Console.WriteLine(max); } }
using System; using System.Linq; using System.Collections.Generic; class Program { static void Main(string[] args) { var S = Console.ReadLine(); var hash = new HashSet<char> { 'A', 'C', 'G', 'T' }; int max = 0; for (int i = 0; i < S.Length; i++) { int len = 0; for (int j = i; j < S.Length; j++) { if (!hash.Contains(S[j])) { break; } len++; } max = Math.Max(max, len); } Console.WriteLine(max); } }
[["+", 0, 7, 8, 196, 0, 57, 15, 241, 0, 111], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["-", 0, 7, 8, 196, 0, 57, 75, 196, 0, 45], ["-", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["-", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["-", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 0, 57, 75, 196, 0, 1, 0, 11, 12, 203], ["-", 0, 7, 8, 196, 0, 57, 75, 196, 0, 46], ["-", 0, 7, 8, 196, 0, 7, 8, 196, 0, 46]]
8
153
12
using System; class AtCoder { static void Main(string[] args) { var input = Console.ReadLine().ToUpper(); var atcg = new char[] { 'A', 'T', 'C', 'G' }; int count = 0; int max = 0; foreach (var chr in input) { switch (chr) { case 'A': case 'T': case 'C': case 'G': count++; break; default: max = count >= max ? count : max; count = 0; break; } } Console.WriteLine(max.ToString()); } }
using System; class AtCoder { static void Main(string[] args) { var input = Console.ReadLine().ToUpper(); var atcg = new char[] { 'A', 'T', 'C', 'G' }; int count = 0; int max = 0; foreach (var chr in input) { switch (chr) { case 'A': case 'T': case 'C': case 'G': count++; max = count >= max ? count : max; break; default: count = 0; break; } } Console.WriteLine(max.ToString()); } }
[["-", 0, 99, 8, 254, 0, 239, 0, 93, 0, 94], ["-", 0, 99, 8, 254, 0, 239, 0, 93, 0, 35], ["-", 0, 99, 8, 254, 0, 239, 0, 265, 0, 162], ["-", 0, 99, 8, 254, 0, 239, 0, 265, 0, 102], ["+", 0, 99, 8, 254, 0, 239, 0, 1, 0, 35], ["+", 0, 99, 8, 254, 0, 239, 0, 93, 0, 94], ["+", 0, 99, 8, 254, 0, 239, 0, 265, 0, 162], ["+", 0, 99, 8, 254, 0, 239, 0, 265, 0, 102]]
8
135
8
using System; using System.Collections.Generic; namespace ConsoleApplication1 { internal class Program { public static void Main(string[] args) { HashSet<string> strSet = new HashSet<string>() { "A", "C", "G", "T" }; var input = Console.ReadLine().ToCharArray(); int count = 0; for (int i = 0; i < input.Length; i++) { int tmpCount = 0; for (int j = i; j < input.Length; j++) { if (strSet.Contains(input[j].ToString())) { tmpCount++; } if (count < tmpCount) { count = tmpCount; } } } Console.WriteLine(count); } } }
using System; using System.Collections.Generic; namespace ConsoleApplication1 { internal class Program { public static void Main(string[] args) { HashSet<string> strSet = new HashSet<string>() { "A", "C", "G", "T" }; var input = Console.ReadLine().ToCharArray(); int count = 0; for (int i = 0; i < input.Length; i++) { int tmpCount = 0; for (int j = i; j < input.Length; j++) { if (strSet.Contains(input[j].ToString())) { tmpCount++; if (count < tmpCount) { count = tmpCount; } } else { tmpCount = 0; } } } Console.WriteLine(count); } } }
[["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 64, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 12, 203]]
8
161
9
using System; using System.Collections.Generic; using System.Linq; using console = System.Console; namespace AtCoderTemplate { public class App { public static void Main(string[] args) { string s = "0"; Console.WriteLine(console.ReadLine() .ToCharArray() .Select(c => "ACGT".Contains(c)) .Select((b) => { s = b ? (int.Parse(s) + 1).ToString() : "0"; return s; }) .Max()); } } }
using System; using System.Collections.Generic; using System.Linq; using console = System.Console; namespace AtCoderTemplate { public class App { public static void Main(string[] args) { string s = "0"; Console.WriteLine( console.ReadLine() .ToCharArray() .Select(c => "ACGT".Contains(c)) .Select((b) => s = b ? (int.Parse(s) + 1).ToString() : "0") .Max(v => int.Parse(v))); } } }
[["-", 3, 4, 0, 28, 0, 218, 8, 196, 0, 45], ["-", 0, 28, 0, 218, 8, 196, 0, 1, 0, 35], ["-", 0, 28, 0, 218, 8, 196, 0, 37, 0, 38], ["-", 0, 28, 0, 218, 8, 196, 0, 37, 0, 22], ["-", 0, 28, 0, 218, 8, 196, 0, 37, 0, 35], ["-", 3, 4, 0, 28, 0, 218, 8, 196, 0, 46], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 218, 0, 221], ["+", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["+", 0, 28, 0, 218, 8, 213, 63, 214, 0, 131], ["+", 0, 28, 0, 218, 8, 213, 63, 214, 141, 22], ["+", 0, 218, 8, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 28, 0, 218, 8, 213, 3, 4, 0, 25]]
8
119
12
using System; using System.Collections.Generic; using System.Linq; using console = System.Console; namespace AtCoderTemplate { public class App { public static void Main(string[] args) { string s = "0"; Console.WriteLine(console.ReadLine() .ToCharArray() .Select(c => "ACGT".Contains(c)) .Select((b) => { s = b ? (int.Parse(s) + 1).ToString() : "0"; return s; }) .Max()); } } }
using System; using System.Collections.Generic; using System.Linq; using console = System.Console; namespace AtCoderTemplate { public class App { public static void Main(string[] args) { string s = "0"; Console.WriteLine(console.ReadLine() .ToCharArray() .Select(c => "ACGT".Contains(c)) .Select((b) => { s = b ? (int.Parse(s) + 1).ToString() : "0"; return s; }) .Select(v => int.Parse(v)) .Max()); } } }
[["+", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["+", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["+", 205, 213, 3, 4, 0, 28, 0, 218, 0, 221], ["+", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["+", 0, 28, 0, 218, 8, 213, 63, 214, 0, 131], ["+", 0, 28, 0, 218, 8, 213, 63, 214, 141, 22], ["+", 0, 28, 0, 218, 8, 213, 3, 4, 0, 24], ["+", 0, 218, 8, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 28, 0, 218, 8, 213, 3, 4, 0, 25], ["+", 0, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131]]
8
119
12
using System; using System.Collections; using System.Collections.Generic; using System.Linq; class Myon { static void Main(string[] args) { var myon = new Myon(); } public Myon() { int[] time = new int[5]; for (int i = 0; i < 5; i++) { time[i] = int.Parse(Console.ReadLine()); } int[] amari = new int[5]; for (int i = 0; i < 5; i++) { amari[i] = time[i] % 10; } int timeProg = 0; int Min = 10; for (int i = 0; i < 5; i++) { if (amari[i] < Min) Min = amari[i]; timeProg += time[i] - amari[i] + 10; } timeProg -= 10 - Min; Console.WriteLine(timeProg); } }
using System; using System.Collections; using System.Collections.Generic; using System.Linq; class Myon { static void Main(string[] args) { var myon = new Myon(); } public Myon() { int[] time = new int[5]; for (int i = 0; i < 5; i++) { time[i] = int.Parse(Console.ReadLine()); } int[] amari = new int[5]; for (int i = 0; i < 5; i++) { amari[i] = time[i] % 10; } int timeProg = 0; int Min = 10; for (int i = 0; i < 5; i++) { if (amari[i] == 0) { timeProg += time[i]; continue; } else if (amari[i] < Min) Min = amari[i]; timeProg += time[i] - amari[i] + 10; } timeProg -= 10 - Min; Console.WriteLine(timeProg); } }
[["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 64, 196, 0, 1, 0, 11, 12, 204, 205, 22], ["+", 0, 1, 0, 11, 12, 204, 206, 207, 0, 70], ["+", 0, 11, 12, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 1, 0, 11, 12, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 116, 0, 117], ["+", 8, 196, 0, 57, 64, 196, 0, 116, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["+", 0, 7, 8, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 7, 8, 196, 0, 57, 75, 57, 0, 24], ["+", 0, 57, 75, 57, 15, 16, 31, 204, 205, 22], ["+", 75, 57, 15, 16, 31, 204, 206, 207, 0, 70], ["+", 15, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 75, 57, 15, 16, 31, 204, 206, 207, 0, 73]]
8
200
21
using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace kyoupuro { class MainClass { public static void Main() { MainClass mainClass = new MainClass(); mainClass.Start(); } public void Start() { int sum = 0, mod = 100; for (int i = 0; i < 5; i++) { var line = int.Parse(Console.ReadLine()); if (line % 10 == 0) { sum += line; } else { sum += line + (10 - line % 10); mod = Math.Min(line % 10, mod); } } if (mod == 100) mod = 0; Console.WriteLine(sum + mod - 10); } List<List<int>> IntInit() { int maxindex = int.Parse(Console.ReadLine()); List<List<int>> array = new List<List<int>>(); for (int i = 0; i < maxindex; i++) { array.Add(new List<int>(Console.ReadLine().Split(' ').Select(int.Parse))); } return array; } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace kyoupuro { class MainClass { public static void Main() { MainClass mainClass = new MainClass(); mainClass.Start(); } public void Start() { int sum = 0, mod = 100; for (int i = 0; i < 5; i++) { var line = int.Parse(Console.ReadLine()); if (line % 10 == 0) { sum += line; } else { sum += line + (10 - line % 10); mod = Math.Min(line % 10, mod); } } if (mod == 100) { Console.WriteLine(sum); } else { Console.WriteLine(sum + mod - 10); } } List<List<int>> IntInit() { int maxindex = int.Parse(Console.ReadLine()); List<List<int>> array = new List<List<int>>(); for (int i = 0; i < maxindex; i++) { array.Add(new List<int>(Console.ReadLine().Split(' ').Select(int.Parse))); } return array; } } }
[["-", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["-", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["-", 8, 196, 0, 57, 64, 1, 0, 11, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
8
258
14
using System; using System.Collections; using System.Collections.Generic; class Program { static int Solve(List<int> p) { if (p.Count == 1) return p[0]; else { int m = int.MaxValue; for (int i = 0; i < p.Count; i++) { List<int> f = new List<int>(); for (int j = 0; j < p.Count; j++) { if (i != j) f.Add(p[j]); } m = Math.Min(m, Solve(f) + (p[i] / 10 + 1) * 10); } return m; } } public static void Main() { List<int> p = new List<int>(); p.Add(int.Parse(Console.ReadLine())); p.Add(int.Parse(Console.ReadLine())); p.Add(int.Parse(Console.ReadLine())); p.Add(int.Parse(Console.ReadLine())); p.Add(int.Parse(Console.ReadLine())); Console.WriteLine(Solve(p)); } }
using System; using System.Collections; using System.Collections.Generic; class Program { static int Solve(List<int> p) { if (p.Count == 1) return p[0]; else { int m = int.MaxValue; for (int i = 0; i < p.Count; i++) { List<int> f = new List<int>(); for (int j = 0; j < p.Count; j++) { if (i != j) f.Add(p[j]); } if (p[i] % 10 == 0) m = Math.Min(m, Solve(f) + p[i]); else m = Math.Min(m, Solve(f) + (p[i] / 10 + 1) * 10); } return m; } } public static void Main() { List<int> p = new List<int>(); p.Add(int.Parse(Console.ReadLine())); p.Add(int.Parse(Console.ReadLine())); p.Add(int.Parse(Console.ReadLine())); p.Add(int.Parse(Console.ReadLine())); p.Add(int.Parse(Console.ReadLine())); Console.WriteLine(Solve(p)); } }
[["+", 75, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 75, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 0, 57, 15, 16, 31, 16, 31, 204, 205, 22], ["+", 15, 16, 31, 16, 31, 204, 206, 207, 0, 70], ["+", 31, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 15, 16, 31, 16, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 75, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 64, 1, 0, 11, 12, 213, 63, 214, 205, 22], ["+", 64, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["+", 64, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 64, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["+", 0, 11, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 64, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["+", 3, 4, 0, 28, 0, 16, 31, 213, 63, 22], ["+", 0, 28, 0, 16, 31, 213, 3, 4, 0, 24], ["+", 0, 16, 31, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 28, 0, 16, 31, 213, 3, 4, 0, 25], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 3, 4, 0, 28, 0, 16, 12, 204, 205, 22], ["+", 0, 28, 0, 16, 12, 204, 206, 207, 0, 70], ["+", 0, 16, 12, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 28, 0, 16, 12, 204, 206, 207, 0, 73], ["+", 64, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 1, 0, 35], ["+", 75, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["+", 8, 196, 0, 57, 75, 1, 0, 11, 31, 22]]
8
263
31
using System; using System.Collections.Generic; using System.IO; using System.Linq; class Program { #region library static int n = 0; static int r = 0; static int c = 0; static string s = ""; static string[] ss; static long sum = 0; static long cnt = 0; static long max = -1; static long min = 2147483647; static bool flg = false; static string alpha = "abcdefghijklmnopqrstuvwxyz"; static long mod = 1000000007; static long[] arr; static char[,] map; static int[,] imap; static Queue<int> qx = new Queue<int>(); static Queue<int> qy = new Queue<int>(); public class Input { static readonly char[] separator = { ' ', '\r', '\n' }; readonly StreamReader sr; readonly Queue<string> queue; public Input(string path = "") { queue = new Queue<string>(); if (string.IsNullOrEmpty(path)) { sr = new StreamReader(Console.OpenStandardInput()); } else { sr = new StreamReader(path); } } public void SetText(IEnumerable<string> items) { foreach (var item in items) { SetText(item); } } public bool SetText(string s) { if (s == null) return false; foreach (var elem in s.Trim().Split( separator, StringSplitOptions.RemoveEmptyEntries)) { queue.Enqueue(elem); } return true; } public bool Any() { return queue.Any() || Read(); } bool Read() { if (!SetText(sr.ReadLine())) return false; if (!queue.Any()) return Read(); return queue.Any(); } public string Next() { if (!queue.Any() && !Read()) { return ""; } return queue.Dequeue(); } bool Accumulate(int n) { while (queue.Count() < n) { if (!Read()) return false; } return true; } public int NextInt() { return int.Parse(Next()); } public long NextLong() { return long.Parse(Next()); } public double NextDouble() { return double.Parse(Next()); } T[] NextT<T>(int n, T offset, Func<string, T> parse, Func<T, T, T> add) { if (!Accumulate(n)) return null; var a = new T[n]; for (int i = 0; i < n; i++) a[i] = add(parse(queue.Dequeue()), offset); return a; } public string[] Next(int n) { return NextT(n, "", x => x, (x, y) => x); } public int[] NextInt(int n, int offset = 0) { return NextT(n, offset, int.Parse, (x, y) => x + y); } public long[] NextLong(int n, long offset = 0) { return NextT(n, offset, long.Parse, (x, y) => x + y); } public double[] NextDouble(int n, double offset = 0.0) { return NextT(n, offset, double.Parse, (x, y) => x + y); } } static Input input; static int Int() { return input.NextInt(); } static long Long() { return input.NextLong(); } static double Double() { return input.NextDouble(); } static string Text() { return input.Next(); } static void wl(object obj = null) { Console.WriteLine(obj); } static void w(object obj) { Console.Write(obj); } static void Yes() { wl("YES"); } static void No() { wl("NO"); } static void Sum() { wl(sum); } static void Cnt() { wl(cnt); } static void SetArray(long num = -1) { if (n == 0) { n = Int(); } arr = new long[n]; for (int i = 0; i < n; i++) { if (num == -1) arr[i] = Int(); else arr[i] = num; } } static void ShowArray() { for (int i = 0; i < arr.Length; i++) { if (i > 0) w(" "); w(arr[i]); } wl(); } static void SetMap(char def = '@') { if (r == 0 && c == 0) { r = Int(); c = Int(); } map = new char[r, c]; for (int i = 0; i < r; i++) { if (def == '@') s = Text(); for (int j = 0; j < c; j++) { map[i, j] = (def == '@') ? s[j] : def; } } } static void SetIMap(int def = -1) { if (r == 0 && c == 0) { r = Int(); c = Int(); } imap = new int[r, c]; for (int i = 0; i < r; i++) { for (int j = 0; j < c; j++) { imap[i, j] = (def == -1) ? Int() : def; } } } static void ShowMap() { for (int i = 0; i < r; i++) { for (int j = 0; j < c; j++) { w(map[i, j]); } wl(); } } static void ShowIMap() { for (int i = 0; i < r; i++) { for (int j = 0; j < c; j++) { w(imap[i, j]); } wl(); } } #endregion #region main static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); input = new Input(); try { Solve(); } catch (Exception ex) { wl(ex); } Console.Out.Flush(); } public static void Solve() { long n = Long(); arr = new long[5]; for (int i = 0; i < 5; i++) { arr[i] = Long(); } Array.Sort(arr); sum = 5; if (n > arr[0]) { sum += n / arr[0]; } Sum(); } #endregion }
using System; using System.Collections.Generic; using System.IO; using System.Linq; class Program { #region library static int n = 0; static int r = 0; static int c = 0; static string s = ""; static string[] ss; static long sum = 0; static long cnt = 0; static long max = -1; static long min = 2147483647; static bool flg = false; static string alpha = "abcdefghijklmnopqrstuvwxyz"; static long mod = 1000000007; static long[] arr; static char[,] map; static int[,] imap; static Queue<int> qx = new Queue<int>(); static Queue<int> qy = new Queue<int>(); public class Input { static readonly char[] separator = { ' ', '\r', '\n' }; readonly StreamReader sr; readonly Queue<string> queue; public Input(string path = "") { queue = new Queue<string>(); if (string.IsNullOrEmpty(path)) { sr = new StreamReader(Console.OpenStandardInput()); } else { sr = new StreamReader(path); } } public void SetText(IEnumerable<string> items) { foreach (var item in items) { SetText(item); } } public bool SetText(string s) { if (s == null) return false; foreach (var elem in s.Trim().Split( separator, StringSplitOptions.RemoveEmptyEntries)) { queue.Enqueue(elem); } return true; } public bool Any() { return queue.Any() || Read(); } bool Read() { if (!SetText(sr.ReadLine())) return false; if (!queue.Any()) return Read(); return queue.Any(); } public string Next() { if (!queue.Any() && !Read()) { return ""; } return queue.Dequeue(); } bool Accumulate(int n) { while (queue.Count() < n) { if (!Read()) return false; } return true; } public int NextInt() { return int.Parse(Next()); } public long NextLong() { return long.Parse(Next()); } public double NextDouble() { return double.Parse(Next()); } T[] NextT<T>(int n, T offset, Func<string, T> parse, Func<T, T, T> add) { if (!Accumulate(n)) return null; var a = new T[n]; for (int i = 0; i < n; i++) a[i] = add(parse(queue.Dequeue()), offset); return a; } public string[] Next(int n) { return NextT(n, "", x => x, (x, y) => x); } public int[] NextInt(int n, int offset = 0) { return NextT(n, offset, int.Parse, (x, y) => x + y); } public long[] NextLong(int n, long offset = 0) { return NextT(n, offset, long.Parse, (x, y) => x + y); } public double[] NextDouble(int n, double offset = 0.0) { return NextT(n, offset, double.Parse, (x, y) => x + y); } } static Input input; static int Int() { return input.NextInt(); } static long Long() { return input.NextLong(); } static double Double() { return input.NextDouble(); } static string Text() { return input.Next(); } static void wl(object obj = null) { Console.WriteLine(obj); } static void w(object obj) { Console.Write(obj); } static void Yes() { wl("YES"); } static void No() { wl("NO"); } static void Sum() { wl(sum); } static void Cnt() { wl(cnt); } static void SetArray(long num = -1) { if (n == 0) { n = Int(); } arr = new long[n]; for (int i = 0; i < n; i++) { if (num == -1) arr[i] = Int(); else arr[i] = num; } } static void ShowArray() { for (int i = 0; i < arr.Length; i++) { if (i > 0) w(" "); w(arr[i]); } wl(); } static void SetMap(char def = '@') { if (r == 0 && c == 0) { r = Int(); c = Int(); } map = new char[r, c]; for (int i = 0; i < r; i++) { if (def == '@') s = Text(); for (int j = 0; j < c; j++) { map[i, j] = (def == '@') ? s[j] : def; } } } static void SetIMap(int def = -1) { if (r == 0 && c == 0) { r = Int(); c = Int(); } imap = new int[r, c]; for (int i = 0; i < r; i++) { for (int j = 0; j < c; j++) { imap[i, j] = (def == -1) ? Int() : def; } } } static void ShowMap() { for (int i = 0; i < r; i++) { for (int j = 0; j < c; j++) { w(map[i, j]); } wl(); } } static void ShowIMap() { for (int i = 0; i < r; i++) { for (int j = 0; j < c; j++) { w(imap[i, j]); } wl(); } } #endregion #region main static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); input = new Input(); try { Solve(); } catch (Exception ex) { wl(ex); } Console.Out.Flush(); } public static void Solve() { long n = Long(); arr = new long[5]; for (int i = 0; i < 5; i++) { arr[i] = Long(); } Array.Sort(arr); sum = 4; if (n > arr[0]) { sum += n / arr[0]; if (n % arr[0] > 0) sum++; } else { sum++; } Sum(); } #endregion }
[["-", 0, 195, 8, 196, 0, 1, 0, 11, 12, 203], ["+", 0, 195, 8, 196, 0, 1, 0, 11, 12, 203], ["+", 0, 1, 0, 11, 12, 16, 12, 204, 205, 22], ["+", 0, 11, 12, 16, 12, 204, 206, 207, 0, 70], ["+", 12, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 11, 12, 16, 12, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 64, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 64, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["+", 64, 196, 0, 57, 64, 1, 0, 223, 0, 22], ["+", 64, 196, 0, 57, 64, 1, 0, 223, 0, 29], ["+", 0, 57, 64, 196, 0, 57, 64, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 57, 75, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 57, 75, 196, 0, 1, 0, 223, 0, 29]]
8
1,484
22
using System; using System.Linq; using System.Collections.Generic; using System.IO; using static System.Console; namespace atcorder2 { class Program { public static long Read() { return long.Parse(ReadLine()); } public static long[] Reads() { return ReadLine().Split().Select(long.Parse).ToArray(); } public static long gcd(long x, long y) { if (x < y) gcd(y, x); while (y != 0) { var z = x; x = y; y = z % y; } return x; } public static long lcm(long x, long y) { return x * y / gcd(x, y); } public static long C(long n, long k) { long x = 1; for (long i = 1; i <= k; i++) { x *= n - i + 1; x /= i; } return x; } static void Main(string[] args) { var sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); var n = Read(); var i = new long[5]; i[0] = Read(); i[1] = Read(); i[2] = Read(); i[3] = Read(); i[4] = Read(); WriteLine(n / i.Min() + 5); Console.Out.Flush(); } } }
using System; using System.Linq; using System.Collections.Generic; using System.IO; using static System.Console; namespace atcorder2 { class Program { public static long Read() { return long.Parse(ReadLine()); } public static long[] Reads() { return ReadLine().Split().Select(long.Parse).ToArray(); } public static long gcd(long x, long y) { if (x < y) gcd(y, x); while (y != 0) { var z = x; x = y; y = z % y; } return x; } public static long lcm(long x, long y) { return x * y / gcd(x, y); } public static long C(long n, long k) { long x = 1; for (long i = 1; i <= k; i++) { x *= n - i + 1; x /= i; } return x; } static void Main(string[] args) { var sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); var n = Read(); var i = new long[5]; i[0] = Read(); i[1] = Read(); i[2] = Read(); i[3] = Read(); i[4] = Read(); if (n % i.Min() == 0) WriteLine(n / i.Min() + 4); else WriteLine(n / i.Min() + 5); Out.Flush(); } } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["+", 15, 16, 31, 16, 12, 213, 63, 214, 205, 22], ["+", 15, 16, 31, 16, 12, 213, 63, 214, 0, 131], ["+", 15, 16, 31, 16, 12, 213, 63, 214, 141, 22], ["+", 15, 16, 31, 16, 12, 213, 3, 4, 0, 24], ["+", 15, 16, 31, 16, 12, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["-", 0, 1, 0, 213, 63, 214, 205, 214, 205, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 8, 196, 0, 57, 75, 1, 0, 213, 63, 22], ["+", 0, 57, 75, 1, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 31, 22], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 17, 85], ["+", 0, 16, 31, 16, 12, 213, 63, 214, 205, 22], ["+", 0, 16, 31, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 16, 31, 16, 12, 213, 3, 4, 0, 24], ["+", 0, 16, 31, 16, 12, 213, 3, 4, 0, 25], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 0, 57, 75, 1, 0, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 75, 1, 0, 35]]
8
324
28