buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
change_count
int64
0
100
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder176 { class Program { static void Main(string[] args) { QB(); } static void QA() { string line = Console.ReadLine(); string[] splited = line.Split(' '); int N = int.Parse(splited[0]); int X = int.Parse(splited[1]); int T = int.Parse(splited[2]); Console.WriteLine(Math.Ceiling((double)N / X) * T); } static void QB() { string line = Console.ReadLine(); long l = 0; foreach (char c in line) { l += short.Parse(c.ToString()); } Console.WriteLine((l % 9 == 0) ? "YES" : "NO"); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder176 { class Program { static void Main(string[] args) { QB(); } static void QA() { string line = Console.ReadLine(); string[] splited = line.Split(' '); int N = int.Parse(splited[0]); int X = int.Parse(splited[1]); int T = int.Parse(splited[2]); Console.WriteLine(Math.Ceiling((double)N / X) * T); } static void QB() { string line = Console.ReadLine(); long l = 0; foreach (char c in line) { l += short.Parse(c.ToString()); } Console.WriteLine((l % 9 == 0) ? "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
202
4
using System; using System.Collections.Generic; using System.Linq; using static System.Console; using static System.Math; namespace B_ABC176 { class MainClass { // static int[] s; public static void Main(string[] args) { // s = ReadLine(); var sstr = ReadLine(); var ans = 0; for (int i = 0; i < sstr.Length; i++) { if (sstr.Length == 1) { int u = int.Parse(sstr); ans += u; ans = ans % 9; } else { ans += sstr[i]; ans = ans % 9; } } if (ans == 0 || ans == 9) { WriteLine("Yes"); } else { WriteLine("No"); } // WriteLine(ans); // if(s[0]%9==0){ // WriteLine("Yes"); // }else{ // WriteLine("No"); // } } public static int LowerBound<T>(T[] a, T v) { return LowerBound(a, v, Comparer<T>.Default); } public static int LowerBound<T>(T[] a, T v, Comparer<T> cmp) { var l = 0; var r = a.Length - 1; while (l <= r) { var mid = l + (r - l) / 2; var res = cmp.Compare(a[mid], v); if (res == -1) l = mid + 1; else r = mid - 1; } return l; } public static int UpperBound<T>(T[] a, T v) { return UpperBound(a, v, Comparer<T>.Default); } public static int UpperBound<T>(T[] a, T v, Comparer<T> cmp) { var l = 0; var r = a.Length - 1; while (l <= r) { var mid = l + (r - l) / 2; var res = cmp.Compare(a[mid], v); if (res <= 0) l = mid + 1; else r = mid - 1; } return l; } } }
using System; using System.Collections.Generic; using System.Linq; using static System.Console; using static System.Math; namespace B_ABC176 { class MainClass { // static int[] s; public static void Main(string[] args) { // s = ReadLine(); var sstr = ReadLine(); var ans = 0; for (int i = 0; i < sstr.Length; i++) { if (sstr.Length == 1) { int u = int.Parse(sstr); ans += u; ans = ans % 9; } else { ans += sstr[i] - '0'; ans = ans % 9; } } if (ans == 0 || ans == 9) { WriteLine("Yes"); } else { WriteLine("No"); } // WriteLine(ans); // if(s[0]%9==0){ // WriteLine("Yes"); // }else{ // WriteLine("No"); // } } public static int LowerBound<T>(T[] a, T v) { return LowerBound(a, v, Comparer<T>.Default); } public static int LowerBound<T>(T[] a, T v, Comparer<T> cmp) { var l = 0; var r = a.Length - 1; while (l <= r) { var mid = l + (r - l) / 2; var res = cmp.Compare(a[mid], v); if (res == -1) l = mid + 1; else r = mid - 1; } return l; } public static int UpperBound<T>(T[] a, T v) { return UpperBound(a, v, Comparer<T>.Default); } public static int UpperBound<T>(T[] a, T v, Comparer<T> cmp) { var l = 0; var r = a.Length - 1; while (l <= r) { var mid = l + (r - l) / 2; var res = cmp.Compare(a[mid], v); if (res <= 0) l = mid + 1; else r = mid - 1; } return l; } } }
[["+", 75, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 0, 1, 0, 11, 12, 16, 12, 252, 0, 104], ["+", 0, 1, 0, 11, 12, 16, 12, 252, 0, 253]]
8
419
4
using System; using System.ComponentModel; namespace Constest { class Program { static void Main(string[] args) { string cnt = Console.ReadLine(); string line = Console.ReadLine(); string[] stArrayData = line.Split(' '); int inc = 0; int max = 0; int sum = 0; foreach (string s in stArrayData) { int i = int.Parse(s); if (max < i) { max = i; } sum += (max - i); inc++; if (int.Parse(cnt) <= inc) { break; } } Console.WriteLine(sum); } } }
using System; using System.ComponentModel; namespace Constest { class Program { static void Main(string[] args) { string cnt = Console.ReadLine(); string line = Console.ReadLine(); string[] stArrayData = line.Split(' '); long inc = 0; long max = 0; long sum = 0; foreach (string s in stArrayData) { int i = int.Parse(s); if (max < i) { max = i; } sum += (max - i); inc++; if (int.Parse(cnt) <= inc) { break; } } Console.WriteLine(sum); } } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
8
138
6
using System; using System.Linq; namespace abc176.c { class Program { static void Main(string[] args) { int num = getIntParam(); int[] paramArray = getIntParams(); int adjust = 0; int level = paramArray[0]; for (int c = 1; c < num; c++) { if (paramArray[c] < level) { adjust += (level - paramArray[c]); } else if (paramArray[c] > level) { level = paramArray[c]; } } Console.WriteLine(adjust); } //↓↓↓ shared function ↓↓↓ static int getIntParam() { return int.Parse(Console.ReadLine()); } static int[] getIntParams() { return Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray(); } static long getLongParam() { return long.Parse(Console.ReadLine()); } static long[] getLongParams() { return Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray(); } static string getStringParam() { return Console.ReadLine(); } static string[] getStringParams() { return Console.ReadLine().Split(' '); } } }
using System; using System.Linq; namespace abc176.c { class Program { static void Main(string[] args) { int num = getIntParam(); long[] paramArray = getLongParams(); long adjust = 0; long level = paramArray[0]; for (int c = 1; c < num; c++) { if (paramArray[c] < level) { adjust += (level - paramArray[c]); } else if (paramArray[c] > level) { level = paramArray[c]; } } Console.WriteLine(adjust); } //↓↓↓ shared function ↓↓↓ static int getIntParam() { return int.Parse(Console.ReadLine()); } static int[] getIntParams() { return Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray(); } static long getLongParam() { return long.Parse(Console.ReadLine()); } static long[] getLongParams() { return Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray(); } static string getStringParam() { return Console.ReadLine(); } static string[] getStringParams() { return Console.ReadLine().Split(' '); } } }
[["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 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, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
8
276
8
using System; class Program { static void Main() { string N = Console.ReadLine(); string A = Console.ReadLine(); string[] a = (A.Split(' ')); int[] an = new int[Convert.ToInt32(N)]; int count = 0; for (int i = 0; i < Convert.ToInt32(N); i++) { an[i] = Convert.ToInt32(a[i]); } for (int i = 0; i < Convert.ToInt32(N) - 1; i++) { if (an[i] > an[i + 1]) { count += an[i] - an[i + 1]; an[i + 1] = an[i]; } } Console.WriteLine(count); } }
using System; class Program { static void Main() { string N = Console.ReadLine(); string A = Console.ReadLine(); string[] a = (A.Split(' ')); double[] an = new double[Convert.ToInt32(N)]; double count = 0; for (int i = 0; i < Convert.ToDouble(N); i++) { an[i] = Convert.ToInt32(a[i]); } for (int i = 0; i < Convert.ToDouble(N) - 1; i++) { if (an[i] > an[i + 1]) { count += an[i] - an[i + 1]; an[i + 1] = an[i]; } } Console.WriteLine(count); } }
[["-", 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, 7, 15, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 7, 15, 16, 12, 213, 63, 214, 141, 22], ["-", 15, 16, 12, 16, 31, 213, 63, 214, 141, 22], ["+", 15, 16, 12, 16, 31, 213, 63, 214, 141, 22]]
8
177
10
using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.Design; using System.IO.Compression; using System.Linq; using System.Numerics; using System.Runtime.CompilerServices; using System.Text; using System.Text.RegularExpressions; using Console = System.Console; namespace Atcoder { class Program { private const long COMDIV = 1000000007; static void Main(string[] args) { var N = int.Parse(Console.ReadLine()); int sum = 0; var As = Console.ReadLine().Split().Select(int.Parse).ToArray(); for (int i = 1; i < N; i++) { var pre = As[i - 1]; var current = As[i]; if (pre > current) { var dif = pre - current; sum += dif; As[i] += dif; } } Console.WriteLine(sum); } } }
using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.Design; using System.IO.Compression; using System.Linq; using System.Numerics; using System.Runtime.CompilerServices; using System.Text; using System.Text.RegularExpressions; using Console = System.Console; namespace Atcoder { class Program { private const long COMDIV = 1000000007; static void Main(string[] args) { var N = int.Parse(Console.ReadLine()); long sum = 0; var As = Console.ReadLine().Split().Select(int.Parse).ToArray(); for (int i = 1; i < N; i++) { var pre = As[i - 1]; var current = As[i]; if (pre > current) { var dif = pre - current; sum += dif; As[i] += dif; } } Console.WriteLine(sum); } } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
8
206
2
using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Net.WebSockets; class Test { // Driver code public static void Main() { /// var t = int.Parse(Console.ReadLine()); // while (t > 0) { // t--; var ii = Console.ReadLine() .Split(' ') .Where(xx => !string.IsNullOrEmpty(xx)) .Select(xx => int.Parse(xx)) .ToArray(); var n = ii[0]; // var x = ii[1]; // var tt = ii[2]; var arr = Console.ReadLine() .Split(' ') .Where(x => !string.IsNullOrEmpty(x)) .Select(xx => int.Parse(xx)) .ToList(); int ans = 0; for (int i = 1; i < n; i++) { if (arr[i] < arr[i - 1]) { ans = ans + arr[i - 1] - arr[i]; arr[i] = arr[i] + (arr[i - 1] - arr[i]); } } Console.Write(ans); Console.WriteLine(); } } }
using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Net.WebSockets; class Test { // Driver code public static void Main() { /// var t = int.Parse(Console.ReadLine()); // while (t > 0) { // t--; var ii = Console.ReadLine() .Split(' ') .Where(xx => !string.IsNullOrEmpty(xx)) .Select(xx => int.Parse(xx)) .ToArray(); var n = ii[0]; // var x = ii[1]; // var tt = ii[2]; var arr = Console.ReadLine() .Split(' ') .Where(x => !string.IsNullOrEmpty(x)) .Select(xx => long.Parse(xx)) .ToList(); long ans = 0; for (int i = 1; i < n; i++) { if (arr[i] < arr[i - 1]) { ans = ans + arr[i - 1] - arr[i]; arr[i] = arr[i] + (arr[i - 1] - arr[i]); } } Console.Write(ans); Console.WriteLine(); } } }
[["-", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["+", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["-", 8, 196, 0, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 196, 0, 197, 0, 198, 39, 199]]
8
237
4
using System; using System.Collections.Generic; using System.Linq; namespace ConsoleApp { class Program { static void Main(string[] args) { var N = int.Parse(Console.ReadLine()); var A = Console.ReadLine().Split().Select(int.Parse).ToArray(); var height = A[0]; var ans = 0; foreach (var i in A) { ans += Math.Max(height - i, 0); height = Math.Max(height, i); } Console.WriteLine(ans); } } }
using System; using System.Collections.Generic; using System.Linq; namespace ConsoleApp { class Program { static void Main(string[] args) { var N = int.Parse(Console.ReadLine()); var A = Console.ReadLine().Split().Select(double.Parse).ToArray(); var height = A[0]; var ans = 0.0; foreach (var i in A) { ans += Math.Max(height - i, 0); height = Math.Max(height, i); } Console.WriteLine(ans); } } }
[["-", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 250]]
8
125
4
using System; using System.IO; class Program { static void Main(string[] args) { var scan = new Scanner(); var writer = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(writer); Console.WriteLine(Solve(scan)); Console.Out.Flush(); } static int Solve(Scanner scan) { var N = scan.NextInt(); var A = scan.ArrayInt(N); var len = A.Length; var temp = 0; var sum = 0; for (int i = 0; i < len; i++) { if (temp < A[i]) temp = A[i]; else sum += temp - A[i]; } return sum; } } class Scanner { string[] s; int i; public Scanner() { s = new string[0]; i = 0; } public string Next() { if (i < s.Length) return s[i++]; string str = Console.ReadLine(); while (str == "") str = Console.ReadLine(); s = str.Split(' ', StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return Next(); i = 0; return s[i++]; } public int NextInt() => int.Parse(Next()); public int[] ArrayInt(int len, int add = 0) { var array = new int[len]; for (int i = 0; i < len; i++) array[i] = NextInt() + add; return array; } }
using System; using System.IO; class Program { static void Main(string[] args) { var scan = new Scanner(); var writer = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(writer); Console.WriteLine(Solve(scan)); Console.Out.Flush(); } static long Solve(Scanner scan) { var N = scan.NextInt(); var A = scan.ArrayInt(N); var len = A.Length; var temp = 0; long sum = 0; for (int i = 0; i < len; i++) { if (temp < A[i]) temp = A[i]; else sum += temp - A[i]; } return sum; } } class Scanner { string[] s; int i; public Scanner() { s = new string[0]; i = 0; } public string Next() { if (i < s.Length) return s[i++]; string str = Console.ReadLine(); while (str == "") str = Console.ReadLine(); s = str.Split(' ', StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return Next(); i = 0; return s[i++]; } public int NextInt() => int.Parse(Next()); public int[] ArrayInt(int len, int add = 0) { var array = new int[len]; for (int i = 0; i < len; i++) array[i] = NextInt() + add; return array; } }
[["-", 0, 208, 0, 235, 8, 201, 0, 195, 39, 199], ["+", 0, 208, 0, 235, 8, 201, 0, 195, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
8
347
4
using System; using System.Linq; class Solution { static int almostSorted(int[] arr) { var minHeigth = 0; var prevH = arr[0]; for (var i = 1; i < arr.Length; i++) { if (arr[i] < prevH) { minHeigth += prevH - arr[i]; } else { prevH = arr[i]; } } return minHeigth; } static void Main(string[] args) { var n = Console.ReadLine(); var arr = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); var result = almostSorted(arr); // var a = almostSorted(new[] { 10, 3 }); Console.WriteLine(result); } }
using System; using System.Linq; class Solution { static long almostSorted(int[] arr) { var minHeigth = 0l; var prevH = arr[0]; for (var i = 1; i < arr.Length; i++) { if (arr[i] < prevH) { minHeigth += prevH - arr[i]; } else { prevH = arr[i]; } } return minHeigth; } static void Main(string[] args) { var n = Console.ReadLine(); var arr = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); var result = almostSorted(arr); // var a = almostSorted(new[] { 10, 3 }); Console.WriteLine(result); } }
[["-", 0, 208, 0, 235, 8, 201, 0, 195, 39, 199], ["+", 0, 208, 0, 235, 8, 201, 0, 195, 39, 199], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203]]
8
155
4
using System; using System.Collections; using System.Collections.Generic; using System.Linq; namespace atcoder { public class Program { public static void Main(string[] args) { var buffer = Console.ReadLine().Split(); var N = int.Parse(buffer[0]); var ans = 0; var before = -1; foreach (var v in Console.ReadLine().Split()) { if (before == -1) { before = int.Parse(v); continue; } var tmp = int.Parse(v); var add = 0; if (before > tmp) ans += add = before - tmp; before = tmp + add; } Console.WriteLine(ans); } } }
using System; using System.Collections; using System.Collections.Generic; using System.Linq; namespace atcoder { public class Program { public static void Main(string[] args) { var buffer = Console.ReadLine().Split(); var N = int.Parse(buffer[0]); long ans = 0; long before = -1; foreach (var v in Console.ReadLine().Split()) { if (before == -1) { before = long.Parse(v); continue; } var tmp = long.Parse(v); long add = 0; if (before > tmp) ans += add = before - tmp; before = tmp + add; } Console.WriteLine(ans); } } }
[["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 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, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 0, 210, 8, 196, 0, 197, 0, 198, 39, 199]]
8
157
10
using System; using System.Linq; namespace AtCoder.Contests.Abc176 { public class Step { public static void Main() { Console.ReadLine(); string input2 = Console.ReadLine(); if (String.IsNullOrEmpty(input2)) { return; } var items = input2.Split(' ').Select(x => Int32.Parse(x)); int p = 0; int sum = 0; foreach (var item in items) { if (item < p) { sum += p - item; } else { p = item; } } Console.WriteLine(sum); } } }
using System; using System.Linq; namespace AtCoder.Contests.Abc176 { public class Step { public static void Main() { Console.ReadLine(); string input2 = Console.ReadLine(); if (String.IsNullOrEmpty(input2)) { return; } var items = input2.Split(' ').Select(x => Int32.Parse(x)); int p = 0; long sum = 0; foreach (var item in items) { if (item < p) { sum += p - item; } else { p = item; } } Console.WriteLine(sum); } } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
8
128
2
using System; using System.Linq; using System.Collections.Generic; using System.Numerics; namespace Sample { class Sample { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); string[] str = Console.ReadLine().Split(' '); int[] height = str.Select(int.Parse).ToArray(); // step.CopyTo(height,0); int ans = 0; for (int i = 1; i < N; i++) { if (height[i] < height[i - 1]) { ans += height[i - 1] - height[i]; height[i] = height[i - 1]; // Console.WriteLine(dif[i]); } } Console.WriteLine(ans); } } }
using System; using System.Linq; using System.Collections.Generic; using System.Numerics; namespace Sample { class Sample { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); string[] str = Console.ReadLine().Split(' '); long[] height = str.Select(long.Parse).ToArray(); // step.CopyTo(height,0); long ans = 0; for (int i = 1; i < N; i++) { if (height[i] < height[i - 1]) { ans += height[i - 1] - height[i]; height[i] = height[i - 1]; // Console.WriteLine(dif[i]); } } Console.WriteLine(ans); } } }
[["-", 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, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
8
161
6
using System; class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); string[] input = Console.ReadLine().Split(' '); int[] A = new int[N]; int step = 0; for (int i = 0; i < N; i++) { A[i] = int.Parse(input[i]); if (i > 0) { if (A[i] < A[i - 1]) { step += (A[i - 1] - A[i]); A[i] += (A[i - 1] - A[i]); } } } //出力 Console.WriteLine(step); } }
using System; class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); string[] input = Console.ReadLine().Split(' '); int[] A = new int[N]; long step = 0; for (int i = 0; i < N; i++) { A[i] = int.Parse(input[i]); if (i > 0) { if (A[i] < A[i - 1]) { step += (A[i - 1] - A[i]); A[i] += (A[i - 1] - A[i]); } } } //出力 Console.WriteLine(step); } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
8
164
2
using System; using System.Linq; namespace aaaaaaaaaaaa { class Program { static void Main(string[] args) { Console.ReadLine(); var a = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray(); var mae = 0; var fumidai = 0; for (int i = 0; i < a.Length; i++) { if (a[i] < mae) { fumidai += mae - a[i]; } if (mae < a[i]) { mae = a[i]; } } Console.WriteLine(fumidai); } } }
using System; using System.Linq; namespace aaaaaaaaaaaa { class Program { static void Main(string[] args) { Console.ReadLine(); var a = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray(); var mae = 0; var fumidai = 0l; for (int i = 0; i < a.Length; i++) { if (a[i] < mae) { fumidai += mae - a[i]; } if (mae < a[i]) { mae = a[i]; } } Console.WriteLine(fumidai); } } }
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203]]
8
137
2
using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Linq; using System.Text; class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); string[] input = Console.ReadLine().Split(' '); int[] hight = new int[N]; int count = 0; for (int i = 0; i < N; i++) { hight[i] = int.Parse(input[i]); if (i == 0) continue; if (hight[i - 1] > hight[i]) { int j = hight[i - 1] - hight[i]; hight[i] += j; count += j; } } Console.WriteLine(count); } }
using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Linq; using System.Text; class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); string[] input = Console.ReadLine().Split(' '); int[] hight = new int[N]; long count = 0; for (int i = 0; i < N; i++) { hight[i] = int.Parse(input[i]); if (i == 0) continue; if (hight[i - 1] > hight[i]) { int j = hight[i - 1] - hight[i]; hight[i] += j; count += j; } } Console.WriteLine(count); } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
8
181
2
using System; class Program { static void Main(string[] args) {   int N = int.Parse(Console.ReadLine()); //標準入力 string dd = Console.ReadLine(); string[] A = dd.Split(' '); int[] Ai = new int[A.Length]; int maxshincho = 0; int dai = 0; for (int i = 0; i < A.Length; i++) { Ai[i] = int.Parse(A[i]); } for (int i = 0; i < Ai.Length - 1; i++) { if (maxshincho < Ai[i]) { maxshincho = Ai[i]; } if (maxshincho > Ai[i + 1]) { dai = dai + maxshincho - Ai[i + 1]; } } Console.WriteLine("{0}", dai); } }
using System; class Program { static void Main(string[] args) {   int N = int.Parse(Console.ReadLine()); //標準入力 string dd = Console.ReadLine(); string[] A = dd.Split(' '); int[] Ai = new int[A.Length]; int maxshincho = 0; decimal dai = 0; for (int i = 0; i < A.Length; i++) { Ai[i] = int.Parse(A[i]); } for (int i = 0; i < Ai.Length - 1; i++) { if (maxshincho < Ai[i]) { maxshincho = Ai[i]; } if (maxshincho > Ai[i + 1]) { dai = dai + (decimal)(maxshincho - Ai[i + 1]); } } Console.WriteLine("{0}", dai); } }
[["-", 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, 16, 12, 74, 0, 24], ["+", 0, 1, 0, 11, 12, 16, 12, 74, 39, 199], ["+", 0, 1, 0, 11, 12, 16, 12, 74, 0, 25], ["+", 0, 11, 12, 16, 12, 74, 51, 23, 0, 24], ["+", 0, 11, 12, 16, 12, 74, 51, 23, 0, 25]]
8
188
7
using System; using System.Collections.Generic; using System.Linq; namespace ABC086A { class Program { static void Main(string[] args) { var N = int.Parse(Console.ReadLine()); var A = Console.ReadLine().Split(' '); var step = 0; for (int i = 1; i < N; i++) { if (int.Parse(A[i]) < int.Parse(A[i - 1])) { var diff = int.Parse(A[i - 1]) - int.Parse(A[i]); step += diff; A[i] = (int.Parse(A[i]) + diff).ToString(); } } System.Console.WriteLine(step); } } }
using System; using System.Collections.Generic; using System.Linq; namespace ABC086A { class Program { static void Main(string[] args) { var N = int.Parse(Console.ReadLine()); var A = Console.ReadLine().Split(' '); long step = 0; for (int i = 1; i < N; i++) { if (int.Parse(A[i]) < int.Parse(A[i - 1])) { long diff = int.Parse(A[i - 1]) - int.Parse(A[i]); step += diff; A[i] = (int.Parse(A[i]) + diff).ToString(); } } System.Console.WriteLine(step); } } }
[["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 64, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 57, 64, 196, 0, 197, 0, 198, 39, 199]]
8
172
4
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder { class ABC168C { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); int[] a = new int[n]; string[] str = Console.ReadLine().Split(' '); for (int i = 0; i < n; i++) { a[i] = int.Parse(str[i]); } int count = 0; for (int i = 1; i < n; i++) { if (a[i] < a[i - 1]) { count += a[i - 1] - a[i]; a[i] = a[i - 1]; } } Console.WriteLine(count); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder { class ABC168C { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); int[] a = new int[n]; string[] str = Console.ReadLine().Split(' '); for (int i = 0; i < n; i++) { a[i] = int.Parse(str[i]); } long count = 0; for (int i = 1; i < n; i++) { if (a[i] < a[i - 1]) { count += a[i - 1] - a[i]; a[i] = a[i - 1]; } } Console.WriteLine(count); } } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
8
190
2
using System; namespace AtCoderSnippet { class Program { static void Main(string[] args) { var N = int.Parse(Console.ReadLine()); var A = Console.ReadLine().Split(" "); var x = 0; for (int i = 0; i < N - 1; i++) { var ax = int.Parse(A[i]); var ay = int.Parse(A[i + 1]); if (ax > ay) { var z = ax - ay; A[i + 1] = (ay + z).ToString(); x += z; } } Console.WriteLine(x); } } }
using System; namespace AtCoderSnippet { class Program { static void Main(string[] args) { var N = long.Parse(Console.ReadLine()); var A = Console.ReadLine().Split(" "); long x = 0; for (int i = 0; i < N - 1; i++) { var ax = long.Parse(A[i]); var ay = long.Parse(A[i + 1]); if (ax > ay) { var z = ax - ay; A[i + 1] = (ay + z).ToString(); x += z; } } Console.WriteLine(x); } } }
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 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
146
8
using System; class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); int[] a = InputIntArray(); int count = 0; for (int i = 1; i < a.Length; i++) { if (a[i - 1] > a[i]) { int c = a[i - 1] - a[i]; a[i] += c; count += c; } } Console.WriteLine(count); } public static int[] InputIntArray() { string[] strs = Console.ReadLine().Split(' '); int[] num = new int[strs.Length]; for (int i = 0; i < num.Length; i++) { num[i] = int.Parse(strs[i]); } return num; } }
using System; class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); int[] a = InputIntArray(); ulong count = 0; for (int i = 1; i < a.Length; i++) { if (a[i - 1] > a[i]) { int c = a[i - 1] - a[i]; a[i] += c; count += (ulong)c; } } Console.WriteLine(count); } public static int[] InputIntArray() { string[] strs = Console.ReadLine().Split(' '); int[] num = new int[strs.Length]; for (int i = 0; i < num.Length; i++) { num[i] = int.Parse(strs[i]); } return num; } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 64, 196, 0, 1, 0, 11, 12, 74, 0, 24], ["+", 64, 196, 0, 1, 0, 11, 12, 74, 39, 199], ["+", 64, 196, 0, 1, 0, 11, 12, 74, 0, 25]]
8
190
5
using System; using System.Collections.Generic; class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); string[] input = Console.ReadLine().Split(' '); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = int.Parse(input[i]); } int r = 0; int h = 0; for (int i = 0; i < n; i++) { if (h > a[i]) { r += h - a[i]; } else { h = a[i]; } } Console.WriteLine(r); } }
using System; using System.Collections.Generic; class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); string[] input = Console.ReadLine().Split(' '); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = int.Parse(input[i]); } long r = 0; long h = 0; for (int i = 0; i < n; i++) { if (h > a[i]) { r += h - a[i]; } else { h = a[i]; } } Console.WriteLine(r); } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
8
162
4
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using static System.Console; using static System.Math; using static AtCoderTemplate.MyLibrary; namespace AtCoderTemplate { class Program { static void Main(string[] args) { string[] str; str = Console.ReadLine().Split(' '); int N = int.Parse(str[0]); int[] A = new int[N]; str = Console.ReadLine().Split(' '); for (int i = 0; i < N; i++) { A[i] = int.Parse(str[i]); } int ans = 0; for (int i = 1; i < N; i++) { if (A[i - 1] > A[i]) { ans += A[i - 1] - A[i]; A[i] = A[i - 1]; } } Console.WriteLine(ans); } } class MyLibrary { public static int GCD(int a, int b) { if (a % b == 0) return b; return GCD(b, a % b); } } }
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using static System.Console; using static System.Math; using static AtCoderTemplate.MyLibrary; namespace AtCoderTemplate { class Program { static void Main(string[] args) { string[] str; str = Console.ReadLine().Split(' '); int N = int.Parse(str[0]); int[] A = new int[N]; str = Console.ReadLine().Split(' '); for (int i = 0; i < N; i++) { A[i] = int.Parse(str[i]); } long ans = 0; for (int i = 1; i < N; i++) { if (A[i - 1] > A[i]) { ans += A[i - 1] - A[i]; A[i] = A[i - 1]; } } Console.WriteLine(ans); } } class MyLibrary { public static int GCD(int a, int b) { if (a % b == 0) return b; return GCD(b, a % b); } } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
8
260
2
using System; using System.IO; using System.Linq; using System.Collections.Generic; using System.Text; using System.Numerics; namespace abc176 { class Program { static void Main(string[] args) { Console.SetOut( new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }); if (File.Exists("input.txt")) { Console.SetIn(new StreamReader("input.txt")); } solve_abc176C(); Console.Out.Flush(); } public static void solve_abc176C() { long n = Convert.ToInt32(Console.ReadLine()); long[] a = Array.ConvertAll(Console.ReadLine().Split(), long.Parse); long cnt = 0; long max = a[0]; for (int i = 1; i < n; i++) { if (a[i] < a[i - 1]) { cnt += max - a[i]; } max = Math.Max(max, a[i]); } Console.WriteLine(cnt); } public static void solve_abc176B() { string s = Console.ReadLine(); int sum = 0; for (int i = 0; i < s.Length; i++) { sum += Convert.ToInt32(s[i].ToString()); } Console.WriteLine(sum % 9 == 0 ? "Yes" : "No"); } public static void solve_abc176A() { int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse); int w = (a[0] + a[1] - 1) / a[1]; Console.WriteLine(w * a[2]); } } }
using System; using System.IO; using System.Linq; using System.Collections.Generic; using System.Text; using System.Numerics; namespace abc176 { class Program { static void Main(string[] args) { Console.SetOut( new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }); if (File.Exists("input.txt")) { Console.SetIn(new StreamReader("input.txt")); } solve_abc176C(); Console.Out.Flush(); } public static void solve_abc176C() { long n = Convert.ToInt32(Console.ReadLine()); long[] a = Array.ConvertAll(Console.ReadLine().Split(), long.Parse); long cnt = 0; long max = a[0]; for (int i = 1; i < n; i++) { if (a[i] < max) { cnt += max - a[i]; } max = Math.Max(max, a[i]); } Console.WriteLine(cnt); } public static void solve_abc176B() { string s = Console.ReadLine(); int sum = 0; for (int i = 0; i < s.Length; i++) { sum += Convert.ToInt32(s[i].ToString()); } Console.WriteLine(sum % 9 == 0 ? "Yes" : "No"); } public static void solve_abc176A() { int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse); int w = (a[0] + a[1] - 1) / a[1]; Console.WriteLine(w * a[2]); } } }
[["-", 8, 196, 0, 57, 15, 16, 12, 204, 205, 22], ["-", 0, 57, 15, 16, 12, 204, 206, 207, 0, 70], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["-", 0, 57, 15, 16, 12, 204, 206, 207, 0, 73], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22]]
8
369
7
using System; using System.Linq; class P { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); int[] a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); int c = 0; int m = 0; foreach (int i in a) { if (i > m) m = i; else if (i < m) { c += m - i; } } Console.WriteLine(c); } }
using System; using System.Linq; class P { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); int[] a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); long c = 0; long m = 0; foreach (int i in a) { if (i > m) m = i; else if (i < m) { c += m - i; } } Console.WriteLine(c); } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
8
117
4
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder_20190707_1 { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); int[] A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); int max = A[0]; int answer = 0; for (int i = 1; i < A.Length; i++) { if (A[i] > max) { max = A[i]; } else { answer += max - A[i]; } } Console.WriteLine(answer); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtCoder_20190707_1 { class Program { static void Main(string[] args) { long N = int.Parse(Console.ReadLine()); long[] A = Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); long max = A[0]; long answer = 0; for (int i = 1; i < A.Length; i++) { if (A[i] > max) { max = A[i]; } else { answer += max - A[i]; } } Console.WriteLine(answer); } } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 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
157
10
using System; using System.Collections.Generic; using System.Linq; using System.Text; public class AC { public static int[] ReadArray() { return Array.ConvertAll(Console.ReadLine().Split(' '), m => Convert.ToInt32(m)); } public static int ReadInt() { return Convert.ToInt32(Console.ReadLine()); } public static string ReadStr() { return Console.ReadLine(); } public static long ReadLong() { return Convert.ToInt64(Console.ReadLine()); } public static long[] ReadLongArray() { return Array.ConvertAll(Console.ReadLine().Split(' '), m => Convert.ToInt64(m)); } public static void Main() { int n = ReadInt(); int[] A = ReadArray(); int ans = 0; int max = 0; for (int i = 0; i < A.Length; i++) { if (A[i] < max) ans += max - A[i]; max = Math.Max(max, A[i]); } Console.WriteLine(ans); } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; public class AC { public static int[] ReadArray() { return Array.ConvertAll(Console.ReadLine().Split(' '), m => Convert.ToInt32(m)); } public static int ReadInt() { return Convert.ToInt32(Console.ReadLine()); } public static string ReadStr() { return Console.ReadLine(); } public static long ReadLong() { return Convert.ToInt64(Console.ReadLine()); } public static long[] ReadLongArray() { return Array.ConvertAll(Console.ReadLine().Split(' '), m => Convert.ToInt64(m)); } public static void Main() { int n = ReadInt(); int[] A = ReadArray(); long ans = 0; int max = 0; for (int i = 0; i < A.Length; i++) { if (A[i] < max) ans += max - A[i]; max = Math.Max(max, A[i]); } Console.WriteLine(ans); } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
8
247
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; 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(int.Parse).ToArray(); var sum = 0; for (int i = 1; i < n; i++) { if (a[i] < a[i - 1]) { sum += a[i - 1] - a[i]; a[i] = a[i - 1]; } } WriteLine(sum); } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; 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(long.Parse).ToArray(); var sum = 0L; for (int i = 1; i < n; i++) { if (a[i] < a[i - 1]) { sum += a[i - 1] - a[i]; a[i] = a[i - 1]; } } WriteLine(sum); } }
[["-", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203]]
8
152
4
using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; namespace AtCoder.C { public class Program { public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); } private static object GetResult() { var N = ReadLong(); var A = ReadLongs(); var sum = 0L; for (int i = 1; i < N; i++) { var dif = A[i] - A[i - 1]; if (dif > 0) { sum += dif; A[i] += dif; } } return sum; } #region Console.Read public static string ReadText() { return Console.ReadLine(); } public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); } public static long ReadLong() { return long.Parse(Console.ReadLine()); } public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); } public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); } public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); } public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); } public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); } #endregion } }
using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; namespace AtCoder.C { public class Program { public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); } private static object GetResult() { var N = ReadLong(); var A = ReadLongs(); var sum = 0L; for (int i = 1; i < N; i++) { var dif = A[i - 1] - A[i]; if (dif > 0) { sum += dif; A[i] += dif; } } return sum; } #region Console.Read public static string ReadText() { return Console.ReadLine(); } public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); } public static long ReadLong() { return long.Parse(Console.ReadLine()); } public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); } public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); } public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); } public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); } public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); } #endregion } }
[["+", 31, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203]]
8
420
4
using static System.Math; using static System.Console; using System.Collections.Generic; using System.Linq; using System.Text; using System; namespace AtCoder { class Program { private static long mod = 1000000007; static void Main(string[] args) { var n = int.Parse(ReadLine()); var line = ReadLine().Split(' ').Select(value => int.Parse(value)).ToArray(); var max = 0; var sum = 0; foreach (var a in line) { if (max > a) { sum += max - a; } else { max = a; } } WriteLine(sum); } } }
using static System.Math; using static System.Console; using System.Collections.Generic; using System.Linq; using System.Text; using System; namespace AtCoder { class Program { private static long mod = 1000000007; static void Main(string[] args) { var n = int.Parse(ReadLine()); var line = ReadLine().Split(' ').Select(value => long.Parse(value)).ToArray(); long max = 0; long sum = 0; foreach (var a in line) { if (max > a) { sum += max - a; } else { max = a; } } WriteLine(sum); } } }
[["-", 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
145
6
using System; namespace C { class Program { static void Main(string[] args) { var N = int.Parse(Console.ReadLine()); var A = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); var max = 0; var result = 0; foreach (int a in A) { if (max < a) max = a; else result += max - a; } Console.WriteLine(result); } } }
using System; namespace C { class Program { static void Main(string[] args) { var N = int.Parse(Console.ReadLine()); var A = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); var max = 0L; var result = 0L; foreach (int a in A) { if (max < a) max = a; else result += max - a; } Console.WriteLine(result); } } }
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203]]
8
104
4
using System; using System.Collections.Generic; using System.Linq; public struct Point { public int X; public int Y; public Point(Point p) { X = p.X; Y = p.Y; } public Point(int x, int y) { X = x; Y = y; } public static bool operator ==(Point a, Point b) { return (a.X == b.X && a.Y == b.Y); } public static bool operator !=(Point a, Point b) { return !(a == b); } // objと自分自身が等価のときはtrueを返す public override bool Equals(object obj) { if (!(obj is Point)) { return false; } Point p = (Point)obj; return (X == p.X && Y == p.Y); } // Equalsがtrueを返すときに同じ値を返す public override int GetHashCode() { return (X << 16) ^ Y; } public Point Clone() { return new Point(X, Y); } public void Reverse() { X = -X; Y = -Y; } public static Point operator +(Point a, Point b) { return new Point(a.X + b.X, a.Y + b.Y); } public static Point operator -(Point a, Point b) { return new Point(a.X - b.X, a.Y - b.Y); } public static Point operator *(Point a, int i) { return new Point(a.X * i, a.Y * i); } public static Point operator /(Point a, int i) { return new Point(a.X / i, a.Y / i); } public static Point operator +(Point a) { return new Point(+a.X, +a.Y); } public static Point operator -(Point a) { return new Point(-a.X, -a.Y); } public override string ToString() { return string.Format("({0},{1})", X, Y); } } public static class Solution { public static void Main() { var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); var H = vals[0]; var W = vals[1]; var M = vals[2]; var yCount = new int[H]; var xCount = new int[W]; var exist = new HashSet<Point>(); for (int i = 0; i < M; i++) { vals = Console.ReadLine().Split(' ').Select(x => int.Parse(x) - 1).ToArray(); var p = new Point(vals[1], vals[0]); yCount[p.Y]++; xCount[p.X]++; exist.Add(p); } var yMax = yCount.Max(); var xMax = xCount.Max(); var yIndexes = Enumerable.Range(0, H).Where(i => yCount[i] == yMax).ToList(); var xIndexes = Enumerable.Range(0, W).Where(i => xCount[i] == xMax).ToList(); int minus = -1; foreach (var y in yIndexes) { foreach (var x in xIndexes) { if (!exist.Contains(new Point(y, x))) { minus = 0; break; } } if (minus == 0) { break; } } var max = yMax + xMax + minus; Console.WriteLine(max); } }
using System; using System.Collections.Generic; using System.Linq; public struct Point { public int X; public int Y; public Point(Point p) { X = p.X; Y = p.Y; } public Point(int x, int y) { X = x; Y = y; } public static bool operator ==(Point a, Point b) { return (a.X == b.X && a.Y == b.Y); } public static bool operator !=(Point a, Point b) { return !(a == b); } // objと自分自身が等価のときはtrueを返す public override bool Equals(object obj) { if (!(obj is Point)) { return false; } Point p = (Point)obj; return (X == p.X && Y == p.Y); } // Equalsがtrueを返すときに同じ値を返す public override int GetHashCode() { return (X << 16) ^ Y; } public Point Clone() { return new Point(X, Y); } public void Reverse() { X = -X; Y = -Y; } public static Point operator +(Point a, Point b) { return new Point(a.X + b.X, a.Y + b.Y); } public static Point operator -(Point a, Point b) { return new Point(a.X - b.X, a.Y - b.Y); } public static Point operator *(Point a, int i) { return new Point(a.X * i, a.Y * i); } public static Point operator /(Point a, int i) { return new Point(a.X / i, a.Y / i); } public static Point operator +(Point a) { return new Point(+a.X, +a.Y); } public static Point operator -(Point a) { return new Point(-a.X, -a.Y); } public override string ToString() { return string.Format("({0},{1})", X, Y); } } public static class Solution { public static void Main() { var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); var H = vals[0]; var W = vals[1]; var M = vals[2]; var yCount = new int[H]; var xCount = new int[W]; var exist = new HashSet<Point>(); for (int i = 0; i < M; i++) { vals = Console.ReadLine().Split(' ').Select(x => int.Parse(x) - 1).ToArray(); var p = new Point(vals[1], vals[0]); yCount[p.Y]++; xCount[p.X]++; exist.Add(p); } var yMax = yCount.Max(); var xMax = xCount.Max(); var yIndexes = Enumerable.Range(0, H).Where(i => yCount[i] == yMax).ToList(); var xIndexes = Enumerable.Range(0, W).Where(i => xCount[i] == xMax).ToList(); int minus = -1; foreach (var y in yIndexes) { foreach (var x in xIndexes) { if (!exist.Contains(new Point(x, y))) { minus = 0; break; } } if (minus == 0) { break; } } var max = yMax + xMax + minus; Console.WriteLine(max); } }
[["-", 0, 28, 0, 230, 3, 4, 0, 28, 0, 22], ["-", 3, 4, 0, 28, 0, 230, 3, 4, 0, 21], ["+", 3, 4, 0, 28, 0, 230, 3, 4, 0, 21], ["+", 0, 28, 0, 230, 3, 4, 0, 28, 0, 22]]
8
758
4
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using Pair = System.Tuple<int, int>; class TEST { static void Main() { Sol mySol = new Sol(); mySol.Solve(); } } class Sol { void ChMax(ref int x, int v) { x = Math.Max(x, v); } int score(int x, int y, int z) { return (x == y && y == z) ? 1 : 0; } public void Solve() { int Inf = (int)1e9; int[][] dp = new int [N + 1][]; for (int i = 0; i < N + 1; i++) { dp[i] = new int[N + 1]; for (int j = 0; j < N + 1; j++) { dp[i][j] = -Inf; } } Action<int, int, int> update = (r, c, v) => { ChMax(ref dp[r][c], v); ChMax(ref dp[c][r], v); ChMax(ref dp[r][N], v); ChMax(ref dp[c][N], v); ChMax(ref dp[N][c], v); ChMax(ref dp[N][r], v); ChMax(ref dp[N][N], v); }; update(A[0], A[1], 0); int offset = 0; for (int i = 0; i < N - 1; i++) { int a = A[2 + i * 3], b = A[3 + i * 3], c = A[4 + i * 3]; // X, Y, a, b, c から3つ取るうち, (a, b, c)を取る以外を考える. //  例えば X,b,cを取ると残りは Y,aなので, //  配るdp的には dp[Y][a] <- Max{ dp[X][Y] + score(X, b, c), dp[Y][a] } // で更新する.  遷移先が (a,b,c) を取るものを除けば 高々O(N) // 個しかないので, //  遷移先から貰うdpに変えて高速化できないか考える.⇒O(1)で貰えるようにできる // Flying // tableが使えないので,更新候補をキューに詰めておいて一気に更新する. if (score(a, b, c) == 1) { offset++; continue; } var q = new Queue<long>(); const long M = 2048L, MM = M * M, MMM = MM * 2; Func<int, int, int, long> enc = (v, x, y) => Math.Abs(v) * MMM + (v < 0 ? 1 : 0) * MM + x * M + y; // (X, Y, a, b, c) => (X, a) // (Y,b,c)を取って(X,a) にする // 各 X = x に対して,すべてのY = y in [0..N-1] が (x,a) に遷移する // ・dp[x][N] := max(dp[x][y]) for y から score 0で dp[x][a] に遷移 // ・dp[x][Y=b], dp[x][Y=c]からは score(Y, b, c) // が1になる可能性があるので個別に遷移させておく // case: (X, Y, a, b, c) => (X, a) for (int x = 0; x < N; x++) { if (dp[x][N] >= 0) q.Enqueue(enc(dp[x][N], x, a)); if (b == c) if (dp[x][b] >= 0) q.Enqueue(enc(dp[x][b] + score(b, b, c), x, a)); if (b == c) if (dp[x][c] >= 0) q.Enqueue(enc(dp[x][c] + score(c, b, c), x, a)); } // case: (X, Y, a, b, c) => (X, b) for (int x = 0; x < N; x++) { if (dp[x][N] >= 0) q.Enqueue(enc(dp[x][N], x, b)); if (a == c) if (dp[x][a] >= 0) q.Enqueue(enc(dp[x][a] + score(a, a, c), x, b)); if (a == c) if (dp[x][c] >= 0) q.Enqueue(enc(dp[x][c] + score(c, a, c), x, b)); } // case: (X, Y, a, b, c) => (X, c) for (int x = 0; x < N; x++) { if (dp[x][N] >= 0) q.Enqueue(enc(dp[x][N], x, c)); if (a == b) if (dp[x][a] >= 0) q.Enqueue(enc(dp[x][a] + score(a, a, b), x, c)); if (a == b) if (dp[x][b] >= 0) q.Enqueue(enc(dp[x][b] + score(b, a, b), x, c)); } // case: (X, Y, a, b, c) => (Y, a) for (int y = 0; y < N; y++) { if (dp[N][y] >= 0) q.Enqueue(enc(dp[N][y], y, a)); if (b == c) if (dp[b][y] >= 0) q.Enqueue(enc(dp[b][y] + score(b, b, c), y, a)); if (b == c) if (dp[c][y] >= 0) q.Enqueue(enc(dp[c][y] + score(c, b, c), y, a)); } // case: (X, Y, a, b, c) => (Y, b) for (int y = 0; y < N; y++) { if (dp[N][y] >= 0) q.Enqueue(enc(dp[N][y], y, b)); if (a == c) if (dp[a][y] >= 0) q.Enqueue(enc(dp[a][y] + score(a, a, c), y, b)); if (a == c) if (dp[c][y] >= 0) q.Enqueue(enc(dp[c][y] + score(c, a, c), y, b)); } // case: (X, Y, a, b, c) => (Y, c) for (int y = 0; y < N; y++) { if (dp[N][y] >= 0) q.Enqueue(enc(dp[N][y], y, c)); if (a == b) if (dp[a][y] >= 0) q.Enqueue(enc(dp[a][y] + score(a, a, b), y, c)); if (a == b) if (dp[b][y] >= 0) q.Enqueue(enc(dp[b][y] + score(b, a, b), y, c)); } // (X, Y, a, b, c) => (a, b) // すべての X = x,すべてのY = y が (a,b) に遷移する // ・dp[N][N] := max(dp[x][y]) for x,y から score 0で dp[a][b] に遷移 // ・dp[c][c] からは score(X, Y, c) // が1になる可能性があるので個別に遷移させておく // case: (X, Y, a, b, c) => (a, b) q.Enqueue(enc(dp[N][N], a, b)); if (dp[c][c] >= 0) q.Enqueue(enc(dp[c][c] + score(c, c, c), a, b)); // case: (X, Y, a, b, c) => (a, c) q.Enqueue(enc(dp[N][N], a, c)); if (dp[b][b] >= 0) q.Enqueue(enc(dp[b][b] + score(b, b, b), a, c)); // case: (X, Y, a, b, c) => (b, c) q.Enqueue(enc(dp[N][N], b, c)); if (dp[b][b] >= 0) q.Enqueue(enc(dp[a][a] + score(a, a, a), b, c)); // Console.WriteLine("ok"); // Update while (q.Count > 0) { var e = q.Dequeue(); int val = (int)(e / MMM); int sig = (int)(e % MMM / MM); int x = (int)(e % MM / M); int y = (int)(e % M); // Console.WriteLine("{0} {1} {2}", val, x, y); if (sig == 0) { dp[x][y] = Math.Max(dp[x][y], val); dp[y][x] = Math.Max(dp[y][x], val); dp[x][N] = Math.Max(dp[x][N], val); dp[y][N] = Math.Max(dp[y][N], val); dp[N][x] = Math.Max(dp[N][x], val); dp[N][y] = Math.Max(dp[N][y], val); dp[N][N] = Math.Max(dp[N][N], val); } // update(x, y, val); } } for (int i = 0; i <= N; i++) { for (int j = 0; j <= N; j++) { dp[i][j] += offset; } } int ans = -Inf; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { ChMax(ref ans, dp[i][j] + score(i, j, A[A.Length - 1])); } } Console.WriteLine(ans); } int N; int[] A; public Sol() { N = ri(); A = ria(); for (int i = 0; i < A.Length; i++) A[i]--; } 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; using Pair = System.Tuple<int, int>; class TEST { static void Main() { Sol mySol = new Sol(); mySol.Solve(); } } class Sol { void ChMax(ref int x, int v) { x = Math.Max(x, v); } int score(int x, int y, int z) { return (x == y && y == z) ? 1 : 0; } public void Solve() { int Inf = (int)1e9; int[][] dp = new int [N + 1][]; for (int i = 0; i < N + 1; i++) { dp[i] = new int[N + 1]; for (int j = 0; j < N + 1; j++) { dp[i][j] = -Inf; } } Action<int, int, int> update = (r, c, v) => { ChMax(ref dp[r][c], v); ChMax(ref dp[c][r], v); ChMax(ref dp[r][N], v); ChMax(ref dp[c][N], v); ChMax(ref dp[N][c], v); ChMax(ref dp[N][r], v); ChMax(ref dp[N][N], v); }; update(A[0], A[1], 0); int offset = 0; for (int i = 0; i < N - 1; i++) { int a = A[2 + i * 3], b = A[3 + i * 3], c = A[4 + i * 3]; // X, Y, a, b, c から3つ取るうち, (a, b, c)を取る以外を考える. //  例えば X,b,cを取ると残りは Y,aなので, //  配るdp的には dp[Y][a] <- Max{ dp[X][Y] + score(X, b, c), dp[Y][a] } // で更新する.  遷移先が (a,b,c) を取るものを除けば 高々O(N) // 個しかないので, //  遷移先から貰うdpに変えて高速化できないか考える.⇒O(1)で貰えるようにできる // Flying // tableが使えないので,更新候補をキューに詰めておいて一気に更新する. if (score(a, b, c) == 1) { offset++; continue; } var q = new Queue<long>(); const long M = 2048L, MM = M * M, MMM = MM * 2; Func<int, int, int, long> enc = (v, x, y) => Math.Abs(v) * MMM + (v < 0 ? 1 : 0) * MM + x * M + y; // (X, Y, a, b, c) => (X, a) // (Y,b,c)を取って(X,a) にする // 各 X = x に対して,すべてのY = y in [0..N-1] が (x,a) に遷移する // ・dp[x][N] := max(dp[x][y]) for y から score 0で dp[x][a] に遷移 // ・dp[x][Y=b], dp[x][Y=c]からは score(Y, b, c) // が1になる可能性があるので個別に遷移させておく // case: (X, Y, a, b, c) => (X, a) for (int x = 0; x < N; x++) { if (dp[x][N] >= 0) q.Enqueue(enc(dp[x][N], x, a)); if (b == c) if (dp[x][b] >= 0) q.Enqueue(enc(dp[x][b] + score(b, b, c), x, a)); if (b == c) if (dp[x][c] >= 0) q.Enqueue(enc(dp[x][c] + score(c, b, c), x, a)); } // case: (X, Y, a, b, c) => (X, b) for (int x = 0; x < N; x++) { if (dp[x][N] >= 0) q.Enqueue(enc(dp[x][N], x, b)); if (a == c) if (dp[x][a] >= 0) q.Enqueue(enc(dp[x][a] + score(a, a, c), x, b)); if (a == c) if (dp[x][c] >= 0) q.Enqueue(enc(dp[x][c] + score(c, a, c), x, b)); } // case: (X, Y, a, b, c) => (X, c) for (int x = 0; x < N; x++) { if (dp[x][N] >= 0) q.Enqueue(enc(dp[x][N], x, c)); if (a == b) if (dp[x][a] >= 0) q.Enqueue(enc(dp[x][a] + score(a, a, b), x, c)); if (a == b) if (dp[x][b] >= 0) q.Enqueue(enc(dp[x][b] + score(b, a, b), x, c)); } // case: (X, Y, a, b, c) => (Y, a) for (int y = 0; y < N; y++) { if (dp[N][y] >= 0) q.Enqueue(enc(dp[N][y], y, a)); if (b == c) if (dp[b][y] >= 0) q.Enqueue(enc(dp[b][y] + score(b, b, c), y, a)); if (b == c) if (dp[c][y] >= 0) q.Enqueue(enc(dp[c][y] + score(c, b, c), y, a)); } // case: (X, Y, a, b, c) => (Y, b) for (int y = 0; y < N; y++) { if (dp[N][y] >= 0) q.Enqueue(enc(dp[N][y], y, b)); if (a == c) if (dp[a][y] >= 0) q.Enqueue(enc(dp[a][y] + score(a, a, c), y, b)); if (a == c) if (dp[c][y] >= 0) q.Enqueue(enc(dp[c][y] + score(c, a, c), y, b)); } // case: (X, Y, a, b, c) => (Y, c) for (int y = 0; y < N; y++) { if (dp[N][y] >= 0) q.Enqueue(enc(dp[N][y], y, c)); if (a == b) if (dp[a][y] >= 0) q.Enqueue(enc(dp[a][y] + score(a, a, b), y, c)); if (a == b) if (dp[b][y] >= 0) q.Enqueue(enc(dp[b][y] + score(b, a, b), y, c)); } // (X, Y, a, b, c) => (a, b) // すべての X = x,すべてのY = y が (a,b) に遷移する // ・dp[N][N] := max(dp[x][y]) for x,y から score 0で dp[a][b] に遷移 // ・dp[c][c] からは score(X, Y, c) // が1になる可能性があるので個別に遷移させておく // case: (X, Y, a, b, c) => (a, b) q.Enqueue(enc(dp[N][N], a, b)); if (dp[c][c] >= 0) q.Enqueue(enc(dp[c][c] + score(c, c, c), a, b)); // case: (X, Y, a, b, c) => (a, c) q.Enqueue(enc(dp[N][N], a, c)); if (dp[b][b] >= 0) q.Enqueue(enc(dp[b][b] + score(b, b, b), a, c)); // case: (X, Y, a, b, c) => (b, c) q.Enqueue(enc(dp[N][N], b, c)); if (dp[a][a] >= 0) q.Enqueue(enc(dp[a][a] + score(a, a, a), b, c)); // Console.WriteLine("ok"); // Update while (q.Count > 0) { var e = q.Dequeue(); int val = (int)(e / MMM); int sig = (int)(e % MMM / MM); int x = (int)(e % MM / M); int y = (int)(e % M); // Console.WriteLine("{0} {1} {2}", val, x, y); if (sig == 0) { dp[x][y] = Math.Max(dp[x][y], val); dp[y][x] = Math.Max(dp[y][x], val); dp[x][N] = Math.Max(dp[x][N], val); dp[y][N] = Math.Max(dp[y][N], val); dp[N][x] = Math.Max(dp[N][x], val); dp[N][y] = Math.Max(dp[N][y], val); dp[N][N] = Math.Max(dp[N][N], val); } // update(x, y, val); } } for (int i = 0; i <= N; i++) { for (int j = 0; j <= N; j++) { dp[i][j] += offset; } } int ans = -Inf; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { ChMax(ref ans, dp[i][j] + score(i, j, A[A.Length - 1])); } } Console.WriteLine(ans); } int N; int[] A; public Sol() { N = ri(); A = ria(); for (int i = 0; i < A.Length; i++) A[i]--; } 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)); } }
[["-", 31, 204, 205, 204, 206, 207, 0, 28, 0, 22], ["+", 31, 204, 205, 204, 206, 207, 0, 28, 0, 22], ["-", 15, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 15, 16, 31, 204, 206, 207, 0, 28, 0, 22]]
8
2,190
4
using System.Linq; using System.Text; using System; using System.Collections; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Diagnostics; using System.Reflection.Metadata; using System.Threading; using System.Runtime.CompilerServices; namespace AtCoder { class Program { struct Point { public int x; public int y; public Point(int x, int y) { this.x = x; this.y = y; } } const int BiggestMod = 1000000007; public static void Main() { var t = Console.ReadLine().Select(x => x == 'S').ToArray(); var res = new bool[] { t[0] == t[1], t[1] == t[2], t[1] == false }; var ans = 0; if (res[3]) { if (res[0] && res[1]) ans = 3; else if (res[0] || res[1]) ans = 2; else ans = 1; } else if (t.Any(x => x == false)) ans = 1; Console.WriteLine(ans); } } }
using System.Linq; using System.Text; using System; using System.Collections; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Diagnostics; using System.Reflection.Metadata; using System.Threading; using System.Runtime.CompilerServices; namespace AtCoder { class Program { struct Point { public int x; public int y; public Point(int x, int y) { this.x = x; this.y = y; } } const int BiggestMod = 1000000007; public static void Main() { var t = Console.ReadLine().Select(x => x == 'S').ToArray(); var res = new bool[] { t[0] == t[1], t[1] == t[2], t[1] == false }; var ans = 0; if (res[2]) { if (res[0] && res[1]) ans = 3; else if (res[0] || res[1]) ans = 2; else ans = 1; } else if (t.Any(x => x == false)) ans = 1; Console.WriteLine(ans); } } }
[["-", 0, 57, 15, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 57, 15, 204, 206, 207, 0, 28, 0, 203]]
8
253
2
namespace AtCoder { using System; using System.Linq; using System.Collections.Generic; using System.IO; using System.Text; using System.Text.RegularExpressions; class Program { static void Main() { var input = System.Console.ReadLine().ToArray(); var a = input[0]; var b = input[1]; var c = input[2]; var rain = 0; if (a == 'R') rain++; if (b == 'R') rain++; if (c == 'R') rain++; if (a == 'R' && b == 'R' && b != 'R') rain--; Output(rain.ToString()); } private static void Output(string str) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); Console.WriteLine(str); Console.Out.Flush(); } } static class Extentions { #region 拡張メソッド(string) public static string LeftB(this string stTarget, int iByteSize) { return MidB(stTarget, 1, iByteSize); } public static string MidB(this string stTarget, int iStart) { System.Text.Encoding hEncoding = System.Text.Encoding.GetEncoding("utf-8"); byte[] bBytes = hEncoding.GetBytes(stTarget); return hEncoding.GetString(bBytes, iStart - 1, bBytes.Length - iStart + 1); } public static string MidB(this string stTarget, int iStart, int iByteSize) { System.Text.Encoding hEncoding = System.Text.Encoding.GetEncoding("utf-8"); byte[] bBytes = hEncoding.GetBytes(stTarget); return hEncoding.GetString(bBytes, iStart - 1, iByteSize); } public static string RightB(this string stTarget, int iByteSize) { System.Text.Encoding hEncoding = System.Text.Encoding.GetEncoding("utf-8"); byte[] bBytes = hEncoding.GetBytes(stTarget); return hEncoding.GetString(bBytes, bBytes.Length - iByteSize, iByteSize); } public static bool IsNullOrEmpty(this string str) { return string.IsNullOrEmpty(str); } /// <summary> /// カルチャに依存した比較、または大文字と小文字を区別しない比較などの序数による比較を指定できる /// Contains。 /// </summary> /// <param name="value">対象文字列</param> /// <param name="partialValue">部分文字列</param> /// <param /// name="comparison">カルチャ、大文字と小文字の区別、および並べ替え規則を指定する /// StringComparison</param> <returns>一致する場合に true /// を返します。</returns> public static bool Contains(this string value, string partialValue, StringComparison comparison = 0) { return value.IndexOf(partialValue, comparison) >= 0; } public static bool IsNumeric(this string value) { return decimal.TryParse(value, out decimal d); } public static int ToInt32(this String number, int retValue = 0) { if (!number.IsNumeric()) return retValue; return int.Parse(number); } #endregion } } /* */ /* using System; using System.Collections.Generic; using System.Linq; // 整数の入力======================================== string[] input = Console.ReadLine().Split(' '); int a = int.Parse(input[0]); int b = int.Parse(input[1]); int c = int.Parse(Console.ReadLine()); //配列操作======================================== var a = System.Console.ReadLine().Split(' ').Select((x) => long.Parse(x)).ToArray(); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = int.Parse(input2[i]); } Array.Sort(a); Array.Reverse(a); // 最小公倍数======================================== public static decimal Lcm(decimal a, decimal b) { return a * b / Gcd(a, b); } // ユークリッドの互除法 ======================================== public static decimal Gcd(decimal a, decimal b) { if (a < b) { // 引数を入替えて自分を呼び出す return Gcd(b, a); } while (b != 0) { var remainder = a % b; a = b; b = remainder; } return a; } //出力======================================== Console.WriteLine(""); var sb = new StringBuilder(); for (int j = 0; j<n; j++) { sb.AppendLine(a[j].ToString()); } var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); Console.WriteLine(sb.ToString()); Console.Out.Flush(); */
namespace AtCoder { using System; using System.Linq; using System.Collections.Generic; using System.IO; using System.Text; using System.Text.RegularExpressions; class Program { static void Main() { var input = System.Console.ReadLine().ToArray(); var a = input[0]; var b = input[1]; var c = input[2]; var rain = 0; if (a == 'R') rain++; if (b == 'R') rain++; if (c == 'R') rain++; if (a == 'R' && c == 'R' && b != 'R') rain--; Output(rain.ToString()); } private static void Output(string str) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); Console.WriteLine(str); Console.Out.Flush(); } } static class Extentions { #region 拡張メソッド(string) public static string LeftB(this string stTarget, int iByteSize) { return MidB(stTarget, 1, iByteSize); } public static string MidB(this string stTarget, int iStart) { System.Text.Encoding hEncoding = System.Text.Encoding.GetEncoding("utf-8"); byte[] bBytes = hEncoding.GetBytes(stTarget); return hEncoding.GetString(bBytes, iStart - 1, bBytes.Length - iStart + 1); } public static string MidB(this string stTarget, int iStart, int iByteSize) { System.Text.Encoding hEncoding = System.Text.Encoding.GetEncoding("utf-8"); byte[] bBytes = hEncoding.GetBytes(stTarget); return hEncoding.GetString(bBytes, iStart - 1, iByteSize); } public static string RightB(this string stTarget, int iByteSize) { System.Text.Encoding hEncoding = System.Text.Encoding.GetEncoding("utf-8"); byte[] bBytes = hEncoding.GetBytes(stTarget); return hEncoding.GetString(bBytes, bBytes.Length - iByteSize, iByteSize); } public static bool IsNullOrEmpty(this string str) { return string.IsNullOrEmpty(str); } /// <summary> /// カルチャに依存した比較、または大文字と小文字を区別しない比較などの序数による比較を指定できる /// Contains。 /// </summary> /// <param name="value">対象文字列</param> /// <param name="partialValue">部分文字列</param> /// <param /// name="comparison">カルチャ、大文字と小文字の区別、および並べ替え規則を指定する /// StringComparison</param> <returns>一致する場合に true /// を返します。</returns> public static bool Contains(this string value, string partialValue, StringComparison comparison = 0) { return value.IndexOf(partialValue, comparison) >= 0; } public static bool IsNumeric(this string value) { return decimal.TryParse(value, out decimal d); } public static int ToInt32(this String number, int retValue = 0) { if (!number.IsNumeric()) return retValue; return int.Parse(number); } #endregion } } /* */ /* using System; using System.Collections.Generic; using System.Linq; // 整数の入力======================================== string[] input = Console.ReadLine().Split(' '); int a = int.Parse(input[0]); int b = int.Parse(input[1]); int c = int.Parse(Console.ReadLine()); //配列操作======================================== var a = System.Console.ReadLine().Split(' ').Select((x) => long.Parse(x)).ToArray(); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = int.Parse(input2[i]); } Array.Sort(a); Array.Reverse(a); // 最小公倍数======================================== public static decimal Lcm(decimal a, decimal b) { return a * b / Gcd(a, b); } // ユークリッドの互除法 ======================================== public static decimal Gcd(decimal a, decimal b) { if (a < b) { // 引数を入替えて自分を呼び出す return Gcd(b, a); } while (b != 0) { var remainder = a % b; a = b; b = remainder; } return a; } //出力======================================== Console.WriteLine(""); var sb = new StringBuilder(); for (int j = 0; j<n; j++) { sb.AppendLine(a[j].ToString()); } var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); Console.WriteLine(sb.ToString()); Console.Out.Flush(); */
[["-", 0, 57, 15, 16, 31, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 16, 31, 16, 12, 16, 31, 22]]
8
552
2
using System; using static System.Console; using static System.Math; using System.Numerics; using System.Collections.Generic; using System.Linq; namespace AtCoder { public class Program { public static void Main(string[] args) { var s = myRead.reatStr(); int ans = 0; int num = 0; for (int i = 0; i < 3; i++) { if (s[i] == 'R') num++; else ; num = 0; if (num > ans) { ans = num; } } WriteLine(ans); } } public static class myRead { public static int readInt() { return int.Parse(ReadLine()); } public static long readLong() { return long.Parse(ReadLine()); } public static string reatStr() { return ReadLine(); } public static int[] readIntArray() { return ReadLine().Split(' ').Select(int.Parse).ToArray(); } public static long[] readLongArray() { return ReadLine().Split(' ').Select(long.Parse).ToArray(); } public static string[] readStrArray() { return ReadLine().Split(' '); } } public static class MyMath { public static long Factorical(long n) { return n <= 1 ? 1L : n * Factorical(n - 1); } public static long Permutation(long n, long m) { return m == 0 ? 1L : (m == n) ? Permutation(n, m - 1) : n * Permutation(n - 1, m - 1); } public static long Combination(long n, long m) { return n - m > m ? Permutation(n, m) / Factorical(m) : Permutation(n, n - m) / Factorical(n - m); } public static long Gcd(long n, long m) { return n % m == 0 ? m : Gcd(m, n % m); } public static long Lcm(long n, long m) { return n * m / Gcd(n, m); } public static long Pow(long n, long m) { return m == 0 ? 1L : m == 1 ? n : n * Pow(n, m - 1); } } }
using System; using static System.Console; using static System.Math; using System.Numerics; using System.Collections.Generic; using System.Linq; namespace AtCoder { public class Program { public static void Main(string[] args) { var s = myRead.reatStr(); int ans = 0; int num = 0; for (int i = 0; i < 3; i++) { if (s[i] == 'R') num++; else num = 0; if (num > ans) { ans = num; } } WriteLine(ans); } } public static class myRead { public static int readInt() { return int.Parse(ReadLine()); } public static long readLong() { return long.Parse(ReadLine()); } public static string reatStr() { return ReadLine(); } public static int[] readIntArray() { return ReadLine().Split(' ').Select(int.Parse).ToArray(); } public static long[] readLongArray() { return ReadLine().Split(' ').Select(long.Parse).ToArray(); } public static string[] readStrArray() { return ReadLine().Split(' '); } } public static class MyMath { public static long Factorical(long n) { return n <= 1 ? 1L : n * Factorical(n - 1); } public static long Permutation(long n, long m) { return m == 0 ? 1L : (m == n) ? Permutation(n, m - 1) : n * Permutation(n - 1, m - 1); } public static long Combination(long n, long m) { return n - m > m ? Permutation(n, m) / Factorical(m) : Permutation(n, n - m) / Factorical(n - m); } public static long Gcd(long n, long m) { return n % m == 0 ? m : Gcd(m, n % m); } public static long Lcm(long n, long m) { return n * m / Gcd(n, m); } public static long Pow(long n, long m) { return m == 0 ? 1L : m == 1 ? n : n * Pow(n, m - 1); } } }
[["-", 0, 7, 8, 196, 0, 57, 75, 260, 0, 35]]
8
489
1
using System; namespace q1 { class q2 { static void Main() { string n = Console.ReadLine(); if (n == "RRR") { Console.WriteLine(3); } if (n == "RRS" || n == "SRR") { Console.WriteLine(2); } if (n == "SSS") { Console.WriteLine(0); } else { Console.WriteLine(1); } } } }
using System; namespace q1 { class q2 { static void Main() { string n = Console.ReadLine(); if (n == "RRR") { Console.WriteLine(3); } else if (n == "RRS" || n == "SRR") { Console.WriteLine(2); } else if (n == "SSS") { Console.WriteLine(0); } else { Console.WriteLine(1); } } } }
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 95]]
8
94
2
using System; namespace ConsoleApp8 { class Program { static void Main(string[] args) { string a = Console.ReadLine(); bool flg = false; int cnt = 0; for (int i = 0; i < 3; i++) { if (flg || a.Substring(i, 1) == "S") { break; } if (a.Substring(i, 1) == "R") { flg = true; cnt++; } } Console.WriteLine(cnt); } } }
using System; namespace ConsoleApp8 { class Program { static void Main(string[] args) { string a = Console.ReadLine(); bool flg = false; int cnt = 0; for (int i = 0; i < 3; i++) { if (flg && a.Substring(i, 1) == "S") { break; } if (a.Substring(i, 1) == "R") { flg = true; cnt++; } } Console.WriteLine(cnt); } } }
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98]]
8
109
2
using System; using System.Linq; using System.Security.Cryptography.X509Certificates; namespace _0815 { class Program { private static string s; static void Main(string[] args) { s = Console.ReadLine(); long result = Solution(); Console.WriteLine(result); } static long Solution() { long res = 0; if (s[0] == 'R') { if (s[1] == 'R') { if (s[2] == 'R') { res = 3; } else { res = 2; } } else { res = 1; } } else { if (s[1] == 'R') { if (s[2] == 'R') { res = 2; } else { res = 1; } } if (s[2] == 'R') { res = 1; } } return res; } } }
using System; using System.Linq; using System.Security.Cryptography.X509Certificates; namespace _0815 { class Program { private static string s; static void Main(string[] args) { s = Console.ReadLine(); long result = Solution(); Console.WriteLine(result); } static long Solution() { long res = 0; if (s[0] == 'R') { if (s[1] == 'R') { if (s[2] == 'R') { res = 3; } else { res = 2; } } else { res = 1; } } else { if (s[1] == 'R') { if (s[2] == 'R') { res = 2; } else { res = 1; } } else if (s[2] == 'R') { res = 1; } } return res; } } }
[["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 95]]
8
192
1
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; namespace AtCoder { class Program { static void Main(string[] args) { var S = Console.ReadLine().ToCharArray(); int count = 0; var isRBefore = true; foreach (var s in S) { if (s == 'R') { if (isRBefore) { count++; } isRBefore = true; } else { isRBefore = false; } } Console.WriteLine(count); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; namespace AtCoder { class Program { static void Main(string[] args) { var S = Console.ReadLine().ToCharArray(); int count = 0; var isRBefore = false; foreach (var s in S) { if (s == 'R') { if (isRBefore || count == 0) { count++; } isRBefore = true; } else { isRBefore = false; } } Console.WriteLine(count); } } }
[["-", 0, 198, 0, 200, 0, 212, 0, 211, 0, 146], ["+", 0, 198, 0, 200, 0, 212, 0, 211, 0, 147], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 106], ["+", 64, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 64, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 64, 196, 0, 57, 15, 16, 12, 16, 12, 203]]
8
122
6
using System; using System.Collections.Generic; using System.Linq; using System.Numerics; namespace atcoder { class Program { static void Main(string[] args) { var f = Console.ReadLine().ToArray(); var result = 0; var tmp = 0; for (var i = 0; i < 3; i++) { if (f[i] == 'S') { if (tmp > result) result = tmp; tmp = 0; } else { tmp++; } } Console.WriteLine(result); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Numerics; namespace atcoder { class Program { static void Main(string[] args) { var f = Console.ReadLine().ToArray(); var result = 0; var tmp = 0; for (var i = 0; i < 3; i++) { if (f[i] == 'S') { if (tmp > result) result = tmp; tmp = 0; } else { tmp++; } } Console.WriteLine(result > tmp ? result : tmp); } } }
[["+", 3, 4, 0, 28, 0, 41, 15, 16, 17, 47], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 12, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 101], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 64, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 102], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 75, 22]]
8
118
6
using System; class Program { static void Main(string[] args) { string input = Console.ReadLine(); int rainCount = 0; for (int i = 0; i < input.Length; i++) { if (input[i] == 'R') { rainCount++; } } if (input[1] == 'S') { rainCount = 1; } Console.Write(rainCount); } }
using System; class Program { static void Main(string[] args) { string input = Console.ReadLine(); int rainCount = 0; for (int i = 0; i < input.Length; i++) { if (input[i] == 'R') { rainCount++; } } if (input[1] == 'S' && rainCount > 0) { rainCount = 1; } Console.Write(rainCount); } }
[["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 47], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203]]
8
90
4
using System; using System.Collections.Generic; using System.ComponentModel; using System.Text; class Program { static long count = 0; static void Main(string[] args) { string s = Console.ReadLine(); int count = 0; int maxCount = 0; for (var i = 0; i < 3; i++) { if (s[i] == 'R') { count++; } else { count--; } if (maxCount < count) { maxCount = count; } } Console.WriteLine(maxCount); } }
using System; using System.Collections.Generic; using System.ComponentModel; using System.Text; class Program { static long count = 0; static void Main(string[] args) { string s = Console.ReadLine(); int count = 0; int maxCount = 0; for (var i = 0; i < 3; i++) { if (s[i] == 'R') { count++; } else { count = 0; } if (maxCount < count) { maxCount = count; } } Console.WriteLine(maxCount); } }
[["-", 0, 57, 75, 196, 0, 1, 0, 223, 0, 68], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 12, 203]]
8
117
3
using System; using System.Text; using System.Collections.Generic; using System.Collections; using static System.Math; using System.Linq; using static System.Array; namespace ConsoleApp2 { class Program { // static long mod = 1000000007; // static char[] az = Enumerable.Range('a', 'z' - 'a' + 1).Select(i => // (Char)i).ToArray(); static void Main(string[] args) { // var A = Console.ReadLine().Split(' ').Select(x => // long.Parse(x)).ToArray(); var N = long.Parse(Console.ReadLine()); var NK = // Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); var N = // NK[0]; var K = NK[1]; var A = Console.ReadLine().Split(' ').Select(x => // int.Parse(x)).ToList(); var S = Console.ReadLine(); var flag = false; long ans = 0; long count = 0; for (int i = 0; i < 3; i++) { if (flag && S[i] == 'R') { count++; ans = Max(ans, count); } else if (S[i] == 'R') { count++; ans = Max(ans, count); flag = true; } else { flag = false; count = 0; } } Console.WriteLine(count); } } }
using System; using System.Text; using System.Collections.Generic; using System.Collections; using static System.Math; using System.Linq; using static System.Array; namespace ConsoleApp2 { class Program { // static long mod = 1000000007; // static char[] az = Enumerable.Range('a', 'z' - 'a' + 1).Select(i => // (Char)i).ToArray(); static void Main(string[] args) { // var A = Console.ReadLine().Split(' ').Select(x => // long.Parse(x)).ToArray(); var N = long.Parse(Console.ReadLine()); var NK = // Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); var N = // NK[0]; var K = NK[1]; var A = Console.ReadLine().Split(' ').Select(x => // int.Parse(x)).ToList(); var S = Console.ReadLine(); var flag = false; long ans = 0; long count = 0; for (int i = 0; i < 3; i++) { if (flag && S[i] == 'R') { count++; ans = Max(ans, count); } else if (S[i] == 'R') { count++; ans = Max(ans, count); flag = true; } else { flag = false; count = 0; } } Console.WriteLine(ans); } } }
[["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
8
179
2
using System; using System.Linq; namespace Csharp { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); int[] L = Console.ReadLine().Split(" ").Select(s => int.Parse(s)).ToArray(); int ans = 0; Array.Sort(L); for (int i = 0; i < N - 2; i++) { for (int j = i + 1; j < N - 1; j++) { if (L[i] >= L[j]) goto idou; int trijouken = L[i] + L[j]; for (int k = j + 1; k < N; k++) { if (L[j] < L[k] && (trijouken - L[k]) >= 0) { ans++; } } idou:; } } Console.WriteLine(ans); } } }
using System; using System.Linq; namespace Csharp { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); int[] L = Console.ReadLine().Split(" ").Select(s => int.Parse(s)).ToArray(); int ans = 0; Array.Sort(L); for (int i = 0; i < N - 2; i++) { for (int j = i + 1; j < N - 1; j++) { if (L[i] >= L[j]) goto idou; int trijouken = L[i] + L[j]; for (int k = j + 1; k < N; k++) { if (L[j] < L[k] && (trijouken - L[k]) > 0) { ans++; } } idou:; } } Console.WriteLine(ans); } } }
[["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 20], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 47]]
8
209
2
using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; namespace B { class Program { static void Main(string[] args) { string line = Console.ReadLine(); int N = int.Parse(line); line = Console.ReadLine(); string[] strs = line.Split(' '); int[] L = new int[N]; for (int i = 0; i < N; i++) { L[i] = int.Parse(strs[i]); } int count = 0; for (int i = 0; i < N - 2; i++) { for (int j = i + 1; j < N - 1; j++) { for (int k = j + 1; k < N; k++) { if (L[i] == L[j] || L[i] == L[k] || L[k] == L[j]) continue; if (L[i] + L[j] >= L[k] && L[j] + L[k] >= L[i] && L[i] + L[k] >= L[j]) { count++; } } } } Console.WriteLine(count); } } }
using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; namespace B { class Program { static void Main(string[] args) { string line = Console.ReadLine(); int N = int.Parse(line); line = Console.ReadLine(); string[] strs = line.Split(' '); int[] L = new int[N]; for (int i = 0; i < N; i++) { L[i] = int.Parse(strs[i]); } int count = 0; for (int i = 0; i < N - 2; i++) { for (int j = i + 1; j < N - 1; j++) { for (int k = j + 1; k < N; k++) { if (L[i] == L[j] || L[i] == L[k] || L[k] == L[j]) continue; if (L[i] + L[j] > L[k] && L[j] + L[k] > L[i] && L[i] + L[k] > L[j]) { count++; } } } } Console.WriteLine(count); } } }
[["-", 0, 57, 15, 16, 31, 16, 31, 16, 17, 20], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 17, 47], ["-", 0, 57, 15, 16, 31, 16, 12, 16, 17, 20], ["+", 0, 57, 15, 16, 31, 16, 12, 16, 17, 47], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 20], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 47]]
8
288
6
using System; namespace ConsoleApp8 { class Program { static void Main(string[] args) { string a = Console.ReadLine(); int n = int.Parse(a); string b = Console.ReadLine(); string[] vs = b.Split(' '); long[] c = new long[n]; for (int i = 0; i < n; i++) { c[i] = int.Parse(vs[i]); } int cnt = 0; for (int i = 0; i < n - 2; i++) { for (int j = i + 1; j < n - 1; j++) { for (int k = j + 1; k < n; k++) { if (c[i] != c[j] && c[i] != c[k] && c[j] != c[k]) { long d = (c[i] + c[j] + c[k]) / 2; if (c[i] < d && c[j] < d && c[k] < d) { cnt++; } } } } } Console.WriteLine(cnt); } } }
using System; namespace ConsoleApp8 { class Program { static void Main(string[] args) { string a = Console.ReadLine(); int n = int.Parse(a); string b = Console.ReadLine(); string[] vs = b.Split(' '); long[] c = new long[n]; for (int i = 0; i < n; i++) { c[i] = int.Parse(vs[i]); } int cnt = 0; for (int i = 0; i < n - 2; i++) { for (int j = i + 1; j < n - 1; j++) { for (int k = j + 1; k < n; k++) { if (c[i] != c[j] && c[i] != c[k] && c[j] != c[k]) { double d = (double)(c[i] + c[j] + c[k]) / 2; if (c[i] < d && c[j] < d && c[k] < d) { cnt++; } } } } } Console.WriteLine(cnt); // Console.ReadLine(); } } }
[["-", 0, 57, 64, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 57, 64, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 0, 24], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 39, 199], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 0, 25]]
8
258
5
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace abc175_c { class Program { static void Main(string[] args) { var X = CIn.ReadLong(); var K = CIn.ReadLong(); var D = CIn.ReadLong(); var x = Math.Abs(X); if (x >= K * D) { Console.WriteLine(x - K * D); } else { if (K % 2 == x / D % 2) { Console.WriteLine(Math.Abs(x % D)); } else { Console.WriteLine(Math.Abs(x % D - D)); } } } } class CIn { private static readonly Queue<string> fieldBuffer = new Queue<string>(); public static string Read() { if (fieldBuffer.Count == 0) { foreach (var field in Console.ReadLine().Split()) { fieldBuffer.Enqueue(field); } } return fieldBuffer.Dequeue(); } public static int ReadInt() => int.Parse(Read()); public static long ReadLong() => long.Parse(Read()); public static double ReadDouble() => double.Parse(Read()); public static string[] ReadStringArray(long n) { var array = new string[n]; for (var i = 0; i < n; i++) { array[i] = Read(); } return array; } public static int[] ReadIntArray(long n) { var array = new int[n]; for (var i = 0; i < n; i++) { array[i] = ReadInt(); } return array; } public static long[] ReadLongArray(long n) { var array = new long[n]; for (var i = 0; i < n; i++) { array[i] = ReadLong(); } return array; } public static double[] ReadDoubleArray(long n) { var array = new double[n]; for (var i = 0; i < n; i++) { array[i] = ReadDouble(); } return array; } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace abc175_c { class Program { static void Main(string[] args) { var X = CIn.ReadLong(); var K = CIn.ReadLong(); var D = CIn.ReadLong(); var x = Math.Abs(X); if (x / D >= K) { Console.WriteLine(x - K * D); } else { if (K % 2 == x / D % 2) { Console.WriteLine(Math.Abs(x % D)); } else { Console.WriteLine(Math.Abs(x % D - D)); } } } } class CIn { private static readonly Queue<string> fieldBuffer = new Queue<string>(); public static string Read() { if (fieldBuffer.Count == 0) { foreach (var field in Console.ReadLine().Split()) { fieldBuffer.Enqueue(field); } } return fieldBuffer.Dequeue(); } public static int ReadInt() => int.Parse(Read()); public static long ReadLong() => long.Parse(Read()); public static double ReadDouble() => double.Parse(Read()); public static string[] ReadStringArray(long n) { var array = new string[n]; for (var i = 0; i < n; i++) { array[i] = Read(); } return array; } public static int[] ReadIntArray(long n) { var array = new int[n]; for (var i = 0; i < n; i++) { array[i] = ReadInt(); } return array; } public static long[] ReadLongArray(long n) { var array = new long[n]; for (var i = 0; i < n; i++) { array[i] = ReadLong(); } return array; } public static double[] ReadDoubleArray(long n) { var array = new double[n]; for (var i = 0; i < n; i++) { array[i] = ReadDouble(); } return array; } } }
[["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 85], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 48], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 12, 22]]
8
468
4
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CS { public class Class1 { static void Main() { long[] l = Console.ReadLine().Split(' ').Select((s) => long.Parse(s)).ToArray(); long X = l[0]; long K = l[1]; long D = l[2]; long x = Math.Abs(X); long ret = 0; long straight = K < X / D ? K : X / D; //真ん中を超えられない場合 K -= straight; X -= straight * D; if (K % 2 == 0) { ret = X; } else { ret = D - X; } Console.WriteLine(ret.ToString()); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CS { public class Class1 { static void Main() { long[] l = Console.ReadLine().Split(' ').Select((s) => long.Parse(s)).ToArray(); long X = l[0]; long K = l[1]; long D = l[2]; long x = Math.Abs(X); long ret = 0; long straight = K < x / D ? K : x / D; //真ん中を超えられない場合 K -= straight; x -= straight * D; if (K % 2 == 0) { ret = x; } else { ret = D - x; } Console.WriteLine(ret.ToString()); } } }
[["-", 0, 212, 0, 41, 15, 16, 12, 16, 31, 22], ["+", 0, 212, 0, 41, 15, 16, 12, 16, 31, 22], ["-", 0, 200, 0, 212, 0, 41, 75, 16, 31, 22], ["+", 0, 200, 0, 212, 0, 41, 75, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["-", 75, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 12, 22]]
8
178
10
using System; using System.Linq; using System.ComponentModel; using System.Collections.Generic; namespace AtCoder { public class TestCode { static void Main(string[] args) { var (X, K, D) = ReadValue<long, long, long>(); long ans = 0; var tmp = Math.Abs(X) / D; if (tmp < K) ans = Math.Abs(X) - (K * D); else { var t = Math.Abs(X) - (tmp * D); if ((K - tmp) % 2 == 0) { ans = t; } else { ans = t - D; } } Console.Write(Math.Abs(ans)); } static T1 ReadValue<T1>() { var t1 = TypeDescriptor.GetConverter(typeof(T1)); return (T1)t1.ConvertFromString(Console.ReadLine()); } static (T1, T2) ReadValue<T1, T2>() { var rl = Console.ReadLine().Trim().Split().ToArray(); var t1 = TypeDescriptor.GetConverter(typeof(T1)); var t2 = TypeDescriptor.GetConverter(typeof(T2)); return ((T1)t1.ConvertFromString(rl[0]), (T2)t2.ConvertFromString(rl[1])); } static (T1, T2, T3) ReadValue<T1, T2, T3>() { var rl = Console.ReadLine().Trim().Split().ToArray(); var t1 = TypeDescriptor.GetConverter(typeof(T1)); var t2 = TypeDescriptor.GetConverter(typeof(T2)); var t3 = TypeDescriptor.GetConverter(typeof(T3)); return ((T1)t1.ConvertFromString(rl[0]), (T2)t2.ConvertFromString(rl[1]), (T3)t3.ConvertFromString(rl[2])); } static (T1, T2, T3, T4) ReadValue<T1, T2, T3, T4>() { var rl = Console.ReadLine().Trim().Split().ToArray(); var t1 = TypeDescriptor.GetConverter(typeof(T1)); var t2 = TypeDescriptor.GetConverter(typeof(T2)); var t3 = TypeDescriptor.GetConverter(typeof(T3)); var t4 = TypeDescriptor.GetConverter(typeof(T4)); return ((T1)t1.ConvertFromString(rl[0]), (T2)t2.ConvertFromString(rl[1]), (T3)t3.ConvertFromString(rl[2]), (T4)t4.ConvertFromString(rl[3])); } static (T1, T2, T3, T4, T5) ReadValue<T1, T2, T3, T4, T5>() { var rl = Console.ReadLine().Trim().Split().ToArray(); var t1 = TypeDescriptor.GetConverter(typeof(T1)); var t2 = TypeDescriptor.GetConverter(typeof(T2)); var t3 = TypeDescriptor.GetConverter(typeof(T3)); var t4 = TypeDescriptor.GetConverter(typeof(T4)); var t5 = TypeDescriptor.GetConverter(typeof(T5)); return ((T1)t1.ConvertFromString(rl[0]), (T2)t2.ConvertFromString(rl[1]), (T3)t3.ConvertFromString(rl[2]), (T4)t4.ConvertFromString(rl[3]), (T5)t5.ConvertFromString(rl[4])); } static string[] stringArray => Console.ReadLine().Split().ToArray(); static int[] intArray => Console.ReadLine().Trim().Split().Select(int.Parse).ToArray(); static long[] longArray => Console.ReadLine().Trim().Split().Select(long.Parse).ToArray(); static double[] doubleArray => Console.ReadLine().Trim().Split().Select(double.Parse).ToArray(); static decimal[] decimalArray => Console.ReadLine().Trim().Split().Select(decimal.Parse).ToArray(); } }
using System; using System.Linq; using System.ComponentModel; using System.Collections.Generic; namespace AtCoder { public class TestCode { static void Main(string[] args) { var (X, K, D) = ReadValue<long, long, long>(); long ans = 0; var tmp = Math.Abs(X) / D; if (tmp > K) ans = Math.Abs(X) - (K * D); else { var t = Math.Abs(X) - (tmp * D); if ((K - tmp) % 2 == 0) { ans = t; } else { ans = t - D; } } Console.Write(Math.Abs(ans)); } static T1 ReadValue<T1>() { var t1 = TypeDescriptor.GetConverter(typeof(T1)); return (T1)t1.ConvertFromString(Console.ReadLine()); } static (T1, T2) ReadValue<T1, T2>() { var rl = Console.ReadLine().Trim().Split().ToArray(); var t1 = TypeDescriptor.GetConverter(typeof(T1)); var t2 = TypeDescriptor.GetConverter(typeof(T2)); return ((T1)t1.ConvertFromString(rl[0]), (T2)t2.ConvertFromString(rl[1])); } static (T1, T2, T3) ReadValue<T1, T2, T3>() { var rl = Console.ReadLine().Trim().Split().ToArray(); var t1 = TypeDescriptor.GetConverter(typeof(T1)); var t2 = TypeDescriptor.GetConverter(typeof(T2)); var t3 = TypeDescriptor.GetConverter(typeof(T3)); return ((T1)t1.ConvertFromString(rl[0]), (T2)t2.ConvertFromString(rl[1]), (T3)t3.ConvertFromString(rl[2])); } static (T1, T2, T3, T4) ReadValue<T1, T2, T3, T4>() { var rl = Console.ReadLine().Trim().Split().ToArray(); var t1 = TypeDescriptor.GetConverter(typeof(T1)); var t2 = TypeDescriptor.GetConverter(typeof(T2)); var t3 = TypeDescriptor.GetConverter(typeof(T3)); var t4 = TypeDescriptor.GetConverter(typeof(T4)); return ((T1)t1.ConvertFromString(rl[0]), (T2)t2.ConvertFromString(rl[1]), (T3)t3.ConvertFromString(rl[2]), (T4)t4.ConvertFromString(rl[3])); } static (T1, T2, T3, T4, T5) ReadValue<T1, T2, T3, T4, T5>() { var rl = Console.ReadLine().Trim().Split().ToArray(); var t1 = TypeDescriptor.GetConverter(typeof(T1)); var t2 = TypeDescriptor.GetConverter(typeof(T2)); var t3 = TypeDescriptor.GetConverter(typeof(T3)); var t4 = TypeDescriptor.GetConverter(typeof(T4)); var t5 = TypeDescriptor.GetConverter(typeof(T5)); return ((T1)t1.ConvertFromString(rl[0]), (T2)t2.ConvertFromString(rl[1]), (T3)t3.ConvertFromString(rl[2]), (T4)t4.ConvertFromString(rl[3]), (T5)t5.ConvertFromString(rl[4])); } static string[] stringArray => Console.ReadLine().Split().ToArray(); static int[] intArray => Console.ReadLine().Trim().Split().Select(int.Parse).ToArray(); static long[] longArray => Console.ReadLine().Trim().Split().Select(long.Parse).ToArray(); static double[] doubleArray => Console.ReadLine().Trim().Split().Select(double.Parse).ToArray(); static decimal[] decimalArray => Console.ReadLine().Trim().Split().Select(decimal.Parse).ToArray(); } }
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47]]
8
886
2
using static System.Math; using static System.Console; using System.Collections.Generic; using System.Linq; using System; using System.Collections; class Program { #region Reader static string ReadStr => Console.ReadLine(); static string[] ReadStrs => Console.ReadLine().Split(' '); static int ReadInt => Convert.ToInt32(Console.ReadLine().Trim()); static int[] ReadInts => Console.ReadLine() .Trim() .Split(' ') .Select(s => Convert.ToInt32(s)) .ToArray(); static long ReadLong => Convert.ToInt64(Console.ReadLine().Trim()); static long[] ReadLongs => Console.ReadLine() .Trim() .Split(' ') .Select(s => Convert.ToInt64(s)) .ToArray(); #endregion #region Method const int mod = 1000000007; public static int Mod(int a, int mod) { return a % mod >= 0 ? a % mod : a % mod + mod; } public static long Mod(long a, long mod = mod) { return a % mod >= 0 ? a % mod : a % mod + mod; } #endregion static void Main() { long[] AS = ReadLongs; long X = Abs(AS[0]); long K = AS[1]; long D = AS[2]; if (X - K * D >= 0) WriteLine(X - K * D); else { K -= X / D; X -= (X / D) * D; WriteLine(K % 2 == 0 ? Abs(X) : Abs(X - D)); } } }
using static System.Math; using static System.Console; using System.Collections.Generic; using System.Linq; using System; using System.Collections; class Program { #region Reader static string ReadStr => Console.ReadLine(); static string[] ReadStrs => Console.ReadLine().Split(' '); static int ReadInt => Convert.ToInt32(Console.ReadLine().Trim()); static int[] ReadInts => Console.ReadLine() .Trim() .Split(' ') .Select(s => Convert.ToInt32(s)) .ToArray(); static long ReadLong => Convert.ToInt64(Console.ReadLine().Trim()); static long[] ReadLongs => Console.ReadLine() .Trim() .Split(' ') .Select(s => Convert.ToInt64(s)) .ToArray(); #endregion #region Method const int mod = 1000000007; public static int Mod(int a, int mod) { return a % mod >= 0 ? a % mod : a % mod + mod; } public static long Mod(long a, long mod = mod) { return a % mod >= 0 ? a % mod : a % mod + mod; } #endregion static void Main() { long[] AS = ReadLongs; long X = Abs(AS[0]); long K = AS[1]; long D = AS[2]; if (X / D > K) WriteLine(X - K * D); else { K -= X / D; X -= (X / D) * D; WriteLine(K % 2 == 0 ? Abs(X) : Abs(X - D)); } } }
[["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 33], ["-", 0, 57, 15, 16, 31, 16, 12, 16, 31, 22], ["-", 0, 57, 15, 16, 31, 16, 12, 16, 17, 48], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 85], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 20], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22]]
8
359
8
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABC175C { class Program { static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); long X = long.Parse(input[0]); long K = long.Parse(input[1]); long D = long.Parse(input[2]); if (X < 0) { X *= -1; } if (X == 0) { if (K % 2 == 0) { Console.WriteLine(0); } else { Console.WriteLine(D); } } else { if (D < X / K) { Console.WriteLine(X - D * K); } else { long amari = X % D; long count = ((X - amari) / D) + 1; long temp = X - (D * count); if ((K - count) % 2 == 0) { Console.WriteLine(temp * (-1)); } else { Console.WriteLine(temp + D); } } } } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABC175C { class Program { static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); long X = long.Parse(input[0]); long K = long.Parse(input[1]); long D = long.Parse(input[2]); if (X < 0) { X *= -1; } if (X == 0) { if (K % 2 == 0) { Console.WriteLine(0); } else { Console.WriteLine(D); } } else { if (K <= X / D) { Console.WriteLine(X - D * K); } else { long amari = X % D; long count = ((X - amari) / D) + 1; long temp = X - (D * count); if ((K - count) % 2 == 0) { Console.WriteLine(temp * (-1)); } else { Console.WriteLine(temp + D); } } } } } }
[["-", 0, 57, 75, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 57, 75, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 17, 19], ["-", 75, 196, 0, 57, 15, 16, 12, 16, 12, 22], ["+", 75, 196, 0, 57, 15, 16, 12, 16, 12, 22]]
8
249
6
using System; using System.Linq; using System.Security.Cryptography.X509Certificates; namespace _0815 { class Program { static long x, k, d; static void Main(string[] args) { var xkd = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray(); x = xkd[0]; k = xkd[1]; d = xkd[2]; long result = Solution(); Console.WriteLine(result); } static long Solution() { x = Math.Abs(x); long res = 0; if (x - k * d >= d) { res = x - k * d; } else { while (x >= d) { x -= d; k--; } k = k % 2; res = x - d * k; } res = Math.Abs(res); return res; } } }
using System; using System.Linq; using System.Security.Cryptography.X509Certificates; namespace _0815 { class Program { static long x, k, d; static void Main(string[] args) { var xkd = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray(); x = xkd[0]; k = xkd[1]; d = xkd[2]; long result = Solution(); Console.WriteLine(result); } static long Solution() { x = Math.Abs(x); long res = 0; if (x / d >= k) { res = x - k * d; } else { while (x >= d) { x -= d; k--; } k = k % 2; res = x - d * k; } res = Math.Abs(res); return res; } } }
[["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 33], ["-", 0, 57, 15, 16, 31, 16, 12, 16, 31, 22], ["-", 0, 57, 15, 16, 31, 16, 12, 16, 17, 48], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 85], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22]]
8
196
6
using System; using static System.Console; using static System.Math; using System.Numerics; using System.Collections.Generic; using System.Linq; namespace AtCoder { public class Program { public static void Main(string[] args) { var s = myRead.readLongArray(); long a = Abs(s[0]) / s[2]; long b = Abs(s[0]) % s[2]; long ans = 0; if (a < s[1]) { long n = s[1] - a; int hugo = s[0] > 0 ? 1 : -1; ans = hugo * (n % 2 == 0 ? b : -(b - s[2])); } else { ans = s[0] > 0 ? s[0] - s[1] * s[2] : s[0] + s[1] * s[2]; } WriteLine(ans); } } public static class myRead { public static int readInt() { return int.Parse(ReadLine()); } public static long readLong() { return long.Parse(ReadLine()); } public static string reatStr() { return ReadLine(); } public static int[] readIntArray() { return ReadLine().Split(' ').Select(int.Parse).ToArray(); } public static long[] readLongArray() { return ReadLine().Split(' ').Select(long.Parse).ToArray(); } public static string[] readStrArray() { return ReadLine().Split(' '); } } public static class MyMath { public static long Factorical(long n) { return n <= 1 ? 1L : n * Factorical(n - 1); } public static long Permutation(long n, long m) { return m == 0 ? 1L : (m == n) ? Permutation(n, m - 1) : n * Permutation(n - 1, m - 1); } public static long Combination(long n, long m) { return n - m > m ? Permutation(n, m) / Factorical(m) : Permutation(n, n - m) / Factorical(n - m); } public static long Gcd(long n, long m) { return n % m == 0 ? m : Gcd(m, n % m); } public static long Lcm(long n, long m) { return n * m / Gcd(n, m); } public static long Pow(long n, long m) { return m == 0 ? 1L : m == 1 ? n : n * Pow(n, m - 1); } } }
using System; using static System.Console; using static System.Math; using System.Numerics; using System.Collections.Generic; using System.Linq; namespace AtCoder { public class Program { public static void Main(string[] args) { var s = myRead.readLongArray(); long a = Abs(s[0]) / s[2]; long b = Abs(s[0]) % s[2]; long ans = 0; if (a < s[1]) { long n = s[1] - a; int hugo = s[0] > 0 ? 1 : -1; ans = hugo * (n % 2 == 0 ? b : -(b - s[2])); } else { ans = s[0] > 0 ? s[0] - s[1] * s[2] : s[0] + s[1] * s[2]; } WriteLine(Abs(ans)); } } public static class myRead { public static int readInt() { return int.Parse(ReadLine()); } public static long readLong() { return long.Parse(ReadLine()); } public static string reatStr() { return ReadLine(); } public static int[] readIntArray() { return ReadLine().Split(' ').Select(int.Parse).ToArray(); } public static long[] readLongArray() { return ReadLine().Split(' ').Select(long.Parse).ToArray(); } public static string[] readStrArray() { return ReadLine().Split(' '); } } public static class MyMath { public static long Factorical(long n) { return n <= 1 ? 1L : n * Factorical(n - 1); } public static long Permutation(long n, long m) { return m == 0 ? 1L : (m == n) ? Permutation(n, m - 1) : n * Permutation(n - 1, m - 1); } public static long Combination(long n, long m) { return n - m > m ? Permutation(n, m) / Factorical(m) : Permutation(n, n - m) / Factorical(n - m); } public static long Gcd(long n, long m) { return n % m == 0 ? m : Gcd(m, n % m); } public static long Lcm(long n, long m) { return n * m / Gcd(n, m); } public static long Pow(long n, long m) { return m == 0 ? 1L : m == 1 ? n : n * Pow(n, m - 1); } } }
[["+", 0, 213, 3, 4, 0, 28, 0, 213, 63, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25]]
8
570
3
using System; using System.Linq; namespace ConsoleApp3 { internal class Program { private static void Main(string[] args) { var input = Console.ReadLine().Split(" ").Select(decimal.Parse).ToArray(); var x = input[0]; var k = input[1]; var d = input[2]; var minX = x % d; var count = Math.Floor(x / d); var leftCount = k - count; if (leftCount < 0) { Console.WriteLine(Math.Abs(x) - k * d); } else if (leftCount % 2 == 0) { Console.WriteLine(Math.Abs(minX)); } else if (minX > 0) { Console.WriteLine(Math.Abs(minX - d)); } else { Console.WriteLine(Math.Abs(minX + d)); } } } }
using System; using System.Linq; namespace ConsoleApp3 { internal class Program { private static void Main(string[] args) { var input = Console.ReadLine().Split(" ").Select(decimal.Parse).ToArray(); var x = input[0]; var k = input[1]; var d = input[2]; var minX = x % d; var count = Math.Floor(Math.Abs(x) / d); var leftCount = k - count; if (leftCount < 0) { Console.WriteLine(Math.Abs(x) - k * d); } else if (leftCount % 2 == 0) { Console.WriteLine(Math.Abs(minX)); } else if (minX > 0) { Console.WriteLine(Math.Abs(minX - d)); } else { Console.WriteLine(Math.Abs(minX + d)); } } } }
[["+", 0, 28, 0, 16, 31, 213, 63, 214, 205, 22], ["+", 0, 28, 0, 16, 31, 213, 63, 214, 0, 131], ["+", 0, 28, 0, 16, 31, 213, 63, 214, 141, 22], ["+", 0, 28, 0, 16, 31, 213, 3, 4, 0, 24], ["+", 0, 28, 0, 16, 31, 213, 3, 4, 0, 25]]
8
193
5
using System; namespace ABC178C { class Program { static void Main(string[] args) { var n = long.Parse(Console.ReadLine()); var mod = 1000000007L; var all = 1L; var except0and9 = 1L; var except0 = 1L; var except9 = 1L; for (var i = 0; i < n; i++) { all = (all * 10) % mod; except0and9 = (except0and9 * 8) % mod; except0 = (except0 * 9) % mod; except9 = (except9 * 9) % mod; } var answer = (all - except0 - except9 + except0and9) % mod; Console.WriteLine(answer); } } }
using System; namespace ABC178C { class Program { static void Main(string[] args) { var n = long.Parse(Console.ReadLine()); var mod = 1000000007L; var all = 1L; var except0and9 = 1L; var except0 = 1L; var except9 = 1L; for (var i = 0; i < n; i++) { all = (all * 10) % mod; except0and9 = (except0and9 * 8) % mod; except0 = (except0 * 9) % mod; except9 = (except9 * 9) % mod; } var answer = (all - except0 - except9 + except0and9 + mod * 4) % mod; Console.WriteLine(answer); } } }
[["+", 0, 212, 0, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 16, 31, 23, 0, 16, 12, 16, 31, 22], ["+", 0, 16, 31, 23, 0, 16, 12, 16, 17, 48], ["+", 0, 16, 31, 23, 0, 16, 12, 16, 12, 203]]
8
139
4
using System; using System.Numerics; namespace ConsoleApp2 { class Program { static void Main(string[] args) { var n = long.Parse(Console.ReadLine()); Console.WriteLine(Resolve(n)); } private static long Resolve(long n) { long A = 1; long B = 1; long C1 = 1; long C2 = 1; long mod = 1000000000 + 7; long res = 1; // 1000000000 + 7; for (long i = 0; i < n; ++i) { A = (10 * A) % mod; B = (8 * B) % mod; C1 = (9 * C1) % mod; C2 = (9 * C2) % mod; } return (A - C1 - C2 + B + mod) % mod; } } }
using System; using System.Numerics; namespace ConsoleApp2 { class Program { static void Main(string[] args) { var n = long.Parse(Console.ReadLine()); Console.WriteLine(Resolve(n)); } private static long Resolve(long n) { long A = 1; long B = 1; long C1 = 1; long C2 = 1; long mod = 1000000000 + 7; long res = 1; // 1000000000 + 7; for (long i = 0; i < n; ++i) { A = (10 * A) % mod; B = (8 * B) % mod; C1 = (9 * C1) % mod; C2 = (9 * C2) % mod; } return (A - C1 - C2 + B + mod + mod) % mod; } } }
[["+", 0, 37, 0, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 37, 0, 16, 31, 23, 0, 16, 12, 22]]
8
165
2
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; static public string al = "abcdefghijklmnopqrstuvwxyz"; public static void Main() { // •ûj // var n = rint(); long all = 1; long i0or9 = 1; long not09 = 1; for (int i = 0; i < n; i++) { all = (all * 10) % mod; i0or9 = (i0or9 * 9) % mod; not09 = (not09 * 8) % mod; } long ans = all - i0or9 * 2 + not09 + mod; WriteLine(ans % mod); } 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) { if (n < r) return 0; 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; } // 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] = double.Parse(read_str_array[countup_i]); } return return_double_array; } // ----------------------------- 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; static public string al = "abcdefghijklmnopqrstuvwxyz"; public static void Main() { // •ûj // var n = rint(); long all = 1; long i0or9 = 1; long not09 = 1; for (int i = 0; i < n; i++) { all = (all * 10) % mod; i0or9 = (i0or9 * 9) % mod; not09 = (not09 * 8) % mod; } long ans = all - i0or9 - i0or9 + not09 + mod + mod; WriteLine(ans % mod); } 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) { if (n < r) return 0; 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; } // 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] = double.Parse(read_str_array[countup_i]); } return return_double_array; } // ----------------------------- 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, 16, 31, 16, 31, 16, 12, 16, 17, 48], ["-", 0, 16, 31, 16, 31, 16, 12, 16, 12, 203], ["+", 0, 16, 31, 16, 31, 16, 31, 16, 17, 33], ["+", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 200, 0, 212, 0, 16, 31, 16, 17, 72], ["+", 0, 200, 0, 212, 0, 16, 31, 16, 12, 22]]
8
1,158
6
using System; using System.Linq; namespace AtCoderBeginnerContest178 { class Program { static readonly int DIV = (int)Math.Pow(10, 9) + 7; static void Main(string[] args) { var input = long.Parse(Console.ReadLine()); if (input == 1) { Console.WriteLine(0); return; } else if (input == 2) { Console.WriteLine(1); return; } // 求めるべきは 10^(n-2) * nC2 long ten = 10; long nine = 9; long eight = 8; for (var i = 0; i < input - 1; i++) { ten = (ten * 10) % DIV; nine = (nine * 9) % DIV; eight = (eight * 8) % DIV; } var tmp = (ten + eight) % DIV; nine = (nine * 2) % DIV; var result = 0L; if (tmp > nine) { result = (ten - nine + eight) % DIV; } else { result = (ten - nine + eight + DIV) % DIV; } Console.WriteLine(result); } } }
using System; using System.Linq; namespace AtCoderBeginnerContest178 { class Program { static readonly int DIV = (int)Math.Pow(10, 9) + 7; static void Main(string[] args) { var input = long.Parse(Console.ReadLine()); if (input == 1) { Console.WriteLine(0); return; } else if (input == 2) { Console.WriteLine(2); return; } // 求めるべきは 10^(n-2) * nC2 long ten = 10; long nine = 9; long eight = 8; for (var i = 0; i < input - 1; i++) { ten = (ten * 10) % DIV; nine = (nine * 9) % DIV; eight = (eight * 8) % DIV; } var tmp = (ten + eight) % DIV; nine = (nine * 2) % DIV; var result = 0L; if (tmp > nine) { result = (ten - nine + eight) % DIV; } else { result = (ten - nine + eight + DIV) % DIV; } Console.WriteLine(result); } } }
[["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203]]
8
229
2
using System; namespace C { class Program { static void Main(string[] args) { var N = long.Parse(Console.ReadLine()); long MOD = 1000000007; long a10 = 1; long a9 = 1; long a8 = 1; for (int i = 0; i < N; i++) { a10 *= 10; a10 %= MOD; a9 *= 9; a9 %= MOD; a8 *= 8; a8 %= MOD; } long result = a10 - 2 * a9 + a8; if (result < 0) result += MOD; Console.WriteLine(result); } } }
using System; namespace C { class Program { static void Main(string[] args) { var N = long.Parse(Console.ReadLine()); long MOD = 1000000007; long a10 = 1; long a9 = 1; long a8 = 1; for (int i = 0; i < N; i++) { a10 *= 10; a10 %= MOD; a9 *= 9; a9 %= MOD; a8 *= 8; a8 %= MOD; } long result = a10 - 2 * a9 + a8; result %= MOD; if (result < 0) result += MOD; Console.WriteLine(result); } } }
[["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 132], ["+", 0, 195, 8, 196, 0, 1, 0, 11, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
8
124
4
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace D { class Program { const long r = 1000000007; static void Main(string[] args) { string line = Console.ReadLine(); int N = int.Parse(line); long[] A = new long[N + 1]; A[1] = 0; A[2] = 0; A[3] = 1; A[4] = 1; A[5] = 1; for (int i = 6; i <= N; i++) { A[i] = A[i - 1] + A[i - 3]; A[i] %= r; } Console.WriteLine(A[N]); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace D { class Program { const long r = 1000000007; static void Main(string[] args) { string line = Console.ReadLine(); int N = int.Parse(line); long[] A = new long[N < 6 ? 6 : N + 1]; A[1] = 0; A[2] = 0; A[3] = 1; A[4] = 1; A[5] = 1; for (int i = 6; i <= N; i++) { A[i] = A[i - 1] + A[i - 3]; A[i] %= r; } Console.WriteLine(A[N]); } } }
[["+", 39, 224, 225, 226, 0, 41, 15, 16, 17, 18], ["+", 39, 224, 225, 226, 0, 41, 15, 16, 12, 203], ["+", 0, 227, 39, 224, 225, 226, 0, 41, 0, 101], ["+", 0, 227, 39, 224, 225, 226, 0, 41, 64, 203], ["+", 0, 227, 39, 224, 225, 226, 0, 41, 0, 102], ["+", 39, 224, 225, 226, 0, 41, 75, 16, 31, 22]]
8
171
6
using System; using static System.Console; namespace abc178 { class Program { static int keyNum = (int)1e9 + 7; static void Main() { var s = int.Parse(ReadLine()); WriteLine(Redistribution(s)); } static int Redistribution(int s) { int[] facts = null; int[] revFacts = null; var total = 0L; for (var len = 1; len * 3 < s; ++len) { var rest = s - len * 3; GetFactorialsDiv(len + rest - 1, keyNum, out facts, out revFacts); total += NCRDiv(len + rest - 1, len - 1, facts, revFacts, keyNum); } return (int)(total % keyNum); } // nCr の計算に必要な階乗リストを求める static void GetFactorialsDiv(int n, int keyNum, out int[] facts, out int[] revFacts) { facts = new int[n + 1]; revFacts = new int[n + 1]; facts[0] = 1; var tmp = 1L; for (var i = 1; i <= n; ++i) { tmp = (tmp * i) % keyNum; facts[i] = (int)tmp; } // n!^-1 = n!^(m-2) (mod m) tmp = Exp(facts[n], keyNum - 2, keyNum); revFacts[n] = (int)tmp; for (var i = n; i > 1; --i) { tmp = (tmp * i) % keyNum; revFacts[i - 1] = (int)tmp; } } // 累乗 mod keyNum static long Exp(int n, int k, int keyNum) { if (k == 0) { return 1; } if (k == 1) { return n; } var half = Exp(n, k / 2, keyNum); var result = (half * half) % keyNum; return ((k % 2) == 0) ? result : ((result * n) % keyNum); } // nCr mod keyNum static int NCRDiv(int n, int r, int[] facts, int[] revFacts, int keyNum) { if (r == 0 || r == n) { return 1; } if (r == 1) { return n; } var result = 1L; result = (result * facts[n]) % keyNum; result = (result * revFacts[r]) % keyNum; result = (result * revFacts[n - r]) % keyNum; return (int)result; } } }
using System; using static System.Console; namespace abc178 { class Program { static int keyNum = (int)1e9 + 7; static void Main() { var s = int.Parse(ReadLine()); WriteLine(Redistribution(s)); } static int Redistribution(int s) { int[] facts = null; int[] revFacts = null; var total = 0L; for (var len = 1; len * 3 <= s; ++len) { var rest = s - len * 3; GetFactorialsDiv(len + rest - 1, keyNum, out facts, out revFacts); total += NCRDiv(len + rest - 1, len - 1, facts, revFacts, keyNum); } return (int)(total % keyNum); } // nCr の計算に必要な階乗リストを求める static void GetFactorialsDiv(int n, int keyNum, out int[] facts, out int[] revFacts) { facts = new int[n + 1]; revFacts = new int[n + 1]; facts[0] = 1; var tmp = 1L; for (var i = 1; i <= n; ++i) { tmp = (tmp * i) % keyNum; facts[i] = (int)tmp; } // n!^-1 = n!^(m-2) (mod m) tmp = Exp(facts[n], keyNum - 2, keyNum); revFacts[n] = (int)tmp; for (var i = n; i > 1; --i) { tmp = (tmp * i) % keyNum; revFacts[i - 1] = (int)tmp; } } // 累乗 mod keyNum static long Exp(int n, int k, int keyNum) { if (k == 0) { return 1; } if (k == 1) { return n; } var half = Exp(n, k / 2, keyNum); var result = (half * half) % keyNum; return ((k % 2) == 0) ? result : ((result * n) % keyNum); } // nCr mod keyNum static int NCRDiv(int n, int r, int[] facts, int[] revFacts, int keyNum) { if (r == 0 || r == n) { return 1; } if (r == 1) { return n; } var result = 1L; result = (result * facts[n]) % keyNum; result = (result * revFacts[r]) % keyNum; result = (result * revFacts[n - r]) % keyNum; return (int)result; } } }
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19]]
8
506
2
using System; using static System.Math; using System.Linq; using System.Text; using System.Collections; using System.Collections.Generic; namespace AtCoder { class Program { static void Main(string[] args) { var N = ReadLineInt(); var pmax = long.MinValue; var pmin = long.MaxValue; var mmax = long.MinValue; var mmin = long.MaxValue; for (int i = 0; i < N - 1; i++) { var line = ReadLineLongSplit(); var x = line[0]; var y = line[1]; pmax = Max(pmax, x + y); pmin = Min(pmin, x + y); mmax = Max(mmax, x - y); mmin = Min(mmin, x - y); } Console.WriteLine(Max(pmax - pmin, mmax - mmin)); } public static long Gcd(long a, long b) { if (a < b) return Gcd(b, a); while (b != 0) { var remainder = a % b; a = b; b = remainder; } return a; } public static int nCm(int n, int m) { if (n == 0) return 0; if (m == 0) return 1; return n * nCm(n - 1, m - 1) / m; } public static string ReadLine() { return Console.ReadLine(); } public static int ReadLineInt() { return int.Parse(ReadLine()); } public static long ReadLineLong() { return long.Parse(ReadLine()); } public static string[] ReadLineStringSplit(char s = ' ') { return ReadLine().Split(s).ToArray(); } public static int[] ReadLineIntSplit(char s = ' ') { return ReadLine().Split(s).Select(x => int.Parse(x)).ToArray(); } public static long[] ReadLineLongSplit(char s = ' ') { return ReadLine().Split(s).Select(x => long.Parse(x)).ToArray(); } } }
using System; using static System.Math; using System.Linq; using System.Text; using System.Collections; using System.Collections.Generic; namespace AtCoder { class Program { static void Main(string[] args) { var N = ReadLineInt(); var pmax = long.MinValue; var pmin = long.MaxValue; var mmax = long.MinValue; var mmin = long.MaxValue; for (int i = 0; i < N; i++) { var line = ReadLineLongSplit(); var x = line[0]; var y = line[1]; pmax = Max(pmax, x + y); pmin = Min(pmin, x + y); mmax = Max(mmax, x - y); mmin = Min(mmin, x - y); } Console.WriteLine(Max(pmax - pmin, mmax - mmin)); } public static long Gcd(long a, long b) { if (a < b) return Gcd(b, a); while (b != 0) { var remainder = a % b; a = b; b = remainder; } return a; } public static int nCm(int n, int m) { if (n == 0) return 0; if (m == 0) return 1; return n * nCm(n - 1, m - 1) / m; } public static string ReadLine() { return Console.ReadLine(); } public static int ReadLineInt() { return int.Parse(ReadLine()); } public static long ReadLineLong() { return long.Parse(ReadLine()); } public static string[] ReadLineStringSplit(char s = ' ') { return ReadLine().Split(s).ToArray(); } public static int[] ReadLineIntSplit(char s = ' ') { return ReadLine().Split(s).Select(x => int.Parse(x)).ToArray(); } public static long[] ReadLineLongSplit(char s = ' ') { return ReadLine().Split(s).Select(x => long.Parse(x)).ToArray(); } } }
[["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203]]
8
451
2
using System; using System.Collections; using System.IO; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Collections.Generic; using System.Threading.Tasks; class Program { // Main static void Main(string[] args) { //読み込む int N = int.Parse(Console.ReadLine()); long inf = 100000000000; // Z,Wそれぞれの最大値と最小値 /* 但し、 Z = x + y, W = x - y; */ long maxZ = 0; long minZ = inf; long maxW = 0; long minW = inf; for (int i = 0; i < N; i++) { long[] xy = Console.ReadLine().Split(' ').Select(j => long.Parse(j)).ToArray(); long z = xy[0] + xy[1]; if (maxZ < z) { maxZ = z; } if (minZ > z) { minZ = z; } long w = xy[0] - xy[1]; if (maxW < w) { maxW = w; } if (minW > w) { minW = w; } } long ans = Math.Max(maxZ - minZ, maxW - minW); Console.WriteLine(ans); } }
using System; using System.Collections; using System.IO; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Collections.Generic; using System.Threading.Tasks; class Program { // Main static void Main(string[] args) { //読み込む int N = int.Parse(Console.ReadLine()); long inf = 100000000000; // Z,Wそれぞれの最大値と最小値 /* 但し、 Z = x + y, W = x - y; */ long maxZ = -inf; long minZ = inf; long maxW = -inf; long minW = inf; for (int i = 0; i < N; i++) { long[] xy = Console.ReadLine().Split(' ').Select(j => long.Parse(j)).ToArray(); long z = xy[0] + xy[1]; if (maxZ < z) { maxZ = z; } if (minZ > z) { minZ = z; } long w = xy[0] - xy[1]; if (maxW < w) { maxW = w; } if (minW > w) { minW = w; } } long ans = Math.Max(maxZ - minZ, maxW - minW); Console.WriteLine(ans); } }
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 241, 0, 33], ["+", 0, 198, 0, 200, 0, 212, 0, 241, 0, 22]]
8
249
6
using System; using System.Linq; namespace AtCoderBeginnerContest178 { class Program { static void Main(string[] args) { var input = int.Parse(Console.ReadLine()); var dist = new int[input]; var rDist = new int[input]; var max = (int)Math.Pow(10, 9); for (var i = 0; i < input; i++) { var inputs = Console.ReadLine().Split().Select(int.Parse).ToArray(); dist[i] = inputs[0] + inputs[1]; rDist[i] = max - inputs[0] + max - inputs[1]; } Console.WriteLine( Math.Max(dist.Max() - dist.Min(), rDist.Max() - rDist.Min())); } } }
using System; using System.Linq; namespace AtCoderBeginnerContest178 { class Program { static void Main(string[] args) { var input = int.Parse(Console.ReadLine()); var dist = new int[input]; var rDist = new int[input]; var max = (int)Math.Pow(10, 9); for (var i = 0; i < input; i++) { var inputs = Console.ReadLine().Split().Select(int.Parse).ToArray(); dist[i] = inputs[0] + inputs[1]; rDist[i] = inputs[0] + max - inputs[1]; } Console.WriteLine( Math.Max(dist.Max() - dist.Min(), rDist.Max() - rDist.Min())); } } }
[["-", 0, 11, 12, 16, 31, 16, 31, 16, 31, 22], ["-", 0, 11, 12, 16, 31, 16, 31, 16, 17, 33]]
8
182
2
using System; using System.Collections; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); long[] xdash = new long[N]; long[] ydash = new long[N]; long[] x = new long[N]; long[] y = new long[N]; long[] xindex = new long[N]; long[] yindex = new long[N]; for (int i = 0; i < N; i++) { var strtmp = Console.ReadLine().Split(' '); xdash[i] = long.Parse(strtmp[0]); ydash[i] = long.Parse(strtmp[1]); x[i] = xdash[i] + ydash[i]; y[i] = xdash[i] - ydash[i]; xindex[i] = i; yindex[i] = i; } QuickSortS2B(x, xindex); QuickSortS2B(y, yindex); long xdiff = x[N - 1] - x[0]; long ydiff = y[N - 1] - x[0]; long ans = 0; if (xdiff > ydiff) { long orig_xdash1 = xdash[xindex[N - 1]]; long orig_xdash2 = xdash[xindex[0]]; long orig_ydash1 = ydash[xindex[N - 1]]; long orig_ydash2 = ydash[xindex[0]]; ans = Math.Abs(orig_xdash1 - orig_xdash2) + Math.Abs(orig_ydash1 - orig_ydash2); } else { long orig_xdash1 = xdash[yindex[N - 1]]; long orig_xdash2 = xdash[yindex[0]]; long orig_ydash1 = ydash[yindex[N - 1]]; long orig_ydash2 = ydash[yindex[0]]; ans = Math.Abs(orig_xdash1 - orig_xdash2) + Math.Abs(orig_ydash1 - orig_ydash2); } Console.WriteLine(ans); } static void QuickSortS2B(long[] a, long[] index) { QuickSortS2B(a, index, 0, a.Length - 1); } static void QuickSortS2B(long[] a, long[] index, int left, int right) { if (left < right) { int i = left; int j = right; long tmp; long pivot = med3(a[i], a[i + (j - i) / 2], a[j]); while (true) { while (a[i] < pivot) i++; while (pivot < a[j]) j--; if (i >= j) break; tmp = a[i]; a[i] = a[j]; a[j] = tmp; tmp = index[i]; index[i] = index[j]; index[j] = tmp; i++; j--; } QuickSortS2B(a, index, left, i - 1); QuickSortS2B(a, index, j + 1, right); } } static long med3(long x, long y, long z) { if (x < y) { if (y < z) { return y; } else if (z < x) { return x; } else { return z; } } else { if (z < y) { return y; } else if (x < z) { return x; } else { return z; } } } } // dotnet run --project test
using System; using System.Collections; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); long[] xdash = new long[N]; long[] ydash = new long[N]; long[] x = new long[N]; long[] y = new long[N]; long[] xindex = new long[N]; long[] yindex = new long[N]; for (int i = 0; i < N; i++) { var strtmp = Console.ReadLine().Split(' '); xdash[i] = long.Parse(strtmp[0]); ydash[i] = long.Parse(strtmp[1]); x[i] = xdash[i] + ydash[i]; y[i] = xdash[i] - ydash[i]; xindex[i] = i; yindex[i] = i; } QuickSortS2B(x, xindex); QuickSortS2B(y, yindex); long xdiff = x[N - 1] - x[0]; long ydiff = y[N - 1] - y[0]; long ans = 0; if (xdiff > ydiff) { long orig_xdash1 = xdash[xindex[N - 1]]; long orig_xdash2 = xdash[xindex[0]]; long orig_ydash1 = ydash[xindex[N - 1]]; long orig_ydash2 = ydash[xindex[0]]; ans = Math.Abs(orig_xdash1 - orig_xdash2) + Math.Abs(orig_ydash1 - orig_ydash2); } else { long orig_xdash1 = xdash[yindex[N - 1]]; long orig_xdash2 = xdash[yindex[0]]; long orig_ydash1 = ydash[yindex[N - 1]]; long orig_ydash2 = ydash[yindex[0]]; ans = Math.Abs(orig_xdash1 - orig_xdash2) + Math.Abs(orig_ydash1 - orig_ydash2); } Console.WriteLine(ans); } static void QuickSortS2B(long[] a, long[] index) { QuickSortS2B(a, index, 0, a.Length - 1); } static void QuickSortS2B(long[] a, long[] index, int left, int right) { if (left < right) { int i = left; int j = right; long tmp; long pivot = med3(a[i], a[i + (j - i) / 2], a[j]); while (true) { while (a[i] < pivot) i++; while (pivot < a[j]) j--; if (i >= j) break; tmp = a[i]; a[i] = a[j]; a[j] = tmp; tmp = index[i]; index[i] = index[j]; index[j] = tmp; i++; j--; } QuickSortS2B(a, index, left, i - 1); QuickSortS2B(a, index, j + 1, right); } } static long med3(long x, long y, long z) { if (x < y) { if (y < z) { return y; } else if (z < x) { return x; } else { return z; } } else { if (z < y) { return y; } else if (x < z) { return x; } else { return z; } } } } // dotnet run --project test
[["-", 0, 200, 0, 212, 0, 16, 12, 204, 205, 22], ["+", 0, 200, 0, 212, 0, 16, 12, 204, 205, 22]]
8
730
2
using System; using System.Collections.Generic; namespace ConsoleApp1 { class ABC178F { // https://atcoder.jp/contests/abc178/tasks/abc178_f const long m = 1000000007; static int[] A = new int[200001]; static int[] B = new int[200001]; static int[] CA = new int[200001]; static int[] CB = new int[200001]; static void Main(string[] args) { int N = Int32.Parse(Console.ReadLine()); var itemsA = Console.ReadLine().Split(); var itemsB = Console.ReadLine().Split(); for (int i = 0; i < N; i++) { A[i] = Int32.Parse(itemsA[i]); B[i] = Int32.Parse(itemsB[i]); CA[A[i]] += 1; CB[B[i]] += 1; } for (int i = 0; i < N; i++) { if (CA[i] + CB[i] > N) { Console.WriteLine("No"); return; } } int max = 0; for (int i = 1; i <= N; i++) { CA[i] += CA[i - 1]; CB[i] += CB[i - 1]; max = Math.Max(max, CA[i] - CB[i - 1]); } Console.WriteLine("Yes"); for (int i = 0; i < N - 1; i++) { int index = (i + N - max) % N; Console.Write(B[index] + " "); } int index2 = (N - 1 + N - max) % N; Console.WriteLine(B[index2]); } } }
using System; using System.Collections.Generic; namespace ConsoleApp1 { class ABC178F { // https://atcoder.jp/contests/abc178/tasks/abc178_f const long m = 1000000007; static int[] A = new int[200001]; static int[] B = new int[200001]; static int[] CA = new int[200001]; static int[] CB = new int[200001]; static void Main(string[] args) { int N = Int32.Parse(Console.ReadLine()); var itemsA = Console.ReadLine().Split(); var itemsB = Console.ReadLine().Split(); for (int i = 0; i < N; i++) { A[i] = Int32.Parse(itemsA[i]); B[i] = Int32.Parse(itemsB[i]); CA[A[i]] += 1; CB[B[i]] += 1; } for (int i = 1; i <= N; i++) { if (CA[i] + CB[i] > N) { Console.WriteLine("No"); return; } } int max = 0; for (int i = 1; i <= N; i++) { CA[i] += CA[i - 1]; CB[i] += CB[i - 1]; max = Math.Max(max, CA[i] - CB[i - 1]); } Console.WriteLine("Yes"); for (int i = 0; i < N - 1; i++) { int index = (i + N - max) % N; Console.Write(B[index] + " "); } int index2 = (N - 1 + N - max) % N; Console.WriteLine(B[index2]); } } }
[["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19]]
8
378
4
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Text; using System.Threading; internal partial class Solver { public void Run() { var n = ni(); var m = ni(); var adj = Enumerable.Range(0, n).Select(_ => new List<int>()).ToArray(); for (var i = 0; i < m; i++) { var a = ni(); var b = ni(); adj[a].Add(b); } return; var scc = new StronglyConnectedComponentTarjan(adj); var g = scc.Run(); cout.WriteLine(g.Count); foreach (var group in g) { cout.Write(group.Count); foreach (var v in group) { cout.Write(" " + v); } cout.WriteLine(); } } } public class StronglyConnectedComponentTarjan { private readonly int _n; private readonly List<int>[] _adjacent; private readonly int[] _indexes, _low; private readonly Stack<int> _stack = new Stack<int>(); private int _index = 0, _groupNum = 0; public StronglyConnectedComponentTarjan(List<int>[] adj) { _adjacent = adj; _n = adj.Length; _indexes = new int[_n]; _low = new int[_n]; _stack = new Stack<int>(_n); } private void Dfs(int v, int[] group) { _low[v] = _indexes[v] = _index++; _stack.Push(v); foreach (var to in _adjacent[v]) { if (_indexes[to] == -1) { Dfs(to, group); _low[v] = Math.Min(_low[v], _low[to]); } else { _low[v] = Math.Min(_low[v], _indexes[to]); } } if (_low[v] == _indexes[v]) { while (true) { var w = _stack.Pop(); _indexes[w] = _adjacent.Length; group[w] = _groupNum; if (v == w) break; } _groupNum++; } } public List<List<int>> Run() { _groupNum = _index = 0; for (int i = 0; i < _adjacent.Length; i++) _indexes[i] = -1; var group = new int[_n]; for (int i = 0; i < _adjacent.Length; i++) { if (_indexes[i] == -1) { Dfs(i, group); } } var count = new int[_groupNum]; for (int i = 0; i < group.Length; i++) { group[i] = _groupNum - 1 - group[i]; count[group[i]]++; } var scc = new List<List<int>>(_groupNum); for (int i = 0; i < _groupNum; i++) { scc.Add(new List<int>(count[i])); } for (int i = 0; i < group.Length; i++) { scc[group[i]].Add(i); } return scc; } public int[] GetGroupArray() { var component = Run(); var group = new int[_n]; for (var i = 0; i < component.Count; i++) { foreach (var x in component[i]) { group[x] = i; } } return group; // group index is topological order } } public class StronglyConnectedComponent { private readonly int _n; private readonly bool[] _isVisited; private readonly List<int>[] _adjacent; private readonly List<int>[] _inverseAdjacent; private readonly Stack<int> _stack = new Stack<int>(); public StronglyConnectedComponent(List<int>[] adj) { _adjacent = adj; _n = adj.Length; _isVisited = new bool[_n]; _inverseAdjacent = new List<int>[_n]; for (var i = 0; i < _n; i++) { _inverseAdjacent[i] = new List<int>(); } for (var i = 0; i < _n; i++) { foreach (var x in adj[i]) { _inverseAdjacent[x].Add(i); } } } private void Traverse(int k, List<int>[] adjacent, List<int> label) { if (_isVisited[k]) { return; } _stack.Push(k); while (_stack.Count > 0) { int top = _stack.Pop(); if (top < 0) { label.Add(-top - 1); continue; } if (_isVisited[top]) { continue; } _isVisited[top] = true; _stack.Push(-(top + 1)); foreach (int x in adjacent[top]) { if (!_isVisited[x]) { _stack.Push(x); } } } } public List<List<int>> Run() { var label = new List<int>(); for (var i = 0; i < _n; i++) { Traverse(i, _adjacent, label); } label.Reverse(); Array.Clear(_isVisited, 0, _isVisited.Length); var components = new List<List<int>>(); foreach (var x in label) { if (!_isVisited[x]) { var group = new List<int>(); Traverse(x, _inverseAdjacent, group); components.Add(group); } } return components; } public int[] GetGroupArray() { var component = Run(); var group = new int[_n]; for (var i = 0; i < component.Count; i++) { foreach (var x in component[i]) { group[x] = i; } } return group; // group index is topological order } } // PREWRITEN CODE BEGINS FROM HERE static public class StringExtensions { static public string JoinToString<T>(this IEnumerable<T> source, string separator = " ") { return string.Join(separator, source); } } internal partial class Solver : Scanner { static readonly int? StackSizeInMebiByte = null; // 50; public static void StartAndJoin(Action action, int maxStackSize) { var thread = new Thread(new ThreadStart(action), maxStackSize); thread.Start(); thread.Join(); } public static void Main() { #if LOCAL byte[] inputBuffer = new byte[1000000]; var inputStream = Console.OpenStandardInput(inputBuffer.Length); using (var reader = new StreamReader(inputStream, Console.InputEncoding, false, inputBuffer.Length)) { Console.SetIn(reader); new Solver(Console.In, Console.Out).Run(); } #else Console.SetOut( new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }); if (StackSizeInMebiByte.HasValue) { StartAndJoin(() => new Solver(Console.In, Console.Out).Run(), StackSizeInMebiByte.Value * 1024 * 1024); } else { new Solver(Console.In, Console.Out).Run(); } Console.Out.Flush(); #endif } #pragma warning disable IDE0052 private readonly TextReader cin; private readonly TextWriter cout; private readonly TextWriter cerr; #pragma warning restore IDE0052 public Solver(TextReader reader, TextWriter writer) : base(reader) { cin = reader; cout = writer; cerr = Console.Error; } public Solver(string input, TextWriter writer) : this(new StringReader(input), writer) {} #pragma warning disable IDE1006 #pragma warning disable IDE0051 private int ni() { return NextInt(); } private int[] ni(int n) { return NextIntArray(n); } private long nl() { return NextLong(); } private long[] nl(int n) { return NextLongArray(n); } private double nd() { return NextDouble(); } private double[] nd(int n) { return NextDoubleArray(n); } private string ns() { return Next(); } private string[] ns(int n) { return NextArray(n); } #pragma warning restore IDE1006 #pragma warning restore IDE0051 } #if DEBUG internal static class LinqPadExtension { public static string TextDump<T>(this T obj) { if (obj is IEnumerable) return (obj as IEnumerable).Cast<object>().JoinToString().Dump(); else return obj.ToString().Dump(); } public static T Dump<T>(this T obj) { return LINQPad.Extensions.Dump(obj); } } #endif public class Scanner { private readonly TextReader Reader; private readonly CultureInfo ci = CultureInfo.InvariantCulture; private readonly char[] buffer = new char[2 * 1024]; private int cursor = 0, length = 0; private string Token; private readonly StringBuilder sb = new StringBuilder(1024); public Scanner() : this(Console.In) {} public Scanner(TextReader reader) { Reader = reader; } public int NextInt() { return checked((int)NextLong()); } public long NextLong() { var s = Next(); long r = 0; int i = 0; bool negative = false; if (s[i] == '-') { negative = true; i++; } for (; i < s.Length; i++) { r = r * 10 + (s[i] - '0'); #if DEBUG if (!char.IsDigit(s[i])) throw new FormatException(); #endif } return negative ? -r : r; } public double NextDouble() { return double.Parse(Next(), ci); } public string[] NextArray(int size) { string[] array = new string[size]; for (int i = 0; i < size; i++) { array[i] = Next(); } return array; } public int[] NextIntArray(int size) { int[] array = new int[size]; for (int i = 0; i < size; i++) { array[i] = NextInt(); } return array; } public long[] NextLongArray(int size) { long[] array = new long[size]; for (int i = 0; i < size; i++) { array[i] = NextLong(); } return array; } public double[] NextDoubleArray(int size) { double[] array = new double[size]; for (int i = 0; i < size; i++) { array[i] = NextDouble(); } return array; } public string Next() { if (Token == null) { if (!StockToken()) { throw new Exception(); } } var token = Token; Token = null; return token; } public bool HasNext() { if (Token != null) { return true; } return StockToken(); } private bool StockToken() { while (true) { sb.Clear(); while (true) { if (cursor >= length) { cursor = 0; if ((length = Reader.Read(buffer, 0, buffer.Length)) <= 0) { break; } } var c = buffer[cursor++]; if (33 <= c && c <= 126) { sb.Append(c); } else { if (sb.Length > 0) break; } } if (sb.Length > 0) { Token = sb.ToString(); return true; } return false; } } }
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Text; using System.Threading; internal partial class Solver { public void Run() { var n = ni(); var m = ni(); var adj = Enumerable.Range(0, n).Select(_ => new List<int>(100)).ToArray(); for (var i = 0; i < m; i++) { var a = ni(); var b = ni(); adj[a].Add(b); } var scc = new StronglyConnectedComponentTarjan(adj); var g = scc.Run(); cout.WriteLine(g.Count); foreach (var group in g) { cout.Write(group.Count); foreach (var v in group) { cout.Write(" " + v); } cout.WriteLine(); } } } public class StronglyConnectedComponentTarjan { private readonly int _n; private readonly List<int>[] _adjacent; private readonly int[] _indexes, _low; private readonly Stack<int> _stack = new Stack<int>(); private int _index = 0, _groupNum = 0; public StronglyConnectedComponentTarjan(List<int>[] adj) { _adjacent = adj; _n = adj.Length; _indexes = new int[_n]; _low = new int[_n]; _stack = new Stack<int>(_n); } private void Dfs(int v, int[] group) { _low[v] = _indexes[v] = _index++; _stack.Push(v); foreach (var to in _adjacent[v]) { if (_indexes[to] == -1) { Dfs(to, group); _low[v] = Math.Min(_low[v], _low[to]); } else { _low[v] = Math.Min(_low[v], _indexes[to]); } } if (_low[v] == _indexes[v]) { while (true) { var w = _stack.Pop(); _indexes[w] = _adjacent.Length; group[w] = _groupNum; if (v == w) break; } _groupNum++; } } public List<List<int>> Run() { _groupNum = _index = 0; for (int i = 0; i < _adjacent.Length; i++) _indexes[i] = -1; var group = new int[_n]; for (int i = 0; i < _adjacent.Length; i++) { if (_indexes[i] == -1) { Dfs(i, group); } } var count = new int[_groupNum]; for (int i = 0; i < group.Length; i++) { group[i] = _groupNum - 1 - group[i]; count[group[i]]++; } var scc = new List<List<int>>(_groupNum); for (int i = 0; i < _groupNum; i++) { scc.Add(new List<int>(count[i])); } for (int i = 0; i < group.Length; i++) { scc[group[i]].Add(i); } return scc; } public int[] GetGroupArray() { var component = Run(); var group = new int[_n]; for (var i = 0; i < component.Count; i++) { foreach (var x in component[i]) { group[x] = i; } } return group; // group index is topological order } } public class StronglyConnectedComponent { private readonly int _n; private readonly bool[] _isVisited; private readonly List<int>[] _adjacent; private readonly List<int>[] _inverseAdjacent; private readonly Stack<int> _stack = new Stack<int>(); public StronglyConnectedComponent(List<int>[] adj) { _adjacent = adj; _n = adj.Length; _isVisited = new bool[_n]; _inverseAdjacent = new List<int>[_n]; for (var i = 0; i < _n; i++) { _inverseAdjacent[i] = new List<int>(); } for (var i = 0; i < _n; i++) { foreach (var x in adj[i]) { _inverseAdjacent[x].Add(i); } } } private void Traverse(int k, List<int>[] adjacent, List<int> label) { if (_isVisited[k]) { return; } _stack.Push(k); while (_stack.Count > 0) { int top = _stack.Pop(); if (top < 0) { label.Add(-top - 1); continue; } if (_isVisited[top]) { continue; } _isVisited[top] = true; _stack.Push(-(top + 1)); foreach (int x in adjacent[top]) { if (!_isVisited[x]) { _stack.Push(x); } } } } public List<List<int>> Run() { var label = new List<int>(); for (var i = 0; i < _n; i++) { Traverse(i, _adjacent, label); } label.Reverse(); Array.Clear(_isVisited, 0, _isVisited.Length); var components = new List<List<int>>(); foreach (var x in label) { if (!_isVisited[x]) { var group = new List<int>(); Traverse(x, _inverseAdjacent, group); components.Add(group); } } return components; } public int[] GetGroupArray() { var component = Run(); var group = new int[_n]; for (var i = 0; i < component.Count; i++) { foreach (var x in component[i]) { group[x] = i; } } return group; // group index is topological order } } // PREWRITEN CODE BEGINS FROM HERE static public class StringExtensions { static public string JoinToString<T>(this IEnumerable<T> source, string separator = " ") { return string.Join(separator, source); } } internal partial class Solver : Scanner { static readonly int? StackSizeInMebiByte = null; // 50; public static void StartAndJoin(Action action, int maxStackSize) { var thread = new Thread(new ThreadStart(action), maxStackSize); thread.Start(); thread.Join(); } public static void Main() { #if LOCAL byte[] inputBuffer = new byte[1000000]; var inputStream = Console.OpenStandardInput(inputBuffer.Length); using (var reader = new StreamReader(inputStream, Console.InputEncoding, false, inputBuffer.Length)) { Console.SetIn(reader); new Solver(Console.In, Console.Out).Run(); } #else Console.SetOut( new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }); if (StackSizeInMebiByte.HasValue) { StartAndJoin(() => new Solver(Console.In, Console.Out).Run(), StackSizeInMebiByte.Value * 1024 * 1024); } else { new Solver(Console.In, Console.Out).Run(); } Console.Out.Flush(); #endif } #pragma warning disable IDE0052 private readonly TextReader cin; private readonly TextWriter cout; private readonly TextWriter cerr; #pragma warning restore IDE0052 public Solver(TextReader reader, TextWriter writer) : base(reader) { cin = reader; cout = writer; cerr = Console.Error; } public Solver(string input, TextWriter writer) : this(new StringReader(input), writer) {} #pragma warning disable IDE1006 #pragma warning disable IDE0051 private int ni() { return NextInt(); } private int[] ni(int n) { return NextIntArray(n); } private long nl() { return NextLong(); } private long[] nl(int n) { return NextLongArray(n); } private double nd() { return NextDouble(); } private double[] nd(int n) { return NextDoubleArray(n); } private string ns() { return Next(); } private string[] ns(int n) { return NextArray(n); } #pragma warning restore IDE1006 #pragma warning restore IDE0051 } #if DEBUG internal static class LinqPadExtension { public static string TextDump<T>(this T obj) { if (obj is IEnumerable) return (obj as IEnumerable).Cast<object>().JoinToString().Dump(); else return obj.ToString().Dump(); } public static T Dump<T>(this T obj) { return LINQPad.Extensions.Dump(obj); } } #endif public class Scanner { private readonly TextReader Reader; private readonly CultureInfo ci = CultureInfo.InvariantCulture; private readonly char[] buffer = new char[2 * 1024]; private int cursor = 0, length = 0; private string Token; private readonly StringBuilder sb = new StringBuilder(1024); public Scanner() : this(Console.In) {} public Scanner(TextReader reader) { Reader = reader; } public int NextInt() { return checked((int)NextLong()); } public long NextLong() { var s = Next(); long r = 0; int i = 0; bool negative = false; if (s[i] == '-') { negative = true; i++; } for (; i < s.Length; i++) { r = r * 10 + (s[i] - '0'); #if DEBUG if (!char.IsDigit(s[i])) throw new FormatException(); #endif } return negative ? -r : r; } public double NextDouble() { return double.Parse(Next(), ci); } public string[] NextArray(int size) { string[] array = new string[size]; for (int i = 0; i < size; i++) { array[i] = Next(); } return array; } public int[] NextIntArray(int size) { int[] array = new int[size]; for (int i = 0; i < size; i++) { array[i] = NextInt(); } return array; } public long[] NextLongArray(int size) { long[] array = new long[size]; for (int i = 0; i < size; i++) { array[i] = NextLong(); } return array; } public double[] NextDoubleArray(int size) { double[] array = new double[size]; for (int i = 0; i < size; i++) { array[i] = NextDouble(); } return array; } public string Next() { if (Token == null) { if (!StockToken()) { throw new Exception(); } } var token = Token; Token = null; return token; } public bool HasNext() { if (Token != null) { return true; } return StockToken(); } private bool StockToken() { while (true) { sb.Clear(); while (true) { if (cursor >= length) { cursor = 0; if ((length = Reader.Read(buffer, 0, buffer.Length)) <= 0) { break; } } var c = buffer[cursor++]; if (33 <= c && c <= 126) { sb.Append(c); } else { if (sb.Length > 0) break; } } if (sb.Length > 0) { Token = sb.ToString(); return true; } return false; } } }
[["+", 0, 218, 8, 230, 3, 4, 0, 28, 0, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 37, 0, 38], ["-", 8, 201, 0, 195, 8, 196, 0, 37, 0, 35]]
8
2,462
3
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 ProblemD { static bool SAIKI = false; static public int numberOfRandomCases = 0; static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker) {} struct E : IEquatable<E> { public long b; public long c; public bool Equals(E other) => b == other.b && c == other.c; } static public void Solve() { var N = NN; var Q = NN; var aList = NNList(N); var seg = new LIB_LazySegTree<long, E>( N, 0, new E { b = 1, c = 0 }, (x, y) => { var t = x + y; if (t >= 998244353) return t - 998244353; return t; }, (x, y, c) => (x * y.b + y.c * c) % 998244353, (x, y) => new E { b = (x.b * y.b) % 998244353, c = (x.c * y.b + y.c) % 998244353 }); for (var i = 0; i < N; i++) seg[i] = aList[i]; for (var i = 0; i < Q; i++) { if (NN == 0) { var l = NN; var r = NN; var b = NN; var c = NN; seg.Update(l, r, new E { b = b, c = c }); } else { var l = NN; var r = NN; Console.WriteLine(seg.Query(l, r) + 1); } } } 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 string Join<T>(this IEnumerable<T> x, string separator = "") => string.Join(separator, x); 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 { [MethodImpl(MethodImplOptions.AggressiveInlining)] 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 { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return isEof; } } [MethodImpl(MethodImplOptions.AggressiveInlining)] 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++]; } [MethodImpl(MethodImplOptions.AggressiveInlining)] char Char() { byte b = 0; do b = read(); while (b < 33 || 126 < b); return (char)b; } [MethodImpl(MethodImplOptions.AggressiveInlining)] 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(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] 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'; } } [MethodImpl(MethodImplOptions.AggressiveInlining)] virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); } } class LIB_FastIODebug : LIB_FastIO { Queue<string> param = new Queue<string>(); [MethodImpl(MethodImplOptions.AggressiveInlining)] string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public LIB_FastIODebug() {} [MethodImpl(MethodImplOptions.AggressiveInlining)] public override string Scan() => NextString(); [MethodImpl(MethodImplOptions.AggressiveInlining)] public override long Long() => long.Parse(NextString()); [MethodImpl(MethodImplOptions.AggressiveInlining)] public override double Double() => double.Parse(NextString()); } class LIB_LazySegTree { static public LIB_LazySegTree<long, long> CreateRangeUpdateRangeMin(IEnumerable<long> init) => new LIB_LazySegTree<long, long>(init, long.MaxValue, long.MinValue + 100, Math.Min, (x, y, c) => y, (x, y) => y); static public LIB_LazySegTree<long, long> CreateRangeAddRangeMin(IEnumerable<long> init) => new LIB_LazySegTree<long, long>(init, long.MaxValue, 0, Math.Min, (x, y, c) => x + y, (x, y) => x + y); static public LIB_LazySegTree<long, long> CreateRangeUpdateRangeMax(IEnumerable<long> init) => new LIB_LazySegTree<long, long>(init, long.MinValue, long.MaxValue - 100, Math.Max, (x, y, c) => y, (x, y) => y); static public LIB_LazySegTree<long, long> CreateRangeAddRangeMax(IEnumerable<long> init) => new LIB_LazySegTree<long, long>(init, long.MinValue, 0, Math.Max, (x, y, c) => x + y, (x, y) => x + y); static public LIB_LazySegTree<long, long> CreateRangeUpdateRangeSum(IEnumerable<long> init) => new LIB_LazySegTree<long, long>(init, 0, long.MaxValue, (x, y) => x + y, (x, y, c) => y * c, (x, y) => y); static public LIB_LazySegTree<long, long> CreateRangeAddRangeSum(IEnumerable<long> init) => new LIB_LazySegTree<long, long>(init, 0, 0, (x, y) => x + y, (x, y, c) => x + y * c, (x, y) => x + y); } class LIB_LazySegTree<T, E> where E : IEquatable<E> { int n, height, sz; int[] rangeSz; T ti; E ei; Func<T, T, T> f; Func<T, E, int, T> g; Func<E, E, E> h; T[] dat; E[] laz; [MethodImpl(MethodImplOptions.AggressiveInlining)] public LIB_LazySegTree(long _n, T _ti, E _ei, Func<T, T, T> _f, Func<T, E, int, T> _g, Func<E, E, E> _h) { n = 1; height = 0; sz = (int)_n; while (n < _n) { n <<= 1; ++height; } ti = _ti; ei = _ei; f = _f; g = _g; h = _h; dat = Enumerable.Repeat(ti, n << 1).ToArray(); laz = Enumerable.Repeat(ei, n << 1).ToArray(); rangeSz = Enumerable.Repeat(0, n << 1).ToArray(); for (var i = 0; i < sz; i++) rangeSz[n + i] = 1; for (var i = n - 1; i > 0; i--) { rangeSz[i] = rangeSz[(i << 1) | 0] + rangeSz[(i << 1) | 1]; dat[i] = f(dat[(i << 1) | 0], dat[(i << 1) | 1]); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public LIB_LazySegTree(IEnumerable<T> l, T _ti, E _ei, Func<T, T, T> _f, Func<T, E, int, T> _g, Func<E, E, E> _h) : this(l.Count(), _ti, _ei, _f, _g, _h) { var idx = 0; foreach (var item in l) dat[n + idx++] = item; for (var i = n - 1; i > 0; i--) dat[i] = f(dat[(i << 1) | 0], dat[(i << 1) | 1]); } [MethodImpl(MethodImplOptions.AggressiveInlining)] T Reflect(long i) => laz[i].Equals(ei) ? dat[i] : g(dat[i], laz[i], rangeSz[i]); [MethodImpl(MethodImplOptions.AggressiveInlining)] void Eval(long i) { if (laz[i].Equals(ei)) return; laz[(i << 1) | 0] = h(laz[(i << 1) | 0], laz[i]); laz[(i << 1) | 1] = h(laz[(i << 1) | 1], laz[i]); dat[i] = Reflect(i); laz[i] = ei; } [MethodImpl(MethodImplOptions.AggressiveInlining)] void Thrust(long i) { for (var j = height; j > 0; j--) Eval(i >> j); dat[i] = Reflect(i); laz[i] = ei; } [MethodImpl(MethodImplOptions.AggressiveInlining)] void Thrust(long l, long r) { if (l == r) { Thrust(l); return; } var xor = l ^ r; var i = height; for (; (xor >> i) != 0; --i) Eval(l >> i); for (; i != 0; --i) { Eval(l >> i); Eval(r >> i); } dat[l] = Reflect(l); laz[l] = ei; dat[r] = Reflect(r); laz[r] = ei; } [MethodImpl(MethodImplOptions.AggressiveInlining)] void Recalc(long i) { while ((i >>= 1) > 0) dat[i] = f(Reflect((i << 1) | 0), Reflect((i << 1) | 1)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] void Recalc(long l, long r) { var xor = l ^ r; while (xor > 1) { xor >>= 1; l >>= 1; r >>= 1; dat[l] = f(Reflect((l << 1) | 0), Reflect((l << 1) | 1)); dat[r] = f(Reflect((r << 1) | 0), Reflect((r << 1) | 1)); } while (l > 1) { l >>= 1; dat[l] = f(Reflect((l << 1) | 0), Reflect((l << 1) | 1)); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Update(long l, long r, E v) { if (l == r) return; if (r < l) throw new Exception(); Thrust(l += n, r += n - 1); for (long li = l, ri = r + 1; li < ri; li >>= 1, ri >>= 1) { if ((li & 1) == 1) { laz[li] = h(laz[li], v); ++li; } if ((ri & 1) == 1) { --ri; laz[ri] = h(laz[ri], v); } } Recalc(l, r); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public T Query(long l, long r) { if (l == r) return ti; if (r < l) throw new Exception(); Thrust(l += n, r += n - 1); var vl = ti; var vr = ti; for (long li = l, ri = r + 1; li < ri; li >>= 1, ri >>= 1) { if ((li & 1) == 1) vl = f(vl, Reflect(li++)); if ((ri & 1) == 1) vr = f(Reflect(--ri), vr); } return f(vl, vr); } [MethodImpl(MethodImplOptions.AggressiveInlining)] int FindToRight(int st, Func<T, bool> check, ref T acc, int k, int l, int r) { if (l + 1 == r) { acc = f(acc, Reflect(k)); return check(acc) ? k - n : sz; } Eval(k); int m = (l + r) >> 1; if (m <= st) return FindToRight(st, check, ref acc, (k << 1) | 1, m, r); if (st <= l && !check(f(acc, dat[k]))) { acc = f(acc, dat[k]); return sz; } int vl = FindToRight(st, check, ref acc, (k << 1) | 0, l, m); if (vl != sz) return vl; return FindToRight(st, check, ref acc, (k << 1) | 1, m, r); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public int FindToRight(int st, Func<T, bool> check) { T acc = ti; return FindToRight(st, check, ref acc, 1, 0, n); } [MethodImpl(MethodImplOptions.AggressiveInlining)] int FindToLeft(int st, Func<T, bool> check, ref T acc, int k, int l, int r) { if (l + 1 == r) { acc = f(Reflect(k), acc); return check(acc) ? k - n : -1; } Eval(k); int m = (l + r) >> 1; if (m > st) return FindToLeft(st, check, ref acc, (k << 1) | 0, l, m); if (st >= r - 1 && !check(f(dat[k], acc))) { acc = f(dat[k], acc); return -1; } int vr = FindToLeft(st, check, ref acc, (k << 1) | 1, m, r); if (vr != -1) return vr; return FindToLeft(st, check, ref acc, (k << 1) | 0, l, m); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public int FindToLeft(int st, Func<T, bool> check) { T acc = ti; return FindToLeft(st, check, ref acc, 1, 0, n); } public T this[long idx] { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { Thrust(idx += n); return Reflect(idx); } [MethodImpl(MethodImplOptions.AggressiveInlining)] set { Thrust(idx += n); dat[idx] = value; laz[idx] = ei; Recalc(idx); } } } }
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 ProblemD { static bool SAIKI = false; static public int numberOfRandomCases = 0; static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker) {} struct E : IEquatable<E> { public long b; public long c; public bool Equals(E other) => b == other.b && c == other.c; } static public void Solve() { var N = NN; var Q = NN; var aList = NNList(N); var seg = new LIB_LazySegTree<long, E>( N, 0, new E { b = 1, c = 0 }, (x, y) => { var t = x + y; if (t >= 998244353) return t - 998244353; return t; }, (x, y, c) => (x * y.b + y.c * c) % 998244353, (x, y) => new E { b = (x.b * y.b) % 998244353, c = (x.c * y.b + y.c) % 998244353 }); for (var i = 0; i < N; i++) seg[i] = aList[i]; for (var i = 0; i < Q; i++) { if (NN == 0) { var l = NN; var r = NN; var b = NN; var c = NN; seg.Update(l, r, new E { b = b, c = c }); } else { var l = NN; var r = NN; Console.WriteLine(seg.Query(l, r)); } } } 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 string Join<T>(this IEnumerable<T> x, string separator = "") => string.Join(separator, x); 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 { [MethodImpl(MethodImplOptions.AggressiveInlining)] 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 { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return isEof; } } [MethodImpl(MethodImplOptions.AggressiveInlining)] 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++]; } [MethodImpl(MethodImplOptions.AggressiveInlining)] char Char() { byte b = 0; do b = read(); while (b < 33 || 126 < b); return (char)b; } [MethodImpl(MethodImplOptions.AggressiveInlining)] 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(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] 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'; } } [MethodImpl(MethodImplOptions.AggressiveInlining)] virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); } } class LIB_FastIODebug : LIB_FastIO { Queue<string> param = new Queue<string>(); [MethodImpl(MethodImplOptions.AggressiveInlining)] string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public LIB_FastIODebug() {} [MethodImpl(MethodImplOptions.AggressiveInlining)] public override string Scan() => NextString(); [MethodImpl(MethodImplOptions.AggressiveInlining)] public override long Long() => long.Parse(NextString()); [MethodImpl(MethodImplOptions.AggressiveInlining)] public override double Double() => double.Parse(NextString()); } class LIB_LazySegTree { static public LIB_LazySegTree<long, long> CreateRangeUpdateRangeMin(IEnumerable<long> init) => new LIB_LazySegTree<long, long>(init, long.MaxValue, long.MinValue + 100, Math.Min, (x, y, c) => y, (x, y) => y); static public LIB_LazySegTree<long, long> CreateRangeAddRangeMin(IEnumerable<long> init) => new LIB_LazySegTree<long, long>(init, long.MaxValue, 0, Math.Min, (x, y, c) => x + y, (x, y) => x + y); static public LIB_LazySegTree<long, long> CreateRangeUpdateRangeMax(IEnumerable<long> init) => new LIB_LazySegTree<long, long>(init, long.MinValue, long.MaxValue - 100, Math.Max, (x, y, c) => y, (x, y) => y); static public LIB_LazySegTree<long, long> CreateRangeAddRangeMax(IEnumerable<long> init) => new LIB_LazySegTree<long, long>(init, long.MinValue, 0, Math.Max, (x, y, c) => x + y, (x, y) => x + y); static public LIB_LazySegTree<long, long> CreateRangeUpdateRangeSum(IEnumerable<long> init) => new LIB_LazySegTree<long, long>(init, 0, long.MaxValue, (x, y) => x + y, (x, y, c) => y * c, (x, y) => y); static public LIB_LazySegTree<long, long> CreateRangeAddRangeSum(IEnumerable<long> init) => new LIB_LazySegTree<long, long>(init, 0, 0, (x, y) => x + y, (x, y, c) => x + y * c, (x, y) => x + y); } class LIB_LazySegTree<T, E> where E : IEquatable<E> { int n, height, sz; int[] rangeSz; T ti; E ei; Func<T, T, T> f; Func<T, E, int, T> g; Func<E, E, E> h; T[] dat; E[] laz; [MethodImpl(MethodImplOptions.AggressiveInlining)] public LIB_LazySegTree(long _n, T _ti, E _ei, Func<T, T, T> _f, Func<T, E, int, T> _g, Func<E, E, E> _h) { n = 1; height = 0; sz = (int)_n; while (n < _n) { n <<= 1; ++height; } ti = _ti; ei = _ei; f = _f; g = _g; h = _h; dat = Enumerable.Repeat(ti, n << 1).ToArray(); laz = Enumerable.Repeat(ei, n << 1).ToArray(); rangeSz = Enumerable.Repeat(0, n << 1).ToArray(); for (var i = 0; i < sz; i++) rangeSz[n + i] = 1; for (var i = n - 1; i > 0; i--) { rangeSz[i] = rangeSz[(i << 1) | 0] + rangeSz[(i << 1) | 1]; dat[i] = f(dat[(i << 1) | 0], dat[(i << 1) | 1]); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public LIB_LazySegTree(IEnumerable<T> l, T _ti, E _ei, Func<T, T, T> _f, Func<T, E, int, T> _g, Func<E, E, E> _h) : this(l.Count(), _ti, _ei, _f, _g, _h) { var idx = 0; foreach (var item in l) dat[n + idx++] = item; for (var i = n - 1; i > 0; i--) dat[i] = f(dat[(i << 1) | 0], dat[(i << 1) | 1]); } [MethodImpl(MethodImplOptions.AggressiveInlining)] T Reflect(long i) => laz[i].Equals(ei) ? dat[i] : g(dat[i], laz[i], rangeSz[i]); [MethodImpl(MethodImplOptions.AggressiveInlining)] void Eval(long i) { if (laz[i].Equals(ei)) return; laz[(i << 1) | 0] = h(laz[(i << 1) | 0], laz[i]); laz[(i << 1) | 1] = h(laz[(i << 1) | 1], laz[i]); dat[i] = Reflect(i); laz[i] = ei; } [MethodImpl(MethodImplOptions.AggressiveInlining)] void Thrust(long i) { for (var j = height; j > 0; j--) Eval(i >> j); dat[i] = Reflect(i); laz[i] = ei; } [MethodImpl(MethodImplOptions.AggressiveInlining)] void Thrust(long l, long r) { if (l == r) { Thrust(l); return; } var xor = l ^ r; var i = height; for (; (xor >> i) != 0; --i) Eval(l >> i); for (; i != 0; --i) { Eval(l >> i); Eval(r >> i); } dat[l] = Reflect(l); laz[l] = ei; dat[r] = Reflect(r); laz[r] = ei; } [MethodImpl(MethodImplOptions.AggressiveInlining)] void Recalc(long i) { while ((i >>= 1) > 0) dat[i] = f(Reflect((i << 1) | 0), Reflect((i << 1) | 1)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] void Recalc(long l, long r) { var xor = l ^ r; while (xor > 1) { xor >>= 1; l >>= 1; r >>= 1; dat[l] = f(Reflect((l << 1) | 0), Reflect((l << 1) | 1)); dat[r] = f(Reflect((r << 1) | 0), Reflect((r << 1) | 1)); } while (l > 1) { l >>= 1; dat[l] = f(Reflect((l << 1) | 0), Reflect((l << 1) | 1)); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Update(long l, long r, E v) { if (l == r) return; if (r < l) throw new Exception(); Thrust(l += n, r += n - 1); for (long li = l, ri = r + 1; li < ri; li >>= 1, ri >>= 1) { if ((li & 1) == 1) { laz[li] = h(laz[li], v); ++li; } if ((ri & 1) == 1) { --ri; laz[ri] = h(laz[ri], v); } } Recalc(l, r); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public T Query(long l, long r) { if (l == r) return ti; if (r < l) throw new Exception(); Thrust(l += n, r += n - 1); var vl = ti; var vr = ti; for (long li = l, ri = r + 1; li < ri; li >>= 1, ri >>= 1) { if ((li & 1) == 1) vl = f(vl, Reflect(li++)); if ((ri & 1) == 1) vr = f(Reflect(--ri), vr); } return f(vl, vr); } [MethodImpl(MethodImplOptions.AggressiveInlining)] int FindToRight(int st, Func<T, bool> check, ref T acc, int k, int l, int r) { if (l + 1 == r) { acc = f(acc, Reflect(k)); return check(acc) ? k - n : sz; } Eval(k); int m = (l + r) >> 1; if (m <= st) return FindToRight(st, check, ref acc, (k << 1) | 1, m, r); if (st <= l && !check(f(acc, dat[k]))) { acc = f(acc, dat[k]); return sz; } int vl = FindToRight(st, check, ref acc, (k << 1) | 0, l, m); if (vl != sz) return vl; return FindToRight(st, check, ref acc, (k << 1) | 1, m, r); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public int FindToRight(int st, Func<T, bool> check) { T acc = ti; return FindToRight(st, check, ref acc, 1, 0, n); } [MethodImpl(MethodImplOptions.AggressiveInlining)] int FindToLeft(int st, Func<T, bool> check, ref T acc, int k, int l, int r) { if (l + 1 == r) { acc = f(Reflect(k), acc); return check(acc) ? k - n : -1; } Eval(k); int m = (l + r) >> 1; if (m > st) return FindToLeft(st, check, ref acc, (k << 1) | 0, l, m); if (st >= r - 1 && !check(f(dat[k], acc))) { acc = f(dat[k], acc); return -1; } int vr = FindToLeft(st, check, ref acc, (k << 1) | 1, m, r); if (vr != -1) return vr; return FindToLeft(st, check, ref acc, (k << 1) | 0, l, m); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public int FindToLeft(int st, Func<T, bool> check) { T acc = ti; return FindToLeft(st, check, ref acc, 1, 0, n); } public T this[long idx] { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { Thrust(idx += n); return Reflect(idx); } [MethodImpl(MethodImplOptions.AggressiveInlining)] set { Thrust(idx += n); dat[idx] = value; laz[idx] = ei; Recalc(idx); } } } }
[["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
8
4,097
2
using System; namespace AtCoderProblems { class MainClass { public static void Main(string[] args) { string[] str = Console.ReadLine().Split(' '); int d = int.Parse(str[0]); int t = int.Parse(str[1]); int s = int.Parse(str[2]); if (d / s > t) { Console.WriteLine("No"); } else { Console.WriteLine("Yes"); } } } }
using System; namespace AtCoderProblems { class MainClass { public static void Main(string[] args) { string[] str = Console.ReadLine().Split(' '); var d = double.Parse(str[0]); var t = double.Parse(str[1]); var s = double.Parse(str[2]); if (d / s > t) { Console.WriteLine("No"); } else { Console.WriteLine("Yes"); } } } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199]]
8
111
12
using System; using System.Linq; namespace DontbeLate { class Program { static void Main(string[] args) { var input = Console.ReadLine().Split(' ').Select(int.Parse).ToList(); var D = input[0]; var T = input[1]; var S = input[2]; if ((D / S) <= T) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } } } }
using System; using System.Linq; namespace DontbeLate { class Program { static void Main(string[] args) { var input = Console.ReadLine().Split(' ').Select(double.Parse).ToList(); var D = input[0]; var T = input[1]; var S = input[2]; if (Math.Ceiling(D / S) <= T) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } } } }
[["-", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 0, 57, 15, 16, 31, 213, 63, 214, 205, 22], ["+", 0, 57, 15, 16, 31, 213, 63, 214, 0, 131], ["+", 0, 57, 15, 16, 31, 213, 63, 214, 141, 22]]
8
111
5
using System; namespace QuestionA { class Program { static void Main(string[] args) { var inputs = Console.ReadLine().Split(); var kyori = int.Parse(inputs[0]); var time = int.Parse(inputs[1]); var speed = int.Parse(inputs[2]); if (kyori / speed <= time) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } } } }
using System; namespace QuestionA { class Program { static void Main(string[] args) { var inputs = Console.ReadLine().Split(); var kyori = double.Parse(inputs[0]); var time = double.Parse(inputs[1]); var speed = double.Parse(inputs[2]); if (kyori / speed <= time) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } } } }
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199]]
8
105
6
using System; using System.Collections.Generic; using System.Linq; namespace ConsoleApp2 { class Program { static void Main(string[] args) { var input = Input( Console.ReadLine().Split(' ').Select(n => int.Parse(n)).ToArray()); Console.WriteLine((input.d <= input.t * input.s) ? "Yes" : "no"); } static (int d, int t, int s) Input(int[] input) { return (input[0], input[1], input[2]); } } }
using System; using System.Collections.Generic; using System.Linq; namespace ConsoleApp2 { class Program { static void Main(string[] args) { var input = Input( Console.ReadLine().Split(' ').Select(n => int.Parse(n)).ToArray()); Console.WriteLine((input.d <= input.t * input.s) ? "Yes" : "No"); } static (int d, int t, int s) Input(int[] input) { return (input[0], input[1], input[2]); } } }
[["-", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222]]
8
134
2
using System; namespace Example03 { class Program { static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); int d = int.Parse(input[0]); int t = int.Parse(input[1]); int s = int.Parse(input[2]); if ((d / s) <= t) Console.WriteLine("Yes"); else Console.WriteLine("No"); } } }
using System; namespace Example03 { class Program { static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); float d = int.Parse(input[0]); float t = int.Parse(input[1]); float s = int.Parse(input[2]); if ((d / s) <= t) Console.WriteLine("Yes"); else Console.WriteLine("No"); } } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
8
108
6
using System; namespace ConsoleApp1 { class ABC117A { static void Main(string[] args) { var DTS = Console.ReadLine().Split(); int D = Int32.Parse(DTS[0]); int T = Int32.Parse(DTS[1]); int S = Int32.Parse(DTS[2]); // Dメートル、T分後、分速Sメートル if (D <= T * S * 60) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } } } }
using System; namespace ConsoleApp1 { class ABC117A { static void Main(string[] args) { var DTS = Console.ReadLine().Split(); int D = Int32.Parse(DTS[0]); int T = Int32.Parse(DTS[1]); int S = Int32.Parse(DTS[2]); // Dメートル、T分後、分速Sメートル if (D <= T * S) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } } } }
[["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 48], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203]]
8
108
2
using System; using System.Linq; class Program { static void Main() { int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray(); Console.WriteLine(input[0] < input[1] * input[2] ? "Yes" : "No"); } }
using System; using System.Linq; class Program { static void Main() { int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray(); Console.WriteLine(input[0] <= input[1] * input[2] ? "Yes" : "No"); } }
[["-", 3, 4, 0, 28, 0, 41, 15, 16, 17, 18], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 17, 19]]
8
73
2
using System; using static System.Console; class A { static void Main() { var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse); if (a[0] > a[1] * a[2]) { WriteLine("No"); } else { WriteLine("No"); } } }
using System; using static System.Console; class A { static void Main() { var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse); if (a[0] > a[1] * a[2]) { WriteLine("No"); } else { WriteLine("Yes"); } } }
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
8
78
2
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Text; class Program { static void Main(string[] args) { var input = Console.ReadLine().Split(" "); var D = int.Parse(input[0]); var T = int.Parse(input[1]); var S = int.Parse(input[2]); var t = (double)D / S; if (Math.Round(t) <= T) Console.WriteLine("Yes"); else Console.WriteLine("No"); } }
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Text; class Program { static void Main(string[] args) { var input = Console.ReadLine().Split(" "); var D = int.Parse(input[0]); var T = int.Parse(input[1]); var S = int.Parse(input[2]); var t = (double)D / S; if (t <= T) Console.WriteLine("Yes"); else Console.WriteLine("No"); } }
[["-", 0, 57, 15, 16, 31, 213, 63, 214, 205, 22], ["-", 0, 57, 15, 16, 31, 213, 63, 214, 0, 131], ["-", 0, 57, 15, 16, 31, 213, 63, 214, 141, 22], ["-", 0, 57, 15, 16, 31, 213, 3, 4, 0, 24], ["-", 0, 57, 15, 16, 31, 213, 3, 4, 0, 25]]
8
140
5
using System; namespace Test { class Program { static void Main(string[] args) { string[] n = Console.ReadLine().Split(' '); int d = int.Parse(n[0]); int t = int.Parse(n[1]); int s = int.Parse(n[2]); float inTime = d / s; Console.WriteLine(inTime <= t ? "Yes" : "No"); } } }
using System; namespace Test { class Program { static void Main(string[] args) { string[] n = Console.ReadLine().Split(' '); float d = float.Parse(n[0]); float t = float.Parse(n[1]); float s = float.Parse(n[2]); float inTime = d / s; Console.WriteLine(inTime <= t ? "Yes" : "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, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199]]
8
103
12
using System; namespace late { class Program { static void Main(string[] args) { int D, T, S; string inD0 = Console.ReadLine(); string[] cngD0 = inD0.Split(' '); D = int.Parse(cngD0[0]); T = int.Parse(cngD0[1]); S = int.Parse(cngD0[2]); float Proc = D / S; if (Proc <= T) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } } } }
using System; namespace late { class Program { static void Main(string[] args) { int D, T; string inD0 = Console.ReadLine(); string[] cngD0 = inD0.Split(' '); D = int.Parse(cngD0[0]); T = int.Parse(cngD0[1]); float S = int.Parse(cngD0[2]); float Proc = D / S; if (Proc <= T) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } } } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 0, 21], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
8
124
3
using System; class Program { static void Main(string[] args) { string[] sp = Console.ReadLine().Split(' '); int d = int.Parse(sp[0]); int t = int.Parse(sp[1]); int s = int.Parse(sp[2]); if (d / s <= t) Console.WriteLine("Yes"); else Console.WriteLine("No"); } }
using System; class Program { static void Main(string[] args) { string[] sp = Console.ReadLine().Split(' '); float d = int.Parse(sp[0]); float t = int.Parse(sp[1]); float s = int.Parse(sp[2]); if (d / s <= t) Console.WriteLine("Yes"); else Console.WriteLine("No"); } }
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
8
102
6
using System; using System.Collections.Generic; using System.Linq; namespace KCLC { class Program { static void Main() { string[] Input = Console.ReadLine().Split(); int Kyori = int.Parse(Input[0]); int Jikan = int.Parse(Input[1]); int Hayasa = int.Parse(Input[2]); if (Kyori / Hayasa <= Jikan) { Console.WriteLine("Yes"); } if (Kyori / Hayasa > Jikan) { Console.WriteLine("No"); } } } }
using System; using System.Collections.Generic; using System.Linq; namespace KCLC { class Program { static void Main() { string[] Input = Console.ReadLine().Split(); double Kyori = double.Parse(Input[0]); int Jikan = int.Parse(Input[1]); double Hayasa = double.Parse(Input[2]); if (Kyori / Hayasa <= Jikan) { Console.WriteLine("Yes"); } if (Kyori / Hayasa > Jikan) { Console.WriteLine("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, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199]]
8
122
8
using System; class Program { static void Main(string[] args) {    string a = Console.ReadLine(); //標準入力 string[] aa = a.Split(' '); int D = int.Parse(aa[0]); int T = int.Parse(aa[1]); int S = int.Parse(aa[2]); bool test = false; double time = D / S; test = (double)T >= time; if (test) { Console.WriteLine("{0}", "Yes"); } else { Console.WriteLine("{0}", "No"); } } }
using System; class Program { static void Main(string[] args) {    string a = Console.ReadLine(); //標準入力 string[] aa = a.Split(' '); int D = int.Parse(aa[0]); int T = int.Parse(aa[1]); int S = int.Parse(aa[2]); bool test = false; double time = (double)D / (double)S; test = (double)T >= time; if (test) { Console.WriteLine("{0}", "Yes"); } else { Console.WriteLine("{0}", "No"); } } }
[["+", 0, 200, 0, 212, 0, 16, 31, 74, 0, 24], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 39, 199], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 0, 25], ["+", 0, 200, 0, 212, 0, 16, 12, 74, 0, 24], ["+", 0, 200, 0, 212, 0, 16, 12, 74, 39, 199], ["+", 0, 200, 0, 212, 0, 16, 12, 74, 0, 25]]
8
138
6
using System; using System.Collections.Generic; using System.Linq; using System.Security.AccessControl; using System.Text; using System.Threading.Tasks; namespace AtCoder177 { class Program { static void Main(string[] args) { QA(); } static void QA() { string[] splited = Console.ReadLine().Split(' '); int D = int.Parse(splited[0]); int T = int.Parse(splited[1]); int S = int.Parse(splited[2]); Console.WriteLine((Math.Ceiling((double)D / S) <= S) ? "Yes" : "No"); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Security.AccessControl; using System.Text; using System.Threading.Tasks; namespace AtCoder177 { class Program { static void Main(string[] args) { QA(); } static void QA() { string[] splited = Console.ReadLine().Split(' '); int D = int.Parse(splited[0]); int T = int.Parse(splited[1]); int S = int.Parse(splited[2]); Console.WriteLine((((double)D / S) <= T) ? "Yes" : "No"); } } }
[["-", 15, 23, 0, 16, 31, 213, 63, 214, 205, 22], ["-", 15, 23, 0, 16, 31, 213, 63, 214, 0, 131], ["-", 15, 23, 0, 16, 31, 213, 63, 214, 141, 22], ["-", 0, 28, 0, 41, 15, 23, 0, 16, 12, 22], ["+", 0, 28, 0, 41, 15, 23, 0, 16, 12, 22]]
8
150
5
using System; using System.Text; using System.Linq; using System.Collections; using System.Collections.Generic; using static System.Math; using static System.Console; using static exMath; using static exReadLine; class Program { static void Main(string[] args) { int D, T, S; intReadLine(out D, out T, out S); if (D / S <= T) { WriteLine("Yes"); } else { WriteLine("No"); } } } static class exReadLine { public static void intReadLine(out int a) { a = int.Parse(ReadLine()); } public static void intReadLine(out int a, out int b) { int[] input = ReadLine().Split().Select(int.Parse).ToArray(); a = input[0]; b = input[1]; } public static void intReadLine(out int a, out int b, out int c) { int[] input = ReadLine().Split().Select(int.Parse).ToArray(); a = input[0]; b = input[1]; c = input[2]; } public static void intReadLine(out int a, out int b, out int c, out int d) { int[] input = ReadLine().Split().Select(int.Parse).ToArray(); a = input[0]; b = input[1]; c = input[2]; d = input[3]; } public static void longReadLine(out long a) { a = long.Parse(ReadLine()); } public static void longReadLine(out long a, out long b) { long[] input = ReadLine().Split().Select(long.Parse).ToArray(); a = input[0]; b = input[1]; } public static void longReadLine(out long a, out long b, out long c) { long[] input = ReadLine().Split().Select(long.Parse).ToArray(); a = input[0]; b = input[1]; c = input[2]; } public static void longReadLine(out long a, out long b, out long c, out long d) { long[] input = ReadLine().Split().Select(long.Parse).ToArray(); a = input[0]; b = input[1]; c = input[2]; d = input[3]; } public static void intArrayReadLine(out int[] a) { a = ReadLine().Split().Select(int.Parse).ToArray(); } public static void longArrayReadLine(out long[] a) { a = ReadLine().Split().Select(long.Parse).ToArray(); } public static void intListReadLine(out List<int> a) { a = ReadLine().Split().Select(int.Parse).ToList(); } public static void longListReadLine(out List<long> a) { a = ReadLine().Split().Select(long.Parse).ToList(); } } static class exMath { /// <summary> /// 最大公約数 /// </summary> public static int Gcd(int a, int b) { if (a < b) return Gcd(b, a); while (b != 0) { var r = a % b; a = b; b = r; } return a; } public static long Gcd(long a, long b) { if (a < b) return Gcd(b, a); while (b != 0) { var r = a % b; a = b; b = r; } return a; } /// <summary> /// 最小公倍数 /// </summary> public static long Lcm(int a, int b) { return BigMul(a, b) / Gcd(a, b); } public static long Lcm(long a, long b) { return a * b / Gcd(a, b); } }
using System; using System.Text; using System.Linq; using System.Collections; using System.Collections.Generic; using static System.Math; using static System.Console; using static exMath; using static exReadLine; class Program { static void Main(string[] args) { int D, T, S; intReadLine(out D, out T, out S); if ((decimal)D / S <= T) { WriteLine("Yes"); } else { WriteLine("No"); } } } static class exReadLine { public static void intReadLine(out int a) { a = int.Parse(ReadLine()); } public static void intReadLine(out int a, out int b) { int[] input = ReadLine().Split().Select(int.Parse).ToArray(); a = input[0]; b = input[1]; } public static void intReadLine(out int a, out int b, out int c) { int[] input = ReadLine().Split().Select(int.Parse).ToArray(); a = input[0]; b = input[1]; c = input[2]; } public static void intReadLine(out int a, out int b, out int c, out int d) { int[] input = ReadLine().Split().Select(int.Parse).ToArray(); a = input[0]; b = input[1]; c = input[2]; d = input[3]; } public static void longReadLine(out long a) { a = long.Parse(ReadLine()); } public static void longReadLine(out long a, out long b) { long[] input = ReadLine().Split().Select(long.Parse).ToArray(); a = input[0]; b = input[1]; } public static void longReadLine(out long a, out long b, out long c) { long[] input = ReadLine().Split().Select(long.Parse).ToArray(); a = input[0]; b = input[1]; c = input[2]; } public static void longReadLine(out long a, out long b, out long c, out long d) { long[] input = ReadLine().Split().Select(long.Parse).ToArray(); a = input[0]; b = input[1]; c = input[2]; d = input[3]; } public static void intArrayReadLine(out int[] a) { a = ReadLine().Split().Select(int.Parse).ToArray(); } public static void longArrayReadLine(out long[] a) { a = ReadLine().Split().Select(long.Parse).ToArray(); } public static void intListReadLine(out List<int> a) { a = ReadLine().Split().Select(int.Parse).ToList(); } public static void longListReadLine(out List<long> a) { a = ReadLine().Split().Select(long.Parse).ToList(); } } static class exMath { /// <summary> /// 最大公約数 /// </summary> public static int Gcd(int a, int b) { if (a < b) return Gcd(b, a); while (b != 0) { var r = a % b; a = b; b = r; } return a; } public static long Gcd(long a, long b) { if (a < b) return Gcd(b, a); while (b != 0) { var r = a % b; a = b; b = r; } return a; } /// <summary> /// 最小公倍数 /// </summary> public static long Lcm(int a, int b) { return BigMul(a, b) / Gcd(a, b); } public static long Lcm(long a, long b) { return a * b / Gcd(a, b); } }
[["+", 0, 57, 15, 16, 31, 16, 31, 74, 0, 24], ["+", 0, 57, 15, 16, 31, 16, 31, 74, 39, 199], ["+", 0, 57, 15, 16, 31, 16, 31, 74, 0, 25]]
8
847
3
using System; using System.Collections.Generic; using System.Linq; public static class Solution { public static void Main() { var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); var D = vals[0]; var T = vals[1]; var S = vals[1]; if (D >= T * S) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } } }
using System; using System.Collections.Generic; using System.Linq; public static class Solution { public static void Main() { var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); var D = vals[0]; var T = vals[1]; var S = vals[2]; if (D <= T * S) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } } }
[["-", 0, 212, 0, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 212, 0, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 20], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 19]]
8
111
4
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Numerics; class Util { static void Main() { Sol mySol = new Sol(); mySol.Solve(); } } class Sol { public void Solve() { int[] DTS = ria(); string ans = "No"; if (DTS[0] / DTS[2] <= DTS[1]) ans = "Yes"; Console.WriteLine(ans); Console.ReadLine(); } 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)); } static int[] generateNums(int num, int N) { return Enumerable.Repeat(num, N).ToArray(); } static int[] generateSuretsu(int N) { return Enumerable.Range(0, N).ToArray(); } } public static class Combination { //使い方:int[][] Is = Combination.Enumerate(nums, k, //withRepetition:false).ToArray(); public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items, int k, bool withRepetition) { if (k == 1) { foreach (var item in items) yield return new T[] { item }; yield break; } foreach (var item in items) { var leftside = new T[] { item }; // item よりも前のものを除く (順列と組み合わせの違い) // 重複を許さないので、unusedから item そのものも取り除く var unused = withRepetition ? items : items.SkipWhile(e => !e.Equals(item)).Skip(1).ToList(); foreach (var rightside in Enumerate(unused, k - 1, withRepetition)) { yield return leftside.Concat(rightside).ToArray(); } } } }
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Numerics; class Util { static void Main() { Sol mySol = new Sol(); mySol.Solve(); } } class Sol { public void Solve() { int[] DTS = ria(); string ans = "No"; if (DTS[0] <= DTS[2] * DTS[1]) ans = "Yes"; Console.WriteLine(ans); Console.ReadLine(); } 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)); } static int[] generateNums(int num, int N) { return Enumerable.Repeat(num, N).ToArray(); } static int[] generateSuretsu(int N) { return Enumerable.Range(0, N).ToArray(); } } public static class Combination { //使い方:int[][] Is = Combination.Enumerate(nums, k, //withRepetition:false).ToArray(); public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items, int k, bool withRepetition) { if (k == 1) { foreach (var item in items) yield return new T[] { item }; yield break; } foreach (var item in items) { var leftside = new T[] { item }; // item よりも前のものを除く (順列と組み合わせの違い) // 重複を許さないので、unusedから item そのものも取り除く var unused = withRepetition ? items : items.SkipWhile(e => !e.Equals(item)).Skip(1).ToList(); foreach (var rightside in Enumerate(unused, k - 1, withRepetition)) { yield return leftside.Concat(rightside).ToArray(); } } } }
[["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 85], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 19], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 19], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 48]]
8
539
4
using System; using System.Linq; namespace A { class Program { static void Main(string[] args) { string[] s = Console.ReadLine().Split(' '); int D = int.Parse(s[0]); int T = int.Parse(s[1]); int S = int.Parse(s[2]); string ans; if (D / S <= T) ans = "Yes"; else ans = "No"; Console.WriteLine(ans); } } }
using System; using System.Linq; namespace A { class Program { static void Main(string[] args) { string[] s = Console.ReadLine().Split(' '); int D = int.Parse(s[0]); int T = int.Parse(s[1]); int S = int.Parse(s[2]); string ans; if ((double)D / S <= (double)T) ans = "Yes"; else ans = "No"; Console.WriteLine(ans); } } }
[["+", 0, 57, 15, 16, 31, 16, 31, 74, 0, 24], ["+", 0, 57, 15, 16, 31, 16, 31, 74, 39, 199], ["+", 0, 57, 15, 16, 31, 16, 31, 74, 0, 25], ["+", 8, 196, 0, 57, 15, 16, 12, 74, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 12, 74, 39, 199], ["+", 8, 196, 0, 57, 15, 16, 12, 74, 0, 25]]
8
115
6
using System; using System.Linq; using System.Collections.Generic; using System.Numerics; namespace ABC177 { class Program { static void Main(string[] args) { var DTS = Console.ReadLine().Split().Select(int.Parse).ToArray(); if (DTS[0] / DTS[2] <= DTS[1]) Console.WriteLine("Yes"); else Console.WriteLine("No"); } } }
using System; using System.Linq; using System.Collections.Generic; using System.Numerics; namespace ABC177 { class Program { static void Main(string[] args) { var DTS = Console.ReadLine().Split().Select(double.Parse).ToArray(); if (Math.Ceiling(DTS[0] / DTS[2]) <= DTS[1]) Console.WriteLine("Yes"); else Console.WriteLine("No"); } } }
[["-", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 0, 57, 15, 16, 31, 213, 63, 214, 205, 22], ["+", 0, 57, 15, 16, 31, 213, 63, 214, 0, 131], ["+", 0, 57, 15, 16, 31, 213, 63, 214, 141, 22], ["+", 0, 57, 15, 16, 31, 213, 3, 4, 0, 24], ["+", 0, 57, 15, 16, 31, 213, 3, 4, 0, 25]]
8
99
7
using System; using System.Linq; namespace ConsoleApp68 { class Program { static void Main(string[] args) { // var ret = 0; var l = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); var ret = l[0] / l[2] > l[1] ? "No" : "Yes"; Console.WriteLine(ret); } } }
using System; using System.Linq; namespace ConsoleApp68 { class Program { static void Main(string[] args) { // var ret = 0; var l = Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); var ret = l[0] / l[2] > l[1] ? "No" : "Yes"; Console.WriteLine(ret); } } }
[["-", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199]]
8
88
2
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace AtCoder { class Program { static void Main(string[] args) { int[] arr = Console.ReadLine() .Trim() .Split(' ') .Select(hogehoge => int.Parse(hogehoge)) .ToArray<int>(); if (arr[0] / arr[2] > arr[1]) { Console.WriteLine("No"); } else { Console.WriteLine("Yes"); } } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace AtCoder { class Program { static void Main(string[] args) { decimal[] arr = Console.ReadLine() .Trim() .Split(' ') .Select(hogehoge => decimal.Parse(hogehoge)) .ToArray<decimal>(); if (arr[0] / arr[2] > arr[1]) { Console.WriteLine("No"); } else { Console.WriteLine("Yes"); } } } }
[["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["+", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["-", 0, 213, 63, 214, 141, 236, 237, 238, 0, 199], ["+", 0, 213, 63, 214, 141, 236, 237, 238, 0, 199]]
8
120
6
using System; using System.Linq; using System.Collections.Generic; namespace Sample { class Sample { static void Main(string[] args) { string[] str = Console.ReadLine().Split(' '); int D = int.Parse(str[0]); int T = int.Parse(str[1]); int S = int.Parse(str[2]); if ((D / S) <= T) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } } } }
using System; using System.Linq; using System.Collections.Generic; namespace Sample { class Sample { static void Main(string[] args) { string[] str = Console.ReadLine().Split(' '); double D = double.Parse(str[0]); double T = double.Parse(str[1]); double S = double.Parse(str[2]); if ((D / S) <= T) { Console.WriteLine("Yes"); } else { Console.WriteLine("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, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199]]
8
124
12
using System; using System.Collections; using System.Collections.Generic; using System.Linq; namespace atcoder { public class Program { public static void Main(string[] args) { var buffer = Console.ReadLine().Split(); var D = float.Parse(buffer[0]); var T = float.Parse(buffer[1]); var S = float.Parse(buffer[2]); if (D / S <= S) Console.WriteLine("Yes"); else Console.WriteLine("No"); } } }
using System; using System.Collections; using System.Collections.Generic; using System.Linq; namespace atcoder { public class Program { public static void Main(string[] args) { var buffer = Console.ReadLine().Split(); var D = float.Parse(buffer[0]); var T = float.Parse(buffer[1]); var S = float.Parse(buffer[2]); if (D / S <= T) Console.WriteLine("Yes"); else Console.WriteLine("No"); } } }
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22]]
8
120
2
using System; using System.Collections.Generic; using System.Text; class Program { static void Main(string[] args) { string[] input = Read(); int d = int.Parse(input[0]); int t = int.Parse(input[1]); int s = int.Parse(input[2]); Write(d > t * s ? "Yes" : "No"); } static string[] Read() { return Console.ReadLine().Split(' '); } static void Write(object o) { Console.WriteLine(o.ToString()); } }
using System; using System.Collections.Generic; using System.Text; class Program { static void Main(string[] args) { string[] input = Read(); int d = int.Parse(input[0]); int t = int.Parse(input[1]); int s = int.Parse(input[2]); Write(d <= t * s ? "Yes" : "No"); } static string[] Read() { return Console.ReadLine().Split(' '); } static void Write(object o) { Console.WriteLine(o.ToString()); } }
[["-", 3, 4, 0, 28, 0, 41, 15, 16, 17, 47], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 17, 19]]
8
138
2
using System; using System.Linq; namespace AtCoderTutorial { public class AtCoder175 { public static void Main(string[] args) { long[] inputs = Console.ReadLine().Split(' ').Select(_ => long.Parse(_)).ToArray(); long X = inputs[0]; long K = inputs[1]; long D = inputs[2]; long min = X; long Y = (X / D) + 1; if (K >= Y) { if ((K - Y) % 2 == 0) { if (X > 0) { min = X - D * Y; } else { min = X + D * Y; } } else { if (X > 0) { min = Math.Min(Math.Abs(X - D * (Y + 1)), Math.Abs(X - D * (Y - 1))); } else { min = Math.Min(Math.Abs(X + D * (Y + 1)), Math.Abs(X + D * (Y - 1))); } } } else { if (X > 0) { min = X - D * K; } else { min = X + D * K; } } Console.WriteLine(Math.Abs(min)); } } }
using System; using System.Linq; namespace AtCoderTutorial { public class AtCoder175 { public static void Main(string[] args) { long[] inputs = Console.ReadLine().Split(' ').Select(_ => long.Parse(_)).ToArray(); long X = inputs[0]; long K = inputs[1]; long D = inputs[2]; long min = X; long Y = (Math.Abs(X) / D) + 1; if (K >= Y) { if ((K - Y) % 2 == 0) { if (X > 0) { min = X - D * Y; } else { min = X + D * Y; } } else { if (X > 0) { min = Math.Min(Math.Abs(X - D * (Y + 1)), Math.Abs(X - D * (Y - 1))); } else { min = Math.Min(Math.Abs(X + D * (Y + 1)), Math.Abs(X + D * (Y - 1))); } } } else { if (X > 0) { min = X - D * K; } else { min = X + D * K; } } Console.WriteLine(Math.Abs(min)); } } }
[["+", 31, 23, 0, 16, 31, 213, 63, 214, 205, 22], ["+", 31, 23, 0, 16, 31, 213, 63, 214, 0, 131], ["+", 31, 23, 0, 16, 31, 213, 63, 214, 141, 22], ["+", 31, 23, 0, 16, 31, 213, 3, 4, 0, 24], ["+", 31, 23, 0, 16, 31, 213, 3, 4, 0, 25]]
8
282
5
using System; using System.Linq; class Test { static void Main(string[] args) { var inputs = System.Console.ReadLine() .Split(' ') .Select(s => long.Parse(s)) .ToArray(); long X = Math.Abs(inputs[0]); long K = inputs[1]; long D = inputs[2]; long result = X; if ((int)X / D > K) { result = X - D * K; } else { result = X - (long)(D * ((long)X / D)); K = K - ((long)X / D); if (K % 2 == 1) { result = Math.Abs(result - D); } } Console.WriteLine(result); } }
using System; using System.Linq; class Test { static void Main(string[] args) { var inputs = System.Console.ReadLine() .Split(' ') .Select(s => long.Parse(s)) .ToArray(); long X = Math.Abs(inputs[0]); long K = inputs[1]; long D = inputs[2]; long result = X; if ((long)(X / D) > K) { result = X - D * K; } else { result = X - (long)(D * ((long)X / D)); K = K - ((long)X / D); if (K % 2 == 1) { result = Math.Abs(result - D); } } Console.WriteLine(result); } }
[["-", 0, 57, 15, 16, 31, 16, 31, 74, 39, 199], ["+", 8, 196, 0, 57, 15, 16, 31, 74, 39, 199], ["+", 0, 57, 15, 16, 31, 74, 51, 23, 0, 24], ["+", 0, 57, 15, 16, 31, 74, 51, 23, 0, 25]]
8
176
4
using System; using System.Linq; namespace AtCoderBeginnerContest175 { class Program { static void Main(string[] args) { var inputs = Console.ReadLine().Split().Select(x => long.Parse(x)).ToList(); var current = inputs[0]; var n = inputs[1]; var d = inputs[2]; var number = Math.Abs(current) / d; if (number > n) { if (current >= 0) { Console.WriteLine(current - n * d); } else { Console.WriteLine(current + n * d); } } else { if (current >= 0) { current -= number * d; n -= number; if (n % 2 == 0) { Console.WriteLine(current); } else { Console.WriteLine(Math.Abs(current - d)); } } else { current += number * d; n -= number; if (n % 2 == 0) { Console.WriteLine(Math.Abs(current)); } else { Console.WriteLine(Math.Abs(current + d)); } } } } } }
using System; using System.Linq; namespace AtCoderBeginnerContest175 { class Program { static void Main(string[] args) { var inputs = Console.ReadLine().Split().Select(x => long.Parse(x)).ToList(); var current = inputs[0]; var n = inputs[1]; var d = inputs[2]; // 0をまたぐ移動になるまでの数 var number = Math.Abs(current) / d; if (number >= n) { // 0に到達しない場合 if (current >= 0) { // 正なら単純に引く Console.WriteLine(current - n * d); } else { Console.WriteLine(Math.Abs(current + n * d)); } } else { if (current >= 0) { // 0までの移動した場合の位置と残り回数を計算 current -= number * d; n -= number; if (n % 2 == 0) { Console.WriteLine(current); } else { Console.WriteLine(Math.Abs(current - d)); } } else { current += number * d; n -= number; if (n % 2 == 0) { Console.WriteLine(Math.Abs(current)); } else { Console.WriteLine(Math.Abs(current + d)); } } } } } }
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 20], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25]]
8
240
7
using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; using System.Numerics; namespace AtCoderWorkspace { public class Solver { public void Solve() { var cin = new Scanner(); var x = cin.nextLong(); var k = cin.nextLong(); var d = cin.nextLong(); var tmp = x / d; var m = x % d; var mm = Math.Abs(m - d); if ((Math.Abs(x) / (double)k) > d) { // 0に届かない場合 Console.WriteLine(Math.Abs(x) - (k * d)); } else { // 何回目で届いたか var nk = k - tmp; if (nk % 2 == 0) { Console.WriteLine(m); } else { Console.WriteLine(mm); } } } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string next() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return next(); i = 0; return s[i++]; } public int nextInt() { return int.Parse(next()); } public int[] ArrayInt(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = nextInt() + add; } return Array; } public int[] DPArrayInt(int N, int ex) { int[] Array = new int[N + ex]; for (int i = 0; i < N; i++) { Array[i] = nextInt(); } return Array; } public long nextLong() { return long.Parse(next()); } public long[] ArrayLong(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = nextLong() + add; } return Array; } public long[] DPArrayLong(int N, int ex) { long[] Array = new long[N + ex]; for (int i = 0; i < N; i++) { Array[i] = nextLong(); } return Array; } public double nextDouble() { return double.Parse(next()); } public double[] ArrayDouble(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = nextDouble() + add; } return Array; } } class Program { static void Main(string[] s) => new Solver().Solve(); } }
using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; using System.Numerics; namespace AtCoderWorkspace { public class Solver { public void Solve() { var cin = new Scanner(); var x = cin.nextLong(); var k = cin.nextLong(); var d = cin.nextLong(); var tmp = x / d; var m = Math.Abs(x % d); var mm = Math.Abs(m - d); if ((Math.Abs(x) / (double)k) > d) { // 0に届かない場合 Console.WriteLine(Math.Abs(x) - (k * d)); } else { // 何回目で届いたか var nk = k - tmp; if (nk % 2 == 0) { Console.WriteLine(m); } else { Console.WriteLine(mm); } } } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string next() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); if (s.Length == 0) return next(); i = 0; return s[i++]; } public int nextInt() { return int.Parse(next()); } public int[] ArrayInt(int N, int add = 0) { int[] Array = new int[N]; for (int i = 0; i < N; i++) { Array[i] = nextInt() + add; } return Array; } public int[] DPArrayInt(int N, int ex) { int[] Array = new int[N + ex]; for (int i = 0; i < N; i++) { Array[i] = nextInt(); } return Array; } public long nextLong() { return long.Parse(next()); } public long[] ArrayLong(int N, long add = 0) { long[] Array = new long[N]; for (int i = 0; i < N; i++) { Array[i] = nextLong() + add; } return Array; } public long[] DPArrayLong(int N, int ex) { long[] Array = new long[N + ex]; for (int i = 0; i < N; i++) { Array[i] = nextLong(); } return Array; } public double nextDouble() { return double.Parse(next()); } public double[] ArrayDouble(int N, double add = 0) { double[] Array = new double[N]; for (int i = 0; i < N; i++) { Array[i] = nextDouble() + add; } return Array; } } class Program { static void Main(string[] s) => new Solver().Solve(); } }
[["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25]]
8
669
5
using System; using System.Collections; using System.Collections.Generic; using System.Text; using System.Linq; namespace contest_Csharp { class Program { public static (long m, long s)[,] dp; static void Main(string[] args) { checked { var sw = new System.IO.StreamWriter( Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); var vals = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); var X = vals[0]; var K = vals[1]; var D = vals[2]; // L.Sort(); long ans = X; if (Math.Abs(K) > Math.Abs(X / D)) { ans = Math.Abs(X); var quo = ans / D; ans = Math.Abs(X % D - ((K - quo) % 2 * D)); } else { ans = Math.Abs(X) - Math.Abs(K * D); } Console.WriteLine(ans); Console.Out.Flush(); } } } }
using System; using System.Collections; using System.Collections.Generic; using System.Text; using System.Linq; namespace contest_Csharp { class Program { public static (long m, long s)[,] dp; static void Main(string[] args) { checked { var sw = new System.IO.StreamWriter( Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); var vals = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); var X = vals[0]; var K = vals[1]; var D = vals[2]; // L.Sort(); long ans = X; if (Math.Abs(K) >= Math.Abs(X / D)) { ans = Math.Abs(X); var quo = ans / D; ans = Math.Abs(ans % D - ((K - quo) % 2 * D)); } else { ans = Math.Abs(X) - Math.Abs(K * D); } Console.WriteLine(ans); Console.Out.Flush(); } } } }
[["-", 0, 287, 0, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 287, 0, 196, 0, 57, 15, 16, 17, 20], ["-", 3, 4, 0, 28, 0, 16, 31, 16, 31, 22], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 31, 22]]
8
247
4
using System; using System.Collections.Generic; using System.Linq; using static System.Console; using static System.Math; class MainClass { static void Main() { var xkd = ReadLine().Split().Select(long.Parse).ToArray(); var X = xkd[0]; var K = xkd[1]; var D = xkd[2]; long d = X / D; long ans = X; if (K < d) { ans = X - D * K; } else { K -= d; X -= D * d; // WriteLine(X); if (K % 2 == 0) ans = X; else ans = Abs(X - D); } WriteLine(ans); } }
using System; using System.Collections.Generic; using System.Linq; using static System.Console; using static System.Math; class MainClass { static void Main() { var xkd = ReadLine().Split().Select(long.Parse).ToArray(); var X = Abs(xkd[0]); var K = xkd[1]; var D = xkd[2]; long d = X / D; long ans = X; if (K < d) { ans = X - D * K; } else { K -= d; X -= D * d; // WriteLine(X); if (K % 2 == 0) ans = X; else ans = Abs(X - D); } WriteLine(ans); } }
[["+", 0, 198, 0, 200, 0, 212, 0, 213, 63, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25]]
8
153
3