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; public class Program { public void Solve() { var sc = new Scanner(); long X = sc.NextInt(); long A = sc.NextInt(); long B = sc.NextInt(); if (A > B) { Console.WriteLine("delicious"); } else if (-A + B <= X) { Console.WriteLine("safe"); } else { Console.WriteLine("dangerous"); } } public static void Main(string[] args) { new Program().Solve(); } } class Scanner { public Scanner() { _pos = 0; _line = new string[0]; } const char Separator = ' '; private int _pos; private string[] _line; #region ใ‚นใƒšใƒผใ‚นๅŒบๅˆ‡ใ‚Šใงๅ–ๅพ— public string Next() { if (_pos >= _line.Length) { _line = Console.ReadLine().Split(Separator); _pos = 0; } return _line[_pos++]; } public int NextInt() { return int.Parse(Next()); } public long NextLong() { return long.Parse(Next()); } public double NextDouble() { return double.Parse(Next()); } #endregion #region ๅž‹ๅค‰ๆ› private int[] ToIntArray(string[] array) { var result = new int[array.Length]; for (int i = 0; i < array.Length; i++) { result[i] = int.Parse(array[i]); } return result; } private long[] ToLongArray(string[] array) { var result = new long[array.Length]; for (int i = 0; i < array.Length; i++) { result[i] = long.Parse(array[i]); } return result; } private double[] ToDoubleArray(string[] array) { var result = new double[array.Length]; for (int i = 0; i < array.Length; i++) { result[i] = double.Parse(array[i]); } return result; } #endregion #region ้…ๅˆ—ๅ–ๅพ— public string[] Array() { if (_pos >= _line.Length) _line = Console.ReadLine().Split(Separator); _pos = _line.Length; return _line; } public int[] IntArray() { return ToIntArray(Array()); } public long[] LongArray() { return ToLongArray(Array()); } public double[] DoubleArray() { return ToDoubleArray(Array()); } #endregion }
using System; public class Program { public void Solve() { var sc = new Scanner(); long X = sc.NextInt(); long A = sc.NextInt(); long B = sc.NextInt(); if (A >= B) { Console.WriteLine("delicious"); } else if (-A + B <= X) { Console.WriteLine("safe"); } else { Console.WriteLine("dangerous"); } } public static void Main(string[] args) { new Program().Solve(); } } class Scanner { public Scanner() { _pos = 0; _line = new string[0]; } const char Separator = ' '; private int _pos; private string[] _line; #region ใ‚นใƒšใƒผใ‚นๅŒบๅˆ‡ใ‚Šใงๅ–ๅพ— public string Next() { if (_pos >= _line.Length) { _line = Console.ReadLine().Split(Separator); _pos = 0; } return _line[_pos++]; } public int NextInt() { return int.Parse(Next()); } public long NextLong() { return long.Parse(Next()); } public double NextDouble() { return double.Parse(Next()); } #endregion #region ๅž‹ๅค‰ๆ› private int[] ToIntArray(string[] array) { var result = new int[array.Length]; for (int i = 0; i < array.Length; i++) { result[i] = int.Parse(array[i]); } return result; } private long[] ToLongArray(string[] array) { var result = new long[array.Length]; for (int i = 0; i < array.Length; i++) { result[i] = long.Parse(array[i]); } return result; } private double[] ToDoubleArray(string[] array) { var result = new double[array.Length]; for (int i = 0; i < array.Length; i++) { result[i] = double.Parse(array[i]); } return result; } #endregion #region ้…ๅˆ—ๅ–ๅพ— public string[] Array() { if (_pos >= _line.Length) _line = Console.ReadLine().Split(Separator); _pos = _line.Length; return _line; } public int[] IntArray() { return ToIntArray(Array()); } public long[] LongArray() { return ToLongArray(Array()); } public double[] DoubleArray() { return ToDoubleArray(Array()); } #endregion }
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 20]]
8
538
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp42 { class Program { static void Main(string[] args) { var st = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); int X = st[0]; int A = st[1]; int B = st[2]; if (A - B > 0) { Console.WriteLine("delicious"); } else if (B - A >= X) { Console.WriteLine("safe"); } else { Console.WriteLine("dangerous"); } } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp42 { class Program { static void Main(string[] args) { var st = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); int X = st[0]; int A = st[1]; int B = st[2]; if (A - B >= 0) { Console.WriteLine("delicious"); } else if (B - A <= X) { Console.WriteLine("safe"); } else { Console.WriteLine("dangerous"); } } } }
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 20], ["-", 8, 196, 0, 57, 75, 57, 15, 16, 17, 20], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 19]]
8
148
4
using System; using System.Collections.Generic; using System.Linq; namespace ziyuutyou { class Program { static void Main(string[] args) { var str = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); if (str[2] < str[1]) { Console.WriteLine("delicious"); } else if (str[0] >= str[2] - str[1]) { Console.WriteLine("safe"); } else { Console.WriteLine("dangerous"); } } } }
using System; using System.Collections.Generic; using System.Linq; namespace ziyuutyou { class Program { static void Main(string[] args) { var str = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); if (str[2] <= str[1]) { Console.WriteLine("delicious"); } else if (str[0] >= str[2] - str[1]) { Console.WriteLine("safe"); } else { Console.WriteLine("dangerous"); } } } }
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 19]]
8
123
2
using System; using System.Linq; namespace A___Expired { class Program { static void Main(string[] args) { var X_A_B = Console.ReadLine().Split().Select(int.Parse).ToArray(); int X = X_A_B[0], A = X_A_B[1], B = X_A_B[2]; Console.WriteLine(A > B ? "delicious" : X + A >= B ? "safe" : "dangerous"); } } }
using System; using System.Linq; namespace A___Expired { class Program { static void Main(string[] args) { var X_A_B = Console.ReadLine().Split().Select(int.Parse).ToArray(); int X = X_A_B[0], A = X_A_B[1], B = X_A_B[2]; Console.WriteLine(A >= B ? "delicious" : X + A >= B ? "safe" : "dangerous"); } } }
[["-", 3, 4, 0, 28, 0, 41, 15, 16, 17, 47], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 17, 20]]
8
100
2
public class Hello { public static void Main() { string[] num = System.Console.ReadLine().Split(' '); int X = int.Parse(num[0]); int A = int.Parse(num[1]); int B = int.Parse(num[2]); if (0 - A + B <= 0) { System.Console.WriteLine("delicious"); } else if (0 - A + B < X) { System.Console.WriteLine("safe"); } else { System.Console.WriteLine("dangerous"); } } }
public class Hello { public static void Main() { string[] num = System.Console.ReadLine().Split(' '); int X = int.Parse(num[0]); int A = int.Parse(num[1]); int B = int.Parse(num[2]); if (0 - A + B <= 0) { System.Console.WriteLine("delicious"); } else if (0 - A + B <= X) { System.Console.WriteLine("safe"); } else { System.Console.WriteLine("dangerous"); } } }
[["-", 8, 196, 0, 57, 75, 57, 15, 16, 17, 18], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 19]]
8
133
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Atcoder { class Atcoderrrrrrr { static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); int X = int.Parse(input[0]); int A = int.Parse(input[1]); int B = int.Parse(input[2]); if (A >= B) { Console.WriteLine("delicious"); } else { Console.WriteLine(Math.Abs(A - B) < X ? "safe" : "dangerous"); } } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Atcoder { class Atcoderrrrrrr { static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); int X = int.Parse(input[0]); int A = int.Parse(input[1]); int B = int.Parse(input[2]); if (A >= B) { Console.WriteLine("delicious"); } else { Console.WriteLine(Math.Abs(A - B) <= X ? "safe" : "dangerous"); } } } }
[["-", 3, 4, 0, 28, 0, 41, 15, 16, 17, 18], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 17, 19]]
8
147
2
using System; class A { static void Main() { var s = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); Console.WriteLine(s[2] - s[1] < 0 ? "delicious" : s[2] - s[1] <= s[0] ? "safe" : "dangerous"); } }
using System; class A { static void Main() { var s = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); Console.WriteLine(s[2] - s[1] <= 0 ? "delicious" : s[2] - s[1] <= s[0] ? "safe" : "dangerous"); } }
[["-", 3, 4, 0, 28, 0, 41, 15, 16, 17, 18], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 17, 19]]
8
83
2
using System; class Program { static void Main(string[] args) { var input = Console.ReadLine().Split(' '); var limit = Convert.ToInt32(input[0]); var buy = Convert.ToInt32(input[1]); var eat = Convert.ToInt32(input[2]); if (buy > eat) Console.WriteLine("delicious"); else if (eat - buy < limit) Console.WriteLine("safe"); else Console.WriteLine("dangerous"); } }
using System; class Program { static void Main(string[] args) { var input = Console.ReadLine().Split(' '); var limit = Convert.ToInt32(input[0]); var buy = Convert.ToInt32(input[1]); var eat = Convert.ToInt32(input[2]); if (buy >= eat) Console.WriteLine("delicious"); else if (eat - buy <= limit) Console.WriteLine("safe"); else Console.WriteLine("dangerous"); } }
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 20], ["-", 8, 196, 0, 57, 75, 57, 15, 16, 17, 18], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 19]]
8
116
4
using System; public class Hello { public static void Main() { string[] line = Console.ReadLine().Trim().Split(' '); var x = int.Parse(line[0]); var a = int.Parse(line[1]); var b = int.Parse(line[2]); var ba = b - a; if (ba <= 0) Console.WriteLine("delicious"); else if (x > ba) Console.WriteLine("safe"); else Console.WriteLine("dangerous"); } }
using System; public class Hello { public static void Main() { string[] line = Console.ReadLine().Trim().Split(' '); var x = int.Parse(line[0]); var a = int.Parse(line[1]); var b = int.Parse(line[2]); var ba = b - a; if (ba <= 0) Console.WriteLine("delicious"); else if (x >= ba) Console.WriteLine("safe"); else Console.WriteLine("dangerous"); } }
[["-", 8, 196, 0, 57, 75, 57, 15, 16, 17, 47], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 20]]
8
125
2
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) { var sw = new System.IO.StreamWriter( Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); new Program().Solve(new MyInputStream(Console.In, ' ')); Console.Out.Flush(); } public void Solve(MyInputStream cin) { var x = cin.ReadInt(); var a = cin.ReadInt(); var b = cin.ReadInt(); if (b - a <= 0) WriteLine("delicious"); else if (b - a < x) WriteLine("safe"); else WriteLine("dangerous"); } } public class MyInputStream { private readonly System.IO.TextReader _stream; private char separator = ' '; private Queue<string> inputStream; public MyInputStream(System.IO.TextReader s, char separator = ' ') { this.separator = separator; this._stream = s; inputStream = new Queue<string>(); } public string Read() { 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() { return _stream.ReadLine(); } public int ReadInt() { return int.Parse(Read()); } public long ReadLong() { return long.Parse(Read()); } public double ReadDouble() { 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) { var sw = new System.IO.StreamWriter( Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); new Program().Solve(new MyInputStream(Console.In, ' ')); Console.Out.Flush(); } public void Solve(MyInputStream cin) { var x = cin.ReadInt(); var a = cin.ReadInt(); var b = cin.ReadInt(); if (b - a <= 0) WriteLine("delicious"); else if (b - a <= x) WriteLine("safe"); else WriteLine("dangerous"); } } public class MyInputStream { private readonly System.IO.TextReader _stream; private char separator = ' '; private Queue<string> inputStream; public MyInputStream(System.IO.TextReader s, char separator = ' ') { this.separator = separator; this._stream = s; inputStream = new Queue<string>(); } public string Read() { 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() { return _stream.ReadLine(); } public int ReadInt() { return int.Parse(Read()); } public long ReadLong() { return long.Parse(Read()); } public double ReadDouble() { 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; } } }
[["-", 8, 196, 0, 57, 75, 57, 15, 16, 17, 18], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 19]]
8
534
2
using System; using System.Linq; using System.Collections.Generic; public class Hello { public static void Main() { string[] s = Console.ReadLine().Split(' '); int X = int.Parse(s[0]); int A = -int.Parse(s[1]); int B = int.Parse(s[2]); string ans = "dangerous"; if ((A + B) < 0) ans = "delicious"; else if ((A + B) < X) ans = "safe"; Console.WriteLine(ans); } }
using System; using System.Linq; using System.Collections.Generic; public class Hello { public static void Main() { string[] s = Console.ReadLine().Split(' '); int X = int.Parse(s[0]); int A = -int.Parse(s[1]); int B = int.Parse(s[2]); string ans = "dangerous"; if ((A + B) <= 0) ans = "delicious"; else if ((A + B) <= X) ans = "safe"; Console.WriteLine(ans); } }
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 19], ["-", 8, 196, 0, 57, 75, 57, 15, 16, 17, 18], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 19]]
8
133
4
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Text; namespace AtCoder { class MainClass { int X, A, B; void Solve() { io.i(out X, out A, out B); io.o((B < A) ? "delicious" : (B < (A + X)) ? "safe" : "dangerous"); } int ManhattanDis(int x1, int y1, int x2, int y2) { return Math.Abs(x1 - x2) + Math.Abs(y1 - y2); } public static void Main(string[] args) { new MainClass().Stream(); } IO io = new IO(); void Stream() { Solve(); io.writeFlush(); } class IO { string[] nextBuffer; int BufferCnt; char[] cs = new char[] { ' ' }; StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; public IO() { nextBuffer = new string[0]; BufferCnt = 0; Console.SetOut(sw); } public string next() { if (BufferCnt < nextBuffer.Length) return nextBuffer[BufferCnt++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); BufferCnt = 0; return nextBuffer[BufferCnt++]; } public char nextChar() { return char.Parse(next()); } public int nextInt() { return int.Parse(next()); } public long nextLong() { return long.Parse(next()); } public double nextDouble() { return double.Parse(next()); } public string[] array() { return Console.ReadLine().Split(' '); } public char[] arrayChar() { return Array.ConvertAll(array(), char.Parse); } public int[] arrayInt() { return Array.ConvertAll(array(), int.Parse); } public long[] arrayLong() { return Array.ConvertAll(array(), long.Parse); } public double[] arrayDouble() { return Array.ConvertAll(array(), double.Parse); } private bool typeEQ<T, U>() { return typeof(T).Equals(typeof(U)); } private T convertType<T, U>(U v) { return (T)Convert.ChangeType(v, typeof(T)); } private T suitType<T>(string s) { if (typeEQ<T, int>()) return convertType<T, int>(int.Parse(s)); if (typeEQ<T, long>()) return convertType<T, long>(long.Parse(s)); if (typeEQ<T, double>()) return convertType<T, double>(double.Parse(s)); if (typeEQ<T, char>()) return convertType<T, char>(char.Parse(s)); return convertType<T, string>(s); } public void i<T>(out T v) { v = suitType<T>(next()); } public void i<T, U>(out T v1, out U v2) { var a = array(); v1 = suitType<T>(a[0]); v2 = suitType<U>(a[1]); } public void i<T, U, V>(out T v1, out U v2, out V v3) { var a = array(); v1 = suitType<T>(a[0]); v2 = suitType<U>(a[1]); v3 = suitType<V>(a[2]); } public void i<T, U, V, W>(out T v1, out U v2, out V v3, out W v4) { var a = array(); v1 = suitType<T>(a[0]); v2 = suitType<U>(a[1]); v3 = suitType<V>(a[2]); v4 = suitType<W>(a[3]); } public void ini(out int[] a, int size) { a = new int[size]; for (int i = 0; i < size; i++) a[i] = nextInt(); } public void ini(out int[] a1, out int[] a2, int size) { a1 = new int[size]; a2 = new int[size]; for (int i = 0; i < size; i++) { a1[i] = nextInt(); a2[i] = nextInt(); } } public void ini(out string[] a, int size) { a = new string[size]; for (int i = 0; i < size; i++) a[i] = next(); } public void o<T>(T v) { Console.WriteLine(v); } public void o<T>(params T[] a) { foreach (T v in a) Console.WriteLine(v); } public void o<T>(List<T> l) { foreach (T v in l) sw.WriteLine(v); } public void ol<T>(T v) { Console.Write(v + " "); } public void ol<T>(params T[] a) { foreach (T v in a) Console.Write(v + " "); Console.WriteLine(""); } public void YN(bool f) { Console.WriteLine(f ? "YES" : "NO"); } public void yn(bool f) { Console.WriteLine(f ? "Yes" : "No"); } public void writeFlush() { Console.Out.Flush(); } } class Mathf { public int mod = 1000000007; // 10^9+7 public long Pow(long a, long b) { if (b == 0) return 1; if (b % 2 == 1) return (a % mod * Pow(a % mod, b - 1) % mod) % mod; else return Pow(a * a % mod, b / 2) % mod; } public long Fact(long n) { return n != 0 ? (n % mod * (Fact(n - 1) % mod) % mod) : 1; } public long C(long n, long r) { if (r == 0 || n == r) return 1; else return (Fact(n) % mod * Pow((Fact(n - r) % mod * Fact(r) % mod) % mod, mod - 2) % mod) % mod; } public long Sum(params long[] a) { return a.Aggregate((v, next) => (v % mod + next) % mod); } public int GCD(int a, int b) { if (a < b) Swap(ref a, ref b); return b == 0 ? a : GCD(b, a % b); } public int GCD(int[] array) { return array.Aggregate((v, next) => GCD(v, next)); } public void Swap<T>(ref T a, ref T b) { T tmp = a; a = b; b = tmp; } public T Max<T>(params T[] v) { return v.Max(); } public T Min<T>(params T[] v) { return v.Min(); } } } }
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Text; namespace AtCoder { class MainClass { int X, A, B; void Solve() { io.i(out X, out A, out B); io.o((B <= A) ? "delicious" : (B <= (A + X)) ? "safe" : "dangerous"); } int ManhattanDis(int x1, int y1, int x2, int y2) { return Math.Abs(x1 - x2) + Math.Abs(y1 - y2); } public static void Main(string[] args) { new MainClass().Stream(); } IO io = new IO(); void Stream() { Solve(); io.writeFlush(); } class IO { string[] nextBuffer; int BufferCnt; char[] cs = new char[] { ' ' }; StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; public IO() { nextBuffer = new string[0]; BufferCnt = 0; Console.SetOut(sw); } public string next() { if (BufferCnt < nextBuffer.Length) return nextBuffer[BufferCnt++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); BufferCnt = 0; return nextBuffer[BufferCnt++]; } public char nextChar() { return char.Parse(next()); } public int nextInt() { return int.Parse(next()); } public long nextLong() { return long.Parse(next()); } public double nextDouble() { return double.Parse(next()); } public string[] array() { return Console.ReadLine().Split(' '); } public char[] arrayChar() { return Array.ConvertAll(array(), char.Parse); } public int[] arrayInt() { return Array.ConvertAll(array(), int.Parse); } public long[] arrayLong() { return Array.ConvertAll(array(), long.Parse); } public double[] arrayDouble() { return Array.ConvertAll(array(), double.Parse); } private bool typeEQ<T, U>() { return typeof(T).Equals(typeof(U)); } private T convertType<T, U>(U v) { return (T)Convert.ChangeType(v, typeof(T)); } private T suitType<T>(string s) { if (typeEQ<T, int>()) return convertType<T, int>(int.Parse(s)); if (typeEQ<T, long>()) return convertType<T, long>(long.Parse(s)); if (typeEQ<T, double>()) return convertType<T, double>(double.Parse(s)); if (typeEQ<T, char>()) return convertType<T, char>(char.Parse(s)); return convertType<T, string>(s); } public void i<T>(out T v) { v = suitType<T>(next()); } public void i<T, U>(out T v1, out U v2) { var a = array(); v1 = suitType<T>(a[0]); v2 = suitType<U>(a[1]); } public void i<T, U, V>(out T v1, out U v2, out V v3) { var a = array(); v1 = suitType<T>(a[0]); v2 = suitType<U>(a[1]); v3 = suitType<V>(a[2]); } public void i<T, U, V, W>(out T v1, out U v2, out V v3, out W v4) { var a = array(); v1 = suitType<T>(a[0]); v2 = suitType<U>(a[1]); v3 = suitType<V>(a[2]); v4 = suitType<W>(a[3]); } public void ini(out int[] a, int size) { a = new int[size]; for (int i = 0; i < size; i++) a[i] = nextInt(); } public void ini(out int[] a1, out int[] a2, int size) { a1 = new int[size]; a2 = new int[size]; for (int i = 0; i < size; i++) { a1[i] = nextInt(); a2[i] = nextInt(); } } public void ini(out string[] a, int size) { a = new string[size]; for (int i = 0; i < size; i++) a[i] = next(); } public void o<T>(T v) { Console.WriteLine(v); } public void o<T>(params T[] a) { foreach (T v in a) Console.WriteLine(v); } public void o<T>(List<T> l) { foreach (T v in l) sw.WriteLine(v); } public void ol<T>(T v) { Console.Write(v + " "); } public void ol<T>(params T[] a) { foreach (T v in a) Console.Write(v + " "); Console.WriteLine(""); } public void YN(bool f) { Console.WriteLine(f ? "YES" : "NO"); } public void yn(bool f) { Console.WriteLine(f ? "Yes" : "No"); } public void writeFlush() { Console.Out.Flush(); } } class Mathf { public int mod = 1000000007; // 10^9+7 public long Pow(long a, long b) { if (b == 0) return 1; if (b % 2 == 1) return (a % mod * Pow(a % mod, b - 1) % mod) % mod; else return Pow(a * a % mod, b / 2) % mod; } public long Fact(long n) { return n != 0 ? (n % mod * (Fact(n - 1) % mod) % mod) : 1; } public long C(long n, long r) { if (r == 0 || n == r) return 1; else return (Fact(n) % mod * Pow((Fact(n - r) % mod * Fact(r) % mod) % mod, mod - 2) % mod) % mod; } public long Sum(params long[] a) { return a.Aggregate((v, next) => (v % mod + next) % mod); } public int GCD(int a, int b) { if (a < b) Swap(ref a, ref b); return b == 0 ? a : GCD(b, a % b); } public int GCD(int[] array) { return array.Aggregate((v, next) => GCD(v, next)); } public void Swap<T>(ref T a, ref T b) { T tmp = a; a = b; b = tmp; } public T Max<T>(params T[] v) { return v.Max(); } public T Min<T>(params T[] v) { return v.Min(); } } } }
[["-", 0, 28, 0, 41, 15, 23, 0, 16, 17, 18], ["+", 0, 28, 0, 41, 15, 23, 0, 16, 17, 19], ["-", 0, 41, 75, 41, 15, 23, 0, 16, 17, 18], ["+", 0, 41, 75, 41, 15, 23, 0, 16, 17, 19]]
8
1,661
4
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; class TEST { static void Main() { Sol mySol = new Sol(); mySol.Solve(); } } class Sol { public Sol() { long[] a = rla(); if (a[2] - a[1] <= 0) { Console.WriteLine("delicious"); } else if (a[1] + a[2] <= a[0]) { Console.WriteLine("safe"); } else { Console.WriteLine("dangerous"); } } public void Solve() {} static String rs() { return Console.ReadLine(); } static int ri() { return int.Parse(Console.ReadLine()); } static long rl() { return long.Parse(Console.ReadLine()); } static double rd() { return double.Parse(Console.ReadLine()); } static String[] rsa(char sep = ' ') { return Console.ReadLine().Split(sep); } static int[] ria(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); } static long[] rla(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); } static double[] rda(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); } }
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; class TEST { static void Main() { Sol mySol = new Sol(); mySol.Solve(); } } class Sol { public Sol() { long[] a = rla(); if (a[2] - a[1] <= 0) { Console.WriteLine("delicious"); } else if (a[2] - a[1] <= a[0]) { Console.WriteLine("safe"); } else { Console.WriteLine("dangerous"); } } public void Solve() {} static String rs() { return Console.ReadLine(); } static int ri() { return int.Parse(Console.ReadLine()); } static long rl() { return long.Parse(Console.ReadLine()); } static double rd() { return double.Parse(Console.ReadLine()); } static String[] rsa(char sep = ' ') { return Console.ReadLine().Split(sep); } static int[] ria(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); } static long[] rla(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); } static double[] rda(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); } }
[["-", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 57, 75, 57, 15, 16, 31, 16, 17, 72], ["+", 0, 57, 75, 57, 15, 16, 31, 16, 17, 33], ["-", 31, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 31, 16, 12, 204, 206, 207, 0, 28, 0, 203]]
8
375
6
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication { class Program { static void Main() { new Solution().answer(); } } class Solution { // string n; string[] input; public Solution() { // n = Console.ReadLine(); input = Console.ReadLine().Split(' '); } public void answer() { int X = Convert.ToInt32(input[0]); int A = Convert.ToInt32(input[1]); int B = Convert.ToInt32(input[2]); int XA = X + A; int BA = B - A; if (BA >= 0 && BA <= X) { Console.WriteLine("safe"); } else if (BA > X) { Console.WriteLine("dangerous"); } else if (B <= A) { Console.WriteLine("delicious"); } } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication { class Program { static void Main() { new Solution().answer(); } } class Solution { // string n; string[] input; public Solution() { // n = Console.ReadLine(); input = Console.ReadLine().Split(' '); } public void answer() { int X = Convert.ToInt32(input[0]); int A = Convert.ToInt32(input[1]); int B = Convert.ToInt32(input[2]); int XA = X + A; int BA = B - A; if (BA > 0 && BA <= X) { Console.WriteLine("safe"); } else if (BA > X) { Console.WriteLine("dangerous"); } else if (BA <= 0) { Console.WriteLine("delicious"); } } } }
[["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 20], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 47], ["-", 0, 57, 75, 57, 75, 57, 15, 16, 31, 22], ["+", 0, 57, 75, 57, 75, 57, 15, 16, 31, 22], ["-", 0, 57, 75, 57, 75, 57, 15, 16, 12, 22], ["+", 0, 57, 75, 57, 75, 57, 15, 16, 12, 203]]
8
200
6
using System; using System.Collections.Generic; namespace ConsoleApp1 { class Program { static void Main(string[] args) { List<int> n = new List<int>(); var input = Console.ReadLine().Split(' '); for (int i = 0; i < 3; i++) { n.Add(int.Parse(input[i])); } if (n[1] > n[2]) { Console.WriteLine("delicious"); } else if (n[1] + n[0] < n[2]) { Console.WriteLine("dangerous"); } else { Console.WriteLine("safe"); } } } }
using System; using System.Collections.Generic; namespace ConsoleApp1 { class Program { static void Main(string[] args) { List<int> n = new List<int>(); var input = Console.ReadLine().Split(' '); for (int i = 0; i < 3; i++) { n.Add(int.Parse(input[i])); } if (n[1] >= n[2]) { Console.WriteLine("delicious"); } else if (n[1] + n[0] < n[2]) { Console.WriteLine("dangerous"); } else { Console.WriteLine("safe"); } } } }
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 20]]
8
154
2
using System; using System.Linq; using System.Collections.Generic; using System.IO; using System.Diagnostics; using System.Text; public class Program { public static void Main() { var watch = new Stopwatch(); watch.Start(); var isTest = false; var stream = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(stream); TextReader reader; string filename = ""; if (filename.Length != 0) { reader = new StreamReader(filename); } else { reader = Console.In; } var input = reader.ReadLine().Split().Select(int.Parse).ToArray(); var x = input[0]; var a = input[1]; var b = input[2]; if (b <= a) { Console.WriteLine("delicious"); } else if (b - a <= x) { Console.WriteLine("safe"); } else { //ใšใฃใจ็ถดใ‚Šใ‚’้–“้•ใˆใฆใ„ใŸ Console.WriteLine("dangelous"); } watch.Stop(); if (isTest) { Console.WriteLine($"ๅฎŸ่กŒๆ™‚้–“{watch.ElapsedMilliseconds}ใƒŸใƒช็ง’"); } Console.Out.Flush(); } }
using System; using System.Linq; using System.Collections.Generic; using System.IO; using System.Diagnostics; using System.Text; public class Program { public static void Main() { var watch = new Stopwatch(); watch.Start(); var isTest = false; var stream = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(stream); TextReader reader; string filename = ""; if (filename.Length != 0) { reader = new StreamReader(filename); } else { reader = Console.In; } var input = reader.ReadLine().Split().Select(int.Parse).ToArray(); var x = input[0]; var a = input[1]; var b = input[2]; if (b <= a) { Console.WriteLine("delicious"); } else if (b - a <= x) { Console.WriteLine("safe"); } else { //ใšใฃใจ็ถดใ‚Šใ‚’้–“้•ใˆใฆใ„ใŸ Console.WriteLine("dangerous"); } watch.Stop(); if (isTest) { Console.WriteLine($"ๅฎŸ่กŒๆ™‚้–“{watch.ElapsedMilliseconds}ใƒŸใƒช็ง’"); } Console.Out.Flush(); } }
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
8
256
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace abc065a { class Program { static void Main(string[] args) { int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray(); if (input[1] > input[2]) { Console.WriteLine("delicious"); } else if (input[0] + input[1] < input[2]) { Console.WriteLine("dangerous"); } else { Console.WriteLine("safe"); } } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace abc065a { class Program { static void Main(string[] args) { int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray(); if (input[1] >= input[2]) { Console.WriteLine("delicious"); } else if (input[0] + input[1] < input[2]) { Console.WriteLine("dangerous"); } else { Console.WriteLine("safe"); } } } }
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 20]]
8
136
2
using System; using System.Collections.Generic; using System.Linq; class Solution { static void Main() { var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); int n = 0; for (int i = 0; i < 3; i++) { n *= 10; n += vals[i]; } Console.WriteLine((n % 4 == 0) ? "YES" : "No"); } }
using System; using System.Collections.Generic; using System.Linq; class Solution { static void Main() { var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); int n = 0; for (int i = 0; i < 3; i++) { n *= 10; n += vals[i]; } Console.WriteLine((n % 4 == 0) ? "YES" : "NO"); } }
[["-", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222]]
8
106
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABC064 { class Program { static void Main(string[] args) { int r, g, b; string[] vals = Console.ReadLine().Split(' '); r = int.Parse(vals[0]); g = int.Parse(vals[1]); b = int.Parse(vals[2]); int num = r * 100 + g * 10 + b; if (num % 4 == 0) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABC064 { class Program { static void Main(string[] args) { int r, g, b; string[] vals = Console.ReadLine().Split(' '); r = int.Parse(vals[0]); g = int.Parse(vals[1]); b = int.Parse(vals[2]); int num = r * 100 + g * 10 + b; if (num % 4 == 0) { Console.WriteLine("YES"); } else { Console.WriteLine("NO"); } } } }
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
8
151
4
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ProCon { class Program { static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); int min = 10000; int max = 0; for (int i = 0; i < input.Length; ++i) { int t = int.Parse(input[i]); if (min > t) { min = t; } if (max < t) { max = t; } } Console.WriteLine(max - min); } } }
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ProCon { class Program { static void Main(string[] args) { Console.ReadLine(); string[] input = Console.ReadLine().Split(' '); int min = 10000; int max = 0; for (int i = 0; i < input.Length; ++i) { int t = int.Parse(input[i]); if (min > t) { min = t; } if (max < t) { max = t; } } Console.WriteLine(max - min); } } }
[["+", 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], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
8
143
6
using System; using System.Linq; using System.Collections.Generic; using static System.Console; using System.Text; using System.IO; using static System.Math; using System.Numerics; namespace AtCoder { public class Program { public static void Main(string[] args) { // SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false }); Solve(); // Out.Flush(); Read(); } static void Solve() { var N = Sarray()[0]; var ai = Sarray(); var min = 0L; for (var i = 1; i < 9; ++i) if (ai.Any(a => (i - 1) * 400 <= a && a < i * 400)) ++min; var max = min + ai.Count(a => 3200 <= a); WriteLine($"{min} {max}"); } static long Mod = (long)1e9 + 7; static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); } static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); } static public (T1 a, T2 b) Slice<T1, T2>() { var t = ReadLine().Split(); return ((T1)Convert.ChangeType(t[0], typeof(T1)), (T2)Convert.ChangeType(t[1], typeof(T2))); } static public (T a, T b) Slice2<T>() { var t = ReadLine().Split(); return ((T)Convert.ChangeType(t[0], typeof(T)), (T)Convert.ChangeType(t[1], typeof(T))); } static public (T a, T b, T c) Slice3<T>() { var t = ReadLine().Split(); return ((T)Convert.ChangeType(t[0], typeof(T)), (T)Convert.ChangeType(t[1], typeof(T)), (T)Convert.ChangeType(t[2], typeof(T))); } } }
using System; using System.Linq; using System.Collections.Generic; using static System.Console; using System.Text; using System.IO; using static System.Math; using System.Numerics; namespace AtCoder { public class Program { public static void Main(string[] args) { // SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false }); Solve(); // Out.Flush(); Read(); } static void Solve() { var N = Sarray()[0]; var ai = Sarray(); var min = 0L; for (var i = 1; i < 9; ++i) if (ai.Any(a => (i - 1) * 400 <= a && a < i * 400)) ++min; var max = min + ai.Count(a => 3200 <= a); WriteLine($"{Max(1, min)} {max}"); } static long Mod = (long)1e9 + 7; static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); } static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); } static public (T1 a, T2 b) Slice<T1, T2>() { var t = ReadLine().Split(); return ((T1)Convert.ChangeType(t[0], typeof(T1)), (T2)Convert.ChangeType(t[1], typeof(T2))); } static public (T a, T b) Slice2<T>() { var t = ReadLine().Split(); return ((T)Convert.ChangeType(t[0], typeof(T)), (T)Convert.ChangeType(t[1], typeof(T))); } static public (T a, T b, T c) Slice3<T>() { var t = ReadLine().Split(); return ((T)Convert.ChangeType(t[0], typeof(T)), (T)Convert.ChangeType(t[1], typeof(T)), (T)Convert.ChangeType(t[2], typeof(T))); } } }
[["+", 0, 28, 0, 283, 0, 284, 0, 213, 63, 22], ["+", 0, 283, 0, 284, 0, 213, 3, 4, 0, 24], ["+", 0, 284, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 283, 0, 284, 0, 213, 3, 4, 0, 21], ["+", 0, 283, 0, 284, 0, 213, 3, 4, 0, 25]]
8
469
5
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Numerics; using static System.Console; using static System.Math; using static System.Array; class Program { public static void Main() { var n = int.Parse(ReadLine()); var a = ReadLine().Split().Select(x => int.Parse(x) / 400).ToArray(); var color = new bool[8]; var wild = 0; for (int i = 0; i < n; i++) { if (a[i] < 8) color[a[i]] = true; else wild++; } var min = color.Count(x => x == true); var max = (min + wild) % 8; if (min == 0 && max != 0) min = 1; WriteLine($"{min} {max}"); } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Numerics; using static System.Console; using static System.Math; using static System.Array; class Program { public static void Main() { var n = int.Parse(ReadLine()); var a = ReadLine().Split().Select(x => int.Parse(x) / 400).ToArray(); var color = new bool[8]; var wild = 0; for (int i = 0; i < n; i++) { if (a[i] < 8) color[a[i]] = true; else wild++; } var min = color.Count(x => x == true); var max = min + wild; if (min == 0 && max != 0) min = 1; WriteLine($"{min} {max}"); } }
[["-", 0, 200, 0, 212, 0, 16, 31, 23, 0, 24], ["-", 0, 200, 0, 212, 0, 16, 31, 23, 0, 25], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 109], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203]]
8
201
4
using System; using System.Linq; public class C { public static void Main() { int n; n = int.Parse(Console.ReadLine()); int[] a = new int[n]; string[] aSt = Console.ReadLine().Split().ToArray(); for (int i = 0; i < n; i++) { a[i] = int.Parse(aSt[i]); } int[] check = new int[9]; for (int i = 0; i < n; i++) { a[i] /= 400; if (a[i] <= 7) { check[a[i]] = 1; } else { check[a[i]]++; } } int ansMin = 0; for (int i = 0; i <= 7; i++) { ansMin += check[i]; } int ansMax = ansMin; if (ansMin == 0 && check[8] > 0) { ansMin++; } ansMax += check[8]; Console.Write(ansMin); Console.Write(' '); Console.WriteLine(ansMax); } }
using System; using System.Linq; public class C { public static void Main() { int n; n = int.Parse(Console.ReadLine()); int[] a = new int[n]; string[] aSt = Console.ReadLine().Split().ToArray(); for (int i = 0; i < n; i++) { a[i] = int.Parse(aSt[i]); } int[] check = new int[9]; for (int i = 0; i < n; i++) { a[i] /= 400; if (a[i] <= 7) { check[a[i]] = 1; } else { check[8]++; } } int ansMin = 0; for (int i = 0; i <= 7; i++) { ansMin += check[i]; } int ansMax = ansMin; if (ansMin == 0 && check[8] > 0) { ansMin++; } ansMax += check[8]; Console.Write(ansMin); Console.Write(' '); Console.WriteLine(ansMax); } }
[["-", 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, 223, 0, 204, 206, 207, 0, 28, 0, 203]]
8
246
5
using System; using System.Collections.Generic; using System.IO; using System.Linq; using static System.Math; using System.Text; using System.Threading; using System.Globalization; using System.Runtime.CompilerServices; using Library; namespace Program { public static class ProblemB { static bool SAIKI = false; static public int numberOfRandomCases = 0; static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker) {} static public void Solve() { var N = NN; var aList = NNList(N); var list = new long[9]; foreach (var item in aList) { list[Min(item / 400, 8)]++; } var cnt = 0; foreach (var item in list.Take(8)) { if (item > 0) ++cnt; } Console.WriteLine($"{cnt} {cnt + list[8]}"); } class Printer : StreamWriter { public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } } public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; } public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; } } static LIB_FastIO fastio = new LIB_FastIODebug(); static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } if (SAIKI) { var t = new Thread(Solve, 134217728); t.Start(); t.Join(); } else Solve(); Console.Out.Flush(); } static long NN => fastio.Long(); static double ND => fastio.Double(); static string NS => fastio.Scan(); static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray(); static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray(); static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray(); static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred); static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n); static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c); static IOrderedEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x, _ => xorshift); static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x.OrderByRand(), e => e); static IOrderedEnumerable<T1> OrderBy<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderBy(x.OrderByRand(), selector); static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x) => Enumerable.OrderByDescending(x.OrderByRand(), e => e); static IOrderedEnumerable<T1> OrderByDescending<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderByDescending(x.OrderByRand(), selector); static IOrderedEnumerable<string> OrderBy(this IEnumerable<string> x) => x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase); static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase); static IOrderedEnumerable<string> OrderByDescending(this IEnumerable<string> x) => x.OrderByRand().OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase); static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderByDescending(selector, StringComparer.OrdinalIgnoreCase); static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } } static IEnumerator<uint> _xsi = _xsc(); static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } } } } namespace Library { class LIB_FastIO { public LIB_FastIO() { str = Console.OpenStandardInput(); } readonly Stream str; readonly byte[] buf = new byte[1024]; int len, ptr; public bool isEof = false; public bool IsEndOfStream { get { return isEof; } } byte read() { if (isEof) throw new EndOfStreamException(); if (ptr >= len) { ptr = 0; if ((len = str.Read(buf, 0, 1024)) <= 0) { isEof = true; return 0; } } return buf[ptr++]; } char Char() { byte b = 0; do b = read(); while (b < 33 || 126 < b); return (char)b; } virtual public string Scan() { var sb = new StringBuilder(); for (var b = Char(); b >= 33 && b <= 126; b = (char)read()) sb.Append(b); return sb.ToString(); } virtual public long Long() { long ret = 0; byte b = 0; var ng = false; do b = read(); while (b != '-' && (b < '0' || '9' < b)); if (b == '-') { ng = true; b = read(); } for (; true; b = read()) { if (b < '0' || '9' < b) return ng ? -ret : ret; else ret = ret * 10 + b - '0'; } } virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); } } class LIB_FastIODebug : LIB_FastIO { Queue<string> param = new Queue<string>(); string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); } public LIB_FastIODebug() {} public override string Scan() => NextString(); public override long Long() => long.Parse(NextString()); public override double Double() => double.Parse(NextString()); } }
using System; using System.Collections.Generic; using System.IO; using System.Linq; using static System.Math; using System.Text; using System.Threading; using System.Globalization; using System.Runtime.CompilerServices; using Library; namespace Program { public static class ProblemB { static bool SAIKI = false; static public int numberOfRandomCases = 0; static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker) {} static public void Solve() { var N = NN; var aList = NNList(N); var list = new long[9]; foreach (var item in aList) { list[Min(item / 400, 8)]++; } var cnt = 0; foreach (var item in list.Take(8)) { if (item > 0) ++cnt; } Console.WriteLine($"{((cnt == 0) ? 1 : cnt)} {cnt + list[8]}"); } class Printer : StreamWriter { public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } } public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; } public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; } } static LIB_FastIO fastio = new LIB_FastIODebug(); static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } if (SAIKI) { var t = new Thread(Solve, 134217728); t.Start(); t.Join(); } else Solve(); Console.Out.Flush(); } static long NN => fastio.Long(); static double ND => fastio.Double(); static string NS => fastio.Scan(); static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray(); static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray(); static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray(); static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred); static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n); static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c); static IOrderedEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x, _ => xorshift); static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x.OrderByRand(), e => e); static IOrderedEnumerable<T1> OrderBy<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderBy(x.OrderByRand(), selector); static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x) => Enumerable.OrderByDescending(x.OrderByRand(), e => e); static IOrderedEnumerable<T1> OrderByDescending<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderByDescending(x.OrderByRand(), selector); static IOrderedEnumerable<string> OrderBy(this IEnumerable<string> x) => x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase); static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase); static IOrderedEnumerable<string> OrderByDescending(this IEnumerable<string> x) => x.OrderByRand().OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase); static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderByDescending(selector, StringComparer.OrdinalIgnoreCase); static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } } static IEnumerator<uint> _xsi = _xsc(); static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } } } } namespace Library { class LIB_FastIO { public LIB_FastIO() { str = Console.OpenStandardInput(); } readonly Stream str; readonly byte[] buf = new byte[1024]; int len, ptr; public bool isEof = false; public bool IsEndOfStream { get { return isEof; } } byte read() { if (isEof) throw new EndOfStreamException(); if (ptr >= len) { ptr = 0; if ((len = str.Read(buf, 0, 1024)) <= 0) { isEof = true; return 0; } } return buf[ptr++]; } char Char() { byte b = 0; do b = read(); while (b < 33 || 126 < b); return (char)b; } virtual public string Scan() { var sb = new StringBuilder(); for (var b = Char(); b >= 33 && b <= 126; b = (char)read()) sb.Append(b); return sb.ToString(); } virtual public long Long() { long ret = 0; byte b = 0; var ng = false; do b = read(); while (b != '-' && (b < '0' || '9' < b)); if (b == '-') { ng = true; b = read(); } for (; true; b = read()) { if (b < '0' || '9' < b) return ng ? -ret : ret; else ret = ret * 10 + b - '0'; } } virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); } } class LIB_FastIODebug : LIB_FastIO { Queue<string> param = new Queue<string>(); string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); } public LIB_FastIODebug() {} public override string Scan() => NextString(); public override long Long() => long.Parse(NextString()); public override double Double() => double.Parse(NextString()); } }
[["+", 0, 28, 0, 283, 0, 284, 0, 23, 0, 24], ["+", 0, 284, 0, 23, 0, 41, 15, 23, 0, 24], ["+", 0, 23, 0, 41, 15, 23, 0, 16, 31, 22], ["+", 0, 23, 0, 41, 15, 23, 0, 16, 17, 60], ["+", 0, 23, 0, 41, 15, 23, 0, 16, 12, 203], ["+", 0, 284, 0, 23, 0, 41, 15, 23, 0, 25], ["+", 0, 283, 0, 284, 0, 23, 0, 41, 0, 101], ["+", 0, 283, 0, 284, 0, 23, 0, 41, 64, 203], ["+", 0, 283, 0, 284, 0, 23, 0, 41, 0, 102], ["+", 0, 28, 0, 283, 0, 284, 0, 23, 0, 25]]
8
1,495
10
using System; using System.Collections.Generic; using System.Globalization; namespace cswork { class Program { public Program() {} Scanner cin; const int MAXIN = 1024; bool[] used = new bool[MAXIN]; int[] perm = new int[MAXIN]; List<int[]> permList = new List<int[]>(); void Omame() { cin = new Scanner(); int n = cin.nextInt(); bool[] colors = new bool[8]; int rainbow = 0; for (int i = 0; i < n; i++) { int a = cin.nextInt(); if (a < 400) { colors[0] = true; } else if (a < 800) { colors[1] = true; } else if (a < 1200) { colors[2] = true; } else if (a < 1600) { colors[3] = true; } else if (a < 2000) { colors[4] = true; } else if (a < 2400) { colors[5] = true; } else if (a < 2800) { colors[6] = true; } else if (a < 3200) { colors[7] = true; } else { rainbow++; } } int count = 0; for (int i = 0; i < colors.Length; i++) { if (colors[i]) { count++; } } int min = count; // int max = Math.Min(8, count + rainbow); int max = count + rainbow; if (count == 0) { min = max; } Console.WriteLine(min + " " + max); } static void Main(string[] args) { new Program().Omame(); } public void Permutation(int pos, int n, int length) { if (pos == n) { permList.Add((int[])perm.Clone()); } for (int i = 0; i < n; i++) { if (!used[i]) { perm[pos] = i; used[i] = true; Permutation(pos + 1, n, length); used[i] = false; } } } } 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; using System.Globalization; namespace cswork { class Program { public Program() {} Scanner cin; const int MAXIN = 1024; bool[] used = new bool[MAXIN]; int[] perm = new int[MAXIN]; List<int[]> permList = new List<int[]>(); void Omame() { cin = new Scanner(); int n = cin.nextInt(); bool[] colors = new bool[8]; int rainbow = 0; for (int i = 0; i < n; i++) { int a = cin.nextInt(); if (a < 400) { colors[0] = true; } else if (a < 800) { colors[1] = true; } else if (a < 1200) { colors[2] = true; } else if (a < 1600) { colors[3] = true; } else if (a < 2000) { colors[4] = true; } else if (a < 2400) { colors[5] = true; } else if (a < 2800) { colors[6] = true; } else if (a < 3200) { colors[7] = true; } else { rainbow++; } } int count = 0; for (int i = 0; i < colors.Length; i++) { if (colors[i]) { count++; } } int min = count; // int max = Math.Min(8, count + rainbow); int max = count + rainbow; if (count == 0) { min = 1; } Console.WriteLine(min + " " + max); } static void Main(string[] args) { new Program().Omame(); } public void Permutation(int pos, int n, int length) { if (pos == n) { permList.Add((int[])perm.Clone()); } for (int i = 0; i < n; i++) { if (!used[i]) { perm[pos] = i; used[i] = true; Permutation(pos + 1, n, length); used[i] = false; } } } } 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()); } } }
[["-", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203]]
8
628
2
using System; using System.Collections.Generic; using System.Linq; namespace AtCoder { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); int[] score = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); List<string> color_list = new List<string>(); string color = null; int black = 0; foreach (int i in score) { if (i < 400) color = "gray"; else if (i < 800) color = "brown"; else if (i < 1200) color = "green"; else if (i < 1600) color = "lightblue"; else if (i < 2000) color = "blue"; else if (i < 2400) color = "yellow"; else if (i < 2800) color = "orange"; else if (i < 3200) color = "red"; else black++; if (!color_list.Contains(color) && !string.IsNullOrEmpty(color)) { color_list.Add(color); } } int min = (color_list.Count == 0) ? 1 : color_list.Count; Console.WriteLine(min + " " + (min + black)); } } }
using System; using System.Collections.Generic; using System.Linq; namespace AtCoder { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); int[] score = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); List<string> color_list = new List<string>(); string color = null; int black = 0; foreach (int i in score) { if (i < 400) color = "gray"; else if (i < 800) color = "brown"; else if (i < 1200) color = "green"; else if (i < 1600) color = "lightblue"; else if (i < 2000) color = "blue"; else if (i < 2400) color = "yellow"; else if (i < 2800) color = "orange"; else if (i < 3200) color = "red"; else black++; if (!color_list.Contains(color) && !string.IsNullOrEmpty(color)) { color_list.Add(color); } } int min = (color_list.Count == 0) ? 1 : color_list.Count; Console.WriteLine(min + " " + (color_list.Count + black)); } } }
[["-", 0, 28, 0, 16, 12, 23, 0, 16, 31, 22], ["+", 0, 16, 12, 23, 0, 16, 31, 214, 205, 22], ["+", 0, 16, 12, 23, 0, 16, 31, 214, 0, 131], ["+", 0, 16, 12, 23, 0, 16, 31, 214, 141, 22]]
8
276
4
using System; using System.Collections.Generic; using System.Linq; using System.Numerics; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ConsoleApp2 { class Program { static void Main(string[] args) { Console.ReadLine(); var an = new List<int>(); an.AddRange(Console.ReadLine().Split().Select(s => int.Parse(s))); var colors = new bool[8]; var asta = 0; foreach (var a in an) { if (a < 400) colors[0] = true; else if (a < 800) colors[1] = true; else if (a < 1200) colors[2] = true; else if (a < 1600) colors[3] = true; else if (a < 2000) colors[4] = true; else if (a < 2400) colors[5] = true; else if (a < 2800) colors[6] = true; else if (a < 3200) colors[7] = true; else asta++; } var min = colors.Count(b => b); if (min == 0) min++; Console.WriteLine($"{min} {min + asta}"); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Numerics; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ConsoleApp2 { class Program { static void Main(string[] args) { Console.ReadLine(); var an = new List<int>(); an.AddRange(Console.ReadLine().Split().Select(s => int.Parse(s))); var colors = new bool[8]; var asta = 0; foreach (var a in an) { if (a < 400) colors[0] = true; else if (a < 800) colors[1] = true; else if (a < 1200) colors[2] = true; else if (a < 1600) colors[3] = true; else if (a < 2000) colors[4] = true; else if (a < 2400) colors[5] = true; else if (a < 2800) colors[6] = true; else if (a < 3200) colors[7] = true; else asta++; } var min = colors.Count(b => b); if (min == 0) { min++; asta--; } Console.WriteLine($"{min} {min + asta}"); } } }
[["+", 0, 195, 8, 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, 68], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
8
276
5
using System; using System.Collections.Generic; using System.Linq; using System.Text; // using System.Numerics; using System.Runtime.CompilerServices; using System.Diagnostics; using ll=System.Int64; using static Contest_C.Lib_IO; using static Contest_C.Lib_Minifunc; public static class Contest_C { public static void Main() { checked{ long n; Lib_IO.rm(out n); ll[]a; ra(out a); int[] c = new int[9]; foreach (var e in a) { c[min(e/400,8)]++; } int c1 = 0; int c2 = c[8]; for (int i = 0; i < 8; i++) { c1+=(0<c[i]?1:0); } if(c1==0){ wm("1 "+min(8,c1+c2).ToString()); }else{ wm(c1.ToString()+" "+min(8,c1+c2).ToString()); } } } #region BaseModule public static class Lib_Minifunc{ [MethodImpl(256)] public static void swap1<T>(ref T a, ref T b) { T t = a; a = b; b = t; } [MethodImpl(256)] public static void swap2<T>(ref T a, ref T b) where T : IComparable { if (a.CompareTo(b)==1) swap1(ref a, ref b); } // b ใฎๆ–นใŒๅฐใ•ใ‘ใ‚Œใฐไบคๆ› [MethodImpl(256)] public static bool chmin<T>(ref T a, T b) where T : IComparable { if (a.CompareTo(b)== 1) { a = b; return true; } return false; } // b ใฎๆ–นใŒๅฐใ•ใ‘ใ‚Œใฐ a ใ‚’ๆ›ดๆ–ฐ [MethodImpl(256)] public static bool chmax<T>(ref T a, T b) where T : IComparable { if (a.CompareTo(b)==-1) { a = b; return true; } return false; } // b ใฎๆ–นใŒๅคงใใ‘ใ‚Œใฐ a ใ‚’ๆ›ดๆ–ฐ [MethodImpl(256)] public static bool inside(long i, long n) => (0<=i&&i<n); [MethodImpl(256)] public static bool inside(long x, long y, long w, long h) => (inside(x,w)&&inside(y,h)); [MethodImpl(256)] public static T min<T>(params T[] a) where T : IComparable => a.Min(); [MethodImpl(256)] public static T max<T>(params T[] a) where T : IComparable => a.Max(); [MethodImpl(256)] public static long mod(long a, long m=MOD1) { var v = a%m; return (v<0?v+m:v); } [MethodImpl(256)] public static long ceiling(long a, long b) => (a%b==0?a/b:a/b+1); // ๆ•ดๆ•ฐๅ•†ใฎๅˆ‡ใ‚ŠไธŠใ’ [MethodImpl(256)] public static P<T,U> initp<T,U>(T a,U b) => new P<T,U>(a,b); [MethodImpl(256)] public static P<T,U,V> initp<T,U,V>(T a,U b,V c) => new P<T,U,V>(a,b,c); [MethodImpl(256)] public static P<T,U,V,W> initp<T,U,V,W>(T a,U b,V c,W d) => new P<T,U,V,W>(a,b,c,d); [MethodImpl(256)] public static bool initd<T,U>(Dictionary<T,U> d, T k) { if(d.ContainsKey(k)) { return false; } else { d[k] = default(U); return true; } } public static T[] inita<T>(long len1) where T : new() { var m = new T[len1]; for (int i=0;i<m.Length;i++) m[i] = new T(); return m; } public static T[][] initm<T>(long len1,long len2,T val) where T : struct { var m = new T[len1][]; for (int i=0;i<m.Length;i++) m[i] = Enumerable.Repeat(val,(int)len2).ToArray(); return m; } public static T[][][] initm<T>(long len1,long len2,long len3,T val) where T : struct { var m = new T[len1][][]; for (int i=0;i<m.Length;i++) m[i] = initm(len2,len3,val); return m; } public const long MOD1 = 1000000007; // 10^9+7 public const double EPS1 = 1e-8; public const long INF1 = 1000000000000000; // 10^15 } public struct P<T,U> { public T A; public U B; public P(T a,U b) { A = a; B = b; } public static implicit operator KeyValuePair<T,U>(P<T,U> a) => new KeyValuePair<T,U>(a.A,a.B); public static implicit operator P<T,U>(KeyValuePair<T,U> a) => new P<T,U>(a.Key,a.Value); } public struct P<T,U,V> { public T A; public U B; public V C; public P(T a,U b,V c) { A = a; B = b; C = c; } } public struct P<T,U,V,W> { public T A; public U B; public V C; public W D; public P(T a,U b,V c,W d) { A = a; B = b; C = c; D = d; } } public static class Lib_IO { class Prt : System.IO.StreamWriter { public override IFormatProvider FormatProvider { get { return System.Globalization.CultureInfo.InvariantCulture; } } public Prt(System.IO.Stream s) : base(s,new UTF8Encoding(false,true)) {} public Prt(System.IO.Stream s,Encoding e) : base(s,e) {} } static Prt sw = new Prt(Console.OpenStandardOutput()); static char[] sp = new char[] {' '}; [MethodImpl(256)] static bool eq<T,U>() => typeof(T).Equals(typeof(U)); [MethodImpl(256)] static T ct<T,U>(U a) => (T)Convert.ChangeType(a,typeof(T)); [MethodImpl(256)] static 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,System.Globalization.CultureInfo.InvariantCulture)) : eq<T,char>() ? ct<T,char>(s[0]) : ct<T,string>(s); public static string[] rm<T>(out T a) { var z = Console.ReadLine().Split(sp,StringSplitOptions.RemoveEmptyEntries); a = cv<T>(z[0]); return z; } public static string[] rm<T,U>(out T a,out U b) { var z = rm<T>(out a); b = cv<U>(z[1]); return z; } public static string[] rm<T,U,V>(out T a,out U b,out V c) { var z = rm<T,U>(out a,out b); c = cv<V>(z[2]); return z; } public static string[] rm<T,U,V,W>(out T a,out U b,out V c,out W d) { var z = rm<T,U,V>(out a,out b,out c); d = cv<W>(z[3]); return z; } public static string[] rm<T,U,V,W,X>(out T a,out U b,out V c,out W d,out X e) { var z = rm<T,U,V,W>(out a,out b,out c,out d); e = cv<X>(z[4]); return z; } public static string[] rm<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 z = rm<T,U,V,W,X>(out a,out b,out c,out d,out e); f = cv<Y>(z[5]); return z; } public static string[] ra<T>(out T[] a) { var z = Console.ReadLine().Split(sp,StringSplitOptions.RemoveEmptyEntries); a = z.Select(cv<T>).ToArray(); return z; } public static string[][] rl<T>(long n,out T[] a) { a = new T[n]; var y = new string[n][]; for(int i=0;i<n;i++) y[i] = rm(out a[i]); return y; } public static string[][] rl<T,U>(long n,out P<T,U>[] a) { a = new P<T,U>[n]; var y = new string[n][]; for(int i=0;i<n;i++) { T o; U p; y[i] = rm(out o,out p); a[i] = new P<T,U>(o,p); } return y; } public static string[][] rl<T,U,V>(long n,out P<T,U,V>[] a) { a = new P<T,U,V>[n]; var y = new string[n][]; for(int i=0;i<n;i++) { T o; U p; V q; y[i] = rm(out o,out p,out q); a[i] = new P<T,U,V>(o,p,q); } return y; } public static string[][] rl<T,U,V,W>(long n,out P<T,U,V,W>[] a) { a = new P<T,U,V,W>[n]; var y = new string[n][]; for(int i=0;i<n;i++) { T o; U p; V q; W r; y[i] = rm(out o,out p,out q,out r); a[i] = new P<T,U,V,W>(o,p,q,r); } return y; } public static string[][] rx<T>(long n,out T[][] a) { a = new T[n][]; var y = new string[n][]; for(int i=0;i<n;i++) y[i] = ra(out a[i]); return y; } static void wwp(Action act){ sw.AutoFlush = false; Console.SetOut(sw); act(); Console.Out.Flush(); sw.AutoFlush = true; Console.SetOut(sw); } [MethodImpl(256)] static string wfm(Type t) =>t.Equals(typeof(double)) ? "{0:F10}" : "{0}"; public static void wm(params object[] a) { wwp(()=>{ for(int i=0;i<a.Length-1;i++) Console.Write(wfm(a[i].GetType())+" ",a[i]); Console.WriteLine(wfm(a[a.Length-1].GetType()),a[a.Length-1]); }); } public static void wa<T>(IList<T> a) { wxa(new IList<T>[]{a}, " "); } public static void wl<T>(IList<T> a) { wwp(()=>{ var f = wfm(typeof(T)); foreach(T x in a) Console.WriteLine(f,x); }); } static void wxa<T>(IList<IList<T>> a, string s) { wwp(()=>{ var f = wfm(typeof(T)); var g = f + s; foreach(var b in a) { for(int i=0;i<b.Count-1;i++) Console.Write(g,b[i]); Console.WriteLine(f,b[b.Count-1]); } }); } public static void wx<T>(IList<IList<T>> a) { wxa(a, " "); } public static void wg<T>(IList<IList<T>> a) { wxa(a, ""); } } #endregion }
using System; using System.Collections.Generic; using System.Linq; using System.Text; // using System.Numerics; using System.Runtime.CompilerServices; using System.Diagnostics; using ll=System.Int64; using static Contest_C.Lib_IO; using static Contest_C.Lib_Minifunc; public static class Contest_C { public static void Main() { checked{ long n; Lib_IO.rm(out n); ll[]a; ra(out a); int[] c = new int[9]; foreach (var e in a) { c[min(e/400,8)]++; } int c1 = 0; int c2 = c[8]; for (int i = 0; i < 8; i++) { c1+=(0<c[i]?1:0); } if(c1==0){ wm("1 "+(c1+c2).ToString()); }else{ wm(c1.ToString()+" "+(c1+c2).ToString()); } } } #region BaseModule public static class Lib_Minifunc{ [MethodImpl(256)] public static void swap1<T>(ref T a, ref T b) { T t = a; a = b; b = t; } [MethodImpl(256)] public static void swap2<T>(ref T a, ref T b) where T : IComparable { if (a.CompareTo(b)==1) swap1(ref a, ref b); } // b ใฎๆ–นใŒๅฐใ•ใ‘ใ‚Œใฐไบคๆ› [MethodImpl(256)] public static bool chmin<T>(ref T a, T b) where T : IComparable { if (a.CompareTo(b)== 1) { a = b; return true; } return false; } // b ใฎๆ–นใŒๅฐใ•ใ‘ใ‚Œใฐ a ใ‚’ๆ›ดๆ–ฐ [MethodImpl(256)] public static bool chmax<T>(ref T a, T b) where T : IComparable { if (a.CompareTo(b)==-1) { a = b; return true; } return false; } // b ใฎๆ–นใŒๅคงใใ‘ใ‚Œใฐ a ใ‚’ๆ›ดๆ–ฐ [MethodImpl(256)] public static bool inside(long i, long n) => (0<=i&&i<n); [MethodImpl(256)] public static bool inside(long x, long y, long w, long h) => (inside(x,w)&&inside(y,h)); [MethodImpl(256)] public static T min<T>(params T[] a) where T : IComparable => a.Min(); [MethodImpl(256)] public static T max<T>(params T[] a) where T : IComparable => a.Max(); [MethodImpl(256)] public static long mod(long a, long m=MOD1) { var v = a%m; return (v<0?v+m:v); } [MethodImpl(256)] public static long ceiling(long a, long b) => (a%b==0?a/b:a/b+1); // ๆ•ดๆ•ฐๅ•†ใฎๅˆ‡ใ‚ŠไธŠใ’ [MethodImpl(256)] public static P<T,U> initp<T,U>(T a,U b) => new P<T,U>(a,b); [MethodImpl(256)] public static P<T,U,V> initp<T,U,V>(T a,U b,V c) => new P<T,U,V>(a,b,c); [MethodImpl(256)] public static P<T,U,V,W> initp<T,U,V,W>(T a,U b,V c,W d) => new P<T,U,V,W>(a,b,c,d); [MethodImpl(256)] public static bool initd<T,U>(Dictionary<T,U> d, T k) { if(d.ContainsKey(k)) { return false; } else { d[k] = default(U); return true; } } public static T[] inita<T>(long len1) where T : new() { var m = new T[len1]; for (int i=0;i<m.Length;i++) m[i] = new T(); return m; } public static T[][] initm<T>(long len1,long len2,T val) where T : struct { var m = new T[len1][]; for (int i=0;i<m.Length;i++) m[i] = Enumerable.Repeat(val,(int)len2).ToArray(); return m; } public static T[][][] initm<T>(long len1,long len2,long len3,T val) where T : struct { var m = new T[len1][][]; for (int i=0;i<m.Length;i++) m[i] = initm(len2,len3,val); return m; } public const long MOD1 = 1000000007; // 10^9+7 public const double EPS1 = 1e-8; public const long INF1 = 1000000000000000; // 10^15 } public struct P<T,U> { public T A; public U B; public P(T a,U b) { A = a; B = b; } public static implicit operator KeyValuePair<T,U>(P<T,U> a) => new KeyValuePair<T,U>(a.A,a.B); public static implicit operator P<T,U>(KeyValuePair<T,U> a) => new P<T,U>(a.Key,a.Value); } public struct P<T,U,V> { public T A; public U B; public V C; public P(T a,U b,V c) { A = a; B = b; C = c; } } public struct P<T,U,V,W> { public T A; public U B; public V C; public W D; public P(T a,U b,V c,W d) { A = a; B = b; C = c; D = d; } } public static class Lib_IO { class Prt : System.IO.StreamWriter { public override IFormatProvider FormatProvider { get { return System.Globalization.CultureInfo.InvariantCulture; } } public Prt(System.IO.Stream s) : base(s,new UTF8Encoding(false,true)) {} public Prt(System.IO.Stream s,Encoding e) : base(s,e) {} } static Prt sw = new Prt(Console.OpenStandardOutput()); static char[] sp = new char[] {' '}; [MethodImpl(256)] static bool eq<T,U>() => typeof(T).Equals(typeof(U)); [MethodImpl(256)] static T ct<T,U>(U a) => (T)Convert.ChangeType(a,typeof(T)); [MethodImpl(256)] static 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,System.Globalization.CultureInfo.InvariantCulture)) : eq<T,char>() ? ct<T,char>(s[0]) : ct<T,string>(s); public static string[] rm<T>(out T a) { var z = Console.ReadLine().Split(sp,StringSplitOptions.RemoveEmptyEntries); a = cv<T>(z[0]); return z; } public static string[] rm<T,U>(out T a,out U b) { var z = rm<T>(out a); b = cv<U>(z[1]); return z; } public static string[] rm<T,U,V>(out T a,out U b,out V c) { var z = rm<T,U>(out a,out b); c = cv<V>(z[2]); return z; } public static string[] rm<T,U,V,W>(out T a,out U b,out V c,out W d) { var z = rm<T,U,V>(out a,out b,out c); d = cv<W>(z[3]); return z; } public static string[] rm<T,U,V,W,X>(out T a,out U b,out V c,out W d,out X e) { var z = rm<T,U,V,W>(out a,out b,out c,out d); e = cv<X>(z[4]); return z; } public static string[] rm<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 z = rm<T,U,V,W,X>(out a,out b,out c,out d,out e); f = cv<Y>(z[5]); return z; } public static string[] ra<T>(out T[] a) { var z = Console.ReadLine().Split(sp,StringSplitOptions.RemoveEmptyEntries); a = z.Select(cv<T>).ToArray(); return z; } public static string[][] rl<T>(long n,out T[] a) { a = new T[n]; var y = new string[n][]; for(int i=0;i<n;i++) y[i] = rm(out a[i]); return y; } public static string[][] rl<T,U>(long n,out P<T,U>[] a) { a = new P<T,U>[n]; var y = new string[n][]; for(int i=0;i<n;i++) { T o; U p; y[i] = rm(out o,out p); a[i] = new P<T,U>(o,p); } return y; } public static string[][] rl<T,U,V>(long n,out P<T,U,V>[] a) { a = new P<T,U,V>[n]; var y = new string[n][]; for(int i=0;i<n;i++) { T o; U p; V q; y[i] = rm(out o,out p,out q); a[i] = new P<T,U,V>(o,p,q); } return y; } public static string[][] rl<T,U,V,W>(long n,out P<T,U,V,W>[] a) { a = new P<T,U,V,W>[n]; var y = new string[n][]; for(int i=0;i<n;i++) { T o; U p; V q; W r; y[i] = rm(out o,out p,out q,out r); a[i] = new P<T,U,V,W>(o,p,q,r); } return y; } public static string[][] rx<T>(long n,out T[][] a) { a = new T[n][]; var y = new string[n][]; for(int i=0;i<n;i++) y[i] = ra(out a[i]); return y; } static void wwp(Action act){ sw.AutoFlush = false; Console.SetOut(sw); act(); Console.Out.Flush(); sw.AutoFlush = true; Console.SetOut(sw); } [MethodImpl(256)] static string wfm(Type t) =>t.Equals(typeof(double)) ? "{0:F10}" : "{0}"; public static void wm(params object[] a) { wwp(()=>{ for(int i=0;i<a.Length-1;i++) Console.Write(wfm(a[i].GetType())+" ",a[i]); Console.WriteLine(wfm(a[a.Length-1].GetType()),a[a.Length-1]); }); } public static void wa<T>(IList<T> a) { wxa(new IList<T>[]{a}, " "); } public static void wl<T>(IList<T> a) { wwp(()=>{ var f = wfm(typeof(T)); foreach(T x in a) Console.WriteLine(f,x); }); } static void wxa<T>(IList<IList<T>> a, string s) { wwp(()=>{ var f = wfm(typeof(T)); var g = f + s; foreach(var b in a) { for(int i=0;i<b.Count-1;i++) Console.Write(g,b[i]); Console.WriteLine(f,b[b.Count-1]); } }); } public static void wx<T>(IList<IList<T>> a) { wxa(a, " "); } public static void wg<T>(IList<IList<T>> a) { wxa(a, ""); } } #endregion }
[["-", 0, 16, 12, 213, 63, 214, 205, 213, 63, 22], ["-", 63, 214, 205, 213, 3, 4, 0, 28, 0, 203], ["-", 12, 213, 63, 214, 205, 213, 3, 4, 0, 21]]
8
3,029
6
using System; using System.Collections.Generic; using System.IO; using System.Linq; using static Asakatsu20200407B.Input; namespace Asakatsu20200407B { static class Input { private static Func<string, T[]> Cast<T>() => _ => _.Split(' ').Select(Convert<T>()).ToArray(); private static Func<string, T> Convert<T>() { Type t = typeof(T); if (t == typeof(string)) return _ => (T)(object)_; if (t == typeof(int)) return _ => (T)(object) int.Parse(_); if (t == typeof(long)) return _ => (T)(object) long.Parse(_); if (t == typeof(double)) return _ => (T)(object) double.Parse(_); if (t == typeof(string[])) return _ => (T)(object)_.Split(' '); if (t == typeof(int[])) return _ => (T)(object)Cast<int>()(_); if (t == typeof(long[])) return _ => (T)(object)Cast<long>()(_); if (t == typeof(double[])) return _ => (T)(object)Cast<double>()(_); throw new NotSupportedException(t + "is not supported."); } private static T Convert<T>(string s) => Convert<T>()(s); private static string String() => Console.ReadLine(); private static string[] String(long rowNumber) => new bool [rowNumber].Select(_ => String()).ToArray(); public static void Cin<T>(out T a) => a = Convert<T>(String()); public static void Cin<T1, T2>(out T1 a1, out T2 a2) { var v = String().Split(' '); set(v[0], out a1); set(v[1], out a2); } public static void Cin<T1, T2, T3>(out T1 a1, out T2 a2, out T3 a3) { var v = String().Split(' '); set(v[0], out a1); set(v[1], out a2); set(v[2], out a3); } public static void Cin<T1, T2, T3, T4>(out T1 a1, out T2 a2, out T3 a3, out T4 a4) { var v = String().Split(' '); set(v[0], out a1); set(v[1], out a2); set(v[2], out a3); set(v[3], out a4); } public static void Cin<T1, T2, T3, T4, T5>(out T1 a1, out T2 a2, out T3 a3, out T4 a4, out T5 a5) { var v = String().Split(' '); set(v[0], out a1); set(v[1], out a2); set(v[2], out a3); set(v[3], out a4); set(v[4], out a5); } public static void Cin<T1, T2, T3, T4, T5, T6>(out T1 a1, out T2 a2, out T3 a3, out T4 a4, out T5 a5, out T6 a6) { var v = String().Split(' '); set(v[0], out a1); set(v[1], out a2); set(v[2], out a3); set(v[3], out a4); set(v[4], out a5); set(v[5], out a6); } private static void set<T1>(string s, out T1 o1) => o1 = Convert<T1>(s); public static void Cin<T>(long n, out T[] l) => l = String(n).Select(Convert<T>()).ToArray(); public static void Cin<T1, T2>(long n, out T1[] l1, out T2[] l2) { l1 = new T1[n]; l2 = new T2[n]; for (int i = 0; i < n; i++) Cin(out l1[i], out l2[i]); } public static void Cin<T1, T2, T3>(long n, out T1[] l1, out T2[] l2, out T3[] l3) { l1 = new T1[n]; l2 = new T2[n]; l3 = new T3[n]; for (int i = 0; i < n; i++) Cin(out l1[i], out l2[i], out l3[i]); } public static void Cin<T1, T2, T3, T4>(long n, out T1[] l1, out T2[] l2, out T3[] l3, out T4[] l4) { l1 = new T1[n]; l2 = new T2[n]; l3 = new T3[n]; l4 = new T4[n]; for (int i = 0; i < n; i++) Cin(out l1[i], out l2[i], out l3[i], out l4[i]); } public static void Cin<T>(out T[] a) => a = Convert<T[]>(String()); public static void Cin<T>(long h, out T[][] map) => map = String(h).Select(Convert<T[]>()).ToArray(); } class Program { public static void Main(string[] args) { StreamWriter streamWriter = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(streamWriter); new Solver().Solve(); Console.Out.Flush(); } public static void Debug() { new Solver().Solve(); } } class Solver { public void Solve() { int n; int[] a; Cin(out n); Cin(out a); int[] count = new int[9]; for (int i = 0; i < n; i++) { var k = a[i] / 400; if (k > 8) k = 8; count[k]++; } int ans = 0; for (int i = 0; i < 8; i++) { if (count[i] > 0) ans++; } if (ans == 0) { Console.WriteLine("1 " + count[8]); } Console.WriteLine("" + ans + " " + (ans + count[8])); } } }
using System; using System.Collections.Generic; using System.IO; using System.Linq; using static Asakatsu20200407B.Input; namespace Asakatsu20200407B { static class Input { private static Func<string, T[]> Cast<T>() => _ => _.Split(' ').Select(Convert<T>()).ToArray(); private static Func<string, T> Convert<T>() { Type t = typeof(T); if (t == typeof(string)) return _ => (T)(object)_; if (t == typeof(int)) return _ => (T)(object) int.Parse(_); if (t == typeof(long)) return _ => (T)(object) long.Parse(_); if (t == typeof(double)) return _ => (T)(object) double.Parse(_); if (t == typeof(string[])) return _ => (T)(object)_.Split(' '); if (t == typeof(int[])) return _ => (T)(object)Cast<int>()(_); if (t == typeof(long[])) return _ => (T)(object)Cast<long>()(_); if (t == typeof(double[])) return _ => (T)(object)Cast<double>()(_); throw new NotSupportedException(t + "is not supported."); } private static T Convert<T>(string s) => Convert<T>()(s); private static string String() => Console.ReadLine(); private static string[] String(long rowNumber) => new bool [rowNumber].Select(_ => String()).ToArray(); public static void Cin<T>(out T a) => a = Convert<T>(String()); public static void Cin<T1, T2>(out T1 a1, out T2 a2) { var v = String().Split(' '); set(v[0], out a1); set(v[1], out a2); } public static void Cin<T1, T2, T3>(out T1 a1, out T2 a2, out T3 a3) { var v = String().Split(' '); set(v[0], out a1); set(v[1], out a2); set(v[2], out a3); } public static void Cin<T1, T2, T3, T4>(out T1 a1, out T2 a2, out T3 a3, out T4 a4) { var v = String().Split(' '); set(v[0], out a1); set(v[1], out a2); set(v[2], out a3); set(v[3], out a4); } public static void Cin<T1, T2, T3, T4, T5>(out T1 a1, out T2 a2, out T3 a3, out T4 a4, out T5 a5) { var v = String().Split(' '); set(v[0], out a1); set(v[1], out a2); set(v[2], out a3); set(v[3], out a4); set(v[4], out a5); } public static void Cin<T1, T2, T3, T4, T5, T6>(out T1 a1, out T2 a2, out T3 a3, out T4 a4, out T5 a5, out T6 a6) { var v = String().Split(' '); set(v[0], out a1); set(v[1], out a2); set(v[2], out a3); set(v[3], out a4); set(v[4], out a5); set(v[5], out a6); } private static void set<T1>(string s, out T1 o1) => o1 = Convert<T1>(s); public static void Cin<T>(long n, out T[] l) => l = String(n).Select(Convert<T>()).ToArray(); public static void Cin<T1, T2>(long n, out T1[] l1, out T2[] l2) { l1 = new T1[n]; l2 = new T2[n]; for (int i = 0; i < n; i++) Cin(out l1[i], out l2[i]); } public static void Cin<T1, T2, T3>(long n, out T1[] l1, out T2[] l2, out T3[] l3) { l1 = new T1[n]; l2 = new T2[n]; l3 = new T3[n]; for (int i = 0; i < n; i++) Cin(out l1[i], out l2[i], out l3[i]); } public static void Cin<T1, T2, T3, T4>(long n, out T1[] l1, out T2[] l2, out T3[] l3, out T4[] l4) { l1 = new T1[n]; l2 = new T2[n]; l3 = new T3[n]; l4 = new T4[n]; for (int i = 0; i < n; i++) Cin(out l1[i], out l2[i], out l3[i], out l4[i]); } public static void Cin<T>(out T[] a) => a = Convert<T[]>(String()); public static void Cin<T>(long h, out T[][] map) => map = String(h).Select(Convert<T[]>()).ToArray(); } class Program { public static void Main(string[] args) { StreamWriter streamWriter = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(streamWriter); new Solver().Solve(); Console.Out.Flush(); } public static void Debug() { new Solver().Solve(); } } class Solver { public void Solve() { int n; int[] a; Cin(out n); Cin(out a); int[] count = new int[9]; for (int i = 0; i < n; i++) { var k = a[i] / 400; if (k > 8) k = 8; count[k]++; } int ans = 0; for (int i = 0; i < 8; i++) { if (count[i] > 0) ans++; } if (ans == 0) { Console.WriteLine("1 " + count[8]); return; } Console.WriteLine("" + ans + " " + (ans + count[8])); } } }
[["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35]]
8
1,522
2
using System; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using static System.Console; using static System.Math; namespace AtCodeeeer { class AtCOOOOOOOOOOOder { static void Main(string[] args) { int n = int.Parse(ReadLine()); var dic = new Dictionary<int, int>(); int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray(); for (int i = 0; i < 8; i++) { dic.Add(i, 0); dic[i] += s.Count(x => 400 * i <= x && x < 400 * (i + 1)); if (i > 1 && dic[i] - dic[i - 1] > 0) dic[i] -= dic[i - 1]; } WriteLine(dic.Count(x => x.Value >= 1) + " " + (dic.Count(x => x.Value >= 1) + s.Count(x => x >= 3200))); } } }
using System; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using static System.Console; using static System.Math; namespace AtCodeeeer { class AtCOOOOOOOOOOOder { static void Main(string[] args) { int n = int.Parse(ReadLine()); var dic = new Dictionary<int, int>(); int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray(); for (int i = 0; i < 8; i++) { dic.Add(i, 0); dic[i] += s.Count(x => 400 * i <= x && x < 400 * (i + 1)); if (i > 1 && dic[i] - dic[i - 1] > 0) dic[i] -= dic[i - 1]; } WriteLine(Max(1, dic.Count(x => x.Value >= 1)) + " " + (dic.Count(x => x.Value >= 1) + s.Count(x => x >= 3200))); } } }
[["+", 0, 28, 0, 16, 31, 16, 31, 213, 63, 22], ["+", 0, 16, 31, 16, 31, 213, 3, 4, 0, 24], ["+", 31, 16, 31, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 16, 31, 16, 31, 213, 3, 4, 0, 21], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25]]
8
239
5
using System; using System.Linq; using System.Collections.Generic; namespace Algorithm { class Program { enum Color { Gray, Brown, Green, LightBlue, Blue, Yellow, Orange, Red, All } const int ColorCount = 9; static void Main(string[] args) { var N = int.Parse(Console.ReadLine()); var a = Console.ReadLine().Split().Select(int.Parse).ToArray(); var cluster = new int[ColorCount]; for (var i = 0; i < N; i++) { Classification(a[i], cluster); } var otherAll = cluster.Count(z => z > 0); if (cluster[(int)Color.All] == 0) Console.WriteLine($"{otherAll} {otherAll}"); else { if (otherAll > 1) otherAll--; Console.WriteLine($"{otherAll} {otherAll + cluster[(int)Color.All]}"); } } static void Classification(int x, int[] cls) { if (x <= 399) cls[(int)Color.Gray]++; else if (x <= 799) cls[(int)Color.Brown]++; else if (x <= 1199) cls[(int)Color.Green]++; else if (x <= 1599) cls[(int)Color.LightBlue]++; else if (x <= 1999) cls[(int)Color.Blue]++; else if (x <= 2399) cls[(int)Color.Yellow]++; else if (x <= 2799) cls[(int)Color.Orange]++; else if (x <= 3199) cls[(int)Color.Red]++; else cls[(int)Color.All]++; } } }
using System; using System.Linq; using System.Collections.Generic; namespace Algorithm { class Program { enum Color { Gray, Brown, Green, LightBlue, Blue, Yellow, Orange, Red, All } const int ColorCount = 9; static void Main(string[] args) { var N = int.Parse(Console.ReadLine()); var a = Console.ReadLine().Split().Select(int.Parse).ToArray(); var cluster = new int[ColorCount]; for (var i = 0; i < N; i++) { Classification(a[i], cluster); } var otherAll = cluster.Count(z => z > 0); if (cluster[(int)Color.All] == 0) Console.WriteLine($"{otherAll} {otherAll}"); else { if (otherAll > 1 || otherAll == 1) otherAll--; Console.WriteLine( $"{(otherAll==0?1:otherAll)} {otherAll + cluster[(int)Color.All]}"); } } static void Classification(int x, int[] cls) { if (x <= 399) cls[(int)Color.Gray]++; else if (x <= 799) cls[(int)Color.Brown]++; else if (x <= 1199) cls[(int)Color.Green]++; else if (x <= 1599) cls[(int)Color.LightBlue]++; else if (x <= 1999) cls[(int)Color.Blue]++; else if (x <= 2399) cls[(int)Color.Yellow]++; else if (x <= 2799) cls[(int)Color.Orange]++; else if (x <= 3199) cls[(int)Color.Red]++; else cls[(int)Color.All]++; } } }
[["+", 0, 57, 75, 196, 0, 57, 15, 16, 17, 106], ["+", 75, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 75, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 75, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 0, 28, 0, 283, 0, 284, 0, 23, 0, 24], ["+", 0, 284, 0, 23, 0, 41, 15, 16, 31, 22], ["+", 0, 284, 0, 23, 0, 41, 15, 16, 17, 60], ["+", 0, 284, 0, 23, 0, 41, 15, 16, 12, 203], ["+", 0, 283, 0, 284, 0, 23, 0, 41, 0, 101], ["+", 0, 283, 0, 284, 0, 23, 0, 41, 64, 203], ["+", 0, 283, 0, 284, 0, 23, 0, 41, 0, 102], ["+", 0, 28, 0, 283, 0, 284, 0, 23, 0, 25]]
8
383
12
using System; using System.Collections.Generic; using System.Linq; using System.Text; using static System.Convert; 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) { int N = cin.ReadInt; Dictionary<string, int> colorCntPairs = new Dictionary<string, int>(); int freeCnt = 0; int notfreeCnt = 0; for (int i = 0; i < N; i++) { string strColor = getColor(cin.ReadInt); if (strColor == "่‡ช็”ฑ") { freeCnt++; } else { if (!colorCntPairs.ContainsKey(strColor)) notfreeCnt++; } if (colorCntPairs.ContainsKey(strColor)) { colorCntPairs[strColor]++; } else { colorCntPairs.Add(strColor, 1); } } int min = notfreeCnt < 0 ? 1 : notfreeCnt; WriteLine($"{min} {notfreeCnt+freeCnt}"); } public static string getColor(int point) { string resultColor = ""; if (point < 400) resultColor = "็ฐ่‰ฒ"; else if (400 <= point && point < 800) resultColor = "่Œถ่‰ฒ"; else if (800 <= point && point < 1200) resultColor = "็ท‘่‰ฒ"; else if (1200 <= point && point < 1600) resultColor = "ๆฐด่‰ฒ"; else if (1600 <= point && point < 2000) resultColor = "้’่‰ฒ"; else if (2000 <= point && point < 2400) resultColor = "้ป„่‰ฒ"; else if (2400 <= point && point < 2800) resultColor = "ๆฉ™่‰ฒ"; else if (2800 <= point && point < 3200) resultColor = "่ตค่‰ฒ"; else { resultColor = "่‡ช็”ฑ"; } return resultColor; } } 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.Collections.Generic; using System.Linq; using System.Text; using static System.Convert; 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) { int N = cin.ReadInt; Dictionary<string, int> colorCntPairs = new Dictionary<string, int>(); int freeCnt = 0; int notfreeCnt = 0; for (int i = 0; i < N; i++) { string strColor = getColor(cin.ReadInt); if (strColor == "่‡ช็”ฑ") { freeCnt++; } else { if (!colorCntPairs.ContainsKey(strColor)) notfreeCnt++; } if (colorCntPairs.ContainsKey(strColor)) { colorCntPairs[strColor]++; } else { colorCntPairs.Add(strColor, 1); } } int min = notfreeCnt == 0 ? 1 : notfreeCnt; WriteLine($"{min} {notfreeCnt+freeCnt}"); } public static string getColor(int point) { string resultColor = ""; if (point < 400) resultColor = "็ฐ่‰ฒ"; else if (400 <= point && point < 800) resultColor = "่Œถ่‰ฒ"; else if (800 <= point && point < 1200) resultColor = "็ท‘่‰ฒ"; else if (1200 <= point && point < 1600) resultColor = "ๆฐด่‰ฒ"; else if (1600 <= point && point < 2000) resultColor = "้’่‰ฒ"; else if (2000 <= point && point < 2400) resultColor = "้ป„่‰ฒ"; else if (2400 <= point && point < 2800) resultColor = "ๆฉ™่‰ฒ"; else if (2800 <= point && point < 3200) resultColor = "่ตค่‰ฒ"; else { resultColor = "่‡ช็”ฑ"; } return resultColor; } } 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, 200, 0, 212, 0, 41, 15, 16, 17, 18], ["+", 0, 200, 0, 212, 0, 41, 15, 16, 17, 60]]
8
729
2
using System; using System.Collections.Generic; using System.Linq; #if !DEBUG using System.IO; #endif public class Program { public static void Main() { #region SetAutoFlushIsFalse #if !DEBUG var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); #endif #endregion var n = ReadLib.ReadAsInt(); var arr = ReadLib.ReadAsIntArray() .Select(i => i / 400) .Select(i => i >= 8 ? 8 : i); var bColor = arr.Where(i => i >= 8).Count(); var colors = arr.Where(i => i < 8).GroupBy(i => i).Count(); Console.WriteLine($"{colors} {colors + bColor}"); #region Flush #if !DEBUG Console.Out.Flush(); sw.Close(); #endif #endregion } } static class ReadLib { public static long ReadAsLong() { return long.Parse(Console.ReadLine()); } public static int ReadAsInt() { return int.Parse(Console.ReadLine()); } public static int[] ReadAsIntArray(int step = 0) { return Console.ReadLine() .Split(' ') .Select(s => int.Parse(s) + step) .ToArray(); } public static long[] ReadAsLongArray(int step = 0) { return Console.ReadLine() .Split(' ') .Select(s => long.Parse(s) + step) .ToArray(); } public static ulong[] ReadAsULongArray() { return Console.ReadLine().Split(' ').Select(s => ulong.Parse(s)).ToArray(); } public static string[] ReadAsStringArray() { return Console.ReadLine().Split(' '); } public static int[] ReadNTimesAsInt(int n, int step = 0) { return Enumerable.Range(1, n) .Select(s => int.Parse(Console.ReadLine()) + step) .ToArray(); } public static int[][] ReadNTimesAsIntArray(int n, int step = 0) { return Enumerable.Range(1, n).Select(s => ReadAsIntArray(step)).ToArray(); } public static string[] ReadNTimesAsString(int n) { return Enumerable.Range(1, n).Select(s => Console.ReadLine()).ToArray(); } } static class MyMath { /// <summary>้šŽไน—</summary> public static long Factorial(int n) { if (n == 0) { return 1; } return Permutation(n, 0); } public static long Permutation(int n, int k) { return Enumerable.Range(0, n - k) .Select(i => n - i) .Aggregate(1, (b, i) => b * i); } /// <summary>nCr, ็ต„ใฟๅˆใ‚ใ›</summary> public static long Combination(int n, int r) { if (r == 0) { return 1; } // ๅˆ†ๅญ var moleculeArr = Enumerable.Range(0, Math.Min(n - r, r)).Select(i => n - i).ToArray(); var moleculeArrLength = moleculeArr.Length; // ๅˆ†ๆฏ var denominatorArr = Enumerable.Range(1, Math.Max(n - r, r)).ToArray(); for (var m = 0; m < moleculeArrLength; m++) { while (true) { var mVal = moleculeArr[m]; var gcds = denominatorArr.Select(b => Gcd(mVal, b)); var maxGcd = gcds.Max(); var maxI = gcds.ToList().IndexOf(maxGcd); if (maxGcd == 1) { break; } denominatorArr[maxI] /= maxGcd; moleculeArr[m] /= maxGcd; } } return FullPower(moleculeArr); } #region FullPower /// <summary>็ทไน—ใ€ฯ€</summary> public static long FullPower(IEnumerable<long> vs) { return vs.Aggregate(1L, (a, b) => a * b); } public static long FullPower(IEnumerable<int> vs) { return vs.Aggregate(1L, (a, b) => a * b); } #endregion /// <summary>ๆœ€ๅคงๅ…ฌ็ด„ๆ•ฐ</summary> public static int Gcd(long item1, long item2) { var a = Math.Max(item1, item2); var b = Math.Min(item1, item2); while (true) { var mod = a % b; if (mod == 0) { break; } a = b; b = mod; } return (int)b; } /// <summary>็ด„ๅˆ†ใ€‚ๆœ€ๅคงๅ…ฌ็ด„ๆ•ฐใงๅ‰ฒใฃใŸใ‚‚ใฎใ‚’่ฟ”ใ™ใ€‚</summary> public static Tuple<long, long> DeviedByGcd(long item1, long item2) { var gcd = Gcd(item1, item2); return new Tuple<long, long>(item1 / gcd, item2 / gcd); } } static class MyMethod { /// <summary>ๆ•ฐใˆไธŠใ’ใฆใ€key, ๅ‡บ็พๅ›žๆ•ฐใซๅค‰ๆ›</summary> public static Dictionary<T, int> CountUp<T>(IEnumerable<T> str) { return str.GroupBy(c => c) .Select(g => new KeyValuePair<T, int>(g.Key, g.Count())) .ToDictionary(e => e.Key, e => e.Value); } } /// <summary>ใ‚ใพใ‚Šใ‚’่จˆ็ฎ—ใ™ใ‚‹ใŸใ‚ใฎintใฎใƒฉใƒƒใƒ‘ใƒผ</summary> struct ModInt { int Value { get; } int Mod { get; } public override string ToString() { return Value.ToString(); } public static explicit operator ModInt(long value) { return new ModInt(value); } public ModInt(long value, int mod = 1000000007) { this.Value = (int)value % mod; this.Mod = mod; } public static explicit operator int(ModInt modInt) { return modInt.Value; } private static void CheckNotEqualMod(ModInt item1, ModInt item2) { if (item1.Mod != item2.Mod) { throw new Exception("mod not equal"); } } public static ModInt operator +(ModInt item1, ModInt item2) { CheckNotEqualMod(item1, item2); long value = item1.Value + item2.Value; return new ModInt(value, item1.Mod); } public static ModInt operator *(ModInt item1, ModInt item2) { CheckNotEqualMod(item1, item2); long value = Math.BigMul(item1.Value, item2.Value); return new ModInt(value, item1.Mod); } public static ModInt operator +(ModInt item1, int item2) { long value = item1.Value + item2; return new ModInt(value, item1.Mod); } public static ModInt operator *(ModInt item1, int item2) { long value = Math.BigMul(item1.Value, item2); return new ModInt(value, item1.Mod); } public override int GetHashCode() { return this.Value; } public override bool Equals(object obj) { if (obj == null || this.GetType() != obj.GetType()) { return false; } var modIntObj = (ModInt)obj; return modIntObj.Value == this.Value; } public static bool operator ==(ModInt item1, ModInt item2) { return item1.Value == item2.Value; } public static bool operator !=(ModInt item1, ModInt item2) { return !(item1 == item2); } public static bool operator ==(ModInt item1, int item2) { return item1.Value == item2; } public static bool operator !=(ModInt item1, int item2) { return !(item1.Value == item2); } public static bool operator >=(ModInt item1, ModInt item2) { return item1.Value >= item2.Value; } public static bool operator <=(ModInt item1, ModInt item2) { return item1.Value <= item2.Value; } public static bool operator >=(ModInt item1, int item2) { return item1.Value >= item2; } public static bool operator <=(ModInt item1, int item2) { return item1.Value <= item2; } public static bool operator>(ModInt item1, ModInt item2) { return item1.Value > item2.Value; } public static bool operator<(ModInt item1, ModInt item2) { return item1.Value < item2.Value; } public static bool operator>(ModInt item1, int item2) { return item1.Value >= item2; } public static bool operator<(ModInt item1, int item2) { return item1.Value <= item2; } }
using System; using System.Collections.Generic; using System.Linq; #if !DEBUG using System.IO; #endif public class Program { public static void Main() { #region SetAutoFlushIsFalse #if !DEBUG var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); #endif #endregion var n = ReadLib.ReadAsInt(); var arr = ReadLib.ReadAsIntArray() .Select(i => i / 400) .Select(i => i >= 8 ? 8 : i); var bColor = arr.Where(i => i >= 8).Count(); var colors = arr.Where(i => i < 8).GroupBy(i => i).Count(); Console.WriteLine( $"{(bColor >= 1 && colors == 0 ? 1 : colors)} {colors + bColor}"); #region Flush #if !DEBUG Console.Out.Flush(); sw.Close(); #endif #endregion } } static class ReadLib { public static long ReadAsLong() { return long.Parse(Console.ReadLine()); } public static int ReadAsInt() { return int.Parse(Console.ReadLine()); } public static int[] ReadAsIntArray(int step = 0) { return Console.ReadLine() .Split(' ') .Select(s => int.Parse(s) + step) .ToArray(); } public static long[] ReadAsLongArray(int step = 0) { return Console.ReadLine() .Split(' ') .Select(s => long.Parse(s) + step) .ToArray(); } public static ulong[] ReadAsULongArray() { return Console.ReadLine().Split(' ').Select(s => ulong.Parse(s)).ToArray(); } public static string[] ReadAsStringArray() { return Console.ReadLine().Split(' '); } public static int[] ReadNTimesAsInt(int n, int step = 0) { return Enumerable.Range(1, n) .Select(s => int.Parse(Console.ReadLine()) + step) .ToArray(); } public static int[][] ReadNTimesAsIntArray(int n, int step = 0) { return Enumerable.Range(1, n).Select(s => ReadAsIntArray(step)).ToArray(); } public static string[] ReadNTimesAsString(int n) { return Enumerable.Range(1, n).Select(s => Console.ReadLine()).ToArray(); } } static class MyMath { /// <summary>้šŽไน—</summary> public static long Factorial(int n) { if (n == 0) { return 1; } return Permutation(n, 0); } public static long Permutation(int n, int k) { return Enumerable.Range(0, n - k) .Select(i => n - i) .Aggregate(1, (b, i) => b * i); } /// <summary>nCr, ็ต„ใฟๅˆใ‚ใ›</summary> public static long Combination(int n, int r) { if (r == 0) { return 1; } // ๅˆ†ๅญ var moleculeArr = Enumerable.Range(0, Math.Min(n - r, r)).Select(i => n - i).ToArray(); var moleculeArrLength = moleculeArr.Length; // ๅˆ†ๆฏ var denominatorArr = Enumerable.Range(1, Math.Max(n - r, r)).ToArray(); for (var m = 0; m < moleculeArrLength; m++) { while (true) { var mVal = moleculeArr[m]; var gcds = denominatorArr.Select(b => Gcd(mVal, b)); var maxGcd = gcds.Max(); var maxI = gcds.ToList().IndexOf(maxGcd); if (maxGcd == 1) { break; } denominatorArr[maxI] /= maxGcd; moleculeArr[m] /= maxGcd; } } return FullPower(moleculeArr); } #region FullPower /// <summary>็ทไน—ใ€ฯ€</summary> public static long FullPower(IEnumerable<long> vs) { return vs.Aggregate(1L, (a, b) => a * b); } public static long FullPower(IEnumerable<int> vs) { return vs.Aggregate(1L, (a, b) => a * b); } #endregion /// <summary>ๆœ€ๅคงๅ…ฌ็ด„ๆ•ฐ</summary> public static int Gcd(long item1, long item2) { var a = Math.Max(item1, item2); var b = Math.Min(item1, item2); while (true) { var mod = a % b; if (mod == 0) { break; } a = b; b = mod; } return (int)b; } /// <summary>็ด„ๅˆ†ใ€‚ๆœ€ๅคงๅ…ฌ็ด„ๆ•ฐใงๅ‰ฒใฃใŸใ‚‚ใฎใ‚’่ฟ”ใ™ใ€‚</summary> public static Tuple<long, long> DeviedByGcd(long item1, long item2) { var gcd = Gcd(item1, item2); return new Tuple<long, long>(item1 / gcd, item2 / gcd); } } static class MyMethod { /// <summary>ๆ•ฐใˆไธŠใ’ใฆใ€key, ๅ‡บ็พๅ›žๆ•ฐใซๅค‰ๆ›</summary> public static Dictionary<T, int> CountUp<T>(IEnumerable<T> str) { return str.GroupBy(c => c) .Select(g => new KeyValuePair<T, int>(g.Key, g.Count())) .ToDictionary(e => e.Key, e => e.Value); } } /// <summary>ใ‚ใพใ‚Šใ‚’่จˆ็ฎ—ใ™ใ‚‹ใŸใ‚ใฎintใฎใƒฉใƒƒใƒ‘ใƒผ</summary> struct ModInt { int Value { get; } int Mod { get; } public override string ToString() { return Value.ToString(); } public static explicit operator ModInt(long value) { return new ModInt(value); } public ModInt(long value, int mod = 1000000007) { this.Value = (int)value % mod; this.Mod = mod; } public static explicit operator int(ModInt modInt) { return modInt.Value; } private static void CheckNotEqualMod(ModInt item1, ModInt item2) { if (item1.Mod != item2.Mod) { throw new Exception("mod not equal"); } } public static ModInt operator +(ModInt item1, ModInt item2) { CheckNotEqualMod(item1, item2); long value = item1.Value + item2.Value; return new ModInt(value, item1.Mod); } public static ModInt operator *(ModInt item1, ModInt item2) { CheckNotEqualMod(item1, item2); long value = Math.BigMul(item1.Value, item2.Value); return new ModInt(value, item1.Mod); } public static ModInt operator +(ModInt item1, int item2) { long value = item1.Value + item2; return new ModInt(value, item1.Mod); } public static ModInt operator *(ModInt item1, int item2) { long value = Math.BigMul(item1.Value, item2); return new ModInt(value, item1.Mod); } public override int GetHashCode() { return this.Value; } public override bool Equals(object obj) { if (obj == null || this.GetType() != obj.GetType()) { return false; } var modIntObj = (ModInt)obj; return modIntObj.Value == this.Value; } public static bool operator ==(ModInt item1, ModInt item2) { return item1.Value == item2.Value; } public static bool operator !=(ModInt item1, ModInt item2) { return !(item1 == item2); } public static bool operator ==(ModInt item1, int item2) { return item1.Value == item2; } public static bool operator !=(ModInt item1, int item2) { return !(item1.Value == item2); } public static bool operator >=(ModInt item1, ModInt item2) { return item1.Value >= item2.Value; } public static bool operator <=(ModInt item1, ModInt item2) { return item1.Value <= item2.Value; } public static bool operator >=(ModInt item1, int item2) { return item1.Value >= item2; } public static bool operator <=(ModInt item1, int item2) { return item1.Value <= item2; } public static bool operator>(ModInt item1, ModInt item2) { return item1.Value > item2.Value; } public static bool operator<(ModInt item1, ModInt item2) { return item1.Value < item2.Value; } public static bool operator>(ModInt item1, int item2) { return item1.Value >= item2; } public static bool operator<(ModInt item1, int item2) { return item1.Value <= item2; } }
[["+", 0, 28, 0, 283, 0, 284, 0, 23, 0, 24], ["+", 0, 23, 0, 41, 15, 16, 31, 16, 31, 22], ["+", 0, 23, 0, 41, 15, 16, 31, 16, 17, 20], ["+", 0, 23, 0, 41, 15, 16, 31, 16, 12, 203], ["+", 0, 284, 0, 23, 0, 41, 15, 16, 17, 98], ["+", 0, 23, 0, 41, 15, 16, 12, 16, 31, 22], ["+", 0, 23, 0, 41, 15, 16, 12, 16, 17, 60], ["+", 0, 23, 0, 41, 15, 16, 12, 16, 12, 203], ["+", 0, 283, 0, 284, 0, 23, 0, 41, 0, 101], ["+", 0, 283, 0, 284, 0, 23, 0, 41, 64, 203], ["+", 0, 283, 0, 284, 0, 23, 0, 41, 0, 102], ["+", 0, 28, 0, 283, 0, 284, 0, 23, 0, 25]]
8
1,696
12
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; namespace ABC064C { class Program { static void Solve() { var n = Input.NextInt(); var a = Input.NextInt(n); var map = Enumerable.Repeat(0, 9).ToArray(); foreach (var m in a) { if (m < 400) map[0]++; else if (m < 800) map[1]++; else if (m < 1200) map[2]++; else if (m < 1600) map[3]++; else if (m < 2000) map[4]++; else if (m < 2400) map[5]++; else if (m < 2800) map[6]++; else if (m < 3200) map[7]++; else map[8]++; } var min = map.Take(8).Count(x => x != 0); Console.WriteLine($"{min} {min + map.Last()}"); } #region Competitive Template public static void Main(string[] args) { var needsFlushOutput = true; if (needsFlushOutput) { // ็ดฐใ‹ใๅ‡บๅŠ›ใ—ใชใ„ใ‚ˆใ†ใซใ™ใ‚‹ var sw = new System.IO.StreamWriter( Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); } // ไปฎๆƒณ็š„ใซๆจ™ๆบ–ๅ…ฅๅŠ›ใ‚’ใ‚ปใƒƒใƒˆใ™ใ‚‹ // NextLine็ณปใ‚’ไฝฟใฃใฆใ„ใ‚‹ใจไฝฟใˆใชใ„ // Input.SetText(""); Solve(); Console.Out.Flush(); } static class Input { static char[] separator = { ' ' }; public static bool IsEof { get; set; } static Queue<string> q { get; set; } static Input() { IsEof = false; q = new Queue<string>(); } /// <summary> /// ๅ…ฅๅŠ›ไบˆ็ด„ /// </summary> /// <param name="items"></param> public static void SetText(IEnumerable<string> items) { foreach (var item in items) { SetText(item); } } /// <summary> /// ๅ…ฅๅŠ›ไบˆ็ด„ /// </summary> /// <param name="s"></param> /// <returns></returns> public static bool SetText(string s) { if (s == null) return false; foreach (var elem in s.Trim().Split( separator, StringSplitOptions.RemoveEmptyEntries)) { q.Enqueue(elem); } return true; } /// <summary> /// ๅ†…้ƒจqueueใซๅ…ฅๅŠ›ใ‹ใ‚‰ใฎๅ€คใ‚’splitใ—ใฆๆ ผ็ดใ™ใ‚‹ /// </summary> /// <returns></returns> static bool read() { var s = Console.ReadLine(); if (s == null) return false; foreach (var elem in s.Trim().Split( separator, StringSplitOptions.RemoveEmptyEntries)) { q.Enqueue(elem); } if (!q.Any()) return read(); return true; } /// <summary> /// ๆฌกใฎstringใ‚’ไธ€ใค่ชญใฟ่พผใ‚€ /// </summary> /// <returns></returns> public static string Next() { if (!q.Any()) { if (!read()) { IsEof = true; return ""; } } return q.Dequeue(); } public static int NextInt() => int.Parse(Next()); public static long NextLong() => long.Parse(Next()); public static double NextDouble() => double.Parse(Next()); public static List<string> Next(int n) => Enumerable.Range(0, n).Select(_ => Next()).ToList(); public static List<int> NextInt(int n) => Next(n).Select(x => int.Parse(x)).ToList(); public static List<long> NextLong(int n) => Next(n).Select(x => long.Parse(x)).ToList(); public static List<double> NextDouble(int n) => Next(n).Select(x => double.Parse(x)).ToList(); public static List<string> NextLine() => Console.ReadLine() .Trim() .Split(separator, StringSplitOptions.RemoveEmptyEntries) .ToList(); public static List<int> NextIntLine() => NextLine().Select(x => int.Parse(x)).ToList(); public static List<long> NextLongLine() => NextLine().Select(x => long.Parse(x)).ToList(); public static List<double> NextDoubleLine() => NextLine().Select(x => double.Parse(x)).ToList(); } #endregion } }
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; namespace ABC064C { class Program { static void Solve() { var n = Input.NextInt(); var a = Input.NextInt(n); var map = Enumerable.Repeat(0, 9).ToArray(); foreach (var m in a) { if (m < 400) map[0]++; else if (m < 800) map[1]++; else if (m < 1200) map[2]++; else if (m < 1600) map[3]++; else if (m < 2000) map[4]++; else if (m < 2400) map[5]++; else if (m < 2800) map[6]++; else if (m < 3200) map[7]++; else map[8]++; } var min = map.Take(8).Count(x => x != 0); Console.WriteLine($"{Math.Max(1, min)} {min + map.Last()}"); } #region Competitive Template public static void Main(string[] args) { var needsFlushOutput = true; if (needsFlushOutput) { // ็ดฐใ‹ใๅ‡บๅŠ›ใ—ใชใ„ใ‚ˆใ†ใซใ™ใ‚‹ var sw = new System.IO.StreamWriter( Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); } // ไปฎๆƒณ็š„ใซๆจ™ๆบ–ๅ…ฅๅŠ›ใ‚’ใ‚ปใƒƒใƒˆใ™ใ‚‹ // NextLine็ณปใ‚’ไฝฟใฃใฆใ„ใ‚‹ใจไฝฟใˆใชใ„ // Input.SetText(""); Solve(); Console.Out.Flush(); } static class Input { static char[] separator = { ' ' }; public static bool IsEof { get; set; } static Queue<string> q { get; set; } static Input() { IsEof = false; q = new Queue<string>(); } /// <summary> /// ๅ…ฅๅŠ›ไบˆ็ด„ /// </summary> /// <param name="items"></param> public static void SetText(IEnumerable<string> items) { foreach (var item in items) { SetText(item); } } /// <summary> /// ๅ…ฅๅŠ›ไบˆ็ด„ /// </summary> /// <param name="s"></param> /// <returns></returns> public static bool SetText(string s) { if (s == null) return false; foreach (var elem in s.Trim().Split( separator, StringSplitOptions.RemoveEmptyEntries)) { q.Enqueue(elem); } return true; } /// <summary> /// ๅ†…้ƒจqueueใซๅ…ฅๅŠ›ใ‹ใ‚‰ใฎๅ€คใ‚’splitใ—ใฆๆ ผ็ดใ™ใ‚‹ /// </summary> /// <returns></returns> static bool read() { var s = Console.ReadLine(); if (s == null) return false; foreach (var elem in s.Trim().Split( separator, StringSplitOptions.RemoveEmptyEntries)) { q.Enqueue(elem); } if (!q.Any()) return read(); return true; } /// <summary> /// ๆฌกใฎstringใ‚’ไธ€ใค่ชญใฟ่พผใ‚€ /// </summary> /// <returns></returns> public static string Next() { if (!q.Any()) { if (!read()) { IsEof = true; return ""; } } return q.Dequeue(); } public static int NextInt() => int.Parse(Next()); public static long NextLong() => long.Parse(Next()); public static double NextDouble() => double.Parse(Next()); public static List<string> Next(int n) => Enumerable.Range(0, n).Select(_ => Next()).ToList(); public static List<int> NextInt(int n) => Next(n).Select(x => int.Parse(x)).ToList(); public static List<long> NextLong(int n) => Next(n).Select(x => long.Parse(x)).ToList(); public static List<double> NextDouble(int n) => Next(n).Select(x => double.Parse(x)).ToList(); public static List<string> NextLine() => Console.ReadLine() .Trim() .Split(separator, StringSplitOptions.RemoveEmptyEntries) .ToList(); public static List<int> NextIntLine() => NextLine().Select(x => int.Parse(x)).ToList(); public static List<long> NextLongLine() => NextLine().Select(x => long.Parse(x)).ToList(); public static List<double> NextDoubleLine() => NextLine().Select(x => double.Parse(x)).ToList(); } #endregion } }
[["+", 0, 283, 0, 284, 0, 213, 63, 214, 205, 22], ["+", 0, 283, 0, 284, 0, 213, 63, 214, 0, 131], ["+", 0, 283, 0, 284, 0, 213, 63, 214, 141, 22], ["+", 0, 283, 0, 284, 0, 213, 3, 4, 0, 24], ["+", 0, 284, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 283, 0, 284, 0, 213, 3, 4, 0, 21], ["+", 0, 283, 0, 284, 0, 213, 3, 4, 0, 25]]
8
884
7
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Program { void Run() { var sc = new Scanner(); int n = sc.NextInt(); int[] c = new int[9]; for (int i = 0; i < n; i++) { int r = sc.NextInt(); c[Math.Min(r / 400, 8)]++; } int res = 0; for (int i = 0; i < c.Length - 1; i++) if (c[i] > 0) res++; Console.WriteLine("{0} {1}", res, res + c[8]); } static void Main(string[] args) { new Program().Run(); } static long Gcd(long a, long b) { if (a < b) return Gcd(b, a); if (b == 0) return a; return Gcd(b, a % b); } } 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 double NextDouble() { CheckNext(); return double.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 { void Run() { var sc = new Scanner(); int n = sc.NextInt(); int[] c = new int[9]; for (int i = 0; i < n; i++) { int r = sc.NextInt(); c[Math.Min(r / 400, 8)]++; } int res = 0; for (int i = 0; i < c.Length - 1; i++) if (c[i] > 0) res++; Console.WriteLine("{0} {1}", res == 0 ? 1 : res, res + c[8]); } static void Main(string[] args) { new Program().Run(); } static long Gcd(long a, long b) { if (a < b) return Gcd(b, a); if (b == 0) return a; return Gcd(b, a % b); } } 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 double NextDouble() { CheckNext(); return double.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, 41, 15, 16, 17, 60], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 12, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 101], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 64, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 102], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 75, 22]]
8
371
6
using System; using System.IO; using System.Collections.Generic; using System.Linq; using System.Numerics; using System.Diagnostics; using System.Text; using System.Threading.Tasks; using System.Runtime.CompilerServices; using static System.Math; class P { static void Main() { int.Parse(Console.ReadLine()); int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray(); int min = a.Where(x => x < 3200).Select(x => x / 400).Distinct().Count(); Console.WriteLine($"{min} {min + a.Count(x => x >= 3200)}"); } }
using System; using System.IO; using System.Collections.Generic; using System.Linq; using System.Numerics; using System.Diagnostics; using System.Text; using System.Threading.Tasks; using System.Runtime.CompilerServices; using static System.Math; class P { static void Main() { int.Parse(Console.ReadLine()); int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray(); int min = a.Where(x => x < 3200).Select(x => x / 400).Distinct().Count(); Console.WriteLine($"{Max(1, min)} {min + a.Count(x => x >= 3200)}"); } }
[["+", 0, 28, 0, 283, 0, 284, 0, 213, 63, 22], ["+", 0, 283, 0, 284, 0, 213, 3, 4, 0, 24], ["+", 0, 284, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 283, 0, 284, 0, 213, 3, 4, 0, 21], ["+", 0, 283, 0, 284, 0, 213, 3, 4, 0, 25]]
8
160
5
using System; using System.Collections.Generic; using System.Linq; using static System.Console; using static System.Convert; using static System.Math; class Program { static void Main(string[] args) { var num = ToInt32(ReadLine()); var rates = Array.ConvertAll(ReadLine().Split(' '), int.Parse); var bet = new[] { 399, 799, 1199, 1599, 1999, 2399, 2799, 3199 }; var set = new HashSet<int>(); var counter = 0; for (var i = 0; i < num; i++) { var index = Search.LowerBound(bet, rates[i]); if (index >= bet.Length) counter++; else set.Add(index); } WriteLine($"{set.Count} {set.Count + counter}"); } } public class Search { public static int LowerBound(int[] array, int value) { var low = 0; var high = array.Length; while (high > low) { var mid = (high + low) / 2; if (array[mid] >= value) high = mid; else low = mid + 1; } return low; } }
using System; using System.Collections.Generic; using System.Linq; using static System.Console; using static System.Convert; using static System.Math; class Program { static void Main(string[] args) { var num = ToInt32(ReadLine()); var rates = Array.ConvertAll(ReadLine().Split(' '), int.Parse); var bet = new[] { 399, 799, 1199, 1599, 1999, 2399, 2799, 3199 }; var set = new HashSet<int>(); var counter = 0; for (var i = 0; i < num; i++) { var index = Search.LowerBound(bet, rates[i]); if (index >= bet.Length) counter++; else set.Add(index); } WriteLine($"{Max(1,set.Count)} {set.Count + counter}"); } } public class Search { public static int LowerBound(int[] array, int value) { var low = 0; var high = array.Length; while (high > low) { var mid = (high + low) / 2; if (array[mid] >= value) high = mid; else low = mid + 1; } return low; } }
[["+", 0, 28, 0, 283, 0, 284, 0, 213, 63, 22], ["+", 0, 283, 0, 284, 0, 213, 3, 4, 0, 24], ["+", 0, 284, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 283, 0, 284, 0, 213, 3, 4, 0, 21], ["+", 0, 283, 0, 284, 0, 213, 3, 4, 0, 25]]
8
264
5
using System; using System.Text; using System.Linq; using System.Collections; using System.Collections.Generic; using static System.Console; using static System.Math; namespace NotFounds { public class Program { public static void Main(string[] args) { var sw = new System.IO.StreamWriter( Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); new Program().Solve(new ConsoleInput(Console.In, ' ')); Console.Out.Flush(); } public void Solve(ConsoleInput cin) { var N = cin.ReadInt; var set = new HashSet<int>(); var col = new int[] { 400, 800, 1200, 1600, 2000, 2400, 2800, 3200 }; var cnt = 0; for (int i = 0; i < N; ++i) { var a = cin.ReadInt; for (int j = 0; j < 8; ++j) { if (a < col[j]) { set.Add(j); break; } } if (a >= 3200) cnt++; } var min = Max(set.Count(), 1); var max = min + cnt; WriteLine($"{min} {max}"); } } 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 void ReadIntArrays(long N, out int[] A, out int[] B) { A = new int[N]; B = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt; B[i] = ReadInt; } } public void ReadLongArrays(long N, out long[] A, out long[] B) { A = new long[N]; B = new long[N]; for (long i = 0; i < N; ++i) { A[i] = ReadLong; B[i] = ReadLong; } } } }
using System; using System.Text; using System.Linq; using System.Collections; using System.Collections.Generic; using static System.Console; using static System.Math; namespace NotFounds { public class Program { public static void Main(string[] args) { var sw = new System.IO.StreamWriter( Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); new Program().Solve(new ConsoleInput(Console.In, ' ')); Console.Out.Flush(); } public void Solve(ConsoleInput cin) { var N = cin.ReadInt; var set = new HashSet<int>(); var col = new int[] { 400, 800, 1200, 1600, 2000, 2400, 2800, 3200 }; var cnt = 0; for (int i = 0; i < N; ++i) { var a = cin.ReadInt; for (int j = 0; j < 8; ++j) { if (a < col[j]) { set.Add(j); break; } } if (a >= 3200) cnt++; } var min = Max(set.Count(), 1); var max = set.Count() + cnt; WriteLine($"{min} {max}"); } } 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 void ReadIntArrays(long N, out int[] A, out int[] B) { A = new int[N]; B = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt; B[i] = ReadInt; } } public void ReadLongArrays(long N, out long[] A, out long[] B) { A = new long[N]; B = new long[N]; for (long i = 0; i < N; ++i) { A[i] = ReadLong; B[i] = ReadLong; } } } }
[["-", 0, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["+", 0, 212, 0, 16, 31, 213, 63, 214, 205, 22], ["+", 0, 212, 0, 16, 31, 213, 63, 214, 0, 131], ["+", 0, 212, 0, 16, 31, 213, 63, 214, 141, 22], ["+", 0, 212, 0, 16, 31, 213, 3, 4, 0, 24], ["+", 0, 212, 0, 16, 31, 213, 3, 4, 0, 25]]
8
745
6
using System.Linq; using System; class Program { static void Main() { var N = int.Parse(Console.ReadLine()); var a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)); bool[] colors = new bool[8]; int others = 0; foreach (var rate in a) { if (rate >= 3200) { others++; } else { colors[rate / 400] = true; } } var min = colors.Count(x => x); var max = min + others; Console.WriteLine($"{min} {max}"); } }
using System.Linq; using System; class Program { static void Main() { var N = int.Parse(Console.ReadLine()); var a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)); bool[] colors = new bool[8]; int others = 0; foreach (var rate in a) { if (rate >= 3200) { others++; } else { colors[rate / 400] = true; } } var min = colors.Count(x => x); var max = min + others; Console.WriteLine($"{(min > 0 ? min : 1)} {max}"); } }
[["+", 0, 28, 0, 283, 0, 284, 0, 23, 0, 24], ["+", 0, 284, 0, 23, 0, 41, 15, 16, 31, 22], ["+", 0, 284, 0, 23, 0, 41, 15, 16, 17, 47], ["+", 0, 284, 0, 23, 0, 41, 15, 16, 12, 203], ["+", 0, 283, 0, 284, 0, 23, 0, 41, 0, 101], ["+", 0, 283, 0, 284, 0, 23, 0, 41, 0, 102], ["+", 0, 283, 0, 284, 0, 23, 0, 41, 75, 203], ["+", 0, 28, 0, 283, 0, 284, 0, 23, 0, 25]]
8
143
8
using System; using System.Linq; using System.IO; using System.Text; using System.Collections; using System.Collections.Generic; using System.Text.RegularExpressions; class Program { static void Main() { int n = int.Parse(Console.ReadLine()); int[] a = Console.ReadLine().Split(' ').Select(elem => int.Parse(elem)).ToArray(); const int NumOfColors = 8; bool[] colors = new bool[NumOfColors]; int NumberOfFreeColor = 0; for (int i = 0; i < n; i++) { if (a[i] >= 3200) { NumberOfFreeColor++; continue; } for (int j = 0; j < NumOfColors; j++) { if (!colors[j] && 400 * j <= a[i] && a[i] <= 400 * (j + 1)) { colors[j] = true; } } } int cnt = colors.Where(elem => elem).Count(); int min = Math.Max(1, cnt); int max = cnt + NumberOfFreeColor; Console.WriteLine("{0} {1}", min, max); } }
using System; using System.Linq; using System.IO; using System.Text; using System.Collections; using System.Collections.Generic; using System.Text.RegularExpressions; class Program { static void Main() { int n = int.Parse(Console.ReadLine()); int[] a = Console.ReadLine().Split(' ').Select(elem => int.Parse(elem)).ToArray(); const int NumOfColors = 8; bool[] colors = new bool[NumOfColors]; int NumberOfFreeColor = 0; for (int i = 0; i < n; i++) { if (a[i] >= 3200) { NumberOfFreeColor++; continue; } for (int j = 0; j < NumOfColors; j++) { if (!colors[j] && 400 * j <= a[i] && a[i] < 400 * (j + 1)) { colors[j] = true; } } } int cnt = colors.Where(elem => elem).Count(); int min = Math.Max(1, cnt); int max = cnt + NumberOfFreeColor; Console.WriteLine("{0} {1}", min, max); } }
[["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 19], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 18]]
8
253
2
using System; using System.Linq; using System.Collections.Generic; using System.IO; using System.Diagnostics; using System.Text; public class Program { public static void Main() { var watch = new Stopwatch(); watch.Start(); var isTest = false; var stream = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(stream); TextReader reader; string filename = ""; if (filename.Length != 0) { reader = new StreamReader(filename); } else { reader = Console.In; } var n = int.Parse(reader.ReadLine()); var a = reader.ReadLine().Split().Select(int.Parse).ToArray(); var cnt = 0; var abure = 0; bool[] bls = new bool[8]; foreach (var x in a) { if (x <= 399) { if (bls[0] == false) bls[0] = true; } else if (x <= 799) { if (bls[1] == false) bls[1] = true; } else if (x <= 1199) { if (bls[2] == false) bls[2] = true; } else if (x <= 1599) { if (bls[3] == false) bls[3] = true; } else if (x <= 1999) { if (bls[4] == false) bls[4] = true; } else if (x <= 2399) { if (bls[5] == false) bls[5] = true; } else if (x <= 2799) { if (bls[6] == false) bls[6] = true; } else if (x <= 3199) { if (bls[7] == false) bls[7] = true; } else abure++; cnt = bls.Count(b => b == true); } //ๆ„š็›ดใซๅ–ใฃใŸใถใ‚“ใŒcntใงๆœ€ๅฐๅ€ค // 3200ไปฅไธŠใฎใ‚‚ใฎใฏcntใจ่ถณใ—ใฆๆœ€ๅคงๅ€คใŒ8 //ใจๆ€ใฃใŸใ‘ใฉๅ…จๅ“กใŒ3200ไปฅไธŠใฎใจใใฏไธ€็จฎ้กžใซใงใใ‚‹ใฎใง Console.WriteLine($"{cnt==0 ? 1 : cnt} {Math.Min(8, cnt+abure)}"); watch.Stop(); if (isTest) { Console.WriteLine($"ๅฎŸ่กŒๆ™‚้–“{watch.ElapsedMilliseconds}ใƒŸใƒช็ง’"); } Console.Out.Flush(); } }
using System; using System.Linq; using System.Collections.Generic; using System.IO; using System.Diagnostics; using System.Text; public class Program { public static void Main() { var watch = new Stopwatch(); watch.Start(); var isTest = false; var stream = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(stream); TextReader reader; string filename = ""; if (filename.Length != 0) { reader = new StreamReader(filename); } else { reader = Console.In; } var n = int.Parse(reader.ReadLine()); var a = reader.ReadLine().Split().Select(int.Parse).ToArray(); var cnt = 0; var abure = 0; bool[] bls = new bool[8]; foreach (var x in a) { if (x <= 399) { if (bls[0] == false) bls[0] = true; } else if (x <= 799) { if (bls[1] == false) bls[1] = true; } else if (x <= 1199) { if (bls[2] == false) bls[2] = true; } else if (x <= 1599) { if (bls[3] == false) bls[3] = true; } else if (x <= 1999) { if (bls[4] == false) bls[4] = true; } else if (x <= 2399) { if (bls[5] == false) bls[5] = true; } else if (x <= 2799) { if (bls[6] == false) bls[6] = true; } else if (x <= 3199) { if (bls[7] == false) bls[7] = true; } else abure++; } cnt = bls.Count(b => b == true); //ๆ„š็›ดใซๅ–ใฃใŸใถใ‚“ใŒcntใงๆœ€ๅฐๅ€ค // 3200ไปฅไธŠใฎใ‚‚ใฎใฏcntใจ่ถณใ—ใฆๆœ€ๅคงๅ€คใŒ8 //ใจๆ€ใฃใŸใ‘ใฉๅ…จๅ“กใŒ3200ไปฅไธŠใฎใจใใฏไธ€็จฎ้กžใซใงใใ‚‹ใฎใง //ใชใœใ‹ใ‚ณใ‚ฑใŸ Console.WriteLine($"{cnt==0 ? 1 : cnt} {cnt+abure}"); watch.Stop(); if (isTest) { Console.WriteLine($"ๅฎŸ่กŒๆ™‚้–“{watch.ElapsedMilliseconds}ใƒŸใƒช็ง’"); } Console.Out.Flush(); } }
[["+", 0, 195, 8, 196, 0, 210, 8, 196, 0, 46], ["-", 0, 195, 8, 196, 0, 210, 8, 196, 0, 46], ["-", 0, 283, 0, 284, 0, 213, 63, 214, 205, 22], ["-", 0, 283, 0, 284, 0, 213, 63, 214, 0, 131], ["-", 0, 283, 0, 284, 0, 213, 63, 214, 141, 22], ["-", 0, 283, 0, 284, 0, 213, 3, 4, 0, 24], ["-", 0, 284, 0, 213, 3, 4, 0, 28, 0, 203], ["-", 0, 283, 0, 284, 0, 213, 3, 4, 0, 21], ["-", 0, 283, 0, 284, 0, 213, 3, 4, 0, 25]]
8
475
9
using System; using System.Collections.Generic; using System.Linq; class Hello { public enum Color { hai, brown, green, mizu, blue, yellow, daidai, red, all /* * * * ใƒฌใƒผใƒˆ 1-399๏ผš็ฐ่‰ฒ ใƒฌใƒผใƒˆ 400-799๏ผš่Œถ่‰ฒ ใƒฌใƒผใƒˆ 800-1199๏ผš็ท‘่‰ฒ ใƒฌใƒผใƒˆ 1200-1599๏ผšๆฐด่‰ฒ ใƒฌใƒผใƒˆ 1600-1999๏ผš้’่‰ฒ ใƒฌใƒผใƒˆ 2000-2399๏ผš้ป„่‰ฒ ใƒฌใƒผใƒˆ 2400-2799๏ผšๆฉ™่‰ฒ ใƒฌใƒผใƒˆ 2800-3199๏ผš่ตค่‰ฒ * * * * * * */ } static void Main() { var n = int.Parse(Console.ReadLine()); int[] a = new int[n]; var s = Console.ReadLine().Split(); Color[] c = new Color[n]; for (int i = 0; i < n; i++) { a[i] = int.Parse(s[i]); int b = a[i] / 400; if (a[i] >= 3200) { c[i] = Color.all; } else { c[i] = (Color)b; } } var c_dis = c.Distinct().ToList(); var c_dis_NoAll = c_dis.Where(e => e != Color.all); var c_dis_All = c_dis.Where(e => e == Color.all); var c_All = c.Where(e => e == Color.all); var min = c_dis_NoAll.Count(); var c_AllCount = c_All.Count(); var c_normalCount = c_dis_NoAll.Count(); int saidai = (c_normalCount); saidai = saidai >= 0 ? saidai : 0; saidai = c_AllCount > saidai ? saidai : c_AllCount; var max = (min + c_AllCount); min = min <= 0 ? 0 : min; { Console.WriteLine((min) + " " + max); } } }
using System; using System.Collections.Generic; using System.Linq; class Hello { public enum Color { hai, brown, green, mizu, blue, yellow, daidai, red, all /* * * * ใƒฌใƒผใƒˆ 1-399๏ผš็ฐ่‰ฒ ใƒฌใƒผใƒˆ 400-799๏ผš่Œถ่‰ฒ ใƒฌใƒผใƒˆ 800-1199๏ผš็ท‘่‰ฒ ใƒฌใƒผใƒˆ 1200-1599๏ผšๆฐด่‰ฒ ใƒฌใƒผใƒˆ 1600-1999๏ผš้’่‰ฒ ใƒฌใƒผใƒˆ 2000-2399๏ผš้ป„่‰ฒ ใƒฌใƒผใƒˆ 2400-2799๏ผšๆฉ™่‰ฒ ใƒฌใƒผใƒˆ 2800-3199๏ผš่ตค่‰ฒ * * * * * * */ } static void Main() { var n = int.Parse(Console.ReadLine()); int[] a = new int[n]; var s = Console.ReadLine().Split(); Color[] c = new Color[n]; for (int i = 0; i < n; i++) { a[i] = int.Parse(s[i]); int b = a[i] / 400; if (a[i] >= 3200) { c[i] = Color.all; } else { c[i] = (Color)b; } } var c_dis = c.Distinct().ToList(); var c_dis_NoAll = c_dis.Where(e => e != Color.all); var c_dis_All = c_dis.Where(e => e == Color.all); var c_All = c.Where(e => e == Color.all); var min = c_dis_NoAll.Count(); var c_AllCount = c_All.Count(); var c_normalCount = c_dis_NoAll.Count(); int saidai = (c_normalCount); saidai = saidai >= 0 ? saidai : 0; saidai = c_AllCount > saidai ? saidai : c_AllCount; var max = (min + c_AllCount); min = min <= 0 ? 1 : min; { Console.WriteLine((min) + " " + max); } } }
[["-", 8, 196, 0, 1, 0, 11, 12, 41, 64, 203], ["+", 8, 196, 0, 1, 0, 11, 12, 41, 64, 203]]
8
323
2
using System; using System.Collections.Generic; using System.Linq; class Program { static void Main() { long n = long.Parse(Console.ReadLine()); var a = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }), number => long.Parse(number)); long sunukeSum = a[0]; long kumaSum = a.Skip(1).Sum(); long differnece = Math.Abs(sunukeSum - kumaSum); for (long i = 1; i < n; ++i) { sunukeSum += a[i]; kumaSum -= a[i]; long tempDifference = Math.Abs(sunukeSum - kumaSum); if (tempDifference < differnece) { differnece = tempDifference; } } Console.WriteLine(differnece); //ใƒ‡ใƒใƒƒใ‚ฐๅฎŸ่กŒใงใฎ็ขบ่ช็”จใ€‚ใใฎใพใพๆๅ‡บใ—ใฆใ‚‚ๅ•้กŒใชใ— Console.ReadKey(); } }
using System; using System.Collections.Generic; using System.Linq; class Program { static void Main() { long n = long.Parse(Console.ReadLine()); var a = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }), number => long.Parse(number)); long sunukeSum = a[0]; long kumaSum = a.Skip(1).Sum(); long differnece = Math.Abs(sunukeSum - kumaSum); for (long i = 1; i < n - 1; ++i) { sunukeSum += a[i]; kumaSum -= a[i]; long tempDifference = Math.Abs(sunukeSum - kumaSum); if (tempDifference < differnece) { differnece = tempDifference; } } Console.WriteLine(differnece); //ใƒ‡ใƒใƒƒใ‚ฐๅฎŸ่กŒใงใฎ็ขบ่ช็”จใ€‚ใใฎใพใพๆๅ‡บใ—ใฆใ‚‚ๅ•้กŒใชใ— Console.ReadKey(); } }
[["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203]]
8
177
2
using System; using System.Linq; class Program { static void Main() { Console.ReadLine(); var a = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }), number => int.Parse(number)); var sunuke = a[0]; var kuma = a.Skip(1).Sum(); var min = Math.Abs(sunuke - kuma); for (var i = 1; i < a.Length - 1; ++i) { sunuke += a[i]; kuma -= a[i]; min = Math.Min(Math.Abs(sunuke - kuma), min); } Console.WriteLine(min); } }
using System; using System.Linq; class Program { static void Main() { Console.ReadLine(); var a = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }), number => long.Parse(number)); long sunuke = a[0]; long kuma = a.Skip(1).Sum(); long min = Math.Abs(sunuke - kuma); for (var i = 1; i < a.Length - 1; ++i) { sunuke += a[i]; kuma -= a[i]; min = Math.Min(Math.Abs(sunuke - kuma), min); } Console.WriteLine(min); } }
[["-", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["+", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
8
153
8
using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; using System.Numerics; using System.Text; using System.Threading.Tasks; namespace AtCorder { public class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); long[] a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); long[] sums = new long[n]; sums[0] = a[0]; for (int i = 1; i < n; i++) { sums[i] += sums[i - 1]; } long sum = sums[n - 1]; long ans = long.MaxValue; for (int i = 0; i < n - 1; i++) { long dif = Math.Abs(sum - sums[i] - sums[i]); ans = Math.Min(ans, dif); } Console.WriteLine(ans); } } }
using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; using System.Numerics; using System.Text; using System.Threading.Tasks; namespace AtCorder { public class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); long[] a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); long[] sums = new long[n]; sums[0] = a[0]; for (int i = 1; i < n; i++) { sums[i] += a[i] + sums[i - 1]; } long sum = sums[n - 1]; long ans = long.MaxValue; for (int i = 0; i < n - 1; i++) { long dif = Math.Abs(sum - sums[i] - sums[i]); ans = Math.Min(ans, dif); } Console.WriteLine(ans); } } }
[["+", 0, 1, 0, 11, 12, 16, 31, 204, 205, 22], ["+", 0, 11, 12, 16, 31, 204, 206, 207, 0, 70], ["+", 12, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 11, 12, 16, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 72]]
8
227
5
using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { var N = sc.ReadInt(); var A = sc.ReadLongArray(N); var sum = new long[N]; sum[0] = A[0]; for (int i = 1; i < N; i++) { sum[i] = sum[0] + A[i]; } var ans = long.MaxValue; for (int i = 0; i < N - 1; i++) { var a = sum[i]; var b = sum[N - 1] - sum[i]; ans = Math.Min(ans, Math.Abs(a - b)); } Console.WriteLine(ans); } static Scanner sc = new Scanner(); } class Scanner { string[] S = new string[0]; int Index = 0; char[] Separators = new char[] { ' ' }; public string Next() { if (this.Index < this.S.Length) return this.S[this.Index++]; var line = ""; while (line == "") line = Console.ReadLine(); this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries); if (this.S.Length == 0) return this.Next(); this.Index = 0; return this.S[this.Index++]; } public string ReadStr() { return this.Next(); } public char ReadChar() { return this.Next()[0]; } public int ReadInt() { return int.Parse(this.Next()); } public uint ReadUInt() { return uint.Parse(this.Next()); } public long ReadLong() { return long.Parse(this.Next()); } public double ReadDouble() { return double.Parse(this.Next()); } public Tuple<int, int> ReadTup(int add = 0) { return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add); } public Tuple<long, long> ReadTupLong(int add = 0) { return Tuple.Create(this.ReadLong() + add, this.ReadLong() + add); } public Tuple<int, int, int> ReadTup3(int add = 0) { return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add, this.ReadInt() + add); } public Tuple<int, int, int, int> ReadTup4(int add = 0) { return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add, this.ReadInt() + add, this.ReadInt() + add); } public int[] ReadIntArray(int n) { var array = new int[n]; for (int i = 0; i < array.Length; i++) { array[i] = this.ReadInt(); } return array; } public long[] ReadLongArray(int n) { var array = new long[n]; for (int i = 0; i < array.Length; i++) { array[i] = this.ReadLong(); } return array; } public double[] ReadDoubleArray(int n) { var array = new double[n]; for (int i = 0; i < array.Length; i++) { array[i] = this.ReadDouble(); } return array; } public char[] ReadCharArray(int n) { var array = new char[n]; for (int i = 0; i < array.Length; i++) { array[i] = this.ReadChar(); } return array; } public string[] ReadStrArray(int n) { var array = new string[n]; for (int i = 0; i < array.Length; i++) { array[i] = this.ReadStr(); } return array; } public Tuple<long, long>[] ReadTupLongArray(int n, int add = 0) { var array = new Tuple<long, long>[n]; for (int i = 0; i < n; i++) { array[i] = this.ReadTupLong(add); } return array; } public Tuple<int, int>[] ReadTupArray(int n, int add = 0) { var array = new Tuple<int, int>[n]; for (int i = 0; i < n; i++) { array[i] = this.ReadTup(add); } return array; } public Tuple<int, int, int>[] ReadTup3Array(int n, int add = 0) { var array = new Tuple<int, int, int>[n]; for (int i = 0; i < n; i++) { array[i] = this.ReadTup3(add); } return array; } public Tuple<int, int, int, int>[] ReadTup4Array(int n, int add = 0) { var array = new Tuple<int, int, int, int>[n]; for (int i = 0; i < n; i++) { array[i] = this.ReadTup4(add); } return array; } }
using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { var N = sc.ReadInt(); var A = sc.ReadLongArray(N); var sum = new long[N]; sum[0] = A[0]; for (int i = 1; i < N; i++) { sum[i] = sum[i - 1] + A[i]; } var ans = long.MaxValue; for (int i = 0; i < N - 1; i++) { var a = sum[i]; var b = sum[N - 1] - sum[i]; ans = Math.Min(ans, Math.Abs(a - b)); } Console.WriteLine(ans); } static Scanner sc = new Scanner(); } class Scanner { string[] S = new string[0]; int Index = 0; char[] Separators = new char[] { ' ' }; public string Next() { if (this.Index < this.S.Length) return this.S[this.Index++]; var line = ""; while (line == "") line = Console.ReadLine(); this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries); if (this.S.Length == 0) return this.Next(); this.Index = 0; return this.S[this.Index++]; } public string ReadStr() { return this.Next(); } public char ReadChar() { return this.Next()[0]; } public int ReadInt() { return int.Parse(this.Next()); } public uint ReadUInt() { return uint.Parse(this.Next()); } public long ReadLong() { return long.Parse(this.Next()); } public double ReadDouble() { return double.Parse(this.Next()); } public Tuple<int, int> ReadTup(int add = 0) { return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add); } public Tuple<long, long> ReadTupLong(int add = 0) { return Tuple.Create(this.ReadLong() + add, this.ReadLong() + add); } public Tuple<int, int, int> ReadTup3(int add = 0) { return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add, this.ReadInt() + add); } public Tuple<int, int, int, int> ReadTup4(int add = 0) { return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add, this.ReadInt() + add, this.ReadInt() + add); } public int[] ReadIntArray(int n) { var array = new int[n]; for (int i = 0; i < array.Length; i++) { array[i] = this.ReadInt(); } return array; } public long[] ReadLongArray(int n) { var array = new long[n]; for (int i = 0; i < array.Length; i++) { array[i] = this.ReadLong(); } return array; } public double[] ReadDoubleArray(int n) { var array = new double[n]; for (int i = 0; i < array.Length; i++) { array[i] = this.ReadDouble(); } return array; } public char[] ReadCharArray(int n) { var array = new char[n]; for (int i = 0; i < array.Length; i++) { array[i] = this.ReadChar(); } return array; } public string[] ReadStrArray(int n) { var array = new string[n]; for (int i = 0; i < array.Length; i++) { array[i] = this.ReadStr(); } return array; } public Tuple<long, long>[] ReadTupLongArray(int n, int add = 0) { var array = new Tuple<long, long>[n]; for (int i = 0; i < n; i++) { array[i] = this.ReadTupLong(add); } return array; } public Tuple<int, int>[] ReadTupArray(int n, int add = 0) { var array = new Tuple<int, int>[n]; for (int i = 0; i < n; i++) { array[i] = this.ReadTup(add); } return array; } public Tuple<int, int, int>[] ReadTup3Array(int n, int add = 0) { var array = new Tuple<int, int, int>[n]; for (int i = 0; i < n; i++) { array[i] = this.ReadTup3(add); } return array; } public Tuple<int, int, int, int>[] ReadTup4Array(int n, int add = 0) { var array = new Tuple<int, int, int, int>[n]; for (int i = 0; i < n; i++) { array[i] = this.ReadTup4(add); } return array; } }
[["-", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 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]]
8
1,143
4
using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using Library; using static Library.Input; namespace AtCoderTemplate { class ProgramC { static void Main() { int N = NextInt; var list = IntList; for (int i = 1; i < N; i++) { list[i] += list[i - 1]; } System.Console.WriteLine( list.Take(N - 1).Min(x => Math.Abs(list.Last() - 2 * x))); } } } namespace Library { class Input { static IEnumerator<string> enumerator = new string[] {}.AsEnumerable().GetEnumerator(); public static string Line => Console.ReadLine(); public static string[] StrArr => Line.Split(' '); public static int NextInt => int.Parse(NextWord()); public static long NextLong => long.Parse(NextWord()); public static List<int> IntList => StrArr.Select(int.Parse).ToList(); public static List<long> LongList => StrArr.Select(long.Parse).ToList(); public static IEnumerable<long[]> TakeLine(int N) { return Enumerable.Repeat(0, N).Select( _ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray()); } public static string NextWord() { while (!enumerator.MoveNext()) { enumerator = StrArr.AsEnumerable().GetEnumerator(); } return enumerator.Current; } } } namespace Library { class Modular { public const int mod = 1000000007; public readonly long value; public Modular(long value) { this.value = value; } public static implicit operator Modular(long a) { var m = a % mod; return new Modular((m < 0) ? m + mod : m); } public static Modular operator +(Modular a, Modular b) { return a.value + b.value; } public static Modular operator -(Modular a, Modular b) { return a.value - b.value; } public static Modular operator *(Modular a, Modular b) { return a.value * b.value; } public static Modular Pow(Modular a, int n) { switch (n) { case 0: return 1; case 1: return a; default: var p = Pow(a, n / 2); return p * p * Pow(a, n % 2); } } public static Modular operator /(Modular a, Modular b) { return a * Pow(b, mod - 2); } private static readonly List<int> facs = new List<int> { 1 }; private static Modular Fac(int n) { for (int i = facs.Count; i <= n; ++i) { facs.Add((int)(Math.BigMul(facs.Last(), i) % mod)); } return facs[n]; } public static Modular Ncr(int n, int r) { return (n < r) ? 0 : (n == r) ? 1 : Fac(n) / (Fac(r) * Fac(n - r)); } public static explicit operator int(Modular a) { return (int)a.value; } } } namespace Library { class MyMath { public static long Gcd(long a, long b) { return b == 0 ? a : Gcd(b, a % b); } public static long Sqrt(long n) { if (n < 0) return 0; long a = 0, tmp = 0, b = 0; for (int i = 62; i >= 0; i -= 2) { tmp = (b << 1) + 1 <= (n >> i) ? 1 : 0; a = a << 1 | tmp; n -= (((b << 1) + 1) * tmp) << i; b = (b << 1) + tmp + tmp; } return a; } public static long Nck(int n, int k) { if (k == 0) return 1; if (n == 0) return 0; return n * Nck(n - 1, k - 1) / k; } } } namespace Library { public class PriorityQueue<T> { readonly List<T> _heap = new List<T>(); readonly Comparison<T> _comparison; public PriorityQueue(Comparison<T> comparison) { _comparison = comparison; } public PriorityQueue() : this(Comparer<T>.Default.Compare) {} public PriorityQueue(IComparer<T> comparer) : this(comparer.Compare) {} public void Enqueue(T item) { _heap.Add(item); int childID = _heap.Count - 1; int parentID = (childID - 1) / 2; while (childID > 0 && _comparison(_heap[parentID], _heap[childID]) > 0) { Swap(parentID, childID); childID = parentID; parentID = (parentID - 1) / 2; } } public T Dequeue() { var first = _heap.First(); _heap[0] = _heap.Last(); _heap.RemoveAt(_heap.Count - 1); int parentID = 0; int childID = parentID * 2 + 2; if (childID >= _heap.Count || _comparison(_heap[childID], _heap[childID - 1]) > 0) childID--; while (childID < _heap.Count && _comparison(_heap[parentID], _heap[childID]) > 0) { Swap(parentID, childID); parentID = childID; childID = parentID * 2 + 2; if (childID >= _heap.Count || _comparison(_heap[childID], _heap[childID - 1]) > 0) childID--; } return first; } void Swap(int parent, int child) { var tmp = _heap[parent]; _heap[parent] = _heap[child]; _heap[child] = tmp; } public T Peek() { return _heap[0]; } public int Count => _heap.Count; public bool Any() { return _heap.Any(); } public List<T> Data => _heap; } } namespace Library { public class UnionFind { public int[] Parents { get; set; } public UnionFind(int size) { Parents = Enumerable.Repeat(-1, size).ToArray(); } public int Find(int num) { if (Parents[num] < 0) return num; Parents[num] = Find(Parents[num]); return Parents[num]; } public int Size(int num) { return -Parents[Find(num)]; } public bool Same(int a, int b) { return Find(a) == Find(b); } public void Unite(int a, int b) { int x = Find(a), y = Find(b); if (Size(x) > Size(y)) { Parents[x] += Parents[y]; Parents[y] = x; } else { Parents[y] += Parents[x]; Parents[x] = y; } } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using Library; using static Library.Input; namespace AtCoderTemplate { class ProgramC { static void Main() { int N = NextInt; var list = LongList; for (int i = 1; i < N; i++) { list[i] += list[i - 1]; } System.Console.WriteLine( list.Take(N - 1).Min(x => Math.Abs(list.Last() - 2 * x))); } } } namespace Library { class Input { static IEnumerator<string> enumerator = new string[] {}.AsEnumerable().GetEnumerator(); public static string Line => Console.ReadLine(); public static string[] StrArr => Line.Split(' '); public static int NextInt => int.Parse(NextWord()); public static long NextLong => long.Parse(NextWord()); public static List<int> IntList => StrArr.Select(int.Parse).ToList(); public static List<long> LongList => StrArr.Select(long.Parse).ToList(); public static IEnumerable<long[]> TakeLine(int N) { return Enumerable.Repeat(0, N).Select( _ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray()); } public static string NextWord() { while (!enumerator.MoveNext()) { enumerator = StrArr.AsEnumerable().GetEnumerator(); } return enumerator.Current; } } } namespace Library { class Modular { public const int mod = 1000000007; public readonly long value; public Modular(long value) { this.value = value; } public static implicit operator Modular(long a) { var m = a % mod; return new Modular((m < 0) ? m + mod : m); } public static Modular operator +(Modular a, Modular b) { return a.value + b.value; } public static Modular operator -(Modular a, Modular b) { return a.value - b.value; } public static Modular operator *(Modular a, Modular b) { return a.value * b.value; } public static Modular Pow(Modular a, int n) { switch (n) { case 0: return 1; case 1: return a; default: var p = Pow(a, n / 2); return p * p * Pow(a, n % 2); } } public static Modular operator /(Modular a, Modular b) { return a * Pow(b, mod - 2); } private static readonly List<int> facs = new List<int> { 1 }; private static Modular Fac(int n) { for (int i = facs.Count; i <= n; ++i) { facs.Add((int)(Math.BigMul(facs.Last(), i) % mod)); } return facs[n]; } public static Modular Ncr(int n, int r) { return (n < r) ? 0 : (n == r) ? 1 : Fac(n) / (Fac(r) * Fac(n - r)); } public static explicit operator int(Modular a) { return (int)a.value; } } } namespace Library { class MyMath { public static long Gcd(long a, long b) { return b == 0 ? a : Gcd(b, a % b); } public static long Sqrt(long n) { if (n < 0) return 0; long a = 0, tmp = 0, b = 0; for (int i = 62; i >= 0; i -= 2) { tmp = (b << 1) + 1 <= (n >> i) ? 1 : 0; a = a << 1 | tmp; n -= (((b << 1) + 1) * tmp) << i; b = (b << 1) + tmp + tmp; } return a; } public static long Nck(int n, int k) { if (k == 0) return 1; if (n == 0) return 0; return n * Nck(n - 1, k - 1) / k; } } } namespace Library { public class PriorityQueue<T> { readonly List<T> _heap = new List<T>(); readonly Comparison<T> _comparison; public PriorityQueue(Comparison<T> comparison) { _comparison = comparison; } public PriorityQueue() : this(Comparer<T>.Default.Compare) {} public PriorityQueue(IComparer<T> comparer) : this(comparer.Compare) {} public void Enqueue(T item) { _heap.Add(item); int childID = _heap.Count - 1; int parentID = (childID - 1) / 2; while (childID > 0 && _comparison(_heap[parentID], _heap[childID]) > 0) { Swap(parentID, childID); childID = parentID; parentID = (parentID - 1) / 2; } } public T Dequeue() { var first = _heap.First(); _heap[0] = _heap.Last(); _heap.RemoveAt(_heap.Count - 1); int parentID = 0; int childID = parentID * 2 + 2; if (childID >= _heap.Count || _comparison(_heap[childID], _heap[childID - 1]) > 0) childID--; while (childID < _heap.Count && _comparison(_heap[parentID], _heap[childID]) > 0) { Swap(parentID, childID); parentID = childID; childID = parentID * 2 + 2; if (childID >= _heap.Count || _comparison(_heap[childID], _heap[childID - 1]) > 0) childID--; } return first; } void Swap(int parent, int child) { var tmp = _heap[parent]; _heap[parent] = _heap[child]; _heap[child] = tmp; } public T Peek() { return _heap[0]; } public int Count => _heap.Count; public bool Any() { return _heap.Any(); } public List<T> Data => _heap; } } namespace Library { public class UnionFind { public int[] Parents { get; set; } public UnionFind(int size) { Parents = Enumerable.Repeat(-1, size).ToArray(); } public int Find(int num) { if (Parents[num] < 0) return num; Parents[num] = Find(Parents[num]); return Parents[num]; } public int Size(int num) { return -Parents[Find(num)]; } public bool Same(int a, int b) { return Find(a) == Find(b); } public void Unite(int a, int b) { int x = Find(a), y = Find(b); if (Size(x) > Size(y)) { Parents[x] += Parents[y]; Parents[y] = x; } else { Parents[y] += Parents[x]; Parents[x] = y; } } } }
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22]]
8
1,503
2
using System; using System.Collections.Generic; namespace MyProgram { class AtCoder { static void Main() { int N = int.Parse(Console.ReadLine()); long[] a = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse); long sum = 0; var sum_a = new List<long>(); for (var i = 0; i < N; i++) { sum += a[i]; sum_a.Add(sum); } long x_min_y = 100000000000000000; for (var i = 0; i < N; i++) { long min = sum - 2 * sum_a[i]; x_min_y = Math.Min(x_min_y, Math.Abs(min)); } Console.WriteLine(x_min_y); } } }
using System; using System.Collections.Generic; namespace MyProgram { class AtCoder { static void Main() { int N = int.Parse(Console.ReadLine()); long[] a = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse); long sum = 0; var sum_a = new List<long>(); for (var i = 0; i < N; i++) { sum += a[i]; sum_a.Add(sum); } long x_min_y = 100000000000000000; for (var i = 0; i < N - 1; i++) { long min = sum - 2 * sum_a[i]; x_min_y = Math.Min(x_min_y, Math.Abs(min)); } Console.WriteLine(x_min_y); } } }
[["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203]]
8
168
2
using System; using System.Collections.Generic; using System.Linq; using Console = System.Console; namespace Atcoder { class Program { static void Main(string[] args) { var N = int.Parse(Console.ReadLine()); var r = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); var sum = r.Sum(); int left = 0; int ret = int.MaxValue; for (int i = 0; i < N - 1; i++) { left += r[i]; var right = sum - left; if (Math.Abs(left - right) < ret) { ret = Math.Abs(left - right); } } Console.WriteLine(ret); } } }
using System; using System.Collections.Generic; using System.Linq; using Console = System.Console; namespace Atcoder { class Program { static void Main(string[] args) { var N = long.Parse(Console.ReadLine()); var r = Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); var sum = r.Sum(); long left = 0; long ret = long.MaxValue; for (long i = 0; i < N - 1; i++) { left += r[i]; var right = sum - left; if (Math.Abs(left - right) < ret) { ret = Math.Abs(left - right); } } Console.WriteLine(ret); } } }
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["-", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 198, 0, 200, 0, 212, 0, 214, 205, 199], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 205, 199], ["-", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199]]
8
168
12
using System.Collections.Generic; using System.Linq; using System; using static System.Console; class Program { static void Main() => new Program().solve(); void solve() { var n = int.Parse(ReadLine()); var seq = ReadLine().Split(' ').Select(long.Parse).ToArray(); var table = new long[n + 1]; for (int i = 0; i < n; i++) { table[i + 1] = table[i] + seq[i]; } var min = long.MaxValue; for (int i = 1; i < n; i++) { min = Math.Min(min, Math.Abs((table[i] << 2) - table[n])); } var ans = min; WriteLine(ans); } }
using System.Collections.Generic; using System.Linq; using System; using static System.Console; class Program { static void Main() => new Program().solve(); void solve() { var n = int.Parse(ReadLine()); var seq = ReadLine().Split(' ').Select(long.Parse).ToArray(); var table = new long[n + 1]; for (int i = 0; i < n; i++) { table[i + 1] = table[i] + seq[i]; } var min = long.MaxValue; for (int i = 1; i < n; i++) { min = Math.Min(min, Math.Abs((table[i] << 1) - table[n])); } var ans = min; WriteLine(ans); } }
[["-", 0, 28, 0, 16, 31, 23, 0, 16, 12, 203], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 12, 203]]
8
188
2
using System; using System.Text; using System.Linq; using System.Collections; using System.Collections.Generic; using static System.Console; using static System.Math; namespace AtCorder { class Program { static void Main(string[] args) { new Program().Solve(new ConsoleInput(Console.In, ' ')); } public void Solve(ConsoleInput cin) { var N = cin.ReadInt; var a = cin.ReadIntArray(N); var sum = a.Sum(); var ans = long.MaxValue; var x = 0; for (int i = 1; i <= N - 1; i++) { x += a[i - 1]; var abs = Abs(2 * x - sum); if (abs < ans) ans = abs; if (ans == 0) break; } WriteLine(ans); } /*public long C(long n, long r) { if (r == 0 || r == n) return 1L; if (n < r) return 0L; long[,] Pascal = new long[n + 1, n + 1]; Pascal[0, 0] = 1; for (long i = 1; i <= n; i++) { Pascal[i, 0] = 1; Pascal[i, i] = 1; for (long j = 1; j < n; j++) { Pascal[i, j] = Pascal[i - 1, j] + Pascal[i - 1, j - 1]; } } return Pascal[n, r]; }*/ 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 AtCorder { class Program { static void Main(string[] args) { new Program().Solve(new ConsoleInput(Console.In, ' ')); } public void Solve(ConsoleInput cin) { var N = cin.ReadInt; var a = cin.ReadLongArray(N); var sum = a.Sum(); var ans = long.MaxValue; var x = 0L; for (int i = 1; i <= N - 1; i++) { x += a[i - 1]; var abs = Abs(2 * x - sum); if (abs < ans) ans = abs; if (ans == 0) break; } WriteLine(ans); } /*public long C(long n, long r) { if (r == 0 || r == n) return 1L; if (n < r) return 0L; long[,] Pascal = new long[n + 1, n + 1]; Pascal[0, 0] = 1; for (long i = 1; i <= n; i++) { Pascal[i, 0] = 1; Pascal[i, i] = 1; for (long j = 1; j < n; j++) { Pascal[i, j] = Pascal[i - 1, j] + Pascal[i - 1, j - 1]; } } return Pascal[n, r]; }*/ 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, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203]]
8
523
4
using System; using System.Collections.Generic; using System.Text; using System.Numerics; using System.IO; namespace SolutionCS { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); string[] s = Console.ReadLine().Split(' '); // int[] v = new int[N]; int[] a = new int[N]; int total = 0; for (int i = 0; i < N; i++) { // v[i] = int.Parse(s[i]); total += int.Parse(s[i]); a[i] = total; } if (N == 2) { Console.WriteLine(Math.Abs(total - a[0] - a[0])); return; } int ans = int.MaxValue; for (int i = 0; i < N - 1; i++) { ans = Math.Min(ans, Math.Abs(total - a[i] - a[i])); } Console.WriteLine(ans); } } }
using System; using System.Collections.Generic; using System.Text; using System.Numerics; using System.IO; namespace SolutionCS { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); string[] s = Console.ReadLine().Split(' '); long[] a = new long[N]; long total = 0; for (int i = 0; i < N; i++) { total += long.Parse(s[i]); a[i] = total; } if (N == 2) { Console.WriteLine(Math.Abs(total - a[0] - a[0])); return; } long ans = long.MaxValue; for (int i = 0; i < N - 1; i++) { ans = Math.Min(ans, Math.Abs(total - a[i] - a[i])); } Console.WriteLine(ans); } } }
[["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["+", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 1, 0, 11, 12, 213, 63, 214, 205, 199], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 205, 199], ["-", 0, 198, 0, 200, 0, 212, 0, 214, 205, 199], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 205, 199]]
8
219
12
using System; using System.Collections.Generic; using System.Linq; namespace ABC067_C { class Program { static void Main(string[] args) { var n = int.Parse(Console.ReadLine()); var num = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse).ToList(); var sum = num.Sum(); var L = new int[n - 1]; L[0] = num[0]; for (var i = 1; i < n - 1; i++) { L[i] += L[i - 1] + num[i]; } var min = int.MaxValue; for (var i = 0; i < n - 1; i++) { var c = Math.Abs(sum - 2 * L[i]); min = Math.Min(c, min); } Console.WriteLine(min); } } }
using System; using System.Collections.Generic; using System.Linq; namespace ABC067_C { class Program { static void Main(string[] args) { var n = int.Parse(Console.ReadLine()); var num = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse).ToList(); var sum = num.Sum(); var L = new long[n - 1]; L[0] = num[0]; for (var i = 1; i < n - 1; i++) { L[i] += L[i - 1] + num[i]; } long min = int.MaxValue; for (var i = 0; i < n - 1; i++) { long c = Math.Abs(sum - 2 * L[i]); min = Math.Min(c, min); } Console.WriteLine(min); } } }
[["-", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["-", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["+", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199]]
8
202
8
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Program { void Run() { var sc = new Scanner(); int n = sc.NextInt(); long[] a = new long[n]; a[0] = sc.NextInt(); for (int i = 1; i < n; i++) a[i] = a[i - 1] + sc.NextInt(); long min = 1 << 37; for (int i = 0; i < n - 1; i++) { long d = Math.Abs(a[a.Length - 1] - 2 * a[i]); if (d < min) min = d; } Console.WriteLine(min); } static void Main(string[] args) { new Program().Run(); } static long Gcd(long a, long b) { if (a < b) return Gcd(b, a); if (b == 0) return a; return Gcd(b, a % b); } } 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 double NextDouble() { CheckNext(); return double.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 { void Run() { var sc = new Scanner(); int n = sc.NextInt(); long[] a = new long[n]; a[0] = sc.NextInt(); for (int i = 1; i < n; i++) a[i] = a[i - 1] + sc.NextInt(); long min = 1L << 37; for (int i = 0; i < n - 1; i++) { long d = Math.Abs(a[a.Length - 1] - 2 * a[i]); if (d < min) min = d; } Console.WriteLine(min); } static void Main(string[] args) { new Program().Run(); } static long Gcd(long a, long b) { if (a < b) return Gcd(b, a); if (b == 0) return a; return Gcd(b, a % b); } } 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 double NextDouble() { CheckNext(); return double.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; } }
[["-", 0, 198, 0, 200, 0, 212, 0, 16, 31, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 31, 203]]
8
387
2
using System; class Program { static void Main(string[] args) { var n = int.Parse(Console.ReadLine()); var s = Console.ReadLine().Split(' '); var d = new int[n]; for (int i = 0; i < n; i++) { d[i] = int.Parse(s[i]); } var left = new int[n - 1]; left[0] = d[0]; for (int i = 1; i < n - 1; i++) { left[i] = left[i - 1] + d[i]; } var right = new int[n - 1]; right[n - 2] = d[n - 1]; for (int i = n - 3; i >= 0; i--) { right[i] = right[i + 1] + d[i + 1]; } var ans = int.MaxValue; for (int i = 0; i < n - 1; i++) { ans = Math.Min(ans, Math.Abs(left[i] - right[i])); } Console.WriteLine(ans); } }
using System; class Program { static void Main(string[] args) { var n = int.Parse(Console.ReadLine()); var s = Console.ReadLine().Split(' '); var d = new long[n]; for (int i = 0; i < n; i++) { d[i] = long.Parse(s[i]); } var left = new long[n - 1]; left[0] = d[0]; for (int i = 1; i < n - 1; i++) { left[i] = left[i - 1] + d[i]; } var right = new long[n - 1]; right[n - 2] = d[n - 1]; for (int i = n - 3; i >= 0; i--) { right[i] = right[i + 1] + d[i + 1]; } var ans = long.MaxValue; for (int i = 0; i < n - 1; i++) { ans = Math.Min(ans, Math.Abs(left[i] - right[i])); } Console.WriteLine(ans); } }
[["-", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["+", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["-", 0, 1, 0, 11, 12, 213, 63, 214, 205, 199], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 205, 199], ["-", 0, 198, 0, 200, 0, 212, 0, 214, 205, 199], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 205, 199]]
8
262
10
using System; using System.Collections.Generic; using System.Linq; using static System.Console; using static System.Convert; using static System.Math; class Program { static void Main(string[] args) { var num = ToInt32(ReadLine()); var ar = Array.ConvertAll(ReadLine().Split(' '), int.Parse); var sum = ar.Sum() - ar[0]; var dif = ar[0]; var min = Abs(sum - dif); for (var i = 1; i < num; i++) { min = Min(min, Abs(sum - dif)); dif += ar[i]; sum -= ar[i]; } WriteLine(min); } private const string ALFA = "abcdefghijklmnopqrstuvwxyz"; private 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; class Program { static void Main(string[] args) { var num = ToInt32(ReadLine()); var ar = Array.ConvertAll(ReadLine().Split(' '), long.Parse); var sum = ar.Sum() - ar[0]; var dif = ar[0]; var min = Abs(sum - dif); for (var i = 1; i < num; i++) { min = Min(min, Abs(sum - dif)); dif += ar[i]; sum -= ar[i]; } WriteLine(min); } private const string ALFA = "abcdefghijklmnopqrstuvwxyz"; private const int MOD = 1000000007; }
[["-", 0, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 0, 213, 3, 4, 0, 28, 0, 214, 205, 199]]
8
178
2
using System; using System.Collections.Generic; using System.Linq; using static Atcoder; using System.Threading.Tasks; using System.ComponentModel; public class Hello { private const int INF = 1000000007; public static void Main() { int N = IntRead(); var ai = SpRead(' ').Select(int.Parse).ToList(); long Sums = ai.Sum(); long Sunuke = ai[0]; long Arai = Sums - Sunuke; long ans = Math.Abs(Sunuke - Arai); for (int i = 1; i < N - 1; i++) { Sunuke += ai[i]; ans = Math.Min(ans, Math.Abs(2 * Sunuke - Sums)); } Console.WriteLine(ans); } } public class Factorization { private static long N; public Factorization(long n) { N = n; } //ๆœ€ๅคงๅ…ฌ็ด„ๆ•ฐใ‚’่ฟ”ใ™ public static long GCD(long a, long b) { if (a < b) return GCD(b, a); long r; while (b != 0) { r = a % b; a = b; b = r; } return a; } //็ด ๆ•ฐๅˆคๅฎš public static bool IsPrime(long n) { if (n < 2) return false; if (n == 2) return true; if (n % 2 == 0) return false; double root = Math.Sqrt(n); for (int i = 3; i <= root; i += 2) { if (n % i == 0) return false; } return true; } //่ฉฆใ—ๅ‰ฒใ‚Š private static int[] TryPrimes = new int[] { 2, 3, 5, 7, 11 }; public long TryAllocation(long p) { long count = 0; while (N % p == 0) { count++; N /= p; } return count; } private int[] xi = new int[] { 13, 17, 19, 23, 29 }; private long f(long x, int suffix) { return (xi[suffix % xi.Count()] * x + suffix) % N; } // nใ‚’ๅˆ†่งฃ public long PollardsRho(long n, int suffix = 0) { //็ด ๆ•ฐใ‚’ๆธกใ™ใจๅคฑๆ•—ใ™ใ‚‹ใ‚‰ใ—ใ„ if (IsPrime(n)) return n; //ใ‚‚ใ†็ด ๆ•ฐ long x = 2, y = 2, d = 1; while (d == 1) { x = f(x, suffix); y = f(f(y, suffix), suffix); d = GCD(Math.Abs(x - y), n); } if (d == n) { // f(x)ใ‚’ๅค‰ใˆใฆ่ฉฆใ™ return PollardsRho(n, suffix + 1); } return d; } public IEnumerable<long> Calc() { //ๅฐใ•ใช็ด ๅ› ๆ•ฐใฎ่จˆ็ฎ— foreach (var prime in TryPrimes) { var box = TryAllocation(prime); for (int i = 0; i < box; i++) yield return prime; } //ๆฎ‹ใ‚Šใ‚’Rhoใง่งฃใ while (true) { if (N == 1) break; var ret = PollardsRho(N); yield return ret; N /= ret; } } } public class Atcoder { static void Swap<T>(ref T a, ref T b) { var t = a; a = b; b = t; } public static int LCM(int a, int b) { int c = a * b; if (a < b) Swap(ref a, ref b); int d = a % b; while (d != 0) { a = b; b = d; d = a % b; } return c / b; } public static string StrReverce(string s) { return new string(s.Reverse().ToArray()); } public static int IntRead() { return int.Parse(Console.ReadLine()); } public static bool IsPrime(int n) { if (n < 2) return false; if (n == 2) return true; if (n % 2 == 0) return false; // double sqrtNum = Math.Sqrt(n); for (int i = 3; i < n; i += 2) { if (n % i == 0) return false; } return true; } public static string[] SpRead(char c) { return Console.ReadLine().Split(c); } public static long[] LSRead() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); } public static long Combination(int n, int r) { if (n == r) return 1; return Enumerable.Range((n - r), r) .ToList() .Aggregate((now, next) => now * next) / Enumerable.Range(1, r).ToList().Aggregate((now, next) => now * next); } public static long LongRead() { return long.Parse(Console.ReadLine()); } }
using System; using System.Collections.Generic; using System.Linq; using static Atcoder; using System.Threading.Tasks; using System.ComponentModel; public class Hello { private const int INF = 1000000007; public static void Main() { int N = IntRead(); // int N = 2 * (int)Math.Pow(10, 5); var ai = SpRead(' ').Select(long.Parse).ToList(); // List<long> ai = new List<long>(); // string b = "1000000000"; // for (int i = 0; i < N; i++) ai.Add(long.Parse(b)); long Sums = ai.Sum(); long Sunuke = ai[0]; long Arai = Sums - Sunuke; long ans = Math.Abs(Sunuke - Arai); for (int i = 1; i < N - 1; i++) { Sunuke += ai[i]; ans = Math.Min(ans, Math.Abs(2 * Sunuke - Sums)); } Console.WriteLine(ans); } } public class Factorization { private static long N; public Factorization(long n) { N = n; } //ๆœ€ๅคงๅ…ฌ็ด„ๆ•ฐใ‚’่ฟ”ใ™ public static long GCD(long a, long b) { if (a < b) return GCD(b, a); long r; while (b != 0) { r = a % b; a = b; b = r; } return a; } //็ด ๆ•ฐๅˆคๅฎš public static bool IsPrime(long n) { if (n < 2) return false; if (n == 2) return true; if (n % 2 == 0) return false; double root = Math.Sqrt(n); for (int i = 3; i <= root; i += 2) { if (n % i == 0) return false; } return true; } //่ฉฆใ—ๅ‰ฒใ‚Š private static int[] TryPrimes = new int[] { 2, 3, 5, 7, 11 }; public long TryAllocation(long p) { long count = 0; while (N % p == 0) { count++; N /= p; } return count; } private int[] xi = new int[] { 13, 17, 19, 23, 29 }; private long f(long x, int suffix) { return (xi[suffix % xi.Count()] * x + suffix) % N; } // nใ‚’ๅˆ†่งฃ public long PollardsRho(long n, int suffix = 0) { //็ด ๆ•ฐใ‚’ๆธกใ™ใจๅคฑๆ•—ใ™ใ‚‹ใ‚‰ใ—ใ„ if (IsPrime(n)) return n; //ใ‚‚ใ†็ด ๆ•ฐ long x = 2, y = 2, d = 1; while (d == 1) { x = f(x, suffix); y = f(f(y, suffix), suffix); d = GCD(Math.Abs(x - y), n); } if (d == n) { // f(x)ใ‚’ๅค‰ใˆใฆ่ฉฆใ™ return PollardsRho(n, suffix + 1); } return d; } public IEnumerable<long> Calc() { //ๅฐใ•ใช็ด ๅ› ๆ•ฐใฎ่จˆ็ฎ— foreach (var prime in TryPrimes) { var box = TryAllocation(prime); for (int i = 0; i < box; i++) yield return prime; } //ๆฎ‹ใ‚Šใ‚’Rhoใง่งฃใ while (true) { if (N == 1) break; var ret = PollardsRho(N); yield return ret; N /= ret; } } } public class Atcoder { static void Swap<T>(ref T a, ref T b) { var t = a; a = b; b = t; } public static int LCM(int a, int b) { int c = a * b; if (a < b) Swap(ref a, ref b); int d = a % b; while (d != 0) { a = b; b = d; d = a % b; } return c / b; } public static string StrReverce(string s) { return new string(s.Reverse().ToArray()); } public static int IntRead() { return int.Parse(Console.ReadLine()); } public static bool IsPrime(int n) { if (n < 2) return false; if (n == 2) return true; if (n % 2 == 0) return false; // double sqrtNum = Math.Sqrt(n); for (int i = 3; i < n; i += 2) { if (n % i == 0) return false; } return true; } public static string[] SpRead(char c) { return Console.ReadLine().Split(c); } public static long[] LSRead() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); } public static long Combination(int n, int r) { if (n == r) return 1; return Enumerable.Range((n - r), r) .ToList() .Aggregate((now, next) => now * next) / Enumerable.Range(1, r).ToList().Aggregate((now, next) => now * next); } public static long LongRead() { return long.Parse(Console.ReadLine()); } }
[["-", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199]]
8
1,002
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Program { static void Main() { Scanner cin = new Scanner(); int N = cin.Int(); int[] a = cin.ArrayInt(N); int sum = 0; foreach (var x in a) { sum += x; } int ans = int.MaxValue, tmp = 0; for (int i = 0; i < N - 1; i++) { tmp += a[i]; int t = Math.Abs(tmp - (sum - tmp)); ans = Math.Min(ans, t); } Console.WriteLine(ans); Console.ReadLine(); } } 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 Int() { 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] = Int() + add; } return Array; } public long Long() { 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] = Long() + add; } return Array; } public double Double() { 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] = Double() + add; } return Array; } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Program { static void Main() { Scanner cin = new Scanner(); int N = cin.Int(); long[] a = cin.ArrayLong(N); long sum = 0; foreach (var x in a) { sum += x; } long ans = int.MaxValue, tmp = 0; for (int i = 0; i < N - 1; i++) { tmp += a[i]; long t = Math.Abs(tmp - (sum - tmp)); ans = Math.Min(ans, t); } Console.WriteLine(ans); Console.ReadLine(); } } 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 Int() { 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] = Int() + add; } return Array; } public long Long() { 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] = Long() + add; } return Array; } public double Double() { 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] = Double() + add; } return Array; } }
[["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199]]
8
512
10
using System; using System.Collections.Generic; using System.Linq; namespace test { class Program { static void Main(string[] args) { var N = ReadInt(); var A = ReadArrayInt(); long snu = A.Sum(); var arai = 0L; var ans = long.MaxValue; for (int i = 0; i < N - 1; i++) { snu -= A[i]; arai += A[i]; ans = Math.Min(ans, Math.Abs(snu - arai)); } Console.WriteLine(ans); Console.ReadLine(); } static string Read() { return Console.ReadLine(); } static int ReadInt() { return int.Parse(Read()); } static long ReadLong() { return long.Parse(Read()); } static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); } static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); } } }
using System; using System.Collections.Generic; using System.Linq; namespace test { class Program { static void Main(string[] args) { var N = ReadLong(); var A = ReadArrayLong(); long snu = A.Sum(); var arai = 0L; var ans = long.MaxValue; for (long i = 0; i < N - 1; i++) { snu -= A[i]; arai += A[i]; ans = Math.Min(ans, Math.Abs(snu - arai)); } Console.WriteLine(ans); Console.ReadLine(); } static string Read() { return Console.ReadLine(); } static int ReadInt() { return int.Parse(Read()); } static long ReadLong() { return long.Parse(Read()); } static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); } static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); } } }
[["-", 0, 198, 0, 200, 0, 212, 0, 213, 63, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 213, 63, 22], ["-", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199]]
8
254
6
using System; using System.Linq; namespace AtCoder { class Program { static void Main() { int n = int.Parse(Console.ReadLine()); var card = Console.ReadLine() .Split() .Select(int.Parse) .Select(x => x * 2) .ToArray(); long ave = card.Sum() / 2; var rSum = new long[n]; for (int i = 1; i < n; i++) rSum[i] = rSum[i - 1] + card[i - 1]; Console.WriteLine( rSum.Select(x => Math.Abs(x - ave)).Where((x, y) => y != 0).Min()); } } }
using System; using System.Linq; namespace AtCoder { class Program { static void Main() { int n = int.Parse(Console.ReadLine()); var card = Console.ReadLine() .Split() .Select(long.Parse) .Select(x => x * 2) .ToArray(); long ave = card.Sum() / 2; var rSum = new long[n]; for (int i = 1; i < n; i++) rSum[i] = rSum[i - 1] + card[i - 1]; Console.WriteLine( rSum.Select(x => Math.Abs(x - ave)).Where((x, y) => y != 0).Min()); } } }
[["-", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199]]
8
161
2
using System; using System.Linq; public class Problem_C { public static void Main() { var N = int.Parse(Console.ReadLine()); var deck = Array.ConvertAll(Console.ReadLine().Split(), int.Parse); decimal total = deck.Sum(); decimal snuke = 0; decimal minDiff = int.MaxValue; for (var i = 0; i < N - 1; i++) { snuke += deck[i]; minDiff = Math.Min(minDiff, Math.Abs(snuke - (total - snuke))); } Console.WriteLine($"{minDiff}"); } }
using System; using System.Linq; public class Problem_C { public static void Main() { var N = int.Parse(Console.ReadLine()); var deck = Array.ConvertAll(Console.ReadLine().Split(), long.Parse); long total = deck.Sum(); long snuke = 0; long minDiff = long.MaxValue; for (var i = 0; i < N - 1; i++) { snuke += deck[i]; minDiff = Math.Min(minDiff, Math.Abs(snuke - (total - snuke))); } Console.WriteLine($"{minDiff}"); } }
[["-", 0, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 0, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 198, 0, 200, 0, 212, 0, 214, 205, 199], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 205, 199]]
8
136
10
using System; using System.Linq; public class Problem_C { public static void Main() { var N = int.Parse(Console.ReadLine()); var deck = Array.ConvertAll(Console.ReadLine().Split(), int.Parse); decimal total = deck.Sum(); decimal snuke = 0; decimal minDiff = decimal.MaxValue; for (var i = 0; i < N - 1; i++) { snuke += deck[i]; decimal kuma = total - snuke; decimal diff = snuke - kuma; minDiff = Math.Min(minDiff, Math.Abs(diff)); } Console.WriteLine($"{minDiff}"); } }
using System; using System.Linq; public class Problem_C { public static void Main() { var N = int.Parse(Console.ReadLine()); var deck = Array.ConvertAll(Console.ReadLine().Split(), long.Parse); decimal total = deck.Sum(); decimal snuke = 0; decimal minDiff = decimal.MaxValue; for (var i = 0; i < N - 1; i++) { snuke += deck[i]; decimal kuma = total - snuke; decimal diff = snuke - kuma; minDiff = Math.Min(minDiff, Math.Abs(diff)); } Console.WriteLine($"{minDiff}"); } }
[["-", 0, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 0, 213, 3, 4, 0, 28, 0, 214, 205, 199]]
8
144
2
using System.Linq; using System; public class C { public const long INF = 999999999999999999; } public class Hello { public static void Main() { var n = int.Parse(Console.ReadLine().Trim()); string[] line = Console.ReadLine().Trim().Split(' '); var a = Array.ConvertAll(line, long.Parse); var asum = a.Sum(); var snk = 0L; var abstmin = -C.INF; for (int i = 0; i < n - 1; i++) { snk += a[i]; var abst = Math.Abs(asum - 2 * snk); abstmin = Math.Min(abstmin, abst); } Console.WriteLine(abstmin); } }
using System.Linq; using System; public class C { public const long INF = 999999999999999999; } public class Hello { public static void Main() { var n = int.Parse(Console.ReadLine().Trim()); string[] line = Console.ReadLine().Trim().Split(' '); var a = Array.ConvertAll(line, long.Parse); var asum = a.Sum(); var snk = 0L; var abstmin = C.INF; for (int i = 0; i < n - 1; i++) { snk += a[i]; var abst = Math.Abs(asum - 2 * snk); abstmin = Math.Min(abstmin, abst); } Console.WriteLine(abstmin); } }
[["-", 0, 198, 0, 200, 0, 212, 0, 241, 0, 33]]
8
166
1
using System; using System.Linq; using System.Collections.Generic; class P { static void Main() { Console.ReadLine(); int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray(); long asum = a.Sum(); long[] sum = new long[a.Length - 1]; sum[0] = a[0]; for (int i = 1; i < a.Length - 1; i++) { sum[i] = sum[i - 1] + a[i]; } long res = long.MaxValue; foreach (var i in sum) { res = Math.Min(res, Math.Abs(asum - i * 2)); } Console.WriteLine(res); } }
using System; using System.Linq; using System.Collections.Generic; class P { static void Main() { Console.ReadLine(); long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray(); long asum = a.Sum(); long[] sum = new long[a.Length - 1]; sum[0] = a[0]; for (int i = 1; i < sum.Length; i++) { sum[i] = sum[i - 1] + a[i]; } long res = long.MaxValue; foreach (var i in sum) { res = Math.Min(res, Math.Abs(asum - i * 2)); } Console.WriteLine(res); } }
[["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["-", 0, 7, 15, 16, 12, 16, 31, 214, 205, 22], ["+", 8, 196, 0, 7, 15, 16, 12, 214, 205, 22], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203]]
8
172
8
using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System; using System.Threading.Tasks; using static System.Math; using static System.Console; public class Program { public static void Main() { long N = long.Parse(Console.ReadLine()); long[] l = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray(); long ans = 9999999999; long a = 0; long b = l.Sum(); long abs = 0; for (int i = 0; i < N; ++i) { a += l[i]; b -= l[i]; abs = Math.Abs(a - b); if (abs < ans) { ans = abs; } if (ans == 0) { break; } } Console.WriteLine(ans); } }
using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System; using System.Threading.Tasks; using static System.Math; using static System.Console; public class Program { public static void Main() { long N = long.Parse(Console.ReadLine()); long[] l = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray(); long ans = 9999999999; long a = 0; long b = l.Sum(); long abs = 0; for (int i = 0; i < N - 1; ++i) { a += l[i]; b -= l[i]; abs = Math.Abs(a - b); if (abs < ans) { ans = abs; } if (ans == 0) { break; } } Console.WriteLine(ans); } }
[["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203]]
8
204
2
using System; using System.Linq; public class Test { public static void Main() { int n = int.Parse(Console.ReadLine()); int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray(); long ret = long.MaxValue; long flont = 0; long back = x.Sum(); for (int i = 0; i < n - 1; i++) { flont += x[i]; back -= x[i]; ret = Math.Min(ret, Math.Abs(flont - back)); } Console.WriteLine(ret); } }
using System; using System.Linq; public class Test { public static void Main() { int n = int.Parse(Console.ReadLine()); long[] x = Console.ReadLine().Split().Select(long.Parse).ToArray(); long ret = long.MaxValue; long flont = 0; long back = x.Sum(); for (int i = 0; i < n - 1; i++) { flont += x[i]; back -= x[i]; ret = Math.Min(ret, Math.Abs(flont - back)); } Console.WriteLine(ret); } }
[["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199]]
8
139
4
using System.Collections.Generic; using System.Linq; using System; class B { static void Main() { var N = int.Parse(Console.ReadLine()); var A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); int sum = 0; for (int i = 0; i < N; i++) { sum += A[i]; } int minVal = A[0]; int minIndex = 0; int sum2 = A[0]; for (int i = 1; i < N - 1; i++) { sum2 += A[i]; if (Math.Abs(minVal - sum / 2) > Math.Abs(sum2 - sum / 2)) { minVal = sum2; minIndex = i; } } Console.WriteLine(Math.Abs(minVal * 2 - sum)); } }
using System.Collections.Generic; using System.Linq; using System; class B { static void Main() { var N = int.Parse(Console.ReadLine()); var A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); long sum = 0; for (int i = 0; i < N; i++) { sum += A[i]; } long minVal = A[0]; int minIndex = 0; long sum2 = A[0]; for (int i = 1; i < N - 1; i++) { sum2 += A[i]; if (Math.Abs(minVal - sum / 2) > Math.Abs(sum2 - sum / 2)) { minVal = sum2; minIndex = i; } } Console.WriteLine(Math.Abs(minVal * 2 - sum)); } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
8
196
6
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace abc67 { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); string[] str = Console.ReadLine().Split(' '); int[] a = new int[N]; int arai = 0; int sunuke = 0; for (int i = 0; i < N; i++) { a[i] = int.Parse(str[i]); arai += a[i]; } arai -= a[0]; sunuke = a[0]; int ans = Math.Abs(arai - sunuke); for (int i = 1; i < N - 1; i++) { arai -= a[i]; sunuke += a[i]; ans = Math.Min(ans, Math.Abs(arai - sunuke)); } Console.WriteLine(ans); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace abc67 { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); string[] str = Console.ReadLine().Split(' '); int[] a = new int[N]; long arai = 0; long sunuke = 0; for (int i = 0; i < N; i++) { a[i] = int.Parse(str[i]); arai += a[i]; } arai -= a[0]; sunuke = a[0]; long ans = Math.Abs(arai - sunuke); for (int i = 1; i < N - 1; i++) { arai -= a[i]; sunuke += a[i]; ans = Math.Min(ans, Math.Abs(arai - sunuke)); } Console.WriteLine(ans); } } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
8
220
6
using System; using System.Linq; using System.IO; using System.Text; using System.Collections; using System.Collections.Generic; using System.Text.RegularExpressions; namespace AtCoder.ABC067 { class Program { static void Main() { int n = int.Parse(Console.ReadLine()); var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); long sum1 = a[0], sum2 = a.Sum() - a[0], diff = 0, minDiff = Math.Abs(sum2 - sum1); for (int i = 1; i < n - 1; i++) { sum1 += a[i]; sum2 -= a[i]; diff = Math.Abs(sum2 - sum1); if (minDiff > diff) minDiff = diff; } Console.WriteLine(minDiff); } } }
using System; using System.Linq; using System.IO; using System.Text; using System.Collections; using System.Collections.Generic; using System.Text.RegularExpressions; namespace AtCoder.ABC067 { class Program { static void Main() { int n = int.Parse(Console.ReadLine()); var a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); long sum1 = a[0], sum2 = a.Sum() - a[0], diff = 0, minDiff = Math.Abs(sum2 - sum1); for (int i = 1; i < n - 1; i++) { sum1 += a[i]; sum2 -= a[i]; diff = Math.Abs(sum2 - sum1); if (minDiff > diff) minDiff = diff; } Console.WriteLine(minDiff); } } }
[["-", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199]]
8
191
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Contest { class Program { static void Main() { int n = int.Parse(Console.ReadLine()); var a = Console.ReadLine().Split().Select(int.Parse).ToArray(); int sum = a.Sum(); int snuke = 0; int diff = int.MaxValue; for (int i = 0; i < n - 1; i++) { snuke += a[i]; diff = Math.Min(diff, Math.Abs(snuke - (sum - snuke))); } Console.WriteLine(diff); #if DEBUG Console.ReadKey(); #endif } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Contest { class Program { static void Main() { int n = int.Parse(Console.ReadLine()); var a = Console.ReadLine().Split().Select(long.Parse).ToArray(); long sum = a.Sum(); long snuke = 0; long diff = long.MaxValue; for (int i = 0; i < n - 1; i++) { snuke += a[i]; diff = Math.Min(diff, Math.Abs(snuke - (sum - snuke))); } Console.WriteLine(diff); #if DEBUG Console.ReadKey(); #endif } } }
[["-", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 198, 0, 200, 0, 212, 0, 214, 205, 199], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 205, 199]]
8
166
10
using System.Collections.Generic; using System.Linq; using System; class D { static int N; static List<int>[] e; static void Main() { N = int.Parse(Console.ReadLine()); e = new List<int>[N]; for (int i = 0; i < N; i++) e[i] = new List<int>(); for (long i = 0; i < N - 1; i++) { var XY = Console.ReadLine().Split(' ').Select(x => int.Parse(x) - 1); e[XY.ElementAt(0)].Add(XY.ElementAt(1)); e[XY.ElementAt(1)].Add(XY.ElementAt(0)); } var Black = DFS(0); var White = DFS(N - 1); var b = 0; for (int i = 0; i < N; i++) { if (Black[i] <= White[i]) b++; } Console.WriteLine(b > N - b ? "Fennec" : "Sunuke"); } static int[] DFS(int root) { var s = new Stack<int>(); var v = new bool[N]; var d = new int[N]; s.Push(root); v[root] = true; while (s.Count > 0) { var current = s.Pop(); foreach (var next in e[current]) { if (!v[next]) { s.Push(next); v[next] = true; d[next] = d[current] + 1; } } } return d; } }
using System.Collections.Generic; using System.Linq; using System; class D { static int N; static List<int>[] e; static void Main() { N = int.Parse(Console.ReadLine()); e = new List<int>[N]; for (int i = 0; i < N; i++) e[i] = new List<int>(); for (long i = 0; i < N - 1; i++) { var XY = Console.ReadLine().Split(' ').Select(x => int.Parse(x) - 1); e[XY.ElementAt(0)].Add(XY.ElementAt(1)); e[XY.ElementAt(1)].Add(XY.ElementAt(0)); } var Black = DFS(0); var White = DFS(N - 1); var b = 0; for (int i = 0; i < N; i++) { if (Black[i] <= White[i]) b++; } Console.WriteLine(b > N - b ? "Fennec" : "Snuke"); } static int[] DFS(int root) { var s = new Stack<int>(); var v = new bool[N]; var d = new int[N]; s.Push(root); v[root] = true; while (s.Count > 0) { var current = s.Pop(); foreach (var next in e[current]) { if (!v[next]) { s.Push(next); v[next] = true; d[next] = d[current] + 1; } } } return d; } }
[["-", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222]]
8
375
2
using System; using System.IO; using System.Linq; using System.Text; using System.Collections; using System.Collections.Generic; using System.Threading.Tasks; namespace ConsoleApplication1.CodeForces { class _4032 { private static int Next() { int c; int res = 0; do { c = reader.Read(); if (c == -1) return res; } while (c < '0' || c > '9'); res = c - '0'; while (true) { c = reader.Read(); if (c < '0' || c > '9') return res; res *= 10; res += c - '0'; } } private static readonly StreamReader reader = new StreamReader( Console.OpenStandardInput(1024 * 10), Encoding.ASCII, false, 1024 * 10); private static readonly StreamWriter writer = new StreamWriter( Console.OpenStandardOutput(1024 * 10), Encoding.ASCII, 1024 * 10); class Node { public int Current { get; set; } } public static string ReverseString(string s) { char[] arr = s.ToCharArray(); Array.Reverse(arr); return new string(arr); } static void Main(String[] args) { var n = int.Parse(Console.ReadLine().TrimEnd()); var edges = new List<int>[n]; for (var i = 0; i < n; i++) { edges[i] = new List<int>(); } for (var i = 0; i < n - 1; i++) { var data = Console.ReadLine() .TrimEnd() .Split(' ') .Select(a => int.Parse(a) - 1) .ToList(); edges[data[0]].Add(data[1]); edges[data[1]].Add(data[0]); } var que = new Queue<Node>(); que.Enqueue(new Node() { Current = 0 }); var visited = new bool[n]; visited[0] = true; var prev = new int[n]; prev[0] = 0; var path = new List<int>(); while (que.Count > 0) { var cur = que.Dequeue(); if (cur.Current == n - 1) { var prevInd = cur.Current; while (prev[prevInd] != 0) { path.Add(prev[prevInd]); prevInd = prev[prevInd]; } break; } for (var i = 0; i < edges[cur.Current].Count; i++) { var ind = edges[cur.Current][i]; if (!visited[ind]) { visited[ind] = true; prev[ind] = cur.Current; que.Enqueue(new Node() { Current = ind }); } } } visited = new bool[n]; var queu1 = new Queue<int>(); var queu2 = new Queue<int>(); queu1.Enqueue(0); queu2.Enqueue(n - 1); visited[0] = true; visited[n - 1] = true; if (path.Count > 0) { var l = path.Count - 1; var s = 0; while (s != l) { queu1.Enqueue(path[l]); queu2.Enqueue(path[s]); visited[path[l]] = true; visited[path[s]] = true; s++; l--; } if (path.Count % 2 == 1) { queu1.Enqueue(path[path.Count / 2]); visited[path[path.Count / 2]] = true; } } while (queu1.Count > 0 && queu2.Count > 0) { var cur1 = queu1.Dequeue(); for (var i = 0; i < edges[cur1].Count; i++) { var ind = edges[cur1][i]; if (!visited[ind]) { visited[ind] = true; queu1.Enqueue(ind); } } var cur2 = queu2.Dequeue(); for (var i = 0; i < edges[cur2].Count; i++) { var ind = edges[cur2][i]; if (!visited[ind]) { visited[ind] = true; queu2.Enqueue(ind); } } } if (queu1.Count == 0) { Console.WriteLine("Snuke"); } else { Console.WriteLine("Fennec"); } } } }
using System; using System.IO; using System.Linq; using System.Text; using System.Collections; using System.Collections.Generic; using System.Threading.Tasks; namespace ConsoleApplication1.CodeForces { class _4032 { private static int Next() { int c; int res = 0; do { c = reader.Read(); if (c == -1) return res; } while (c < '0' || c > '9'); res = c - '0'; while (true) { c = reader.Read(); if (c < '0' || c > '9') return res; res *= 10; res += c - '0'; } } private static readonly StreamReader reader = new StreamReader( Console.OpenStandardInput(1024 * 10), Encoding.ASCII, false, 1024 * 10); private static readonly StreamWriter writer = new StreamWriter( Console.OpenStandardOutput(1024 * 10), Encoding.ASCII, 1024 * 10); class Node { public int Current { get; set; } } public static string ReverseString(string s) { char[] arr = s.ToCharArray(); Array.Reverse(arr); return new string(arr); } static void Main(String[] args) { var n = int.Parse(Console.ReadLine().TrimEnd()); var edges = new List<int>[n]; for (var i = 0; i < n; i++) { edges[i] = new List<int>(); } for (var i = 0; i < n - 1; i++) { var data = Console.ReadLine() .TrimEnd() .Split(' ') .Select(a => int.Parse(a) - 1) .ToList(); edges[data[0]].Add(data[1]); edges[data[1]].Add(data[0]); } var que = new Queue<Node>(); que.Enqueue(new Node() { Current = 0 }); var visited = new bool[n]; visited[0] = true; var prev = new int[n]; prev[0] = 0; var path = new List<int>(); while (que.Count > 0) { var cur = que.Dequeue(); if (cur.Current == n - 1) { var prevInd = cur.Current; while (prev[prevInd] != 0) { path.Add(prev[prevInd]); prevInd = prev[prevInd]; } break; } for (var i = 0; i < edges[cur.Current].Count; i++) { var ind = edges[cur.Current][i]; if (!visited[ind]) { visited[ind] = true; prev[ind] = cur.Current; que.Enqueue(new Node() { Current = ind }); } } } visited = new bool[n]; var queu1 = new Queue<int>(); var queu2 = new Queue<int>(); queu1.Enqueue(0); queu2.Enqueue(n - 1); visited[0] = true; visited[n - 1] = true; if (path.Count > 0) { var l = path.Count - 1; var s = 0; while (s < l) { queu1.Enqueue(path[l]); queu2.Enqueue(path[s]); visited[path[l]] = true; visited[path[s]] = true; s++; l--; } if (path.Count % 2 == 1) { queu1.Enqueue(path[path.Count / 2]); visited[path[path.Count / 2]] = true; } } while (queu1.Count > 0 && queu2.Count > 0) { var cur1 = queu1.Dequeue(); for (var i = 0; i < edges[cur1].Count; i++) { var ind = edges[cur1][i]; if (!visited[ind]) { visited[ind] = true; queu1.Enqueue(ind); } } var cur2 = queu2.Dequeue(); for (var i = 0; i < edges[cur2].Count; i++) { var ind = edges[cur2][i]; if (!visited[ind]) { visited[ind] = true; queu2.Enqueue(ind); } } } if (queu1.Count == 0) { Console.WriteLine("Snuke"); } else { Console.WriteLine("Fennec"); } } } }
[["-", 0, 57, 64, 196, 0, 52, 15, 16, 17, 79], ["+", 0, 57, 64, 196, 0, 52, 15, 16, 17, 18]]
8
983
2
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; class TEST { static void Main() { Sol mySol = new Sol(); mySol.Solve(); } } class Sol { public void Solve() { int[] parent = new int[N]; int[] depth = new int[N]; parent[0] = -1; depth[0] = 0; var Q = new Queue<int>(); Q.Enqueue(0); while (Q.Count > 0) { var now = Q.Dequeue(); foreach (var nxt in E[now]) { if (nxt == parent[now]) continue; parent[nxt] = now; depth[nxt] = depth[now] + 1; Q.Enqueue(nxt); } } int len = depth[N - 1]; int tt = len / 2; var nn = N - 1; for (int i = 0; i < tt - 1; i++) { nn = parent[nn]; } bool[] visit = new bool[N]; visit[nn] = true; Q.Enqueue(nn); while (Q.Count > 0) { var now = Q.Dequeue(); foreach (var nxt in E[now]) { if (nxt == parent[now]) continue; visit[nxt] = true; Q.Enqueue(nxt); } } int snuke = visit.Count(e => e); int fennec = N - snuke; Console.WriteLine(fennec > snuke ? "Fennec" : "Snuke"); } int N; List<int>[] E; public Sol() { N = ri(); E = new List<int>[N]; for (int i = 0; i < N; i++) E[i] = new List<int>(); for (int i = 0; i < N - 1; i++) { var d = ria(); E[d[0] - 1].Add(d[1] - 1); E[d[1] - 1].Add(d[0] - 1); } } static String rs() { return Console.ReadLine(); } static int ri() { return int.Parse(Console.ReadLine()); } static long rl() { return long.Parse(Console.ReadLine()); } static double rd() { return double.Parse(Console.ReadLine()); } static String[] rsa(char sep = ' ') { return Console.ReadLine().Split(sep); } static int[] ria(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); } static long[] rla(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); } static double[] rda(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); } }
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; class TEST { static void Main() { Sol mySol = new Sol(); mySol.Solve(); } } class Sol { public void Solve() { int[] parent = new int[N]; int[] depth = new int[N]; parent[0] = -1; depth[0] = 0; var Q = new Queue<int>(); Q.Enqueue(0); while (Q.Count > 0) { var now = Q.Dequeue(); foreach (var nxt in E[now]) { if (nxt == parent[now]) continue; parent[nxt] = now; depth[nxt] = depth[now] + 1; Q.Enqueue(nxt); } } int len = depth[N - 1]; int tt = (len + 1) / 2; // Console.WriteLine(len + " " + tt); var nn = N - 1; for (int i = 0; i < tt - 1; i++) { nn = parent[nn]; } bool[] visit = new bool[N]; visit[nn] = true; Q.Enqueue(nn); while (Q.Count > 0) { var now = Q.Dequeue(); foreach (var nxt in E[now]) { if (nxt == parent[now]) continue; visit[nxt] = true; Q.Enqueue(nxt); } } int snuke = visit.Count(e => e); int fennec = N - snuke; // Console.WriteLine(fennec + " " + snuke); Console.WriteLine(fennec > snuke ? "Fennec" : "Snuke"); } int N; List<int>[] E; public Sol() { N = ri(); E = new List<int>[N]; for (int i = 0; i < N; i++) E[i] = new List<int>(); for (int i = 0; i < N - 1; i++) { var d = ria(); E[d[0] - 1].Add(d[1] - 1); E[d[1] - 1].Add(d[0] - 1); } } static String rs() { return Console.ReadLine(); } static int ri() { return int.Parse(Console.ReadLine()); } static long rl() { return long.Parse(Console.ReadLine()); } static double rd() { return double.Parse(Console.ReadLine()); } static String[] rsa(char sep = ' ') { return Console.ReadLine().Split(sep); } static int[] ria(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); } static long[] rla(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); } static double[] rda(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); } }
[["+", 0, 200, 0, 212, 0, 16, 31, 23, 0, 24], ["+", 0, 212, 0, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 212, 0, 16, 31, 23, 0, 16, 12, 203], ["+", 0, 200, 0, 212, 0, 16, 31, 23, 0, 25]]
8
697
4
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(Console.ReadLine()); } public static long[] Reads() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); } public static long C(long n, long k) { long bunsi = 1; for (long i = 1; i <= k; i++) { bunsi *= n--; bunsi /= i; } return bunsi; } static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); var np = Reads(); var n = np[0]; var p = np[1]; var a = Reads(); var odd = 0; var even = 0; for (int i = 0; i < n; i++) { if (a[i] % 2 == 0) even++; else odd++; } long oddo = 0; long odde = 0; WriteLine(odd); for (long i = 0; i <= odd; i++) { if (i % 2 == 0) odde += C(odd, i); else oddo += C(odd, i); } WriteLine(p == 1 ? (long)Math.Pow(2, even) * oddo : (long)Math.Pow(2, even) * odde); 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(Console.ReadLine()); } public static long[] Reads() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); } public static long C(long n, long k) { long bunsi = 1; for (long i = 1; i <= k; i++) { bunsi *= n--; bunsi /= i; } return bunsi; } static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); var np = Reads(); var n = np[0]; var p = np[1]; var a = Reads(); var odd = 0; var even = 0; for (int i = 0; i < n; i++) { if (a[i] % 2 == 0) even++; else odd++; } long oddo = 0; long odde = 0; for (long i = 0; i <= odd; i++) { if (i % 2 == 0) odde += C(odd, i); else oddo += C(odd, i); } WriteLine(p == 1 ? (long)Math.Pow(2, even) * oddo : (long)Math.Pow(2, even) * odde); Console.Out.Flush(); } } }
[["-", 0, 195, 8, 196, 0, 1, 0, 213, 63, 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
343
5
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Diagnostics; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Numerics; using System.IO; using System.Runtime.InteropServices; using static System.Math; using static Math2; using static io; using static Utils; public class CompetitiveProgramming { public void Solve() { var o = Ints; var N = o[0]; var P = o[1]; var A = Ints; if (A.Count(a => a % 2 == 1) == 0) { if (P == 0) Write(Power2(2, N)); else Write(0); } Write(Power2(2, N - 1)); } } public static class Math2 { public const int INF = 1 << 29; public const long INFL = 1L << 60; public const long MOD = 1000000007; public const int MOD2 = 998244353; public static long Power(long a, long b, long MOD = 1000000007) // i^N { long res = 1; while (b > 0) { if ((b & 1) != 0) res = res * a % MOD; a = a * a % MOD; b >>= 1; } return res; } public static long Power2(long a, long b) // i^N { long res = 1; while (b > 0) { if ((b & 1) != 0) res = res * a; a = a * a; b >>= 1; } return res; } public static long GCD(long a, long b) { while (b > 0) { var r = a % b; a = b; b = r; } return a; } public static long LCM(long a, long b) => (b / GCD(a, b)) * a; public static long Comb(long n, long r, int MOD = 1000000007) { long ret = 1; long x = 1; for (long i = n; i >= n - r + 1; --i) { ret = ret / x * i; ret %= MOD; x++; } return ret; } public static long Comb2(long n, long r) { long Nume = 1; long Deno = 1; if (r > n - r) r = n - r; for (long i = 1; i <= r; ++i) { Deno *= i; Nume *= n - i + 1; } return Nume / Deno; } } public static class Utils { public static void Swap<T>(ref T A, ref T B) { T x = A; A = B; B = x; } public static int DigitSum(int N) { string s = N.ToString(); int ret = 0; for (int i = 0; i < s.Length; ++i) ret += s[i] - '0'; return ret; } } class Program { static void Main(string[] args) { var CompetitiveProgramming = new CompetitiveProgramming(); CompetitiveProgramming.Solve(); } } public static class io { public static string Str => Console.ReadLine(); public static string[] Strs => Str.Split(' '); public static long[] Longs => Strs.Select(long.Parse).ToArray(); public static int[] Ints => Strs.Select(int.Parse).ToArray(); public static char[] Chars => Str.ToArray(); public static double[] Doubles => Strs.Select(double.Parse).ToArray(); public static long Long1 => Longs[0]; public static int Int1 => Ints[0]; public static char Char1 => Chars[0]; public static double Double1 => Doubles[0]; public static long[] VerticalRead(int N) { long[] A = new long[N]; for (int i = 0; i < N; ++i) A[i] = Long1; return A; } public static void Write(string a) => Console.WriteLine(a); public static void Write(params object[] i) => Write(string.Join(" ", i)); // public static void Write<T>(IEnumerable<T> a) => Write(string.Join(" ", // a)); public static void Verticalwrite<T>(IEnumerable<T> a) { foreach (var z in a) Write(z); } public static void YN(bool i) { if (i) Write("Yes"); else Write("No"); } }
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Diagnostics; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Numerics; using System.IO; using System.Runtime.InteropServices; using static System.Math; using static Math2; using static io; using static Utils; public class CompetitiveProgramming { public void Solve() { var o = Ints; var N = o[0]; var P = o[1]; var A = Ints; if (A.Count(a => a % 2 == 1) == 0) { if (P == 0) Write(Power2(2, N)); else Write(0); } else Write(Power2(2, N - 1)); } } public static class Math2 { public const int INF = 1 << 29; public const long INFL = 1L << 60; public const long MOD = 1000000007; public const int MOD2 = 998244353; public static long Power(long a, long b, long MOD = 1000000007) // i^N { long res = 1; while (b > 0) { if ((b & 1) != 0) res = res * a % MOD; a = a * a % MOD; b >>= 1; } return res; } public static long Power2(long a, long b) // i^N { long res = 1; while (b > 0) { if ((b & 1) != 0) res = res * a; a = a * a; b >>= 1; } return res; } public static long GCD(long a, long b) { while (b > 0) { var r = a % b; a = b; b = r; } return a; } public static long LCM(long a, long b) => (b / GCD(a, b)) * a; public static long Comb(long n, long r, int MOD = 1000000007) { long ret = 1; long x = 1; for (long i = n; i >= n - r + 1; --i) { ret = ret / x * i; ret %= MOD; x++; } return ret; } public static long Comb2(long n, long r) { long Nume = 1; long Deno = 1; if (r > n - r) r = n - r; for (long i = 1; i <= r; ++i) { Deno *= i; Nume *= n - i + 1; } return Nume / Deno; } } public static class Utils { public static void Swap<T>(ref T A, ref T B) { T x = A; A = B; B = x; } public static int DigitSum(int N) { string s = N.ToString(); int ret = 0; for (int i = 0; i < s.Length; ++i) ret += s[i] - '0'; return ret; } } class Program { static void Main(string[] args) { var CompetitiveProgramming = new CompetitiveProgramming(); CompetitiveProgramming.Solve(); } } public static class io { public static string Str => Console.ReadLine(); public static string[] Strs => Str.Split(' '); public static long[] Longs => Strs.Select(long.Parse).ToArray(); public static int[] Ints => Strs.Select(int.Parse).ToArray(); public static char[] Chars => Str.ToArray(); public static double[] Doubles => Strs.Select(double.Parse).ToArray(); public static long Long1 => Longs[0]; public static int Int1 => Ints[0]; public static char Char1 => Chars[0]; public static double Double1 => Doubles[0]; public static long[] VerticalRead(int N) { long[] A = new long[N]; for (int i = 0; i < N; ++i) A[i] = Long1; return A; } public static void Write(string a) => Console.WriteLine(a); public static void Write(params object[] i) => Write(string.Join(" ", i)); // public static void Write<T>(IEnumerable<T> a) => Write(string.Join(" ", // a)); public static void Verticalwrite<T>(IEnumerable<T> a) { foreach (var z in a) Write(z); } public static void YN(bool i) { if (i) Write("Yes"); else Write("No"); } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95]]
8
943
1
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Diagnostics; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Numerics; using System.IO; using System.Runtime.InteropServices; using static System.Math; using static Math2; using static io; using static Utils; public class CompetitiveProgramming { public void Solve() { var o = Ints; var N = o[0]; var P = o[1]; var A = Ints; var ev = A.Count(y => y % 2 == 0); long ans = 0; int x; if (P == 0) { x = 0; } else x = 1; while (x <= N - ev) { ans += Comb2(N - ev, x); x += 2; } long ans2 = (1 << ev); Write(ans * ans2); } } public static class Math2 { public const int INF = 1 << 29; public const long INFL = 1L << 60; public const long MOD = 1000000007; public const int MOD2 = 998244353; public static long Power(long i, long N, long MOD = 1000000007) // i^N { long res = 1; while (N > 0) { if ((N & 1) != 0) res = res * i % MOD; i = i * i % MOD; N >>= 1; } return res; } public static long Power2(long i, long N) // i^N { long res = 1; while (N > 0) { if ((N & 1) != 0) res = res * i; i = i * i; N >>= 1; } return res; } public static long GCD(long i, long N) { if (i > N) Swap(ref i, ref N); if (i == 0) return N; while (N != 0) { var r = i % N; i = N; N = r; } return i; } public static long LCM(long i, long N) => i * N / GCD(i, N); public static long Comb(long N, long R, int MOD = 1000000007) { long ret = 1; long x = 1; for (long i = N; i >= N - R + 1; --i) { ret = ret / x * i; ret %= MOD; x++; } return ret; } public static long Comb2(long N, long R) { long Nume = 1; long Deno = 1; if (R > N - R) R = N - R; for (long i = 1; i <= R; ++i) { Deno *= i; Nume *= N - i + 1; } return Nume / Deno; } } public static class Utils { public static void Swap<T>(ref T A, ref T B) { T x = A; A = B; B = x; } public static int DigitSum(int N) { string s = N.ToString(); int ret = 0; for (int i = 0; i < s.Length; ++i) ret += s[i] - '0'; return ret; } } class Program { static void Main(string[] args) { var CompetitiveProgramming = new CompetitiveProgramming(); CompetitiveProgramming.Solve(); } } public static class io { public static string Str => Console.ReadLine(); public static string[] Strs => Str.Split(' '); public static long[] Longs => Strs.Select(long.Parse).ToArray(); public static int[] Ints => Strs.Select(int.Parse).ToArray(); public static char[] Chars => Str.ToArray(); public static double[] Doubles => Strs.Select(double.Parse).ToArray(); public static long Long1 => Longs[0]; public static int Int1 => Ints[0]; public static char Char1 => Chars[0]; public static double Double1 => Doubles[0]; public static long[] VerticalRead(int N) { long[] A = new long[N]; for (int i = 0; i < N; ++i) A[i] = Long1; return A; } public static void Write(string a) => Console.WriteLine(a); public static void Write(params object[] i) => Write(string.Join(" ", i)); public static void Write<T>(IEnumerable<T> a) => Write(string.Join(" ", a)); public static void Verticalwrite<T>(IEnumerable<T> a) { foreach (var z in a) Write(z); } public static void YN(bool i) { if (i) Write("Yes"); else Write("No"); } }
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Diagnostics; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Numerics; using System.IO; using System.Runtime.InteropServices; using static System.Math; using static Math2; using static io; using static Utils; public class CompetitiveProgramming { public void Solve() { var o = Ints; var N = o[0]; var P = o[1]; var A = Ints; var ev = A.Count(y => y % 2 == 0); long ans = 0; long x; if (P == 0) { x = 0; } else x = 1; while (x <= N - ev) { ans += Comb2(N - ev, x); x += 2; } long ans2 = (1L << ev); Write(ans * ans2); } } public static class Math2 { public const int INF = 1 << 29; public const long INFL = 1L << 60; public const long MOD = 1000000007; public const int MOD2 = 998244353; public static long Power(long i, long N, long MOD = 1000000007) // i^N { long res = 1; while (N > 0) { if ((N & 1) != 0) res = res * i % MOD; i = i * i % MOD; N >>= 1; } return res; } public static long Power2(long i, long N) // i^N { long res = 1; while (N > 0) { if ((N & 1) != 0) res = res * i; i = i * i; N >>= 1; } return res; } public static long GCD(long i, long N) { if (i > N) Swap(ref i, ref N); if (i == 0) return N; while (N != 0) { var r = i % N; i = N; N = r; } return i; } public static long LCM(long i, long N) => i * N / GCD(i, N); public static long Comb(long N, long R, int MOD = 1000000007) { long ret = 1; long x = 1; for (long i = N; i >= N - R + 1; --i) { ret = ret / x * i; ret %= MOD; x++; } return ret; } public static long Comb2(long N, long R) { long Nume = 1; long Deno = 1; if (R > N - R) R = N - R; for (long i = 1; i <= R; ++i) { Deno *= i; Nume *= N - i + 1; } return Nume / Deno; } } public static class Utils { public static void Swap<T>(ref T A, ref T B) { T x = A; A = B; B = x; } public static int DigitSum(int N) { string s = N.ToString(); int ret = 0; for (int i = 0; i < s.Length; ++i) ret += s[i] - '0'; return ret; } } class Program { static void Main(string[] args) { var CompetitiveProgramming = new CompetitiveProgramming(); CompetitiveProgramming.Solve(); } } public static class io { public static string Str => Console.ReadLine(); public static string[] Strs => Str.Split(' '); public static long[] Longs => Strs.Select(long.Parse).ToArray(); public static int[] Ints => Strs.Select(int.Parse).ToArray(); public static char[] Chars => Str.ToArray(); public static double[] Doubles => Strs.Select(double.Parse).ToArray(); public static long Long1 => Longs[0]; public static int Int1 => Ints[0]; public static char Char1 => Chars[0]; public static double Double1 => Doubles[0]; public static long[] VerticalRead(int N) { long[] A = new long[N]; for (int i = 0; i < N; ++i) A[i] = Long1; return A; } public static void Write(string a) => Console.WriteLine(a); public static void Write(params object[] i) => Write(string.Join(" ", i)); public static void Write<T>(IEnumerable<T> a) => Write(string.Join(" ", a)); public static void Verticalwrite<T>(IEnumerable<T> a) { foreach (var z in a) Write(z); } public static void YN(bool i) { if (i) Write("Yes"); else Write("No"); } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 200, 0, 212, 0, 23, 0, 16, 31, 203], ["+", 0, 200, 0, 212, 0, 23, 0, 16, 31, 203]]
8
1,021
4
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.IO; using static System.Console; using static System.Math; public class Solve { static public int mod = 1000000007; public static void Main() { // โ€ขรปj // var n = inta(); var a = longa(); int odd = 0; int even = 0; for (int i = 0; i < n[0]; i++) { if (a[i] % 2 == 0) { even++; } else { odd++; } } long ans = 0; long selecteven = 1; for (int i = 0; i < even; i++) { selecteven *= 2; } for (int i = 0; i < odd; i++) { if (i % 2 == n[1]) { ans += ncr2(odd, (long)i) * selecteven; } } WriteLine(ans); } // 1โ€šยฉโ€šรงaโ€šรœโ€šร…โ€šรŒโ€ลกโ€ขร€โ€šร—โ€˜ร–โ€šยฆโ€˜Sโ€™รŠโ€šรจโ€ขร”โ€šยทโ€šรขโ€šร‚ static List<string> permutation(int a) { var list = new List<string>(); if (a == 1) { list.Add("1"); return list; } else { foreach (var k in permutation(a - 1)) { var ch = k.ToCharArray(); for (int i = 0; i <= ch.Length; i++) { string intemp = ""; if (i == 0) { intemp += a.ToString(); } for (int j = 0; j < ch.Length; j++) { intemp += ch[j].ToString(); if (i == j + 1) { intemp += a.ToString(); } } list.Add(intemp); } } } return list; } public static void swap(ref int a, ref int b) { int temp = a; a = b; b = temp; } static void charswap(ref char a, ref char b) { char temp = a; a = b; b = temp; } static int ncr(int n, int r) { r = Min(r, n - r); long nn = 1; for (int i = n - r + 1; i <= n; i++) { nn = nn * i % mod; } long rr = 1; for (int i = 1; i <= r; i++) { rr = rr * i % mod; } rr = square((int)rr, mod - 2); nn = nn * rr % mod; return (int)nn; } static long ncr2(long n, long r) { r = Min(r, n - r); long nn = 1; for (var i = n - r + 1; i <= n; i++) { nn = nn * i; } long rr = 1; for (int i = 1; i <= r; i++) { rr = rr * i; } return nn / rr; } // a^b mod static int square(int a, int b) { string binary = Convert.ToString(b, 2); int bileng = binary.Length; long a_power = a; long value = 1; for (int i = bileng - 1; i >= 0; i--) { if (binary[i] == '1') { value = value * a_power % mod; } a_power = a_power * a_power % mod; } return (int)value; } static int square2(int a, int b) { long output = 1; var list = new List<long>(); int sh = 1; long n = a; list.Add(a); while (sh < b) { sh *= 2; n = n * n % mod; list.Add(n); } for (int i = list.Count - 1; i >= 0; i--) { if (b > sh) { b -= sh; sh /= 2; output = output * list[i] % mod; } } return (int)output; } //ล eรญโ€œร‡รฆ static string rstr() { return ReadLine(); } static int rint() { return int.Parse(ReadLine()); } static long rlong() { return long.Parse(ReadLine()); } static string[] stra() { return ReadLine().Split(' '); } static char[] chara() { string[] a = stra(); string b = ""; for (int i = 0; i < a.Length; i++) { b += a[i]; } return b.ToCharArray(); } static int[] inta() { string[] read_str_array = ReadLine().Split(' '); int[] return_int_array = new int[read_str_array.Length]; for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_int_array[countup_i] = int.Parse(read_str_array[countup_i]); } return return_int_array; } static int[,] inta2(int num_array, int in_array) { int[,] int_array2 = new int[num_array, in_array]; for (int i = 0; i < num_array; i++) { int[] temp_array = inta(); for (int j = 0; j < in_array; j++) { int_array2[i, j] = temp_array[j]; } } return int_array2; } static long[] longa() { string[] read_str_array = ReadLine().Split(' '); long[] return_long_array = new long[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_long_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_long_array; } static double[] doublea() { string[] read_str_array = ReadLine().Split(' '); double[] return_double_array = new double[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_double_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_double_array; } // ----------------------------- static long divideup(long divided, long divid) { long temp_divide = divided / divid; if (divided % divid > 0) { temp_divide++; } return temp_divide; } static long GCD(long a, long b) { if (a < b) { long temp = a; a = b; b = temp; } if (a % b == 0) { return b; } else { long temp = b; b = a % b; a = temp; return GCD(a, b); } } static long LCM(long a, long b) { return a * b / GCD(a, b); } static void WriteArray(int[,] a, int b, int c) { for (int i = 0; i < b; i++) { for (int j = 0; j < c; j++) { if (j != 0) Write(" "); Write(a[i, j]); } WriteLine(); } } }
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.IO; using static System.Console; using static System.Math; public class Solve { static public int mod = 1000000007; public static void Main() { // โ€ขรปj // var n = inta(); var a = longa(); int odd = 0; int even = 0; for (int i = 0; i < n[0]; i++) { if (a[i] % 2 == 0) { even++; } else { odd++; } } long ans = 0; long selecteven = 1; for (int i = 0; i < even; i++) { selecteven *= 2; } for (int i = 0; i <= odd; i++) { if (i % 2 == n[1]) { ans += ncr2(odd, (long)i) * selecteven; } } WriteLine(ans); } // 1โ€šยฉโ€šรงaโ€šรœโ€šร…โ€šรŒโ€ลกโ€ขร€โ€šร—โ€˜ร–โ€šยฆโ€˜Sโ€™รŠโ€šรจโ€ขร”โ€šยทโ€šรขโ€šร‚ static List<string> permutation(int a) { var list = new List<string>(); if (a == 1) { list.Add("1"); return list; } else { foreach (var k in permutation(a - 1)) { var ch = k.ToCharArray(); for (int i = 0; i <= ch.Length; i++) { string intemp = ""; if (i == 0) { intemp += a.ToString(); } for (int j = 0; j < ch.Length; j++) { intemp += ch[j].ToString(); if (i == j + 1) { intemp += a.ToString(); } } list.Add(intemp); } } } return list; } public static void swap(ref int a, ref int b) { int temp = a; a = b; b = temp; } static void charswap(ref char a, ref char b) { char temp = a; a = b; b = temp; } static int ncr(int n, int r) { r = Min(r, n - r); long nn = 1; for (int i = n - r + 1; i <= n; i++) { nn = nn * i % mod; } long rr = 1; for (int i = 1; i <= r; i++) { rr = rr * i % mod; } rr = square((int)rr, mod - 2); nn = nn * rr % mod; return (int)nn; } static long ncr2(long n, long r) { r = Min(r, n - r); long nn = 1; for (var i = n - r + 1; i <= n; i++) { nn = nn * i; } long rr = 1; for (int i = 1; i <= r; i++) { rr = rr * i; } return nn / rr; } // a^b mod static int square(int a, int b) { string binary = Convert.ToString(b, 2); int bileng = binary.Length; long a_power = a; long value = 1; for (int i = bileng - 1; i >= 0; i--) { if (binary[i] == '1') { value = value * a_power % mod; } a_power = a_power * a_power % mod; } return (int)value; } static int square2(int a, int b) { long output = 1; var list = new List<long>(); int sh = 1; long n = a; list.Add(a); while (sh < b) { sh *= 2; n = n * n % mod; list.Add(n); } for (int i = list.Count - 1; i >= 0; i--) { if (b > sh) { b -= sh; sh /= 2; output = output * list[i] % mod; } } return (int)output; } //ล eรญโ€œร‡รฆ static string rstr() { return ReadLine(); } static int rint() { return int.Parse(ReadLine()); } static long rlong() { return long.Parse(ReadLine()); } static string[] stra() { return ReadLine().Split(' '); } static char[] chara() { string[] a = stra(); string b = ""; for (int i = 0; i < a.Length; i++) { b += a[i]; } return b.ToCharArray(); } static int[] inta() { string[] read_str_array = ReadLine().Split(' '); int[] return_int_array = new int[read_str_array.Length]; for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_int_array[countup_i] = int.Parse(read_str_array[countup_i]); } return return_int_array; } static int[,] inta2(int num_array, int in_array) { int[,] int_array2 = new int[num_array, in_array]; for (int i = 0; i < num_array; i++) { int[] temp_array = inta(); for (int j = 0; j < in_array; j++) { int_array2[i, j] = temp_array[j]; } } return int_array2; } static long[] longa() { string[] read_str_array = ReadLine().Split(' '); long[] return_long_array = new long[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_long_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_long_array; } static double[] doublea() { string[] read_str_array = ReadLine().Split(' '); double[] return_double_array = new double[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_double_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_double_array; } // ----------------------------- static long divideup(long divided, long divid) { long temp_divide = divided / divid; if (divided % divid > 0) { temp_divide++; } return temp_divide; } static long GCD(long a, long b) { if (a < b) { long temp = a; a = b; b = temp; } if (a % b == 0) { return b; } else { long temp = b; b = a % b; a = temp; return GCD(a, b); } } static long LCM(long a, long b) { return a * b / GCD(a, b); } static void WriteArray(int[,] a, int b, int c) { for (int i = 0; i < b; i++) { for (int j = 0; j < c; j++) { if (j != 0) Write(" "); Write(a[i, j]); } WriteLine(); } } }
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19]]
8
1,483
2
using System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.Linq; using System.Web; namespace Competitive { internal class Solution { public int N, P; public int[] A; public void Run() { { var line = Input.ReadIntArray(); N = line[0]; P = line[1]; A = Input.ReadIntArray(); } int[] mods = new int[2]; for (int i = 0; i < N; i++) { mods[i % 2]++; } // corner case if (P == 1 && mods[1] == 0) { Console.WriteLine(0); return; } int c = mods[0] + Math.Max(mods[1] - 1, 0); long ret = Power2(2, c); Console.WriteLine(ret); } public long Power(long x, long n) { long tmp = 1; if (n > 0) { tmp = Power(x, n / 2); if (n % 2 == 0) tmp = tmp * tmp; else tmp = tmp * tmp * x; } return tmp; } public long Power2(long x, long n) { long tmp = 1; for (int i = 0; i < n; i++) { tmp *= 2; } return tmp; } } // libs ---------- // common ---------- internal static class Input { public static string ReadString() { string line = Console.ReadLine(); return line; } public static int ReadInt() { string line = Console.ReadLine(); return int.Parse(line); } public static int[] ReadIntArray() { string line = Console.ReadLine(); return line.Split(' ').Select(int.Parse).ToArray(); } public static long ReadLong() { string line = Console.ReadLine(); return long.Parse(line); } public static long[] ReadLongArray() { string line = Console.ReadLine(); return line.Split(' ').Select(long.Parse).ToArray(); } public static double[] ReadDoubleArray() { string line = Console.ReadLine(); return line.Split(' ').Select(double.Parse).ToArray(); } } internal class Program { public static void Main(string[] args) { var s = new Solution(); s.Run(); } } }
using System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.Linq; using System.Web; namespace Competitive { internal class Solution { public int N, P; public int[] A; public void Run() { { var line = Input.ReadIntArray(); N = line[0]; P = line[1]; A = Input.ReadIntArray(); } int[] mods = new int[2]; for (int i = 0; i < N; i++) { mods[A[i] % 2]++; } // corner case if (P == 1 && mods[1] == 0) { Console.WriteLine(0); return; } int c = mods[0] + Math.Max(mods[1] - 1, 0); long ret = Power2(2, c); Console.WriteLine(ret); } public long Power(long x, long n) { long tmp = 1; if (n > 0) { tmp = Power(x, n / 2); if (n % 2 == 0) tmp = tmp * tmp; else tmp = tmp * tmp * x; } return tmp; } public long Power2(long x, long n) { long tmp = 1; for (int i = 0; i < n; i++) { tmp *= 2; } return tmp; } } // libs ---------- // common ---------- internal static class Input { public static string ReadString() { string line = Console.ReadLine(); return line; } public static int ReadInt() { string line = Console.ReadLine(); return int.Parse(line); } public static int[] ReadIntArray() { string line = Console.ReadLine(); return line.Split(' ').Select(int.Parse).ToArray(); } public static long ReadLong() { string line = Console.ReadLine(); return long.Parse(line); } public static long[] ReadLongArray() { string line = Console.ReadLine(); return line.Split(' ').Select(long.Parse).ToArray(); } public static double[] ReadDoubleArray() { string line = Console.ReadLine(); return line.Split(' ').Select(double.Parse).ToArray(); } } internal class Program { public static void Main(string[] args) { var s = new Solution(); s.Run(); } } }
[["+", 206, 207, 0, 28, 0, 16, 31, 204, 205, 22], ["+", 0, 28, 0, 16, 31, 204, 206, 207, 0, 70], ["+", 0, 28, 0, 16, 31, 204, 206, 207, 0, 73]]
8
518
3
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace AtCoder { class Program { private const int MODULO = 1000000007; 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(int N, int P, int[] A) { var dp = new long[] { 1, 0 }; for (int i = 0; i < N; ++i) { if (A[0] % 2 == 0) { dp[0] *= 2; dp[1] *= 2; } else { long sum = dp.Sum(); dp[0] = sum; dp[1] = sum; } } return dp[P]; } static void Main(string[] args) { var V = ReadInts(); var A = ReadInts(); Console.WriteLine(Solve(V[0], V[1], A)); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace AtCoder { class Program { private const int MODULO = 1000000007; 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(int N, int P, int[] A) { var dp = new long[] { 1, 0 }; for (int i = 0; i < N; ++i) { if (A[i] % 2 == 0) { dp[0] *= 2; dp[1] *= 2; } else { long sum = dp.Sum(); dp[0] = sum; dp[1] = sum; } } return dp[P]; } static void Main(string[] args) { var V = ReadInts(); var A = ReadInts(); Console.WriteLine(Solve(V[0], V[1], A)); } } }
[["-", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 31, 16, 31, 204, 206, 207, 0, 28, 0, 22]]
8
338
2
using System; public class Hello { public static void Main() { string[] line = Console.ReadLine().Trim().Split(' '); var n = int.Parse(line[0]); var p = int.Parse(line[1]); line = Console.ReadLine().Trim().Split(' '); var a = Array.ConvertAll(line, int.Parse); var evenall = true; for (int i = 0; i < n; i++) if (a[i] % 2 == 1) { evenall = false; break; } if (evenall) Console.WriteLine(p == 0 ? Math.Pow(2, n - 1) : 0); else Console.WriteLine(Math.Pow(2, n - 1)); } }
using System; public class Hello { public static void Main() { string[] line = Console.ReadLine().Trim().Split(' '); var n = int.Parse(line[0]); var p = int.Parse(line[1]); line = Console.ReadLine().Trim().Split(' '); var a = Array.ConvertAll(line, int.Parse); var evenall = true; for (int i = 0; i < n; i++) if (a[i] % 2 == 1) { evenall = false; break; } if (evenall) Console.WriteLine(p == 0 ? Math.Pow(2, n) : 0); else Console.WriteLine(Math.Pow(2, n - 1)); } }
[["-", 64, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["-", 64, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
8
178
2
using System; using System.Linq; using System.Collections.Generic; namespace AtCoder.Grand017 { public class AGC017A_Biscuits { public static void Main(string[] args) { // ็ทๆ•ฐใจไฝ™ใ‚Šใฎๆ•ฐใฎๅ…ฅๅŠ› int[] nums = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); int n = nums[0]; int p = nums[1]; // ่ข‹ๆฏŽใฎใƒ“ใ‚นใ‚ฑใƒƒใƒˆๆ•ฐใฎๅ…ฅๅŠ› int[] biscuitNum = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); int evenNum = biscuitNum.Count(num => num % 2 == 0); int oddNum = biscuitNum.Count(num => num % 2 == 1); if (p == 0) { // ๅถๆ•ฐๆžš้ฃŸในใ‚‹ // ๅถๆ•ฐ่ข‹ใ‹ใ‚‰ไปปๆ„ใฎๆ•ฐใจใ€ๅฅ‡ๆ•ฐ่ข‹ใ‹ใ‚‰ๅถๆ•ฐ decimal evenCombi = 0; for (int i = 0; i <= evenNum; i++) { evenCombi += MathMod.Combination(evenNum, i); } decimal oddCombi = 0; for (int i = 0; i <= oddNum; i += 2) { oddCombi += MathMod.Combination(oddNum, i); } // ็ตๆžœๅ‡บๅŠ› Console.WriteLine(evenCombi * oddCombi); } else { // ๅฅ‡ๆ•ฐๆžš้ฃŸในใ‚‹ // ๅถๆ•ฐ่ข‹ใ‹ใ‚‰ไปปๆ„ใฎๆ•ฐใจใ€ๅฅ‡ๆ•ฐ่ข‹ใ‹ใ‚‰ๅฅ‡ๆ•ฐ decimal evenCombi = 0; for (int i = 0; i <= evenNum; i++) { evenCombi += MathMod.Combination(evenNum, i); } decimal oddCombi = 0; for (int i = 1; i <= oddNum; i += 2) { oddCombi += MathMod.Combination(oddNum, i); } // ็ตๆžœๅ‡บๅŠ› Console.WriteLine(evenCombi * oddCombi); } } public class MathMod { // ้šŽไน—่จˆ็ฎ—ใซไฝฟใ†็ด ๆ•ฐ(้šŽไน—่จˆ็ฎ—ใฎไธŠ้™ๆ•ฐ) static decimal modVal = 2147483647m; // ้šŽไน—่จˆ็ฎ—ใ‚’่กŒใ†ๆ•ฐ private static int FactorialMax = 60; // ้šŽไน—ใฎๅ‰ฐไฝ™ private static decimal[] factorialMod = new decimal[FactorialMax + 1]; // ้šŽไน—ใฎ้€†ๅ…ƒ private static decimal[] factorialInverse = new decimal[FactorialMax + 1]; static MathMod() { // ้šŽไน—ใฎๅ‰ฐไฝ™ใƒป้€†ๅ…ƒใ‚’่จˆ็ฎ— factorialMod[0] = 1; factorialInverse[0] = 1; for (long i = 1; i <= FactorialMax; i++) { factorialMod[i] = (factorialMod[i - 1] * i) % modVal; factorialInverse[i] = Pow(factorialMod[i], modVal - 2); } } /// <summary>็ดฏไน—ใ‚’ๆฑ‚ใ‚ใ‚‹</summary> public static decimal Pow(decimal x, decimal y) { decimal remaining = y; decimal p = x; decimal ret = 1; while (remaining > 0) { if (remaining % 2 == 0) { p = (p * p) % modVal; remaining /= 2; } else { ret = (ret * p) % modVal; remaining -= 1; } } return ret; } /// <summary>้šŽไน—ใ‚’ๆฑ‚ใ‚ใ‚‹</summary> public static decimal Factorial(int n) { if (n < 0 || n > FactorialMax) { throw new ArgumentOutOfRangeException(); } return factorialMod[n]; } /// <summary>็ต„ใฟๅˆใ‚ใ›ๆ•ฐใ‚’ๆฑ‚ใ‚ใ‚‹</summary> /// <param name="n">ๅ…จไฝ“้›†ๅˆใฎ่ฆ็ด ๆ•ฐ</param> /// <param name="r">ๅ–ใ‚Šๅ‡บใ™่ฆ็ด ๆ•ฐ</param> /// <returns>็ต„ใฟๅˆใ‚ใ›ๆ•ฐ</returns> public static decimal Combination(int n, int r) { if (n > FactorialMax || r > FactorialMax) { throw new ArgumentOutOfRangeException(); } if (n < r || n < 0 || r < 0) { return 0; } return (factorialMod[n] * factorialInverse[r] % modVal * factorialInverse[n - r] % modVal); } } } }
using System; using System.Linq; using System.Collections.Generic; namespace AtCoder.Grand017 { public class AGC017A_Biscuits { public static void Main(string[] args) { // ็ทๆ•ฐใจไฝ™ใ‚Šใฎๆ•ฐใฎๅ…ฅๅŠ› int[] nums = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); int n = nums[0]; int p = nums[1]; // ่ข‹ๆฏŽใฎใƒ“ใ‚นใ‚ฑใƒƒใƒˆๆ•ฐใฎๅ…ฅๅŠ› int[] biscuitNum = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); int evenNum = biscuitNum.Count(num => num % 2 == 0); int oddNum = biscuitNum.Count(num => num % 2 == 1); if (p == 0) { // ๅถๆ•ฐๆžš้ฃŸในใ‚‹ // ๅถๆ•ฐ่ข‹ใ‹ใ‚‰ไปปๆ„ใฎๆ•ฐใจใ€ๅฅ‡ๆ•ฐ่ข‹ใ‹ใ‚‰ๅถๆ•ฐ decimal evenCombi = 0; for (int i = 0; i <= evenNum; i++) { evenCombi += MathMod.Combination(evenNum, i); } decimal oddCombi = 0; for (int i = 0; i <= oddNum; i += 2) { oddCombi += MathMod.Combination(oddNum, i); } // ็ตๆžœๅ‡บๅŠ› Console.WriteLine(evenCombi * oddCombi); } else { // ๅฅ‡ๆ•ฐๆžš้ฃŸในใ‚‹ // ๅถๆ•ฐ่ข‹ใ‹ใ‚‰ไปปๆ„ใฎๆ•ฐใจใ€ๅฅ‡ๆ•ฐ่ข‹ใ‹ใ‚‰ๅฅ‡ๆ•ฐ decimal evenCombi = 0; for (int i = 0; i <= evenNum; i++) { evenCombi += MathMod.Combination(evenNum, i); } decimal oddCombi = 0; for (int i = 1; i <= oddNum; i += 2) { oddCombi += MathMod.Combination(oddNum, i); } // ็ตๆžœๅ‡บๅŠ› Console.WriteLine(evenCombi * oddCombi); } } public class MathMod { // ้šŽไน—่จˆ็ฎ—ใซไฝฟใ†็ด ๆ•ฐ(้šŽไน—่จˆ็ฎ—ใฎไธŠ้™ๆ•ฐ) static decimal modVal = 261241490581607m; // ้šŽไน—่จˆ็ฎ—ใ‚’่กŒใ†ๆ•ฐ private static int FactorialMax = 60; // ้šŽไน—ใฎๅ‰ฐไฝ™ private static decimal[] factorialMod = new decimal[FactorialMax + 1]; // ้šŽไน—ใฎ้€†ๅ…ƒ private static decimal[] factorialInverse = new decimal[FactorialMax + 1]; static MathMod() { // ้šŽไน—ใฎๅ‰ฐไฝ™ใƒป้€†ๅ…ƒใ‚’่จˆ็ฎ— factorialMod[0] = 1; factorialInverse[0] = 1; for (long i = 1; i <= FactorialMax; i++) { factorialMod[i] = (factorialMod[i - 1] * i) % modVal; factorialInverse[i] = Pow(factorialMod[i], modVal - 2); } } /// <summary>็ดฏไน—ใ‚’ๆฑ‚ใ‚ใ‚‹</summary> public static decimal Pow(decimal x, decimal y) { decimal remaining = y; decimal p = x; decimal ret = 1; while (remaining > 0) { if (remaining % 2 == 0) { p = (p * p) % modVal; remaining /= 2; } else { ret = (ret * p) % modVal; remaining -= 1; } } return ret; } /// <summary>้šŽไน—ใ‚’ๆฑ‚ใ‚ใ‚‹</summary> public static decimal Factorial(int n) { if (n < 0 || n > FactorialMax) { throw new ArgumentOutOfRangeException(); } return factorialMod[n]; } /// <summary>็ต„ใฟๅˆใ‚ใ›ๆ•ฐใ‚’ๆฑ‚ใ‚ใ‚‹</summary> /// <param name="n">ๅ…จไฝ“้›†ๅˆใฎ่ฆ็ด ๆ•ฐ</param> /// <param name="r">ๅ–ใ‚Šๅ‡บใ™่ฆ็ด ๆ•ฐ</param> /// <returns>็ต„ใฟๅˆใ‚ใ›ๆ•ฐ</returns> public static decimal Combination(int n, int r) { if (n > FactorialMax || r > FactorialMax) { throw new ArgumentOutOfRangeException(); } if (n < r || n < 0 || r < 0) { return 0; } return (factorialMod[n] * factorialInverse[r] % modVal * factorialInverse[n - r] % modVal); } } } }
[["-", 0, 124, 0, 198, 0, 200, 0, 212, 0, 250], ["+", 0, 124, 0, 198, 0, 200, 0, 212, 0, 250]]
8
629
2
using System; using System.Linq; //ใƒชใ‚นใƒˆใฎไฝฟ็”จ using System.Collections.Generic; class Program { static void Main() { string[] input = Console.ReadLine().Split( ' '); // SplitใงๅŒบๅˆ‡ใ‚Šๆ–‡ๅญ—ใ‚’ๆŒ‡ๅฎšใ—ใฆ่ค‡ๆ•ฐๅ€‹ๅ—ใ‘ๅ–ใ‚‹ใ€‚ long n = long.Parse(input[0]); long a = long.Parse(input[1]); long b = long.Parse(input[2]); long c = long.Parse(input[3]); long d = long.Parse(input[4]); bool answer = false; for (long i = 0; i <= n - 2; i++) { if (a - d * (n - 2 - i) + c * i <= b && b <= a - c * (n - 2 - i) + d * i) answer = true; } Console.WriteLine((answer) ? "YES" : "NO"); } }
using System; using System.Linq; //ใƒชใ‚นใƒˆใฎไฝฟ็”จ using System.Collections.Generic; class Program { static void Main() { string[] input = Console.ReadLine().Split( ' '); // SplitใงๅŒบๅˆ‡ใ‚Šๆ–‡ๅญ—ใ‚’ๆŒ‡ๅฎšใ—ใฆ่ค‡ๆ•ฐๅ€‹ๅ—ใ‘ๅ–ใ‚‹ใ€‚ long n = long.Parse(input[0]); long a = long.Parse(input[1]); long b = long.Parse(input[2]); long c = long.Parse(input[3]); long d = long.Parse(input[4]); bool answer = false; for (long i = 0; i <= n - 1; i++) { if (a - d * (n - 1 - i) + c * i <= b && b <= a - c * (n - 1 - i) + d * i) answer = true; } Console.WriteLine((answer) ? "YES" : "NO"); } }
[["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["-", 12, 16, 12, 23, 0, 16, 31, 16, 12, 203], ["+", 12, 16, 12, 23, 0, 16, 31, 16, 12, 203]]
8
193
6
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABC066A { class Program { static void Main(string[] args) { int a, b, c, s; string[] ward = Console.ReadLine().Split(' '); a = int.Parse(ward[0]); b = int.Parse(ward[1]); c = int.Parse(ward[2]); // a,b,c,ใฎๆœ€ๅคงๅ€คใ‚’ๆฑ‚ใ‚ใ‚‹ int m = a; if (b > m) m = b; if (c > m) m = c; //ๆœ€ๅคงๅ€คใ‚’้™คใ้‡‘้กใฎๅ’Œ s = a + b + c - m; s = 100; Console.WriteLine(s); // Console.ReadKey(); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABC066A { class Program { static void Main(string[] args) { int a, b, c, s; string[] ward = Console.ReadLine().Split(' '); a = int.Parse(ward[0]); b = int.Parse(ward[1]); c = int.Parse(ward[2]); // a,b,c,ใฎๆœ€ๅคงๅ€คใ‚’ๆฑ‚ใ‚ใ‚‹ int m = a; if (b > m) m = b; if (c > m) m = c; //ๆœ€ๅคงๅ€คใ‚’้™คใ้‡‘้กใฎๅ’Œ s = a + b + c - m; Console.WriteLine(s); // Console.ReadKey(); } } }
[["-", 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, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
8
158
4
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABC066A { class Program { static void Main(string[] args) { int a, b, c, s, x, y, z; string[] word = Console.ReadLine().Split(' '); a = int.Parse(word[0]); b = int.Parse(word[1]); c = int.Parse(word[2]); s = 0; x = a + b; y = a + c; z = b + c; s = x; if (x >= y) s = y; if (y >= z) s = z; Console.WriteLine(s); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABC066A { class Program { static void Main(string[] args) { int a, b, c, s, x, y, z; string[] word = Console.ReadLine().Split(' '); a = int.Parse(word[0]); b = int.Parse(word[1]); c = int.Parse(word[2]); s = 0; x = a + b; y = a + c; z = b + c; s = x; if (s > y) s = y; if (s > z) s = z; Console.WriteLine(s); } } }
[["-", 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, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47]]
8
168
8
using System; namespace ABC026A { class Program { static void Main(string[] args) { int a, b, c; var word = Console.ReadLine().Split(' '); a = int.Parse(word[0]); b = int.Parse(word[1]); c = int.Parse(word[2]); if (a + b <= a + c && a + b <= b + c) Console.WriteLine(a + b); if (a + c <= a + b && a + c <= b + c) Console.WriteLine(a + c); if (b + c <= a + b && b + c <= a + c) Console.WriteLine(b + c); Console.ReadKey(); } } }
using System; namespace ABC026A { class Program { static void Main(string[] args) { int a, b, c; var word = Console.ReadLine().Split(' '); a = int.Parse(word[0]); b = int.Parse(word[1]); c = int.Parse(word[2]); if (a + b <= a + c && a + b <= b + c) Console.WriteLine(a + b); else if (a + c <= a + b && a + c <= b + c) Console.WriteLine(a + c); else if (b + c <= a + b && b + c <= a + c) Console.WriteLine(b + c); Console.ReadKey(); } } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 95]]
8
168
2
using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; namespace A { public class Program { static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); Solve(); Console.Out.Flush(); } public static void Solve() { var A = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray(); var answer = Math.Min(A[0] + A[1], A[0] + A[1]); answer = Math.Min(answer, A[1] + A[2]); Console.WriteLine(answer); } } }
using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; namespace A { public class Program { static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); Solve(); Console.Out.Flush(); } public static void Solve() { var A = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray(); var answer = Math.Min(A[0] + A[1], A[0] + A[2]); answer = Math.Min(answer, A[1] + A[2]); Console.WriteLine(answer); } } }
[["-", 0, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 16, 12, 204, 206, 207, 0, 28, 0, 203]]
8
175
2
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Numerics; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using static System.Math; using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute; using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions; public static class P { public static void Main() { Console.WriteLine(Console.ReadLine() .Split() .Select(int.Parse) .OrderBy(x => x) .Skip(1) .Sum()); } }
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Numerics; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using static System.Math; using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute; using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions; public static class P { public static void Main() { Console.WriteLine(Console.ReadLine() .Split() .Select(int.Parse) .OrderBy(x => x) .Take(2) .Sum()); } }
[["-", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["-", 63, 214, 205, 213, 3, 4, 0, 28, 0, 203], ["+", 63, 214, 205, 213, 3, 4, 0, 28, 0, 203]]
8
134
4
using System; class Program { static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); int a = int.Parse(input[0]); int b = int.Parse(input[1]); int c = int.Parse(input[2]); if (a > b) Swap(a, b); if (b > c) Swap(b, c); Console.WriteLine("{0}", a + b); } static void Swap(int a, int b) { int tmp = a; a = b; b = tmp; } }
using System; class Program { static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); int a = int.Parse(input[0]); int b = int.Parse(input[1]); int c = int.Parse(input[2]); if (a > b) Swap(ref a, ref b); if (b > c) Swap(ref b, ref c); Console.WriteLine("{0}", a + b); } static void Swap(ref int a, ref int b) { int tmp = a; a = b; b = tmp; } }
[["+", 64, 1, 0, 213, 3, 4, 0, 28, 0, 275], ["+", 8, 201, 0, 195, 54, 55, 0, 220, 0, 276]]
8
139
6
using System; using System.Collections.Generic; using System.Linq; using System.Text; class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); string str = Console.ReadLine(); int hidariSUu = 0; for (int i = 0; i < str.Length; i++) { if (str[i] == '(') { } else { if (hidariSUu == 0) { Console.Write("("); } else { hidariSUu--; } } } Console.Write(str); for (hidariSUu = hidariSUu; hidariSUu > 0; hidariSUu--) { Console.Write(")"); } Console.WriteLine(); Console.ReadLine(); } public static Boolean uso() { return false; } public static long gcd(long a, long b) { while (true) { if (a == 0) { return b; } if (b == 0) { return a; } if (a > b) { a -= b; } else { b -= a; } } } public static long lcm(long a, long b) { return a * b / gcd(a, b); } public static bool IsPrime(long n) { if (n < 2) return false; if (n == 2) return true; for (long i = 2; i < n; i++) { if (n % i == 0) return false; } return true; } } public static class Read { public static void outl(string n = "") { Console.WriteLine(n); return; } public static long Long() { return long.Parse(Console.ReadLine()); } public static long[] longs() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); } public static string Str() { return Console.ReadLine(); } public static string[] Strs() { return Console.ReadLine().Split(); } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); string str = Console.ReadLine(); int hidariSUu = 0; for (int i = 0; i < str.Length; i++) { if (str[i] == '(') { hidariSUu++; } else { if (hidariSUu == 0) { Console.Write("("); } else { hidariSUu--; } } } Console.Write(str); for (hidariSUu = hidariSUu; hidariSUu > 0; hidariSUu--) { Console.Write(")"); } Console.WriteLine(); Console.ReadLine(); } public static Boolean uso() { return false; } public static long gcd(long a, long b) { while (true) { if (a == 0) { return b; } if (b == 0) { return a; } if (a > b) { a -= b; } else { b -= a; } } } public static long lcm(long a, long b) { return a * b / gcd(a, b); } public static bool IsPrime(long n) { if (n < 2) return false; if (n == 2) return true; for (long i = 2; i < n; i++) { if (n % i == 0) return false; } return true; } } public static class Read { public static void outl(string n = "") { Console.WriteLine(n); return; } public static long Long() { return long.Parse(Console.ReadLine()); } public static long[] longs() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); } public static string Str() { return Console.ReadLine(); } public static string[] Strs() { return Console.ReadLine().Split(); } }
[["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 29], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35]]
8
433
3
using System; using System.Collections.Generic; class Program { static string InputPattern = "InputX"; static List<string> GetInputList() { var WillReturn = new List<string>(); if (InputPattern == "Input1") { WillReturn.Add("3"); WillReturn.Add("())"); //(()) } else if (InputPattern == "Input2") { WillReturn.Add("6"); WillReturn.Add(")))())"); //(((()))()) } else if (InputPattern == "Input3") { WillReturn.Add("8"); WillReturn.Add("))))(((("); //(((())))(((()))) } else { string wkStr; while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr); } return WillReturn; } static void Main() { List<string> InputList = GetInputList(); string S = InputList[1]; int PutFirst = 0; int StackCnt = 0; foreach (char EachChar in S) { if (EachChar == '(') { StackCnt++; } if (EachChar == ')') { if (StackCnt == 0) PutFirst++; } } var Answer = new System.Text.StringBuilder(); if (PutFirst > 0) Answer.Append(new string('(', PutFirst)); Answer.Append(S); if (StackCnt > 0) Answer.Append(new string('(', StackCnt)); Console.WriteLine(Answer.ToString()); } }
using System; using System.Collections.Generic; class Program { static string InputPattern = "InputX"; static List<string> GetInputList() { var WillReturn = new List<string>(); if (InputPattern == "Input1") { WillReturn.Add("3"); WillReturn.Add("())"); //(()) } else if (InputPattern == "Input2") { WillReturn.Add("6"); WillReturn.Add(")))())"); //(((()))()) } else if (InputPattern == "Input3") { WillReturn.Add("8"); WillReturn.Add("))))(((("); //(((())))(((()))) } else { string wkStr; while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr); } return WillReturn; } static void Main() { List<string> InputList = GetInputList(); string S = InputList[1]; int PutFirst = 0; int StackCnt = 0; foreach (char EachChar in S) { if (EachChar == '(') { StackCnt++; } if (EachChar == ')') { if (StackCnt == 0) PutFirst++; else StackCnt--; } } var Answer = new System.Text.StringBuilder(); if (PutFirst > 0) Answer.Append(new string('(', PutFirst)); Answer.Append(S); if (StackCnt > 0) Answer.Append(new string(')', StackCnt)); Console.WriteLine(Answer.ToString()); } }
[["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 95], ["+", 64, 196, 0, 57, 75, 1, 0, 223, 0, 22], ["+", 64, 196, 0, 57, 75, 1, 0, 223, 0, 68], ["+", 0, 57, 64, 196, 0, 57, 75, 1, 0, 35], ["-", 0, 230, 3, 4, 0, 28, 0, 252, 0, 253], ["+", 0, 230, 3, 4, 0, 28, 0, 252, 0, 253]]
8
310
6
using System; using System.IO; using System.Collections.Generic; using System.Linq; using System.Numerics; namespace AtCoder.Contest.A { static class Program { public static void Solve(Scanner cin) { var x = cin.ReadIntArray(2).Sum(); Console.WriteLine((x >= 10) ? "Error" : x.ToString()); } public static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); var cin = new Scanner(); Solve(cin); Console.Out.Flush(); } public static void YESNO(bool condition) { if (condition) Console.WriteLine("YES"); else Console.WriteLine("NO"); } public static void YesNo(bool condition) { if (condition) Console.WriteLine("Yes"); else Console.WriteLine("No"); } public static void yesno(bool condition) { if (condition) Console.WriteLine("yes"); else Console.WriteLine("no"); } } class Scanner { string[] s; int i; char[] separator = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string Read() => ReadString(); public string ReadString() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(separator, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return ReadString(); i = 0; return s[i++]; } public string[] ReadStringArray(int N) { string[] Array = new string[N]; for (int i = 0; i < N; i++) { Array[i] = ReadString(); } return Array; } public int ReadInt() { return int.Parse(ReadString()); } public int[] ReadIntArray(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = ReadInt() + add; } return Array; } public long ReadLong() { return long.Parse(ReadString()); } public long[] ReadLongArray(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = ReadLong() + add; } return Array; } public double ReadDouble() { return double.Parse(ReadString()); } public double[] ReadDoubleArray(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = ReadDouble() + add; } return Array; } public T1 ReadValue<T1>() => (T1)Convert.ChangeType(ReadString(), typeof(T1)); public (T1, T2) ReadValue<T1, T2>() { var inputs = ReadStringArray(2); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); return (v1, v2); } public (T1, T2, T3) ReadValue<T1, T2, T3>() { var inputs = ReadStringArray(3); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); return (v1, v2, v3); } public (T1, T2, T3, T4) ReadValue<T1, T2, T3, T4>() { var inputs = ReadStringArray(4); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4)); return (v1, v2, v3, v4); } public (T1, T2, T3, T4, T5) ReadValue<T1, T2, T3, T4, T5>() { var inputs = ReadStringArray(5); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4)); var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5)); return (v1, v2, v3, v4, v5); } public (T1, T2, T3, T4, T5, T6) ReadValue<T1, T2, T3, T4, T5, T6>() { var inputs = ReadStringArray(6); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4)); var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5)); var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6)); return (v1, v2, v3, v4, v5, v6); } public (T1, T2, T3, T4, T5, T6, T7) ReadValue<T1, T2, T3, T4, T5, T6, T7>() { var inputs = ReadStringArray(7); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4)); var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5)); var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6)); var v7 = (T7)Convert.ChangeType(inputs[6], typeof(T7)); return (v1, v2, v3, v4, v5, v6, v7); } public T1[] ReadValueArray<T1>(int N) { var v1 = new T1[N]; for (int i = 0; i < N; i++) { v1[i] = ReadValue<T1>(); } return v1; } public (T1[], T2[]) ReadValueArray<T1, T2>(int N) { var (v1, v2) = (new T1[N], new T2[N]); for (int i = 0; i < N; i++) { var (t1, t2) = ReadValue<T1, T2>(); v1[i] = t1; v2[i] = t2; } return (v1, v2); } public (T1[], T2[], T3[]) ReadValueArray<T1, T2, T3>(int N) { var (v1, v2, v3) = (new T1[N], new T2[N], new T3[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3) = ReadValue<T1, T2, T3>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; } return (v1, v2, v3); } public (T1[], T2[], T3[], T4[]) ReadValueArray<T1, T2, T3, T4>(int N) { var (v1, v2, v3, v4) = (new T1[N], new T2[N], new T3[N], new T4[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3, t4) = ReadValue<T1, T2, T3, T4>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; v4[i] = t4; } return (v1, v2, v3, v4); } public (T1[], T2[], T3[], T4[], T5[]) ReadValueArray<T1, T2, T3, T4, T5>(int N) { var (v1, v2, v3, v4, v5) = (new T1[N], new T2[N], new T3[N], new T4[N], new T5[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3, t4, t5) = ReadValue<T1, T2, T3, T4, T5>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; v4[i] = t4; v5[i] = t5; } return (v1, v2, v3, v4, v5); } public (T1[], T2[], T3[], T4[], T5[], T6[]) ReadValueArray<T1, T2, T3, T4, T5, T6>(int N) { var (v1, v2, v3, v4, v5, v6) = (new T1[N], new T2[N], new T3[N], new T4[N], new T5[N], new T6[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3, t4, t5, t6) = ReadValue<T1, T2, T3, T4, T5, T6>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; v4[i] = t4; v5[i] = t5; v6[i] = t6; } return (v1, v2, v3, v4, v5, v6); } public (T1[], T2[], T3[], T4[], T5[], T6[], T7[]) ReadValueArray<T1, T2, T3, T4, T5, T6, T7>(int N) { var (v1, v2, v3, v4, v5, v6, v7) = (new T1[N], new T2[N], new T3[N], new T4[N], new T5[N], new T6[N], new T7[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3, t4, t5, t6, t7) = ReadValue<T1, T2, T3, T4, T5, T6, T7>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; v4[i] = t4; v5[i] = t5; v6[i] = t6; v7[i] = t7; } return (v1, v2, v3, v4, v5, v6, v7); } } }
using System; using System.IO; using System.Collections.Generic; using System.Linq; using System.Numerics; namespace AtCoder.Contest.A { static class Program { public static void Solve(Scanner cin) { var x = cin.ReadIntArray(2).Sum(); Console.WriteLine((x >= 10) ? "error" : x.ToString()); } public static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); var cin = new Scanner(); Solve(cin); Console.Out.Flush(); } public static void YESNO(bool condition) { if (condition) Console.WriteLine("YES"); else Console.WriteLine("NO"); } public static void YesNo(bool condition) { if (condition) Console.WriteLine("Yes"); else Console.WriteLine("No"); } public static void yesno(bool condition) { if (condition) Console.WriteLine("yes"); else Console.WriteLine("no"); } } class Scanner { string[] s; int i; char[] separator = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string Read() => ReadString(); public string ReadString() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(separator, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return ReadString(); i = 0; return s[i++]; } public string[] ReadStringArray(int N) { string[] Array = new string[N]; for (int i = 0; i < N; i++) { Array[i] = ReadString(); } return Array; } public int ReadInt() { return int.Parse(ReadString()); } public int[] ReadIntArray(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = ReadInt() + add; } return Array; } public long ReadLong() { return long.Parse(ReadString()); } public long[] ReadLongArray(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = ReadLong() + add; } return Array; } public double ReadDouble() { return double.Parse(ReadString()); } public double[] ReadDoubleArray(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = ReadDouble() + add; } return Array; } public T1 ReadValue<T1>() => (T1)Convert.ChangeType(ReadString(), typeof(T1)); public (T1, T2) ReadValue<T1, T2>() { var inputs = ReadStringArray(2); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); return (v1, v2); } public (T1, T2, T3) ReadValue<T1, T2, T3>() { var inputs = ReadStringArray(3); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); return (v1, v2, v3); } public (T1, T2, T3, T4) ReadValue<T1, T2, T3, T4>() { var inputs = ReadStringArray(4); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4)); return (v1, v2, v3, v4); } public (T1, T2, T3, T4, T5) ReadValue<T1, T2, T3, T4, T5>() { var inputs = ReadStringArray(5); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4)); var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5)); return (v1, v2, v3, v4, v5); } public (T1, T2, T3, T4, T5, T6) ReadValue<T1, T2, T3, T4, T5, T6>() { var inputs = ReadStringArray(6); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4)); var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5)); var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6)); return (v1, v2, v3, v4, v5, v6); } public (T1, T2, T3, T4, T5, T6, T7) ReadValue<T1, T2, T3, T4, T5, T6, T7>() { var inputs = ReadStringArray(7); var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1)); var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2)); var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3)); var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4)); var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5)); var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6)); var v7 = (T7)Convert.ChangeType(inputs[6], typeof(T7)); return (v1, v2, v3, v4, v5, v6, v7); } public T1[] ReadValueArray<T1>(int N) { var v1 = new T1[N]; for (int i = 0; i < N; i++) { v1[i] = ReadValue<T1>(); } return v1; } public (T1[], T2[]) ReadValueArray<T1, T2>(int N) { var (v1, v2) = (new T1[N], new T2[N]); for (int i = 0; i < N; i++) { var (t1, t2) = ReadValue<T1, T2>(); v1[i] = t1; v2[i] = t2; } return (v1, v2); } public (T1[], T2[], T3[]) ReadValueArray<T1, T2, T3>(int N) { var (v1, v2, v3) = (new T1[N], new T2[N], new T3[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3) = ReadValue<T1, T2, T3>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; } return (v1, v2, v3); } public (T1[], T2[], T3[], T4[]) ReadValueArray<T1, T2, T3, T4>(int N) { var (v1, v2, v3, v4) = (new T1[N], new T2[N], new T3[N], new T4[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3, t4) = ReadValue<T1, T2, T3, T4>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; v4[i] = t4; } return (v1, v2, v3, v4); } public (T1[], T2[], T3[], T4[], T5[]) ReadValueArray<T1, T2, T3, T4, T5>(int N) { var (v1, v2, v3, v4, v5) = (new T1[N], new T2[N], new T3[N], new T4[N], new T5[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3, t4, t5) = ReadValue<T1, T2, T3, T4, T5>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; v4[i] = t4; v5[i] = t5; } return (v1, v2, v3, v4, v5); } public (T1[], T2[], T3[], T4[], T5[], T6[]) ReadValueArray<T1, T2, T3, T4, T5, T6>(int N) { var (v1, v2, v3, v4, v5, v6) = (new T1[N], new T2[N], new T3[N], new T4[N], new T5[N], new T6[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3, t4, t5, t6) = ReadValue<T1, T2, T3, T4, T5, T6>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; v4[i] = t4; v5[i] = t5; v6[i] = t6; } return (v1, v2, v3, v4, v5, v6); } public (T1[], T2[], T3[], T4[], T5[], T6[], T7[]) ReadValueArray<T1, T2, T3, T4, T5, T6, T7>(int N) { var (v1, v2, v3, v4, v5, v6, v7) = (new T1[N], new T2[N], new T3[N], new T4[N], new T5[N], new T6[N], new T7[N]); for (int i = 0; i < N; i++) { var (t1, t2, t3, t4, t5, t6, t7) = ReadValue<T1, T2, T3, T4, T5, T6, T7>(); v1[i] = t1; v2[i] = t2; v3[i] = t3; v4[i] = t4; v5[i] = t5; v6[i] = t6; v7[i] = t7; } return (v1, v2, v3, v4, v5, v6, v7); } } }
[["-", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222]]
8
2,554
2
using System; using System.Collections.Generic; using System.Linq; using static System.Math; class AtCoder { public static void Main() { var input = Console.ReadLine().Split(); int a = int.Parse(input[0]); int b = int.Parse(input[1]); if (a + b >= 10) { Console.WriteLine("error"); } Console.WriteLine(a + b); } }
using System; using System.Collections.Generic; using System.Linq; using static System.Math; class AtCoder { public static void Main() { var input = Console.ReadLine().Split(); int a = int.Parse(input[0]); int b = int.Parse(input[1]); if (a + b >= 10) { Console.WriteLine("error"); } else { Console.WriteLine(a + b); } } }
[["+", 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
100
3
using System; namespace ABC_063_A_Csharp_ver { class Program { static void Main(string[] args) { var word = Console.ReadLine().Split(' '); int A = int.Parse(word[0]); int B = int.Parse(word[1]); if (A + B > 10) { Console.WriteLine("error"); } else { Console.WriteLine(A + B); } Console.ReadLine(); } } }
using System; namespace ABC_063_A_Csharp_ver { class Program { static void Main(string[] args) { var word = Console.ReadLine().Split(' '); int A = int.Parse(word[0]); int B = int.Parse(word[1]); if (A + B >= 10) { Console.WriteLine("error"); } else { Console.WriteLine(A + B); } Console.ReadLine(); } } }
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 20]]
8
101
2
using System; namespace abc063A { class MainClass { public static void Main(string[] args) { string[] str = Console.ReadLine().Split(); int A = int.Parse(str[0]); int B = int.Parse(str[1]); if (A + B > 10) Console.WriteLine("error"); else Console.WriteLine(A + B); } } }
using System; namespace abc063A { class MainClass { public static void Main(string[] args) { string[] str = Console.ReadLine().Split(); int A = int.Parse(str[0]); int B = int.Parse(str[1]); if (A + B >= 10) Console.WriteLine("error"); else Console.WriteLine(A + B); } } }
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 20]]
8
91
2
using System; namespace ABC063Ax { class Program { static void Main(string[] args) { int a, b; var word = Console.ReadLine().Split(' '); a = int.Parse(word[0]); b = int.Parse(word[1]); if (a + b <= 10) Console.WriteLine(a + b); if (a + b >= 10 || a + b == 10) Console.WriteLine("error"); Console.ReadKey(); } } }
using System; namespace ABC063Ax { class Program { static void Main(string[] args) { int a, b; var word = Console.ReadLine().Split(' '); a = int.Parse(word[0]); b = int.Parse(word[1]); if (a + b < 10) Console.WriteLine(a + b); if (a + b >= 10 || a + b == 10) Console.WriteLine("error"); Console.ReadKey(); } } }
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 19], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18]]
8
113
2
using System; class p { static void Main() { string[] input = Console.ReadLine().Split(' '); int n = int.Parse(input[0]) * int.Parse(input[1]); Console.WriteLine(n < 10 ? n.ToString() : "error"); } }
using System; class p { static void Main() { string[] input = Console.ReadLine().Split(' '); int n = int.Parse(input[0]) + int.Parse(input[1]); Console.WriteLine(n < 10 ? n.ToString() : "error"); } }
[["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 48], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72]]
8
74
2
using System; using System.Linq; class prog { static void Main() { int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray(); Console.WriteLine(n[0] + n[1] < 10 ? "" + n[0] + n[1] : "error"); } }
using System; using System.Linq; class prog { static void Main() { int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray(); Console.WriteLine(n[0] + n[1] < 10 ? "" + (n[0] + n[1]) : "error"); } }
[["+", 0, 28, 0, 41, 64, 16, 12, 23, 0, 24], ["+", 0, 28, 0, 41, 64, 16, 12, 23, 0, 25]]
8
79
2
using System; using System.Linq; namespace abc063_a { class Program { static void Main(string[] args) { int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray(); a[0] += a[1]; if (a[0] > 10) { Console.WriteLine("error"); } else { Console.WriteLine(a[0]); } } } }
using System; using System.Linq; namespace abc063_a { class Program { static void Main(string[] args) { int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray(); a[0] += a[1]; if (a[0] >= 10) { Console.WriteLine("error"); } else { Console.WriteLine(a[0]); } } } }
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 20]]
8
96
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Console = System.Console; namespace Atcoder { class Program { static void Main(string[] args) { var S = Read(); string str = string.Empty; foreach (var s in S) { if (str.Contains(s)) { Console.WriteLine("no"); return; } str += s.ToString(); } Console.WriteLine("Yes"); } public static readonly Func<string> Read = () => Console.ReadLine(); public static readonly Func<string[]> ReadStringArray = () => Console.ReadLine().Split(); public static readonly Func<int[]> ReadIntArray = () => Console.ReadLine().Split().Select(int.Parse).ToArray(); public static readonly Func<long[]> ReadLongArray = () => Console.ReadLine().Split().Select(long.Parse).ToArray(); } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Console = System.Console; namespace Atcoder { class Program { static void Main(string[] args) { var S = Read(); string str = string.Empty; foreach (var s in S) { if (str.Contains(s)) { Console.WriteLine("no"); return; } str += s.ToString(); } Console.WriteLine("yes"); } public static readonly Func<string> Read = () => Console.ReadLine(); public static readonly Func<string[]> ReadStringArray = () => Console.ReadLine().Split(); public static readonly Func<int[]> ReadIntArray = () => Console.ReadLine().Split().Select(int.Parse).ToArray(); public static readonly Func<long[]> ReadLongArray = () => Console.ReadLine().Split().Select(long.Parse).ToArray(); } }
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
8
220
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp69 { class Program { static void Main(string[] args) { string S = Console.ReadLine(); char[] S_ = S.ToCharArray(); Console.WriteLine(S_.Count() == S_.Distinct().Count() ? "Yes" : "No"); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp69 { class Program { static void Main(string[] args) { string S = Console.ReadLine(); char[] S_ = S.ToCharArray(); Console.WriteLine(S_.Count() == S_.Distinct().Count() ? "yes" : "no"); } } }
[["-", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["-", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222]]
8
95
4