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.Linq; //リストの使用
using System.Collections.Generic;
class Program {
static void Main() {
string[] input = Console.ReadLine().Split(
' '); // Splitで区切り文字を指定して複数個受け取る。
long n = long.Parse(input[0]);
long a = long.Parse(input[1]);
long b = long.Parse(input[2]);
if (n == 1) {
if (a == b)
Console.WriteLine(1);
else
Console.WriteLine(0);
} else {
if (a > b)
Console.WriteLine(0);
else
Console.WriteLine((b - a + 1) * (n - 2) - 1);
}
}
}
|
using System;
using System.Linq; //リストの使用
using System.Collections.Generic;
class Program {
static void Main() {
string[] input = Console.ReadLine().Split(
' '); // Splitで区切り文字を指定して複数個受け取る。
long n = long.Parse(input[0]);
long a = long.Parse(input[1]);
long b = long.Parse(input[2]);
if (n == 1) {
if (a == b)
Console.WriteLine(1);
else
Console.WriteLine(0);
} else {
if (a > b)
Console.WriteLine(0);
else
Console.WriteLine((b - a) * (n - 2) + 1);
}
}
}
|
[["-", 0, 16, 31, 16, 31, 23, 0, 16, 17, 72], ["-", 0, 16, 31, 16, 31, 23, 0, 16, 12, 203], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72]]
| 8
| 152
| 4
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
// using static System.Linq.Enumerable;
using static System.Console;
using static AtCoder.Util;
using static AtCoder.Cin;
using static System.Math;
using static AtCoder.MyMath;
namespace AtCoder {
class Program {
static void Main() {
var n = ReadInt();
var a = ReadInt();
var b = ReadInt();
var x = a > b ? 0 : n == 1 ? (a == b ? 1 : 0) : (b - a) * (n - 2) + 1;
WriteLine(x);
}
}
}
/* ***************** Following Contents are my common library ******** */
namespace AtCoder {
static class MyMath {
public static long ToNearestInt(this double d) {
var l = (long)Math.Floor(d);
var r = l + 1;
return r - d < d - l ? r : l;
}
public static long Factorial(this long n) => Range(1, n).Aggregate(1L,
Multiply);
public static long nPr(int n, int r) => r < 0 || r > n? 0
: FromTo(n - r + 1, n)
.Select(x => (long)x)
.Aggregate(1L, Multiply);
public static long nCr(int n, int r) => nPr(n, r) / Factorial(r);
public static long Inc(long i) => i + 1;
public static long Dec(long i) => i - 1;
public static long Plus(long i, long j) => i + j;
public static Func<long, long> Plus(long j) => i => i + j;
public static long Minus(long i, long j) => i - j;
public static Func<long, long> Minus(long j) => i => i - j;
public static long Multiply(long i, long j) => i * j;
public static Func<long, long> Multiply(long j) => i => i * j;
public static long Divide(long i, long j) => j / j;
public static Func<long, long> Divide(long j) => i => i * j;
public static long Mod(long i, long j) => i % j;
public static Func<long, long> Mod(long j) => i => i % j;
public static long Max(params long[] ns) => ns.Max();
public static long LowerBound(this long m, long lbound) => Max(m, lbound);
public static long UpperBound(this long m, long ubound) => Min(m, ubound);
public static long Bound(this long m, long lowerBound, long UpperBound) =>
m.LowerBound(lowerBound).UpperBound(UpperBound);
public static long LowerBound(this int m, long lbound) => Max(m, lbound);
public static long UpperBound(this int m, long ubound) => Min(m, ubound);
public static long Bound(this int m, long lowerBound, long UpperBound) =>
m.LowerBound(lowerBound).UpperBound(UpperBound);
public static bool InRange(this long x, long min, long max) => min <= x
&& x <= max;
public static bool IsEven(this int x) => x % 2 == 0;
public static bool IsOdd(this int x) => x % 2 != 1;
public static bool IsEven(this long x) => x % 2 == 0;
public static bool IsOdd(this long x) => x % 2 != 1;
}
static class Util {
public static string
Show(this IEnumerable<char> source) => new string(source.ToArray());
public static IEnumerable<int>
ToDigits(this long n) => n.ToString().Select(x => x.ToInt());
public static IEnumerable<int> ToDigits(this int n) => ((long)n).ToDigits();
public static IEnumerable<int> Factors(this int n) {
for (int i = 1; i <= n; i++)
if (n % i == 0)
yield return i;
}
public static IEnumerable<int> Natural() {
for (int i = 0;; i++)
yield return i;
}
public static IEnumerable<int> Positive() => Natural().Skip(1);
public static long Pow(long i, long exp) => (exp == 0) ? 1
: i * Pow(i, exp - 1);
public static HashSet<T>
ToHashSet<T>(this IEnumerable<T> source) => new HashSet<T>(source);
public static MultiSet<T>
ToMultiSet<T>(this IEnumerable<T> t) => new MultiSet<T>(t);
public static int Max(this int i, int j) => i > j? i : j;
public static bool IsPalindrome(string s) {
for (int i = 0; i < s.Length / 2; i++) {
if (s[i] != s[s.Length - 1 - i])
return false;
}
return true;
}
public readonly static VectorInt2[] Dir8 = {
new VectorInt2(-1, -1), new VectorInt2(-1, 0), new VectorInt2(-1, 1),
new VectorInt2(0, -1), new VectorInt2(0, 1), new VectorInt2(1, -1),
new VectorInt2(1, 0), new VectorInt2(1, 1)
};
public const long MODCONST = 1000000007;
public static T debug<T>(this T value) {
Console.Error.WriteLine($"debug:{value}");
return value;
}
public static T Id<T>(T t) => t;
public static long ToLong(this String s) => long.Parse(s);
public static long ToLong(this char c) => c - '0';
public static int ToInt(this String s) => int.Parse(s);
public static int ToInt(this char c) => c - '0';
public static void Times(this int n, Action action) {
for (int i = 0; i < n; i++)
action();
}
public static void Times(this long n, Action action) {
for (long i = 0; i < n; i++)
action();
}
public static IEnumerable<T> Times<T>(this int n, Func<T> func) {
for (long i = 0; i < n; i++)
yield return func();
}
public static IEnumerable<T> Times<T>(this long n, Func<T> func) {
for (long i = 0; i < n; i++)
yield return func();
}
public static Func<S, U> Then<S, T, U>(this Func<S, T> f,
Func<T, U> g) => x => g(f(x));
public static Func<S, U> Compose<S, T, U>(this Func<T, U> f,
Func<S, T> g) => x => f(g(x));
public static void Call<T>(this T t, Action<T> action) => action(t);
public static bool In<T>(this T t, IEnumerable<T> range) => range.Contains(t);
public static void WriteLine<T>(this T t) => Console.WriteLine(t);
public static T Call<S, T>(this S s, Func<S, T> func) => func(s);
public static void Each<T>(this IEnumerable<T> e, Action<T> action) {
foreach (var v in e)
action(v);
}
public static long
Prod(this IEnumerable<long> source) => source.Aggregate(Multiply);
public static IEnumerable<int> FromTo(int a,
int b) => Range(a, Max(b - a + 1, 0));
public static IEnumerable<T> Repeat<T>(T t) {
while (true)
yield return t;
}
public static IEnumerable<T> Replicate<T>(int n, T t) => Repeat(t).Take(n);
public static IEnumerable<T> Cycle<T>(this IEnumerable<T> e) {
while (true)
foreach (var v in e)
yield return v;
}
public static IEnumerable<T> Scan<S, T>(this IEnumerable<S> source, T init,
Func<T, S, T> accumulator) {
var result = init;
foreach (var item in source) {
result = accumulator(result, item);
yield return result;
}
}
public static T[] ToArray<T>(params T[] ns) => ns;
public static List<T> ToList<T>(params T[] ns) => ns.ToList();
public static IEnumerable<T> Scan0<S, T>(this IEnumerable<S> source, T init,
Func<T, S, T> accumulator) {
yield return init;
foreach (var item in Scan(source, init, accumulator))
yield return item;
}
public static IEnumerable<List<T>> Buffer<T>(this IEnumerable<T> source,
int length) {
while (source.Any()) {
yield return source.Take(length).ToList();
source = source.Skip(length);
}
}
public static IEnumerable<List<T>> ChunkBy<T>(this IEnumerable<T> source) =>
ChunkBy(source, Id, EqualityComparer<T>.Default);
public static IEnumerable<List<T>> ChunkBy<S, T>(this IEnumerable<T> source,
Func<T, S> selector) =>
ChunkBy(source, selector, EqualityComparer<S>.Default);
public static IEnumerable<List<T>>
ChunkBy<S, T>(this IEnumerable<T> source, Func<T, S> selector,
IEqualityComparer<S> comparer) {
while (source.Any()) {
var v = selector(source.First());
var l = source.TakeWhile(x => comparer.Equals(selector(x), v)).ToList();
yield return l;
source = source.Skip(l.Count());
}
}
public static VectorInt2 ReadVectorInt2() => new VectorInt2(ReadInt(),
ReadInt());
public static string ReplaceX(this string input, string pattern,
string replace) => Regex.Replace(input, pattern,
replace);
public static IEnumerable<int> Range(int i, int j) => Enumerable.Range(i, j);
public static IEnumerable<long> Range(long i, long j) {
for (long k = i; k < i + j; k++)
yield return k;
}
public static void Swap<T>(this IList<T> enumerable, int i, int j) {
var buf = enumerable[i];
enumerable[i] = enumerable[j];
enumerable[j] = buf;
}
public static void ReverseRange<T>(this IList<T> enumerable, int i, int j) {
int half = (j - i) / 2;
for (int k = 0; k <= half; k++)
enumerable.Swap(i + k, j - k);
}
public static bool
isEmpty<T>(this IEnumerable<T> enumerable) => !enumerable.Any();
}
static class Cin {
private static Queue<string> tokens;
static Cin() {
string line;
tokens = new Queue<string>();
while ((line = Console.ReadLine()) != null) {
foreach (var token in line.Split(' ')) {
tokens.Enqueue(token);
}
}
}
static public int ReadInt() => int.Parse(tokens.Dequeue());
static public List<int> ReadInt(long n) {
var list = new List<int>();
n.Times(() => list.Add(ReadInt()));
return list;
}
static public long ReadLong() => long.Parse(tokens.Dequeue());
static public List<long> ReadLong(long n) {
var list = new List<long>();
n.Times(() => list.Add(ReadLong()));
return list;
}
static public string ReadString() => tokens.Dequeue();
static public List<string> ReadString(long n) {
var list = new List<string>();
n.Times(() => list.Add(ReadString()));
return list;
}
static public void SayYesNo(this bool b) => (b ? "Yes" : "No").WriteLine();
}
struct VectorInt2 {
public int X { get; set; }
public int Y { get; set; }
public VectorInt2(int x, int y) {
X = x;
Y = y;
}
static public VectorInt2 operator +(VectorInt2 v1, VectorInt2 v2) =>
new VectorInt2(v1.X + v2.X, v1.Y + v2.Y);
static public VectorInt2 operator -(VectorInt2 v1, VectorInt2 v2) =>
new VectorInt2(v1.X - v2.X, v1.Y - v2.Y);
static public VectorInt2 operator *(VectorInt2 v1, VectorInt2 v2) =>
new VectorInt2(v1.X * v2.X, v1.Y *v2.Y);
static public VectorInt2
operator *(VectorInt2 v1, int i) => new VectorInt2(v1.X * i, v1.Y *i);
static public VectorInt2
operator *(int i, VectorInt2 v2) => new VectorInt2(i * v2.X, i *v2.Y);
static public VectorInt2
operator /(VectorInt2 v1, int i) => new VectorInt2(v1.X / i, v1.Y / i);
}
class Maxer<T>
where T : IComparable<T> {
public T Value;
public Maxer(T t) { Value = t; }
public void Max(T other) {
if (Value.CompareTo(other) < 0)
Value = other;
}
}
class MultiSet<T> : IEnumerable<KeyValuePair<T, int>> {
Dictionary<T, int> dictionary = new Dictionary<T, int>();
public MultiSet(IEnumerable<T> data) {
foreach (var datum in data) {
if (dictionary.ContainsKey(datum)) {
dictionary[datum]++;
} else {
dictionary[datum] = 1;
}
}
}
public int this[T key] {
get { return dictionary.ContainsKey(key) ? dictionary[key] : 0; }
}
public MultiSet() {}
public static MultiSet<S>
ToMultiSet<S>(IEnumerable<S> source) => new MultiSet<S>(source);
public Dictionary<T, int> AsDict() => dictionary;
public IEnumerator<KeyValuePair<T, int>>
GetEnumerator() => dictionary.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator();
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
// using static System.Linq.Enumerable;
using static System.Console;
using static AtCoder.Util;
using static AtCoder.Cin;
using static System.Math;
using static AtCoder.MyMath;
// 100 55 6
namespace AtCoder {
class Program {
static void Main() {
var n = ReadLong();
var a = ReadLong();
var b = ReadLong();
var x = a > b ? 0 : n == 1 ? (a == b ? 1 : 0) : (b - a) * (n - 2) + 1;
WriteLine(x);
}
}
}
/* ***************** Following Contents are my common library ******** */
namespace AtCoder {
static class MyMath {
public static long ToNearestInt(this double d) {
var l = (long)Math.Floor(d);
var r = l + 1;
return r - d < d - l ? r : l;
}
public static long Factorial(this long n) => Range(1, n).Aggregate(1L,
Multiply);
public static long nPr(int n, int r) => r < 0 || r > n? 0
: FromTo(n - r + 1, n)
.Select(x => (long)x)
.Aggregate(1L, Multiply);
public static long nCr(int n, int r) => nPr(n, r) / Factorial(r);
public static long Inc(long i) => i + 1;
public static long Dec(long i) => i - 1;
public static long Plus(long i, long j) => i + j;
public static Func<long, long> Plus(long j) => i => i + j;
public static long Minus(long i, long j) => i - j;
public static Func<long, long> Minus(long j) => i => i - j;
public static long Multiply(long i, long j) => i * j;
public static Func<long, long> Multiply(long j) => i => i * j;
public static long Divide(long i, long j) => j / j;
public static Func<long, long> Divide(long j) => i => i * j;
public static long Mod(long i, long j) => i % j;
public static Func<long, long> Mod(long j) => i => i % j;
public static long Max(params long[] ns) => ns.Max();
public static long LowerBound(this long m, long lbound) => Max(m, lbound);
public static long UpperBound(this long m, long ubound) => Min(m, ubound);
public static long Bound(this long m, long lowerBound, long UpperBound) =>
m.LowerBound(lowerBound).UpperBound(UpperBound);
public static long LowerBound(this int m, long lbound) => Max(m, lbound);
public static long UpperBound(this int m, long ubound) => Min(m, ubound);
public static long Bound(this int m, long lowerBound, long UpperBound) =>
m.LowerBound(lowerBound).UpperBound(UpperBound);
public static bool InRange(this long x, long min, long max) => min <= x
&& x <= max;
public static bool IsEven(this int x) => x % 2 == 0;
public static bool IsOdd(this int x) => x % 2 != 1;
public static bool IsEven(this long x) => x % 2 == 0;
public static bool IsOdd(this long x) => x % 2 != 1;
}
static class Util {
public static string
Show(this IEnumerable<char> source) => new string(source.ToArray());
public static IEnumerable<int>
ToDigits(this long n) => n.ToString().Select(x => x.ToInt());
public static IEnumerable<int> ToDigits(this int n) => ((long)n).ToDigits();
public static IEnumerable<int> Factors(this int n) {
for (int i = 1; i <= n; i++)
if (n % i == 0)
yield return i;
}
public static IEnumerable<int> Natural() {
for (int i = 0;; i++)
yield return i;
}
public static IEnumerable<int> Positive() => Natural().Skip(1);
public static long Pow(long i, long exp) => (exp == 0) ? 1
: i * Pow(i, exp - 1);
public static HashSet<T>
ToHashSet<T>(this IEnumerable<T> source) => new HashSet<T>(source);
public static MultiSet<T>
ToMultiSet<T>(this IEnumerable<T> t) => new MultiSet<T>(t);
public static int Max(this int i, int j) => i > j? i : j;
public static bool IsPalindrome(string s) {
for (int i = 0; i < s.Length / 2; i++) {
if (s[i] != s[s.Length - 1 - i])
return false;
}
return true;
}
public readonly static VectorInt2[] Dir8 = {
new VectorInt2(-1, -1), new VectorInt2(-1, 0), new VectorInt2(-1, 1),
new VectorInt2(0, -1), new VectorInt2(0, 1), new VectorInt2(1, -1),
new VectorInt2(1, 0), new VectorInt2(1, 1)
};
public const long MODCONST = 1000000007;
public static T debug<T>(this T value) {
Console.Error.WriteLine($"debug:{value}");
return value;
}
public static T Id<T>(T t) => t;
public static long ToLong(this String s) => long.Parse(s);
public static long ToLong(this char c) => c - '0';
public static int ToInt(this String s) => int.Parse(s);
public static int ToInt(this char c) => c - '0';
public static void Times(this int n, Action action) {
for (int i = 0; i < n; i++)
action();
}
public static void Times(this long n, Action action) {
for (long i = 0; i < n; i++)
action();
}
public static IEnumerable<T> Times<T>(this int n, Func<T> func) {
for (long i = 0; i < n; i++)
yield return func();
}
public static IEnumerable<T> Times<T>(this long n, Func<T> func) {
for (long i = 0; i < n; i++)
yield return func();
}
public static Func<S, U> Then<S, T, U>(this Func<S, T> f,
Func<T, U> g) => x => g(f(x));
public static Func<S, U> Compose<S, T, U>(this Func<T, U> f,
Func<S, T> g) => x => f(g(x));
public static void Call<T>(this T t, Action<T> action) => action(t);
public static bool In<T>(this T t, IEnumerable<T> range) => range.Contains(t);
public static void WriteLine<T>(this T t) => Console.WriteLine(t);
public static T Call<S, T>(this S s, Func<S, T> func) => func(s);
public static void Each<T>(this IEnumerable<T> e, Action<T> action) {
foreach (var v in e)
action(v);
}
public static long
Prod(this IEnumerable<long> source) => source.Aggregate(Multiply);
public static IEnumerable<int> FromTo(int a,
int b) => Range(a, Max(b - a + 1, 0));
public static IEnumerable<T> Repeat<T>(T t) {
while (true)
yield return t;
}
public static IEnumerable<T> Replicate<T>(int n, T t) => Repeat(t).Take(n);
public static IEnumerable<T> Cycle<T>(this IEnumerable<T> e) {
while (true)
foreach (var v in e)
yield return v;
}
public static IEnumerable<T> Scan<S, T>(this IEnumerable<S> source, T init,
Func<T, S, T> accumulator) {
var result = init;
foreach (var item in source) {
result = accumulator(result, item);
yield return result;
}
}
public static T[] ToArray<T>(params T[] ns) => ns;
public static List<T> ToList<T>(params T[] ns) => ns.ToList();
public static IEnumerable<T> Scan0<S, T>(this IEnumerable<S> source, T init,
Func<T, S, T> accumulator) {
yield return init;
foreach (var item in Scan(source, init, accumulator))
yield return item;
}
public static IEnumerable<List<T>> Buffer<T>(this IEnumerable<T> source,
int length) {
while (source.Any()) {
yield return source.Take(length).ToList();
source = source.Skip(length);
}
}
public static IEnumerable<List<T>> ChunkBy<T>(this IEnumerable<T> source) =>
ChunkBy(source, Id, EqualityComparer<T>.Default);
public static IEnumerable<List<T>> ChunkBy<S, T>(this IEnumerable<T> source,
Func<T, S> selector) =>
ChunkBy(source, selector, EqualityComparer<S>.Default);
public static IEnumerable<List<T>>
ChunkBy<S, T>(this IEnumerable<T> source, Func<T, S> selector,
IEqualityComparer<S> comparer) {
while (source.Any()) {
var v = selector(source.First());
var l = source.TakeWhile(x => comparer.Equals(selector(x), v)).ToList();
yield return l;
source = source.Skip(l.Count());
}
}
public static VectorInt2 ReadVectorInt2() => new VectorInt2(ReadInt(),
ReadInt());
public static string ReplaceX(this string input, string pattern,
string replace) => Regex.Replace(input, pattern,
replace);
public static IEnumerable<int> Range(int i, int j) => Enumerable.Range(i, j);
public static IEnumerable<long> Range(long i, long j) {
for (long k = i; k < i + j; k++)
yield return k;
}
public static void Swap<T>(this IList<T> enumerable, int i, int j) {
var buf = enumerable[i];
enumerable[i] = enumerable[j];
enumerable[j] = buf;
}
public static void ReverseRange<T>(this IList<T> enumerable, int i, int j) {
int half = (j - i) / 2;
for (int k = 0; k <= half; k++)
enumerable.Swap(i + k, j - k);
}
public static bool
isEmpty<T>(this IEnumerable<T> enumerable) => !enumerable.Any();
}
static class Cin {
private static Queue<string> tokens;
static Cin() {
string line;
tokens = new Queue<string>();
while ((line = Console.ReadLine()) != null) {
foreach (var token in line.Split(' ')) {
tokens.Enqueue(token);
}
}
}
static public int ReadInt() => int.Parse(tokens.Dequeue());
static public List<int> ReadInt(long n) {
var list = new List<int>();
n.Times(() => list.Add(ReadInt()));
return list;
}
static public long ReadLong() => long.Parse(tokens.Dequeue());
static public List<long> ReadLong(long n) {
var list = new List<long>();
n.Times(() => list.Add(ReadLong()));
return list;
}
static public string ReadString() => tokens.Dequeue();
static public List<string> ReadString(long n) {
var list = new List<string>();
n.Times(() => list.Add(ReadString()));
return list;
}
static public void SayYesNo(this bool b) => (b ? "Yes" : "No").WriteLine();
}
struct VectorInt2 {
public int X { get; set; }
public int Y { get; set; }
public VectorInt2(int x, int y) {
X = x;
Y = y;
}
static public VectorInt2 operator +(VectorInt2 v1, VectorInt2 v2) =>
new VectorInt2(v1.X + v2.X, v1.Y + v2.Y);
static public VectorInt2 operator -(VectorInt2 v1, VectorInt2 v2) =>
new VectorInt2(v1.X - v2.X, v1.Y - v2.Y);
static public VectorInt2 operator *(VectorInt2 v1, VectorInt2 v2) =>
new VectorInt2(v1.X * v2.X, v1.Y *v2.Y);
static public VectorInt2
operator *(VectorInt2 v1, int i) => new VectorInt2(v1.X * i, v1.Y *i);
static public VectorInt2
operator *(int i, VectorInt2 v2) => new VectorInt2(i * v2.X, i *v2.Y);
static public VectorInt2
operator /(VectorInt2 v1, int i) => new VectorInt2(v1.X / i, v1.Y / i);
}
class Maxer<T>
where T : IComparable<T> {
public T Value;
public Maxer(T t) { Value = t; }
public void Max(T other) {
if (Value.CompareTo(other) < 0)
Value = other;
}
}
class MultiSet<T> : IEnumerable<KeyValuePair<T, int>> {
Dictionary<T, int> dictionary = new Dictionary<T, int>();
public MultiSet(IEnumerable<T> data) {
foreach (var datum in data) {
if (dictionary.ContainsKey(datum)) {
dictionary[datum]++;
} else {
dictionary[datum] = 1;
}
}
}
public int this[T key] {
get { return dictionary.ContainsKey(key) ? dictionary[key] : 0; }
}
public MultiSet() {}
public static MultiSet<S>
ToMultiSet<S>(IEnumerable<S> source) => new MultiSet<S>(source);
public Dictionary<T, int> AsDict() => dictionary;
public IEnumerator<KeyValuePair<T, int>>
GetEnumerator() => dictionary.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator();
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 213, 63, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 213, 63, 22]]
| 8
| 3,165
| 6
|
using System;
using System.IO;
using System.Collections.Generic;
namespace AGC015A {
public class Program {
void Solve(StreamScanner ss, StreamWriter sw) {
//---------------------------------
var N = ss.Next(long.Parse);
var A = ss.Next(long.Parse);
var B = ss.Next(long.Parse);
if (N == 1 && A != B) {
sw.WriteLine(0);
return;
}
if (N == 1 && A == B) {
sw.WriteLine(1);
return;
}
if (A >= B) {
sw.WriteLine(0);
return;
}
sw.WriteLine(B * (N - 2) - A * (N - 2) + 1);
//---------------------------------
}
static void Main() {
var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
new Program().Solve(ss, sw);
sw.Flush();
}
static readonly Func<string, string> String = s => s;
}
public class StreamScanner {
static readonly char[] Sep = { ' ' };
readonly Queue<string> buffer = new Queue<string>();
readonly TextReader textReader;
public StreamScanner(TextReader textReader) { this.textReader = textReader; }
public T Next<T>(Func<string, T> parser) {
if (buffer.Count != 0)
return parser(buffer.Dequeue());
var nextStrings =
textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
foreach (var nextString in nextStrings)
buffer.Enqueue(nextString);
return Next(parser);
}
public T[] Next<T>(Func<string, T> parser, int x) {
var ret = new T[x];
for (var i = 0; i < x; ++i)
ret[i] = Next(parser);
return ret;
}
public T[][] Next<T>(Func<string, T> parser, int x, int y) {
var ret = new T[y][];
for (var i = 0; i < y; ++i)
ret[i] = Next(parser, x);
return ret;
}
}
}
|
using System;
using System.IO;
using System.Collections.Generic;
namespace AGC015A {
public class Program {
void Solve(StreamScanner ss, StreamWriter sw) {
//---------------------------------
var N = ss.Next(long.Parse);
var A = ss.Next(long.Parse);
var B = ss.Next(long.Parse);
if (N == 1 && A != B) {
sw.WriteLine(0);
return;
}
if (A == B) {
sw.WriteLine(1);
return;
}
if (A > B) {
sw.WriteLine(0);
return;
}
sw.WriteLine(B * (N - 2) - A * (N - 2) + 1);
//---------------------------------
}
static void Main() {
var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
new Program().Solve(ss, sw);
sw.Flush();
}
static readonly Func<string, string> String = s => s;
}
public class StreamScanner {
static readonly char[] Sep = { ' ' };
readonly Queue<string> buffer = new Queue<string>();
readonly TextReader textReader;
public StreamScanner(TextReader textReader) { this.textReader = textReader; }
public T Next<T>(Func<string, T> parser) {
if (buffer.Count != 0)
return parser(buffer.Dequeue());
var nextStrings =
textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
foreach (var nextString in nextStrings)
buffer.Enqueue(nextString);
return Next(parser);
}
public T[] Next<T>(Func<string, T> parser, int x) {
var ret = new T[x];
for (var i = 0; i < x; ++i)
ret[i] = Next(parser);
return ret;
}
public T[][] Next<T>(Func<string, T> parser, int x, int y) {
var ret = new T[y][];
for (var i = 0; i < y; ++i)
ret[i] = Next(parser, x);
return ret;
}
}
}
|
[["-", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 20], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47]]
| 8
| 478
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AGC015_A {
class Program {
static void Main(string[] args) {
var s = Console.ReadLine().Split();
var n = int.Parse(s[0]);
var a = int.Parse(s[1]);
var b = int.Parse(s[2]);
if (a > b) {
Console.WriteLine(0);
return;
} else if (n == 1) {
if (a == b) {
Console.WriteLine(1);
} else {
Console.WriteLine(0);
}
return;
} else {
Console.WriteLine(((n - 2) * (b - a) + 1));
return;
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AGC015_A {
class Program {
static void Main(string[] args) {
var s = Console.ReadLine().Split();
var n = long.Parse(s[0]);
var a = long.Parse(s[1]);
var b = long.Parse(s[2]);
if (a > b) {
Console.WriteLine(0);
return;
} else if (n == 1) {
if (a == b) {
Console.WriteLine(1);
} else {
Console.WriteLine(0);
}
return;
} else {
Console.WriteLine(((n - 2) * (b - a) + 1));
return;
}
}
}
}
|
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199]]
| 8
| 177
| 6
|
using System;
public class Hello {
public static void Main() {
string[] line = Console.ReadLine().Trim().Split(' ');
var n = long.Parse(line[0]);
var a = long.Parse(line[1]);
var b = long.Parse(line[2]);
if (a > b) {
Console.WriteLine(0);
goto end;
}
if (a != b && n == 1) {
Console.WriteLine(0);
goto end;
} else if (a == b && n == 1) {
Console.WriteLine(1);
goto end;
}
var ret = (n - 2) * (b - a);
Console.WriteLine(ret);
end:;
}
}
|
using System;
public class Hello {
public static void Main() {
string[] line = Console.ReadLine().Trim().Split(' ');
var n = long.Parse(line[0]);
var a = long.Parse(line[1]);
var b = long.Parse(line[2]);
if (a > b) {
Console.WriteLine(0);
goto end;
}
if (a != b && n == 1) {
Console.WriteLine(0);
goto end;
} else if (a == b && n == 1) {
Console.WriteLine(1);
goto end;
}
var ret = (n - 2) * (b - a) + 1;
Console.WriteLine(ret);
end:;
}
}
|
[["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203]]
| 8
| 165
| 2
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Runtime.InteropServices;
using System.Runtime.Remoting.Messaging;
using System.Security.Principal;
using System.Text;
class Simple {
private long N, A, B;
void Solve() {
// input
N = io.Long;
A = io.Long;
B = io.Long;
// cal
var ans = 0L;
if (N == 0 || A > B || (N == 0 && A != B)) {
ans = 0;
} else {
// var Max = A + (N - 1) * B;
// var Min = (N - 1) * A + B;
var range = (B - A) * (N - 2);
ans += range + 1;
}
// ret
Console.WriteLine(ans);
}
SimpleIO io = new SimpleIO();
public static void Main(string[] args) => new Simple().Stream();
void Stream() {
Solve();
io.writeFlush();
}
}
class SimpleIO {
string[] nextBuffer;
int BufferCnt;
char[] cs = new char[] { ' ' };
StreamWriter sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
public SimpleIO() {
nextBuffer = new string[0];
BufferCnt = 0;
Console.SetOut(sw);
}
public string Next() {
if (BufferCnt < nextBuffer.Length)
return nextBuffer[BufferCnt++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
BufferCnt = 0;
return nextBuffer[BufferCnt++];
}
public string String => Next();
public char Char => char.Parse(String);
public int Int => int.Parse(String);
public long Long => long.Parse(String);
public double Double => double.Parse(String);
public void writeFlush() { Console.Out.Flush(); }
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Runtime.InteropServices;
using System.Runtime.Remoting.Messaging;
using System.Security.Principal;
using System.Text;
class Simple {
private long N, A, B;
void Solve() {
// input
N = io.Long;
A = io.Long;
B = io.Long;
// cal
var ans = 0L;
if (N == 0 || A > B || (N == 1 && A != B)) {
ans = 0;
} else {
// var Max = A + (N - 1) * B;
// var Min = (N - 1) * A + B;
var range = (B - A) * (N - 2);
ans += range + 1;
}
// ret
Console.WriteLine(ans);
}
SimpleIO io = new SimpleIO();
public static void Main(string[] args) => new Simple().Stream();
void Stream() {
Solve();
io.writeFlush();
}
}
class SimpleIO {
string[] nextBuffer;
int BufferCnt;
char[] cs = new char[] { ' ' };
StreamWriter sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
public SimpleIO() {
nextBuffer = new string[0];
BufferCnt = 0;
Console.SetOut(sw);
}
public string Next() {
if (BufferCnt < nextBuffer.Length)
return nextBuffer[BufferCnt++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
BufferCnt = 0;
return nextBuffer[BufferCnt++];
}
public string String => Next();
public char Char => char.Parse(String);
public int Int => int.Parse(String);
public long Long => long.Parse(String);
public double Double => double.Parse(String);
public void writeFlush() { Console.Out.Flush(); }
}
|
[["-", 15, 16, 12, 23, 0, 16, 31, 16, 12, 203], ["+", 15, 16, 12, 23, 0, 16, 31, 16, 12, 203]]
| 8
| 419
| 2
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
namespace AtCoder {
class MainClass {
// C#7.0/////////////////////////////////////////////////////
int N, A, B;
void Solve() {
io.i(out N, out A, out B);
long ans = 0;
if (N == 0 || A > B) {
ans = 0;
} else if (N == 1) {
ans = (A == B) ? 1 : 0;
} else {
ans = (B - A) * (N - 2) + 1;
}
io.o(ans);
}
////////////////////////////////////////////////////////////
public static void Main(string[] args) { new MainClass().Stream(); }
IO io = new IO();
void Stream() {
Solve();
io.writeFlush();
}
// void Stream() { Test(); io.writeFlush(); }
void Test() {}
#region MockMacro
// Hack Update
void FOR(int a, int b, Action<int> act) {
for (int i = a; i < b; i++)
act(i);
}
void FOR(int a, int b, Action<int> act, Func<int, bool> con) {
for (int i = a; i < b && con(i); i++)
act(i);
}
void RFOR(int a, int b, Action<int> act) {
for (int i = a; i >= b; i--)
act(i);
}
void RFOR(int a, int b, Action<int> act, Func<int, bool> con) {
for (int i = a; i >= b && con(i); i--)
act(i);
}
void REP(int n, Action<int> act, Func<int, bool> con) {
for (int i = 0; i < n && con(i); i++)
act(i);
}
void REP(int n, Action<int> act) {
for (int i = 0; i < n; i++)
act(i);
}
void RREP(int n, Action<int> act) {
for (int i = n - 1; i >= 0; i--)
act(i);
}
void RREP(int n, Action<int> act, Func<int, bool> con) {
for (int i = n - 1; i >= 0 && con(i); i--)
act(i);
}
#endregion
}
#region default
class IO {
string[] nextBuffer;
int BufferCnt;
char[] cs = new char[] { ' ' };
StreamWriter sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
public IO() {
nextBuffer = new string[0];
BufferCnt = 0;
Console.SetOut(sw);
}
public string next() {
if (BufferCnt < nextBuffer.Length)
return nextBuffer[BufferCnt++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
BufferCnt = 0;
return nextBuffer[BufferCnt++];
}
public char nextChar() { return char.Parse(next()); }
public int nextInt() { return int.Parse(next()); }
public long nextLong() { return long.Parse(next()); }
public double nextDouble() { return double.Parse(next()); }
public string[] arr() { return Console.ReadLine().Split(' '); }
public char[] arrayChar() { return Array.ConvertAll(arr(), char.Parse); }
public int[] arrayInt() { return Array.ConvertAll(arr(), int.Parse); }
public long[] arrayLong() { return Array.ConvertAll(arr(), long.Parse); }
public double[] arrayDouble() {
return Array.ConvertAll(arr(), double.Parse);
}
private bool typeEQ<T, U>() { return typeof(T).Equals(typeof(U)); }
private T convertType<T, U>(U v) {
return (T)Convert.ChangeType(v, typeof(T));
}
private T suitType<T>(string s) {
if (typeEQ<T, int>())
return convertType<T, int>(int.Parse(s));
if (typeEQ<T, long>())
return convertType<T, long>(long.Parse(s));
if (typeEQ<T, double>())
return convertType<T, double>(double.Parse(s));
if (typeEQ<T, char>())
return convertType<T, char>(char.Parse(s));
return convertType<T, string>(s);
}
public void i<T>(out T v) { v = suitType<T>(next()); }
public void i<T, U>(out T v1, out U v2) {
i(out v1);
i(out v2);
}
public void i<T, U, V>(out T v1, out U v2, out V v3) {
i(out v1);
i(out v2);
i(out v3);
}
public void i<T, U, V, W>(out T v1, out U v2, out V v3, out W v4) {
i(out v1);
i(out v2);
i(out v3);
i(out v4);
}
public void i<T, U, V, W, X>(out T v1, out U v2, out V v3, out W v4,
out X v5) {
i(out v1);
i(out v2);
i(out v3);
i(out v4);
i(out v5);
}
public void ini(out int[] a, int size) {
a = new int[size];
for (int i = 0; i < size; i++)
a[i] = nextInt();
}
public void ini(out long[] a, int size) {
a = new long[size];
for (int i = 0; i < size; i++)
a[i] = nextLong();
}
public void ini(out int[] a1, out int[] a2, int size) {
a1 = new int[size];
a2 = new int[size];
for (int i = 0; i < size; i++) {
a1[i] = nextInt();
a2[i] = nextInt();
}
}
public void ini(out long[] a1, out long[] a2, int size) {
a1 = new long[size];
a2 = new long[size];
for (int i = 0; i < size; i++) {
a1[i] = nextLong();
a2[i] = nextLong();
}
}
public void ini(out int[,] g, int h, int w) {
g = new int[h, w];
for (int i = 0; i < h; i++)
for (int j = 0; j < w; j++)
g[i, j] = nextInt();
}
public void ini(out string[] a, int size) {
a = new string[size];
for (int i = 0; i < size; i++)
a[i] = next();
}
public void inii(out int[] a, int size) {
a = new int[size];
for (int i = 0; i < size; i++)
a[i] = nextInt() - 1;
}
public void inii(out int[] a1, out int[] a2, int size) {
a1 = new int[size];
a2 = new int[size];
for (int i = 0; i < size; i++) {
a1[i] = nextInt() - 1;
a2[i] = nextInt() - 1;
}
}
public void inii(out int[,] a, int size) {
a = new int[size, size];
for (int i = 0; i < size; i++)
for (int j = 0; j < size; j++)
a[i, j] = nextInt() - 1;
}
public void o<T>(T v) { Console.WriteLine(v); }
public void ol<T>(T v) { Console.Write(v + " "); }
public void o<T>(params T[] a) {
foreach (T v in a)
o(v);
}
public void o<T>(List<T> l) { o(l.ToArray()); }
public void ol<T>(params T[] a) {
foreach (T v in a) {
ol(v);
}
br();
}
public void ol<T>(List<T> l) { ol(l.ToArray()); }
public void YN(bool f) { o(f ? "YES" : "NO"); }
public void Yn(bool f) { o(f ? "Yes" : "No"); }
public void yn(bool f) { o(f ? "yes" : "no"); }
public void br() { o(""); }
public void writeFlush() { Console.Out.Flush(); }
}
#endregion
#region other
class Mat {
public int mod = 1000000007; // 10^9+7
public long Pow(long a, long b) {
if (b == 0)
return 1;
if (b % 2 == 1)
return (a % mod * Pow(a % mod, b - 1) % mod) % mod;
else
return Pow(a * a % mod, b / 2) % mod;
}
public long Fact(long n) {
return (n != 0) ? (n % mod * (Fact(n - 1) % mod) % mod) : 1;
}
public long C(long n, long r) {
if (r == 0 || n == r)
return 1;
else
return (Fact(n) % mod *
Pow((Fact(n - r) % mod * Fact(r) % mod) % mod, mod - 2) % mod) %
mod;
}
public long Sum(params long[] a) {
return a.Aggregate((v, next) => (v % mod + next) % mod);
}
public int GCD(int a, int b) {
if (a < b)
Swap(ref a, ref b);
return b == 0 ? a : GCD(b, a % b);
}
public int GCD(int[] array) {
return array.Aggregate((v, next) => GCD(v, next));
}
public bool isPrime(long n) {
if (n == 2)
return true;
if (n < 2 || n % 2 == 0)
return false;
for (long v = 3; v <= (long)Math.Sqrt(n); v += 2)
if (n % v == 0)
return false;
return true;
}
public void Swap<T>(ref T a, ref T b) {
T tmp = a;
a = b;
b = tmp;
}
public T Max<T>(params T[] v) { return v.Max(); }
public T Min<T>(params T[] v) { return v.Min(); }
public double Dis(int x1, int y1, int x2, int y2) {
return Math.Sqrt(Math.Pow((x2 - x1), 2) + Math.Pow((y2 - y1), 2));
}
public int mDis(int x1, int y1, int x2, int y2) {
return Math.Abs(x1 - x2) + Math.Abs(y1 - y2);
}
public int Digit(long n) { return (n == 0) ? 1 : (int)Math.Log10(n) + 1; }
// test
public int DigitValue(int n, int dig) {
return (n % (int)Pow(10, dig)) / (int)Pow(10, dig - 1);
}
/*
public int[] DigVal(int n) {//桁の順番...
int[] ret = new int[Digit(n)];
return ret;
}
*/
//
public int Clamp(int n, int a, int b) {
return (n < a) ? a : (b < n) ? b : n;
}
public long Clamp(long n, long a, long b) {
return (n < a) ? a : (b < n) ? b : n;
}
public double Clamp(double n, double a, double b) {
return (n < a) ? a : (b < n) ? b : n;
}
public long Tousa(long a, long d, int n) { return a + (n - 1) * d; }
public long TousaSum(long a, long d, int n) {
return n * (2 * a + (n - 1) * d) / 2;
}
}
class AssociativeArray<T> {
public Dictionary<T, int> dic;
public AssociativeArray() { dic = new Dictionary<T, int>(); }
public AssociativeArray(params T[] a) {
dic = new Dictionary<T, int>();
Add(a);
}
public void Add(params T[] a) {
for (int i = 0; i < a.Length; i++) {
if (!dic.ContainsKey(a[i]))
dic[a[i]] = 0;
dic[a[i]]++;
}
}
public T[] Keys() { return dic.Keys.ToArray<T>(); }
public int Val(T k) { return (dic.ContainsKey(k)) ? dic[k] : 0; }
public int ValueSum() { return dic.Values.Sum(); }
public int KeyNum() { return dic.Keys.Count; }
public int MaxVal() { return dic.Values.Max(); }
public int MinVal() { return dic.Values.Min(); }
public T MaxKey() { return dic.First(d => d.Value == MaxVal()).Key; }
public T MinKey() { return dic.First(d => d.Value == MinVal()).Key; }
public bool isContainsK(T k) { return dic.ContainsKey(k); }
public bool anyContainsK(params T[] k) {
return k.Any(key => isContainsK(key));
}
public bool allContainsK(params T[] k) {
return k.All(key => isContainsK(key));
}
public void Show() {
foreach (var v in dic) {
Console.WriteLine(v.Key + " : " + v.Value);
}
}
//:sort->array
}
class WarshallFloyd {
int INF;
public WarshallFloyd() { INF = (int)(1e8); }
public WarshallFloyd(int INF) { this.INF = INF; }
public int[,] Run(int[,] m) {
int edgeLength = m.GetLength(0);
for (int i = 0; i < edgeLength; i++)
for (int j = 0; j < edgeLength; j++)
for (int k = 0; k < edgeLength; k++)
m[j, k] = Math.Min(m[j, k], m[j, i] + m[i, k]);
return m;
}
public int[,] Init(int n) {
int[,] m = new int[n, n];
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
m[i, j] = INF;
for (int i = 0; i < n; i++)
m[i, i] = 0;
return m;
}
}
class Time {
public bool isLeapYear(int y) {
return (y % 400 == 0 || (y % 4 == 0 && y % 100 != 0));
}
}
class BucketSort {
public int[] bucket;
public void Init(int[] a) {
bucket = new int[a.Max() + 1];
for (int i = 0; i < a.Length; ++i)
++bucket[a[i]];
for (int i = 0, j = 0; j < bucket.Length; ++j)
for (int k = bucket[j]; k != 0; --k, ++i)
a[i] = j;
}
}
#endregion
#region Ex
static class StringEX { //文字
public static string Reversed(this string s) {
return string.Join("", s.Reverse());
}
public static string Repeat(this string s, int n) {
return string.Concat(Enumerable.Repeat(s, n).ToArray());
}
public static int toInt(this string s) {
int n;
return (int.TryParse(s.TrimStart('0'), out n)) ? n : 0;
}
public static int toInt(this char c) { return toInt(c.ToString()); }
public static int toInt(this char[] c) { return toInt(new string(c)); }
}
static class NumericEx { //数値
public static string pad0<T>(this T v, int n) {
return v.ToString().PadLeft(n, '0');
}
}
static class ArrayEX {
public static T[] Sort<T>(this T[] a) {
Array.Sort(a);
return a;
}
public static void Set<T>(this T[] a, T v) {
for (int i = 0; i < a.Length; i++) {
a[i] = v;
}
}
public static void Set<T>(this T[,] a, T v) {
for (int i = 0; i < a.GetLength(0); i++)
for (int j = 0; j < a.GetLength(1); j++)
a[i, j] = v;
}
}
#endregion
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
namespace AtCoder {
class MainClass {
// C#7.0/////////////////////////////////////////////////////
long N, A, B;
void Solve() {
io.i(out N, out A, out B);
long ans = 0;
if (N == 0 || A > B) {
ans = 0;
} else if (N == 1) {
ans = (A == B) ? 1 : 0;
} else {
ans = (B - A) * (N - 2) + 1;
}
io.o(ans);
}
////////////////////////////////////////////////////////////
public static void Main(string[] args) { new MainClass().Stream(); }
IO io = new IO();
void Stream() {
Solve();
io.writeFlush();
}
// void Stream() { Test(); io.writeFlush(); }
void Test() {}
#region MockMacro
// Hack Update
void FOR(int a, int b, Action<int> act) {
for (int i = a; i < b; i++)
act(i);
}
void FOR(int a, int b, Action<int> act, Func<int, bool> con) {
for (int i = a; i < b && con(i); i++)
act(i);
}
void RFOR(int a, int b, Action<int> act) {
for (int i = a; i >= b; i--)
act(i);
}
void RFOR(int a, int b, Action<int> act, Func<int, bool> con) {
for (int i = a; i >= b && con(i); i--)
act(i);
}
void REP(int n, Action<int> act, Func<int, bool> con) {
for (int i = 0; i < n && con(i); i++)
act(i);
}
void REP(int n, Action<int> act) {
for (int i = 0; i < n; i++)
act(i);
}
void RREP(int n, Action<int> act) {
for (int i = n - 1; i >= 0; i--)
act(i);
}
void RREP(int n, Action<int> act, Func<int, bool> con) {
for (int i = n - 1; i >= 0 && con(i); i--)
act(i);
}
#endregion
}
#region default
class IO {
string[] nextBuffer;
int BufferCnt;
char[] cs = new char[] { ' ' };
StreamWriter sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
public IO() {
nextBuffer = new string[0];
BufferCnt = 0;
Console.SetOut(sw);
}
public string next() {
if (BufferCnt < nextBuffer.Length)
return nextBuffer[BufferCnt++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
BufferCnt = 0;
return nextBuffer[BufferCnt++];
}
public char nextChar() { return char.Parse(next()); }
public int nextInt() { return int.Parse(next()); }
public long nextLong() { return long.Parse(next()); }
public double nextDouble() { return double.Parse(next()); }
public string[] arr() { return Console.ReadLine().Split(' '); }
public char[] arrayChar() { return Array.ConvertAll(arr(), char.Parse); }
public int[] arrayInt() { return Array.ConvertAll(arr(), int.Parse); }
public long[] arrayLong() { return Array.ConvertAll(arr(), long.Parse); }
public double[] arrayDouble() {
return Array.ConvertAll(arr(), double.Parse);
}
private bool typeEQ<T, U>() { return typeof(T).Equals(typeof(U)); }
private T convertType<T, U>(U v) {
return (T)Convert.ChangeType(v, typeof(T));
}
private T suitType<T>(string s) {
if (typeEQ<T, int>())
return convertType<T, int>(int.Parse(s));
if (typeEQ<T, long>())
return convertType<T, long>(long.Parse(s));
if (typeEQ<T, double>())
return convertType<T, double>(double.Parse(s));
if (typeEQ<T, char>())
return convertType<T, char>(char.Parse(s));
return convertType<T, string>(s);
}
public void i<T>(out T v) { v = suitType<T>(next()); }
public void i<T, U>(out T v1, out U v2) {
i(out v1);
i(out v2);
}
public void i<T, U, V>(out T v1, out U v2, out V v3) {
i(out v1);
i(out v2);
i(out v3);
}
public void i<T, U, V, W>(out T v1, out U v2, out V v3, out W v4) {
i(out v1);
i(out v2);
i(out v3);
i(out v4);
}
public void i<T, U, V, W, X>(out T v1, out U v2, out V v3, out W v4,
out X v5) {
i(out v1);
i(out v2);
i(out v3);
i(out v4);
i(out v5);
}
public void ini(out int[] a, int size) {
a = new int[size];
for (int i = 0; i < size; i++)
a[i] = nextInt();
}
public void ini(out long[] a, int size) {
a = new long[size];
for (int i = 0; i < size; i++)
a[i] = nextLong();
}
public void ini(out int[] a1, out int[] a2, int size) {
a1 = new int[size];
a2 = new int[size];
for (int i = 0; i < size; i++) {
a1[i] = nextInt();
a2[i] = nextInt();
}
}
public void ini(out long[] a1, out long[] a2, int size) {
a1 = new long[size];
a2 = new long[size];
for (int i = 0; i < size; i++) {
a1[i] = nextLong();
a2[i] = nextLong();
}
}
public void ini(out int[,] g, int h, int w) {
g = new int[h, w];
for (int i = 0; i < h; i++)
for (int j = 0; j < w; j++)
g[i, j] = nextInt();
}
public void ini(out string[] a, int size) {
a = new string[size];
for (int i = 0; i < size; i++)
a[i] = next();
}
public void inii(out int[] a, int size) {
a = new int[size];
for (int i = 0; i < size; i++)
a[i] = nextInt() - 1;
}
public void inii(out int[] a1, out int[] a2, int size) {
a1 = new int[size];
a2 = new int[size];
for (int i = 0; i < size; i++) {
a1[i] = nextInt() - 1;
a2[i] = nextInt() - 1;
}
}
public void inii(out int[,] a, int size) {
a = new int[size, size];
for (int i = 0; i < size; i++)
for (int j = 0; j < size; j++)
a[i, j] = nextInt() - 1;
}
public void o<T>(T v) { Console.WriteLine(v); }
public void ol<T>(T v) { Console.Write(v + " "); }
public void o<T>(params T[] a) {
foreach (T v in a)
o(v);
}
public void o<T>(List<T> l) { o(l.ToArray()); }
public void ol<T>(params T[] a) {
foreach (T v in a) {
ol(v);
}
br();
}
public void ol<T>(List<T> l) { ol(l.ToArray()); }
public void YN(bool f) { o(f ? "YES" : "NO"); }
public void Yn(bool f) { o(f ? "Yes" : "No"); }
public void yn(bool f) { o(f ? "yes" : "no"); }
public void br() { o(""); }
public void writeFlush() { Console.Out.Flush(); }
}
#endregion
#region other
class Mat {
public int mod = 1000000007; // 10^9+7
public long Pow(long a, long b) {
if (b == 0)
return 1;
if (b % 2 == 1)
return (a % mod * Pow(a % mod, b - 1) % mod) % mod;
else
return Pow(a * a % mod, b / 2) % mod;
}
public long Fact(long n) {
return (n != 0) ? (n % mod * (Fact(n - 1) % mod) % mod) : 1;
}
public long C(long n, long r) {
if (r == 0 || n == r)
return 1;
else
return (Fact(n) % mod *
Pow((Fact(n - r) % mod * Fact(r) % mod) % mod, mod - 2) % mod) %
mod;
}
public long Sum(params long[] a) {
return a.Aggregate((v, next) => (v % mod + next) % mod);
}
public int GCD(int a, int b) {
if (a < b)
Swap(ref a, ref b);
return b == 0 ? a : GCD(b, a % b);
}
public int GCD(int[] array) {
return array.Aggregate((v, next) => GCD(v, next));
}
public bool isPrime(long n) {
if (n == 2)
return true;
if (n < 2 || n % 2 == 0)
return false;
for (long v = 3; v <= (long)Math.Sqrt(n); v += 2)
if (n % v == 0)
return false;
return true;
}
public void Swap<T>(ref T a, ref T b) {
T tmp = a;
a = b;
b = tmp;
}
public T Max<T>(params T[] v) { return v.Max(); }
public T Min<T>(params T[] v) { return v.Min(); }
public double Dis(int x1, int y1, int x2, int y2) {
return Math.Sqrt(Math.Pow((x2 - x1), 2) + Math.Pow((y2 - y1), 2));
}
public int mDis(int x1, int y1, int x2, int y2) {
return Math.Abs(x1 - x2) + Math.Abs(y1 - y2);
}
public int Digit(long n) { return (n == 0) ? 1 : (int)Math.Log10(n) + 1; }
// test
public int DigitValue(int n, int dig) {
return (n % (int)Pow(10, dig)) / (int)Pow(10, dig - 1);
}
/*
public int[] DigVal(int n) {//桁の順番...
int[] ret = new int[Digit(n)];
return ret;
}
*/
//
public int Clamp(int n, int a, int b) {
return (n < a) ? a : (b < n) ? b : n;
}
public long Clamp(long n, long a, long b) {
return (n < a) ? a : (b < n) ? b : n;
}
public double Clamp(double n, double a, double b) {
return (n < a) ? a : (b < n) ? b : n;
}
public long Tousa(long a, long d, int n) { return a + (n - 1) * d; }
public long TousaSum(long a, long d, int n) {
return n * (2 * a + (n - 1) * d) / 2;
}
}
class AssociativeArray<T> {
public Dictionary<T, int> dic;
public AssociativeArray() { dic = new Dictionary<T, int>(); }
public AssociativeArray(params T[] a) {
dic = new Dictionary<T, int>();
Add(a);
}
public void Add(params T[] a) {
for (int i = 0; i < a.Length; i++) {
if (!dic.ContainsKey(a[i]))
dic[a[i]] = 0;
dic[a[i]]++;
}
}
public T[] Keys() { return dic.Keys.ToArray<T>(); }
public int Val(T k) { return (dic.ContainsKey(k)) ? dic[k] : 0; }
public int ValueSum() { return dic.Values.Sum(); }
public int KeyNum() { return dic.Keys.Count; }
public int MaxVal() { return dic.Values.Max(); }
public int MinVal() { return dic.Values.Min(); }
public T MaxKey() { return dic.First(d => d.Value == MaxVal()).Key; }
public T MinKey() { return dic.First(d => d.Value == MinVal()).Key; }
public bool isContainsK(T k) { return dic.ContainsKey(k); }
public bool anyContainsK(params T[] k) {
return k.Any(key => isContainsK(key));
}
public bool allContainsK(params T[] k) {
return k.All(key => isContainsK(key));
}
public void Show() {
foreach (var v in dic) {
Console.WriteLine(v.Key + " : " + v.Value);
}
}
//:sort->array
}
class WarshallFloyd {
int INF;
public WarshallFloyd() { INF = (int)(1e8); }
public WarshallFloyd(int INF) { this.INF = INF; }
public int[,] Run(int[,] m) {
int edgeLength = m.GetLength(0);
for (int i = 0; i < edgeLength; i++)
for (int j = 0; j < edgeLength; j++)
for (int k = 0; k < edgeLength; k++)
m[j, k] = Math.Min(m[j, k], m[j, i] + m[i, k]);
return m;
}
public int[,] Init(int n) {
int[,] m = new int[n, n];
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
m[i, j] = INF;
for (int i = 0; i < n; i++)
m[i, i] = 0;
return m;
}
}
class Time {
public bool isLeapYear(int y) {
return (y % 400 == 0 || (y % 4 == 0 && y % 100 != 0));
}
}
class BucketSort {
public int[] bucket;
public void Init(int[] a) {
bucket = new int[a.Max() + 1];
for (int i = 0; i < a.Length; ++i)
++bucket[a[i]];
for (int i = 0, j = 0; j < bucket.Length; ++j)
for (int k = bucket[j]; k != 0; --k, ++i)
a[i] = j;
}
}
#endregion
#region Ex
static class StringEX { //文字
public static string Reversed(this string s) {
return string.Join("", s.Reverse());
}
public static string Repeat(this string s, int n) {
return string.Concat(Enumerable.Repeat(s, n).ToArray());
}
public static int toInt(this string s) {
int n;
return (int.TryParse(s.TrimStart('0'), out n)) ? n : 0;
}
public static int toInt(this char c) { return toInt(c.ToString()); }
public static int toInt(this char[] c) { return toInt(new string(c)); }
}
static class NumericEx { //数値
public static string pad0<T>(this T v, int n) {
return v.ToString().PadLeft(n, '0');
}
}
static class ArrayEX {
public static T[] Sort<T>(this T[] a) {
Array.Sort(a);
return a;
}
public static void Set<T>(this T[] a, T v) {
for (int i = 0; i < a.Length; i++) {
a[i] = v;
}
}
public static void Set<T>(this T[,] a, T v) {
for (int i = 0; i < a.GetLength(0); i++)
for (int j = 0; j < a.GetLength(1); j++)
a[i, j] = v;
}
}
#endregion
}
|
[["-", 0, 235, 8, 201, 0, 124, 0, 198, 39, 199], ["+", 0, 235, 8, 201, 0, 124, 0, 198, 39, 199]]
| 8
| 3,898
| 2
|
using System.Linq;
using System.Collections.Generic;
using System;
class Program {
static void Main() {
Func<int> InputNumber = () => int.Parse(Console.ReadLine());
Func<string> InputString = () => Console.ReadLine();
Func<IEnumerable<int>> InputNumbers = () =>
Console.ReadLine().Split(' ').Select(x => int.Parse(x));
Func<string[]> InputStrings = () => Console.ReadLine().Split(' ');
var NAB = Console.ReadLine().Split(' ');
var N = int.Parse(NAB[0]);
var A = int.Parse(NAB[1]);
var B = int.Parse(NAB[2]);
if (A > B || N == 1 && A != B) {
Console.WriteLine(0);
} else {
int min = A * (N - 1) + B;
int max = A + B * (N - 1);
Console.WriteLine(max - min + 1);
}
}
}
|
using System.Linq;
using System.Collections.Generic;
using System;
class Program {
static void Main() {
Func<int> InputNumber = () => int.Parse(Console.ReadLine());
Func<string> InputString = () => Console.ReadLine();
Func<IEnumerable<int>> InputNumbers = () =>
Console.ReadLine().Split(' ').Select(x => int.Parse(x));
Func<string[]> InputStrings = () => Console.ReadLine().Split(' ');
var NAB = Console.ReadLine().Split(' ');
var N = long.Parse(NAB[0]);
var A = long.Parse(NAB[1]);
var B = long.Parse(NAB[2]);
if (A > B || N == 1 && A != B) {
Console.WriteLine(0);
} else {
long min = A * (N - 1) + B;
long max = A + B * (N - 1);
Console.WriteLine(max - min + 1);
}
}
}
|
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["-", 0, 57, 75, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 57, 75, 196, 0, 197, 0, 198, 39, 199]]
| 8
| 240
| 10
|
using System;
class MyMain {
static void Main() {
string[] s = System.Console.ReadLine().Trim().Split(' ');
int N = int.Parse(s[0]), A = int.Parse(s[1]), B = int.Parse(s[2]), x;
if (A > B)
x = 0;
else if (N == 1 && A != B)
x = 0;
else if (N == 1 && A == B)
x = 1;
else
x = (B - A) * (N - 2) + 1;
System.Console.WriteLine(x);
System.Console.ReadLine();
}
}
|
using System;
class MyMain {
static void Main() {
string[] s = System.Console.ReadLine().Trim().Split(' ');
long N = long.Parse(s[0]), A = long.Parse(s[1]), B = long.Parse(s[2]), x;
if (A > B)
x = 0;
else if (N == 1 && A != B)
x = 0;
else if (N == 1 && A == B)
x = 1;
else
x = (B - A) * (N - 2) + 1;
System.Console.WriteLine(x);
System.Console.ReadLine();
}
}
|
[["-", 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
| 151
| 8
|
using System;
using System.Linq;
namespace agc015_a {
class Program {
static void Main(string[] args) {
int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
int ret = ((x[0] - 1) * x[2] + x[1]) - ((x[0] - 1) * x[1] + x[2]) + 1;
Console.WriteLine(Math.Max(0, ret));
}
}
}
|
using System;
using System.Linq;
namespace agc015_a {
class Program {
static void Main(string[] args) {
long[] x = Console.ReadLine().Split().Select(long.Parse).ToArray();
long ret = ((x[0] - 1) * x[2] + x[1]) - ((x[0] - 1) * x[1] + x[2]) + 1;
Console.WriteLine(Math.Max(0, ret));
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
| 8
| 114
| 6
|
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
class Program {
static void Main() {
string[] inputs = Console.ReadLine().Split(' ');
int n = int.Parse(inputs[0]);
int a = int.Parse(inputs[1]);
int b = int.Parse(inputs[2]);
int pattern = Math.Max(((b - a) * (n - 2) + 1), 0);
Console.WriteLine(pattern);
}
}
|
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
class Program {
static void Main() {
string[] inputs = Console.ReadLine().Split(' ');
int n = int.Parse(inputs[0]);
int a = int.Parse(inputs[1]);
int b = int.Parse(inputs[2]);
long pattern = Math.Max(((long)(b - a) * (n - 2) + 1), 0);
Console.WriteLine(pattern);
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 23, 0, 16, 31, 16, 31, 74, 0, 24], ["+", 0, 23, 0, 16, 31, 16, 31, 74, 39, 199], ["+", 0, 23, 0, 16, 31, 16, 31, 74, 0, 25]]
| 8
| 138
| 5
|
using System;
namespace AtCoder {
static class Solver {
static IO io = new IO();
public static void Solve() {
io.ReadSplit();
int N = io.Int();
int A = io.Int();
int B = io.Int();
io.WriteLine(Ans(N, A, B).ToString());
}
static long Ans(int N, int A, int B) {
if (N == 1) {
if (A != B) {
return 0;
} else {
return 1;
}
} else if (B < A) {
return 0;
} else {
return B * (N - 2) - A * (N - 2) + 1;
}
}
}
}
namespace AtCoder {
class Program {
static void Main(string[] args) { Solver.Solve(); }
}
class IO {
private string[] _Inputs;
private int _Index;
public void Read() {
_Inputs = new string[1];
_Inputs[0] = Console.ReadLine();
_Index = 0;
}
public void ReadSplit() {
_Inputs = Console.ReadLine().Split(' ');
_Index = 0;
}
public string String() { return _Inputs[_Index++]; }
public string[] String(int xCount) {
string[] rv = new string[xCount];
Array.Copy(_Inputs, _Index, rv, 0, xCount);
_Index += xCount;
return rv;
}
public int Int() { return int.Parse(_Inputs[_Index++]); }
public int[] Int(int xCount) {
int[] rv = new int[xCount];
for (int i = 0; i < xCount; ++i) {
rv[i] = int.Parse(_Inputs[_Index++]);
}
return rv;
}
public long Long() { return long.Parse(_Inputs[_Index++]); }
public long[] Long(int xCount) {
long[] rv = new long[xCount];
for (int i = 0; i < xCount; ++i) {
rv[i] = long.Parse(_Inputs[_Index++]);
}
return rv;
}
public void Write(string xStr) { Console.Write(xStr); }
public void WriteLine(string xStr) { Console.WriteLine(xStr); }
}
}
|
using System;
namespace AtCoder {
static class Solver {
static IO io = new IO();
public static void Solve() {
io.ReadSplit();
int N = io.Int();
int A = io.Int();
int B = io.Int();
io.WriteLine(Ans(N, A, B).ToString());
}
static long Ans(long N, long A, long B) {
if (N == 1) {
if (A != B) {
return 0;
} else {
return 1;
}
} else if (B < A) {
return 0;
} else {
return B * (N - 2) - A * (N - 2) + 1;
}
}
}
}
namespace AtCoder {
class Program {
static void Main(string[] args) { Solver.Solve(); }
}
class IO {
private string[] _Inputs;
private int _Index;
public void Read() {
_Inputs = new string[1];
_Inputs[0] = Console.ReadLine();
_Index = 0;
}
public void ReadSplit() {
_Inputs = Console.ReadLine().Split(' ');
_Index = 0;
}
public string String() { return _Inputs[_Index++]; }
public string[] String(int xCount) {
string[] rv = new string[xCount];
Array.Copy(_Inputs, _Index, rv, 0, xCount);
_Index += xCount;
return rv;
}
public int Int() { return int.Parse(_Inputs[_Index++]); }
public int[] Int(int xCount) {
int[] rv = new int[xCount];
for (int i = 0; i < xCount; ++i) {
rv[i] = int.Parse(_Inputs[_Index++]);
}
return rv;
}
public long Long() { return long.Parse(_Inputs[_Index++]); }
public long[] Long(int xCount) {
long[] rv = new long[xCount];
for (int i = 0; i < xCount; ++i) {
rv[i] = long.Parse(_Inputs[_Index++]);
}
return rv;
}
public void Write(string xStr) { Console.Write(xStr); }
public void WriteLine(string xStr) { Console.WriteLine(xStr); }
}
}
|
[["-", 8, 201, 0, 195, 54, 55, 0, 220, 39, 199], ["+", 8, 201, 0, 195, 54, 55, 0, 220, 39, 199]]
| 8
| 491
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace agc15 {
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
int N = int.Parse(str[0]);
int A = int.Parse(str[1]);
int B = int.Parse(str[2]);
long ans = (N - 2) * (B - A) + 1;
if (B < A || ans < 0) {
ans = 0;
}
Console.WriteLine(ans);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace agc15 {
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
long N = int.Parse(str[0]);
long A = int.Parse(str[1]);
long B = int.Parse(str[2]);
long ans = (N - 2) * (B - A) + 1;
if (B < A || ans < 0) {
ans = 0;
}
Console.WriteLine(ans);
}
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
| 8
| 143
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace AIZU {
class Program {
#region Reserve
static int cin() { return cin(-1); }
static int cin(int D) {
string s = Console.ReadLine();
if (string.IsNullOrEmpty(s))
return D;
return int.Parse(s);
}
static int[] cins(char spliter) {
string s = Console.ReadLine();
if (string.IsNullOrEmpty(s))
return new int[] {};
string[] ss = s.Split(spliter);
int[] Res = new int[ss.Length];
int g;
for (int i = 0; i < ss.Length; i++) {
if (int.TryParse(ss[i], out g))
Res[i] = g;
}
return Res;
}
static int[] cins() { return cins(' '); }
static void print(object j) { Console.WriteLine(j.ToString()); }
static void print(string j) { Console.WriteLine(j); }
#endregion
static void Main(string[] args) {
int[] I = cins();
if (I[1] > I[2]) {
print(0);
return;
}
if (I[1] == I[2]) {
print(1);
return;
}
if (I[0] == 1 && I[1] != I[2]) {
print(0);
return;
}
long Res = (I[2] - I[1]) * (I[0] - 2) + 1;
print(Res);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace AIZU {
class Program {
#region Reserve
static int cin() { return cin(-1); }
static int cin(int D) {
string s = Console.ReadLine();
if (string.IsNullOrEmpty(s))
return D;
return int.Parse(s);
}
static int[] cins(char spliter) {
string s = Console.ReadLine();
if (string.IsNullOrEmpty(s))
return new int[] {};
string[] ss = s.Split(spliter);
int[] Res = new int[ss.Length];
int g;
for (int i = 0; i < ss.Length; i++) {
if (int.TryParse(ss[i], out g))
Res[i] = g;
}
return Res;
}
static int[] cins() { return cins(' '); }
static void print(object j) { Console.WriteLine(j.ToString()); }
static void print(string j) { Console.WriteLine(j); }
#endregion
static void Main(string[] args) {
int[] I = cins();
if (I[1] > I[2]) {
print(0);
return;
}
if (I[1] == I[2]) {
print(1);
return;
}
if (I[0] == 1 && I[1] != I[2]) {
print(0);
return;
}
long Res = (long)(I[2] - I[1]) * (I[0] - 2) + 1;
print(Res);
}
}
}
|
[["+", 0, 212, 0, 16, 31, 16, 31, 74, 39, 199], ["+", 0, 212, 0, 16, 31, 16, 31, 74, 0, 25], ["+", 0, 16, 31, 16, 31, 74, 51, 23, 0, 24]]
| 8
| 362
| 3
|
using System;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
namespace Rextester {
public class Program {
private static readonly StreamReader reader = new StreamReader(
Console.OpenStandardInput(1024 * 10), Encoding.ASCII, false, 1024 * 10);
public static void Main(string[] args) {
int n = Next();
int a = Next();
int b = Next();
int ret = 0;
if (a > b || (n == 1 && a != b)) {
Console.WriteLine(ret);
} else if (n == 1 && a == b) {
ret++;
Console.WriteLine(ret);
} else {
ret = 1;
ret += (n - 2) * (b - a);
Console.WriteLine(ret);
}
}
private static int Next() {
int c;
int m = 1;
do {
c = reader.Read();
if (c == '-')
m = -1;
} while (c < '0' || c > '9');
int res = c - '0';
while (true) {
c = reader.Read();
if (c < '0' || c > '9')
return m * res;
res *= 10;
res += c - '0';
}
}
}
}
|
using System;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
namespace Rextester {
public class Program {
private static readonly StreamReader reader = new StreamReader(
Console.OpenStandardInput(1024 * 10), Encoding.ASCII, false, 1024 * 10);
public static void Main(string[] args) {
int n = Next();
int a = Next();
int b = Next();
long ret = 0;
if (a > b || (n == 1 && a != b)) {
Console.WriteLine(ret);
} else if (n == 1 && a == b) {
ret++;
Console.WriteLine(ret);
} else {
ret = 1;
ret += (long)(n - 2) * (b - a);
Console.WriteLine(ret);
}
}
private static int Next() {
int c;
int m = 1;
do {
c = reader.Read();
if (c == '-')
m = -1;
} while (c < '0' || c > '9');
int res = c - '0';
while (true) {
c = reader.Read();
if (c < '0' || c > '9')
return m * res;
res *= 10;
res += c - '0';
}
}
}
}
|
[["-", 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, 31, 74, 0, 24], ["+", 0, 1, 0, 11, 12, 16, 31, 74, 39, 199], ["+", 0, 1, 0, 11, 12, 16, 31, 74, 0, 25]]
| 8
| 298
| 5
|
using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;
class Program {
const long mod = 1000000007;
// public static int[] max;
static void Main(string[] args) {
char[] cs = new char[] { ' ', ',' };
// int val = int.Parse(Console.ReadLine());
int[] vals = parseAry(Console.ReadLine().Split(cs));
// string str = Console.ReadLine();
// string[] strs = Console.ReadLine().Split(cs);
// int[] vals = parseAry(Console.ReadLine().Split(cs));
// int n = vals[0];
// string res="";
// int y = vals[0];
// int x = vals[1];
long res = 0;
if (vals[1] > vals[2]) {
Console.WriteLine(res);
return;
}
if ((vals[0] == 1) && vals[1] != vals[2]) {
Console.WriteLine(res);
return;
}
int sa = vals[2] - vals[1];
res = sa * (vals[0] - 2) + 1;
Console.WriteLine(res);
return;
}
// String[] -----> int[]
static int[] parseAry(string[] str) {
int[] nums = new int[str.Length];
for (int i = 0; i < str.Length; i++) {
nums[i] = int.Parse(str[i]);
}
return nums;
}
// String[] -----> long[]
static long[] parseAryl(string[] str) {
long[] nums = new long[str.Length];
for (int i = 0; i < str.Length; i++) {
nums[i] = int.Parse(str[i]);
}
return nums;
}
//文字列を1文字ずつString[]に入れる
static string[] strAry(String str) {
string[] re = new string[str.Length];
for (int i = 0; i < str.Length; i++) {
re[i] = str[i].ToString();
}
return re;
}
}
|
using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;
class Program {
const long mod = 1000000007;
// public static int[] max;
static void Main(string[] args) {
char[] cs = new char[] { ' ', ',' };
// int val = int.Parse(Console.ReadLine());
int[] vals = parseAry(Console.ReadLine().Split(cs));
// string str = Console.ReadLine();
// string[] strs = Console.ReadLine().Split(cs);
// int[] vals = parseAry(Console.ReadLine().Split(cs));
// int n = vals[0];
// string res="";
// int y = vals[0];
// int x = vals[1];
long res = 0;
if (vals[1] > vals[2]) {
Console.WriteLine(res);
return;
}
if ((vals[0] == 1) && vals[1] != vals[2]) {
Console.WriteLine(res);
return;
}
long sa = vals[2] - vals[1];
res = sa * (long)(vals[0] - 2) + 1;
Console.WriteLine(res);
return;
}
// String[] -----> int[]
static int[] parseAry(string[] str) {
int[] nums = new int[str.Length];
for (int i = 0; i < str.Length; i++) {
nums[i] = int.Parse(str[i]);
}
return nums;
}
// String[] -----> long[]
static long[] parseAryl(string[] str) {
long[] nums = new long[str.Length];
for (int i = 0; i < str.Length; i++) {
nums[i] = int.Parse(str[i]);
}
return nums;
}
//文字列を1文字ずつString[]に入れる
static string[] strAry(String str) {
string[] re = new string[str.Length];
for (int i = 0; i < str.Length; i++) {
re[i] = str[i].ToString();
}
return re;
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 11, 12, 16, 31, 16, 12, 74, 0, 24], ["+", 0, 11, 12, 16, 31, 16, 12, 74, 39, 199], ["+", 0, 11, 12, 16, 31, 16, 12, 74, 0, 25]]
| 8
| 371
| 5
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Globalization;
using System.IO;
#region code challenges entry point
#if !SOLVER_ATWORKSPACE
class Program {
static void Main(string[] args) {
using (
var output = new CC.BP.FormattedStreamWriter(
Console
.OpenStandardOutput())) using (var input =
new CC.BP.BufferedStreamReader(
Console
.OpenStandardInput())) new CC
.ConcreteSolver(input, output)
.Do();
}
}
#endif
#endregion
#region code helpers boilerplate
namespace CC.BP {
class BufferedStreamReader : StreamReader {
const int QUEUE_INITSIZE = 1000;
public BufferedStreamReader(String fileName) : base(fileName) {}
public BufferedStreamReader(Stream stream) : base(stream) {}
private Queue<string> buffer = new Queue<string>(QUEUE_INITSIZE);
public override string ReadLine() {
if (buffer.Count > 0)
throw new InvalidOperationException("must read from buffer first");
return base.ReadLine();
}
public string ReadToken() {
while (buffer.Count == 0) {
base.ReadLine()
.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)
.ToList()
.ForEach((t) => { buffer.Enqueue(t); });
}
return buffer.Dequeue();
}
public void ResetBuffer() { buffer = new Queue<string>(QUEUE_INITSIZE); }
}
class FormattedStreamWriter : StreamWriter {
public FormattedStreamWriter(Stream stream) : base(stream) {}
public FormattedStreamWriter(string filePath) : base(filePath) {}
public override IFormatProvider FormatProvider {
get { return CultureInfo.InvariantCulture; }
}
}
static class IOExtensions {
public static string String(this BufferedStreamReader reader) {
return reader.ReadToken();
}
public static string[] StringArray(this BufferedStreamReader reader,
int n) {
var array = new string[n];
for (int i = 0; i < n; ++i) {
array[i] = reader.ReadToken();
}
return array;
}
public static int Int(this BufferedStreamReader reader) {
return int.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
public static int[] IntArray(this BufferedStreamReader reader, int n) {
var array = new int[n];
for (int i = 0; i < n; ++i) {
array[i] = int.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
return array;
}
public static uint UnsignedInt(this BufferedStreamReader reader) {
return uint.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
public static long Long(this BufferedStreamReader reader) {
return long.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
public static long[] LongArray(this BufferedStreamReader reader, int n) {
var array = new long[n];
for (int i = 0; i < n; ++i) {
array[i] = long.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
return array;
}
public static ulong UnsignedLong(this BufferedStreamReader reader) {
return ulong.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
public static double Double(this BufferedStreamReader reader) {
return double.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
public static double[] DoubleArray(this BufferedStreamReader reader,
int n) {
var array = new double[n];
for (int i = 0; i < n; ++i) {
array[i] =
double.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
return array;
}
public static decimal Decimal(this BufferedStreamReader reader) {
return decimal.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
public static decimal[] DecimalArray(this BufferedStreamReader reader,
int n) {
var array = new decimal[n];
for (int i = 0; i < n; ++i) {
array[i] =
decimal.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
return array;
}
public static void ArrayLine<T>(this FormattedStreamWriter writer,
T[] array, int n, string format = "{0}",
string separator = " ") {
for (int i = 0; i < n; ++i) {
if (i > 0)
writer.Write(separator);
writer.Write(format, array[i]);
}
writer.WriteLine();
}
public static void ArrayLine<T>(this FormattedStreamWriter writer,
T[] array, string format = "{0}",
string separator = " ") {
writer.ArrayLine(array, array.Length, format, separator);
}
}
abstract class BaseSolver {
public static T[][] Create2DArray<T>(int dim1, int dim2) {
var res = new T[dim1][];
for (int i = 0; i < dim1; ++i)
res[i] = new T[dim2];
return res;
}
public static T[][][] Create3DArray<T>(int dim1, int dim2, int dim3) {
var res = new T[dim1][][];
for (int i = 0; i < dim1; ++i)
res[i] = Create2DArray<T>(dim2, dim3);
return res;
}
public static T[][][][] Create4DArray<T>(int dim1, int dim2, int dim3,
int dim4) {
var res = new T[dim1][][][];
for (int i = 0; i < dim1; ++i)
res[i] = Create3DArray<T>(dim2, dim3, dim4);
return res;
}
public abstract void Do();
}
static class Utils {
public static void Swap<T>(ref T one, ref T second) {
T tmp = one;
one = second;
second = tmp;
}
}
}
#endregion
namespace CC {
using CC.BP;
using System.Diagnostics;
class ConcreteSolver : BaseSolver {
private readonly BufferedStreamReader read;
private readonly FormattedStreamWriter write;
public ConcreteSolver(BufferedStreamReader read,
FormattedStreamWriter write) {
this.read = read;
this.write = write;
}
public ulong Max2(ulong x) {
if (x == 0)
return 0;
ulong res = 1;
while (x >= (res << 1))
res <<= 1;
return res;
}
public override void Do() {
var a = read.UnsignedLong();
var b = read.UnsignedLong();
while (b > 0 && Max2(a) == Max2(b)) {
var m2 = Max2(a);
a &= ~m2;
b &= ~m2;
}
if (b == 0)
write.WriteLine(1);
else {
var m2 = Max2(b);
var u = Max2(b & (~m2));
if (u > 0)
u = (u << 1) - 1;
var res = m2 - a + m2;
if (u < a - 1)
res -= a - 1 - u;
write.WriteLine(res);
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Globalization;
using System.IO;
#region code challenges entry point
#if !SOLVER_ATWORKSPACE
class Program {
static void Main(string[] args) {
using (
var output = new CC.BP.FormattedStreamWriter(
Console
.OpenStandardOutput())) using (var input =
new CC.BP.BufferedStreamReader(
Console
.OpenStandardInput())) new CC
.ConcreteSolver(input, output)
.Do();
}
}
#endif
#endregion
#region code helpers boilerplate
namespace CC.BP {
class BufferedStreamReader : StreamReader {
const int QUEUE_INITSIZE = 1000;
public BufferedStreamReader(String fileName) : base(fileName) {}
public BufferedStreamReader(Stream stream) : base(stream) {}
private Queue<string> buffer = new Queue<string>(QUEUE_INITSIZE);
public override string ReadLine() {
if (buffer.Count > 0)
throw new InvalidOperationException("must read from buffer first");
return base.ReadLine();
}
public string ReadToken() {
while (buffer.Count == 0) {
base.ReadLine()
.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)
.ToList()
.ForEach((t) => { buffer.Enqueue(t); });
}
return buffer.Dequeue();
}
public void ResetBuffer() { buffer = new Queue<string>(QUEUE_INITSIZE); }
}
class FormattedStreamWriter : StreamWriter {
public FormattedStreamWriter(Stream stream) : base(stream) {}
public FormattedStreamWriter(string filePath) : base(filePath) {}
public override IFormatProvider FormatProvider {
get { return CultureInfo.InvariantCulture; }
}
}
static class IOExtensions {
public static string String(this BufferedStreamReader reader) {
return reader.ReadToken();
}
public static string[] StringArray(this BufferedStreamReader reader,
int n) {
var array = new string[n];
for (int i = 0; i < n; ++i) {
array[i] = reader.ReadToken();
}
return array;
}
public static int Int(this BufferedStreamReader reader) {
return int.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
public static int[] IntArray(this BufferedStreamReader reader, int n) {
var array = new int[n];
for (int i = 0; i < n; ++i) {
array[i] = int.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
return array;
}
public static uint UnsignedInt(this BufferedStreamReader reader) {
return uint.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
public static long Long(this BufferedStreamReader reader) {
return long.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
public static long[] LongArray(this BufferedStreamReader reader, int n) {
var array = new long[n];
for (int i = 0; i < n; ++i) {
array[i] = long.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
return array;
}
public static ulong UnsignedLong(this BufferedStreamReader reader) {
return ulong.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
public static double Double(this BufferedStreamReader reader) {
return double.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
public static double[] DoubleArray(this BufferedStreamReader reader,
int n) {
var array = new double[n];
for (int i = 0; i < n; ++i) {
array[i] =
double.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
return array;
}
public static decimal Decimal(this BufferedStreamReader reader) {
return decimal.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
public static decimal[] DecimalArray(this BufferedStreamReader reader,
int n) {
var array = new decimal[n];
for (int i = 0; i < n; ++i) {
array[i] =
decimal.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
return array;
}
public static void ArrayLine<T>(this FormattedStreamWriter writer,
T[] array, int n, string format = "{0}",
string separator = " ") {
for (int i = 0; i < n; ++i) {
if (i > 0)
writer.Write(separator);
writer.Write(format, array[i]);
}
writer.WriteLine();
}
public static void ArrayLine<T>(this FormattedStreamWriter writer,
T[] array, string format = "{0}",
string separator = " ") {
writer.ArrayLine(array, array.Length, format, separator);
}
}
abstract class BaseSolver {
public static T[][] Create2DArray<T>(int dim1, int dim2) {
var res = new T[dim1][];
for (int i = 0; i < dim1; ++i)
res[i] = new T[dim2];
return res;
}
public static T[][][] Create3DArray<T>(int dim1, int dim2, int dim3) {
var res = new T[dim1][][];
for (int i = 0; i < dim1; ++i)
res[i] = Create2DArray<T>(dim2, dim3);
return res;
}
public static T[][][][] Create4DArray<T>(int dim1, int dim2, int dim3,
int dim4) {
var res = new T[dim1][][][];
for (int i = 0; i < dim1; ++i)
res[i] = Create3DArray<T>(dim2, dim3, dim4);
return res;
}
public abstract void Do();
}
static class Utils {
public static void Swap<T>(ref T one, ref T second) {
T tmp = one;
one = second;
second = tmp;
}
}
}
#endregion
namespace CC {
using CC.BP;
using System.Diagnostics;
class ConcreteSolver : BaseSolver {
private readonly BufferedStreamReader read;
private readonly FormattedStreamWriter write;
public ConcreteSolver(BufferedStreamReader read,
FormattedStreamWriter write) {
this.read = read;
this.write = write;
}
public ulong Max2(ulong x) {
if (x == 0)
return 0;
ulong res = 1;
while (x >= (res << 1))
res <<= 1;
return res;
}
public override void Do() {
var a = read.UnsignedLong();
var b = read.UnsignedLong();
while (b > 0 && Max2(a) == Max2(b)) {
var m2 = Max2(a);
a &= ~m2;
b &= ~m2;
}
if (b == 0)
write.WriteLine(1);
else {
var m2 = Max2(b);
var u = Max2(b & (~m2));
if (u > 0)
u = (u << 1) - 1;
var res = m2 - a + m2;
if (u + 1 <= a)
res -= a - 1 - u;
write.WriteLine(res);
}
}
}
}
|
[["-", 0, 57, 75, 196, 0, 57, 15, 16, 17, 18], ["-", 75, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["-", 75, 196, 0, 57, 15, 16, 12, 16, 17, 33], ["+", 75, 196, 0, 57, 15, 16, 31, 16, 17, 72], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 17, 19], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 12, 22]]
| 8
| 1,458
| 6
|
using System;
using System.Collections.Generic;
namespace A___Grouping {
class Program {
static void Main(string[] args) {
var input = Console.ReadLine().Split(' ');
var x = input[0];
var y = input[1];
var z = new List<string> { "1", "3", "5", "7", "8", "12" };
var a = new List<string> { "4", "6", "9", "11" };
var b = "2";
if (z.Contains(x) && z.Contains(y) || a.Contains(x) && a.Contains(y) ||
x == "2" && y == "2") {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
using System;
using System.Collections.Generic;
namespace A___Grouping {
class Program {
static void Main(string[] args) {
var input = Console.ReadLine().Split(' ');
var x = input[0];
var y = input[1];
var z = new List<string> { "1", "3", "5", "7", "8", "10", "12" };
var a = new List<string> { "4", "6", "9", "11" };
var b = "2";
if (z.Contains(x) && z.Contains(y) || a.Contains(x) && a.Contains(y) ||
x == "2" && y == "2") {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
[["+", 0, 212, 0, 230, 10, 229, 0, 5, 0, 222], ["+", 0, 212, 0, 230, 10, 229, 0, 5, 0, 62], ["+", 0, 200, 0, 212, 0, 230, 10, 229, 0, 21]]
| 8
| 193
| 4
|
using System;
class c {
static void Main() {
string[] s = Console.ReadLine().Split(' ');
int x = int.Parse(s[0]);
int y = int.Parse(s[1]);
string ans = "No";
if (x == 2 && y == 2)
ans = "Yes";
else if (y == 2 || x == 2)
ans = "No";
else if (x < 8 && y < 8 && y % 2 == y % 2)
ans = "Yes";
else if (x >= 8 && y < 8 && y % 2 != y % 2)
ans = "Yes";
else if (x < 8 && y >= 8 && y % 2 != y % 2)
ans = "Yes";
else if (x >= 8 && y >= 8 && y % 2 == y % 2)
ans = "Yes";
Console.WriteLine(ans);
}
}
|
using System;
class c {
static void Main() {
string[] s = Console.ReadLine().Split(' ');
int x = int.Parse(s[0]);
int y = int.Parse(s[1]);
string ans = "No";
if (x == 2 && y == 2)
ans = "Yes";
else if (y == 2 || x == 2)
ans = "No";
else if (x < 8 && y < 8 && x % 2 == y % 2)
ans = "Yes";
else if (x >= 8 && y < 8 && x % 2 != y % 2)
ans = "Yes";
else if (x < 8 && y >= 8 && x % 2 != y % 2)
ans = "Yes";
else if (x >= 8 && y >= 8 && x % 2 == y % 2)
ans = "Yes";
Console.WriteLine(ans);
}
}
|
[["-", 75, 57, 15, 16, 12, 16, 31, 16, 31, 22], ["+", 75, 57, 15, 16, 12, 16, 31, 16, 31, 22]]
| 8
| 205
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace A___Grouping {
class Program {
static void Main(string[] args) {
var x_y = Console.ReadLine().Split().Select(int.Parse).ToArray();
var group = new List<int[]>();
group.Add(new int[] { 1, 3, 5, 7, 8, 10, 12 });
group.Add(new int[] { 4, 6, 9, 11 });
group.Add(new int[] { 2 });
foreach (var g in group) {
if (g.Contains(x_y[0]) && g.Contains(x_y[1])) {
Console.WriteLine("yes");
return;
}
}
Console.WriteLine("no");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace A___Grouping {
class Program {
static void Main(string[] args) {
var x_y = Console.ReadLine().Split().Select(int.Parse).ToArray();
var group = new List<int[]>();
group.Add(new int[] { 1, 3, 5, 7, 8, 10, 12 });
group.Add(new int[] { 4, 6, 9, 11 });
group.Add(new int[] { 2 });
foreach (var g in group) {
if (g.Contains(x_y[0]) && g.Contains(x_y[1])) {
Console.WriteLine("Yes");
return;
}
}
Console.WriteLine("No");
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 181
| 4
|
using System;
using System.Collections.Generic;
namespace AGC14 {
class MainClass {
public static void Main(string[] args) { new MainClass().solve(); }
int INF = 123456789;
Scanner cin;
int h, w, k;
int ans = 0;
string[] r; // room
int[,] log;
List<Tuple<int, int>> can;
int[] dir = { 0, 1, 0, -1, 0 };
int[,] dis;
void solve() {
cin = new Scanner();
can = new List<Tuple<int, int>>();
h = cin.nextInt();
w = cin.nextInt();
k = cin.nextInt();
r = new string[h];
dis = new int[h, w];
log = new int[h, w];
int sx, sy;
Queue<Tuple<int, int>> que = new Queue<Tuple<int, int>>();
for (int i = 0; i < w; i++) {
r[i] = cin.next();
}
// first step
for (int i = 0; i < h; i++)
for (int j = 0; j < w; j++)
dis[i, j] = INF;
for (int i = 0; i < h; i++)
for (int j = 0; j < w; j++)
if (r[i][j] == 'S') {
sy = i;
sx = j;
dis[sy, sx] = 0;
que.Enqueue(Tuple.Create(sy, sx));
}
while (que.Count > 0) {
Tuple<int, int> cur = que.Dequeue();
int y = cur.Item1;
int x = cur.Item2;
can.Add(Tuple.Create(y, x));
for (int i = 0; i < 4; i++) {
int dy = y + dir[i];
int dx = x + dir[i + 1];
if (0 <= dx && dx < w && 0 <= dy && dy < h && dis[dy, dx] == INF &&
r[dy][dx] != '#') {
dis[dy, dx] = dis[y, x] + 1;
if (dis[dy, dx] <= k)
que.Enqueue(Tuple.Create(dy, dx));
}
}
}
// n step
int minY = h;
int minX = w;
int minXY = INF;
int min = minXY;
for (int i = 0; i < can.Count; i++) {
minY = Math.Min(can[i].Item2, w - 1 - can[i].Item2);
minX = Math.Min(can[i].Item1, h - 1 - can[i].Item1);
minXY = Math.Min(minY, minX);
min = Math.Min(min, minXY);
}
if (min % k == 0) {
ans = 1 + (min) / k;
} else {
ans = 2 + (min) / k;
}
Console.WriteLine(ans);
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
}
}
|
using System;
using System.Collections.Generic;
namespace AGC14 {
class MainClass {
public static void Main(string[] args) { new MainClass().solve(); }
int INF = 123456789;
Scanner cin;
int h, w, k;
int ans = 0;
string[] r; // room
int[,] log;
List<Tuple<int, int>> can;
int[] dir = { 0, 1, 0, -1, 0 };
int[,] dis;
void solve() {
cin = new Scanner();
can = new List<Tuple<int, int>>();
h = cin.nextInt();
w = cin.nextInt();
k = cin.nextInt();
r = new string[h];
dis = new int[h, w];
log = new int[h, w];
int sx, sy;
Queue<Tuple<int, int>> que = new Queue<Tuple<int, int>>();
for (int i = 0; i < h; i++) {
r[i] = cin.next();
}
// first step
for (int i = 0; i < h; i++)
for (int j = 0; j < w; j++)
dis[i, j] = INF;
for (int i = 0; i < h; i++)
for (int j = 0; j < w; j++)
if (r[i][j] == 'S') {
sy = i;
sx = j;
dis[sy, sx] = 0;
que.Enqueue(Tuple.Create(sy, sx));
}
while (que.Count > 0) {
Tuple<int, int> cur = que.Dequeue();
int y = cur.Item1;
int x = cur.Item2;
can.Add(Tuple.Create(y, x));
for (int i = 0; i < 4; i++) {
int dy = y + dir[i];
int dx = x + dir[i + 1];
if (0 <= dx && dx < w && 0 <= dy && dy < h && dis[dy, dx] == INF &&
r[dy][dx] != '#') {
dis[dy, dx] = dis[y, x] + 1;
if (dis[dy, dx] <= k)
que.Enqueue(Tuple.Create(dy, dx));
}
}
}
// n step
int minY = h;
int minX = w;
int minXY = INF;
int min = minXY;
for (int i = 0; i < can.Count; i++) {
minY = Math.Min(can[i].Item2, w - 1 - can[i].Item2);
minX = Math.Min(can[i].Item1, h - 1 - can[i].Item1);
minXY = Math.Min(minY, minX);
min = Math.Min(min, minXY);
}
if (min % k == 0) {
ans = 1 + (min) / k;
} else {
ans = 2 + (min) / k;
}
Console.WriteLine(ans);
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
}
}
|
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22]]
| 8
| 810
| 2
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve {
List<int>[] G;
bool b;
bool[] us;
public Solve() {}
StringBuilder sb;
public static int Main() {
new Solve().Run();
return 0;
}
void Run() {
sb = new StringBuilder();
Calc();
Console.Write(sb.ToString());
}
void Calc() {
int N = int.Parse(Console.ReadLine());
if (N == 2) {
sb.Append("Second\n");
return;
}
G = new List<int>[N];
for (int i = 0; i < N; i++) {
G[i] = new List<int>();
}
for (int i = 0; i < N - 1; i++) {
string[] str = Console.ReadLine().Split(' ');
int a = int.Parse(str[0]) - 1;
int b = int.Parse(str[1]) - 1;
G[a].Add(b);
G[b].Add(a);
}
us = new bool[N];
if (G[0].Count == 1) {
if (dfs(G[0][0]) == 0) {
b = true;
}
} else {
if (dfs(0) == 0) {
b = true;
}
}
sb.Append((b ? "First" : "Second") + "\n");
}
int dfs(int v) {
us[v] = true;
if (G[v].Count == 1) {
return 1;
}
int state = 0;
for (int i = 0; i < G[v].Count; i++) {
int t = G[v][i];
if (!us[t]) {
int j = dfs(t);
if (state == 0) {
if (j == 1) {
state = 1;
}
} else {
if (j == 1) {
b = true;
}
}
}
}
if (state == 1) {
return 0;
} else {
return 1;
}
}
}
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve {
List<int>[] G;
bool b;
bool[] us;
public Solve() {}
StringBuilder sb;
public static int Main() {
new Solve().Run();
return 0;
}
void Run() {
sb = new StringBuilder();
Calc();
Console.Write(sb.ToString());
}
void Calc() {
int N = int.Parse(Console.ReadLine());
if (N == 2) {
sb.Append("Second\n");
return;
}
G = new List<int>[N];
for (int i = 0; i < N; i++) {
G[i] = new List<int>();
}
for (int i = 0; i < N - 1; i++) {
string[] str = Console.ReadLine().Split(' ');
int a = int.Parse(str[0]) - 1;
int b = int.Parse(str[1]) - 1;
G[a].Add(b);
G[b].Add(a);
}
us = new bool[N];
if (G[0].Count == 1) {
if (dfs(G[0][0]) == 1) {
b = true;
}
} else {
if (dfs(0) == 1) {
b = true;
}
}
sb.Append((b ? "First" : "Second") + "\n");
}
int dfs(int v) {
us[v] = true;
if (G[v].Count == 1) {
return 1;
}
int state = 0;
for (int i = 0; i < G[v].Count; i++) {
int t = G[v][i];
if (!us[t]) {
int j = dfs(t);
if (state == 0) {
if (j == 1) {
state = 1;
}
} else {
if (j == 1) {
b = true;
}
}
}
}
if (state == 1) {
return 0;
} else {
return 1;
}
}
}
|
[["-", 0, 57, 64, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 203], ["-", 0, 57, 75, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 12, 203]]
| 8
| 482
| 4
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace ABC {
class ProgramA {
static void Main(string[] args) {
var inputs = Console.ReadLine().Split(" ");
var a = inputs[0];
var b = inputs[1];
var c = inputs[2];
if (a[a.Length - 1] != b[0] || b[b.Length - 1] != c[0]) {
Console.WriteLine("No");
return;
}
Console.WriteLine("Yes");
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace ABC {
class ProgramA {
static void Main(string[] args) {
var inputs = Console.ReadLine().Split(" ");
var a = inputs[0];
var b = inputs[1];
var c = inputs[2];
if (a[a.Length - 1] != b[0] || b[b.Length - 1] != c[0]) {
Console.WriteLine("NO");
return;
}
Console.WriteLine("YES");
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 126
| 4
|
using System;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
var word = Console.ReadLine().Split(' ');
int LenA = word[0].Length; // Aの文字数
int LenB = word[1].Length; // Bの文字数
// char Ae = word[0].ToCharArray()[LenA - 1]; // Aの最後の文字
// char Bs = word[1].ToCharArray()[0]; // Bの最初の文字
// char Be = word[1].ToCharArray()[LenB -1]; // Bの最後の文字
// char Cs = word[2].ToCharArray()[0]; // Cの最初の文字
string Ae = word[0].Substring(LenA - 2, 1);
string Bs = word[1].Substring(0, 1);
string Be = word[1].Substring(LenB - 2, 1);
string Cs = word[2].Substring(0, 1);
if (Ae == Bs && Be == Cs) {
Console.WriteLine("YES");
} else {
Console.WriteLine("NO");
}
}
}
}
|
using System;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
var word = Console.ReadLine().Split(' ');
int LenA = word[0].Length; // Aの文字数
int LenB = word[1].Length; // Bの文字数
// char Ae = word[0].ToCharArray()[LenA - 1]; // Aの最後の文字
// char Bs = word[1].ToCharArray()[0]; // Bの最初の文字
// char Be = word[1].ToCharArray()[LenB -1]; // Bの最後の文字
// char Cs = word[2].ToCharArray()[0]; // Cの最初の文字
string Ae = word[0].Substring(LenA - 1, 1);
string Bs = word[1].Substring(0, 1);
string Be = word[1].Substring(LenB - 1, 1);
string Cs = word[2].Substring(0, 1);
if (Ae == Bs && Be == Cs) {
Console.WriteLine("YES");
} else {
Console.WriteLine("NO");
}
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
| 8
| 161
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace A {
class Program {
public static void Main(string[] args) {
var n = ReadLineStringSplit();
var re = "NO";
if (n[0][n[0].Length - 1] == n[1][0] && n[1][n[1].Length - 1] == n[2][0]) {
re = "Yes";
}
Console.WriteLine(re);
ReadLine();
}
/// <summary>
/// stringを一文字ずつintにキャストして配列に変換します。
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public static int[] StringCharArrayIntArray(string str) {
List<int> b = new List<int>();
for (int i = 0; i < str.Length; i++) {
b.Add(int.Parse(str[i].ToString()));
}
return b.ToArray();
}
public static string ReadLine() { return Console.ReadLine(); }
public static int ReadLineInt() { return int.Parse(Console.ReadLine()); }
public static string[] ReadLineStringSplit(char a = ' ') {
return ReadLine().Split(a).ToArray();
}
public static int[] ReadLineIntSpilit(char a = ' ') {
return ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace A {
class Program {
public static void Main(string[] args) {
var n = ReadLineStringSplit();
var re = "NO";
if (n[0][n[0].Length - 1] == n[1][0] && n[1][n[1].Length - 1] == n[2][0]) {
re = "YES";
}
Console.WriteLine(re);
ReadLine();
}
/// <summary>
/// stringを一文字ずつintにキャストして配列に変換します。
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public static int[] StringCharArrayIntArray(string str) {
List<int> b = new List<int>();
for (int i = 0; i < str.Length; i++) {
b.Add(int.Parse(str[i].ToString()));
}
return b.ToArray();
}
public static string ReadLine() { return Console.ReadLine(); }
public static int ReadLineInt() { return int.Parse(Console.ReadLine()); }
public static string[] ReadLineStringSplit(char a = ' ') {
return ReadLine().Split(a).ToArray();
}
public static int[] ReadLineIntSpilit(char a = ' ') {
return ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
}
}
}
|
[["-", 64, 196, 0, 1, 0, 11, 12, 5, 0, 222], ["+", 64, 196, 0, 1, 0, 11, 12, 5, 0, 222]]
| 8
| 310
| 2
|
using System;
namespace A___Shiritori {
class Program {
static void Main(string[] args) {
var input = Console.ReadLine().Split(' ');
var a = input[0];
var b = input[1];
var c = input[2];
if (a[a.Length - 1] == b[0] && b[b.Length - 1] == c[0]) {
Console.WriteLine("YES");
} else {
Console.WriteLine("No");
}
}
}
}
|
using System;
namespace A___Shiritori {
class Program {
static void Main(string[] args) {
var input = Console.ReadLine().Split(' ');
var a = input[0];
var b = input[1];
var c = input[2];
if (a[a.Length - 1] == b[0] && b[b.Length - 1] == c[0]) {
Console.WriteLine("YES");
} else {
Console.WriteLine("NO");
}
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 115
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
namespace At {
class Program {
static void Main(string[] args) {
var input = Reads();
if (input[0][input[0].Length - 1].ToString() == input[1][0].ToString()) {
if (input[1][input[1].Length - 1].ToString() == input[2][0].ToString()) {
WriteLine("Yes");
return;
}
}
WriteLine("NO");
}
private static string Read() { return ReadLine(); }
private static string[] Reads() { return (Read().Split()); }
private static int ReadInt() { return int.Parse(Read()); }
private static long ReadLong() { return long.Parse(Read()); }
private static double ReadDouble() { return double.Parse(Read()); }
private static int[] ReadInts() {
return Array.ConvertAll(Read().Split(), int.Parse);
}
private static long[] ReadLongs() {
return Array.ConvertAll(Read().Split(), long.Parse);
}
private static double[] ReadDoubles() {
return Array.ConvertAll(Read().Split(), double.Parse);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
namespace At {
class Program {
static void Main(string[] args) {
var input = Reads();
if (input[0][input[0].Length - 1].ToString() == input[1][0].ToString()) {
if (input[1][input[1].Length - 1].ToString() == input[2][0].ToString()) {
WriteLine("YES");
return;
}
}
WriteLine("NO");
}
private static string Read() { return ReadLine(); }
private static string[] Reads() { return (Read().Split()); }
private static int ReadInt() { return int.Parse(Read()); }
private static long ReadLong() { return long.Parse(Read()); }
private static double ReadDouble() { return double.Parse(Read()); }
private static int[] ReadInts() {
return Array.ConvertAll(Read().Split(), int.Parse);
}
private static long[] ReadLongs() {
return Array.ConvertAll(Read().Split(), long.Parse);
}
private static double[] ReadDoubles() {
return Array.ConvertAll(Read().Split(), double.Parse);
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 316
| 2
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main() {
var input = Console.ReadLine().Split(' ').ToList();
if (input[0].Substring(input[0].Length - 1, 1) ==
input[1].Substring(0, 1) &&
input[1].Substring(input[0].Length - 1, 1) ==
input[2].Substring(0, 1)) {
Console.WriteLine("YES");
} else {
Console.WriteLine("NO");
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main() {
var input = Console.ReadLine().Split(' ').ToList();
if (input[0].Substring(input[0].Length - 1, 1) ==
input[1].Substring(0, 1) &&
input[1].Substring(input[1].Length - 1, 1) ==
input[2].Substring(0, 1)) {
Console.WriteLine("YES");
} else {
Console.WriteLine("NO");
}
}
}
|
[["-", 31, 214, 205, 204, 206, 207, 0, 28, 0, 203], ["+", 31, 214, 205, 204, 206, 207, 0, 28, 0, 203]]
| 8
| 133
| 2
|
using System;
namespace ConsoleApplication1 {
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
if (str[0].Substring(str[0].Length - 1) == str[1].Substring(0, 1) &&
str[1].Substring(str[1].Length - 1) == str[2].Substring(0, 1)) {
Console.WriteLine("YES.");
} else {
Console.WriteLine("NO.");
}
Console.ReadKey();
}
}
}
|
using System;
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
if (str[0].Substring(str[0].Length - 1) == str[1].Substring(0, 1) &&
str[1].Substring(str[1].Length - 1) == str[2].Substring(0, 1)) {
Console.WriteLine("YES");
} else {
Console.WriteLine("NO");
}
Console.ReadKey();
}
}
|
[["-", 36, 36, 36, 36, 0, 208, 0, 209, 0, 256], ["-", 36, 36, 36, 36, 0, 208, 0, 209, 141, 22], ["-", 36, 36, 0, 208, 0, 209, 8, 201, 0, 45], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["-", 0, 235, 8, 201, 0, 195, 8, 196, 0, 46]]
| 8
| 129
| 8
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
var A = cin.ReadInt;
var B = cin.ReadInt;
var C = cin.ReadInt;
var ans = false;
for (int i = 1; i < 150; i++) {
if (A * i % B == C) {
ans = true;
break;
}
}
WriteLine(ans ? "Yes" : "No");
}
public int GetMod(int num) {
var mod = 1000000007;
var result = num % mod;
if (result < 0)
result += mod;
return result;
}
public void Display(char[] array) {
var txt = "";
foreach (var item in array) {
txt += " " + item;
}
WriteLine("{0}", txt);
}
public void Display(int[] array) {
var txt = "";
foreach (var item in array) {
txt += " " + item.ToString();
}
WriteLine("{0}", txt);
}
public void Display(int index, int[] array) {
var txt = "";
foreach (var item in array) {
txt += " " + item.ToString();
}
WriteLine("{0} : {1}", index, txt);
}
public void Display(List<int>[] list) {
for (int i = 0; i < list.Length; i++) {
Display(i, list[i].ToArray());
}
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; i++)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
var A = cin.ReadInt;
var B = cin.ReadInt;
var C = cin.ReadInt;
var ans = false;
for (int i = 1; i < 150; i++) {
if (A * i % B == C) {
ans = true;
break;
}
}
WriteLine(ans ? "YES" : "NO");
}
public int GetMod(int num) {
var mod = 1000000007;
var result = num % mod;
if (result < 0)
result += mod;
return result;
}
public void Display(char[] array) {
var txt = "";
foreach (var item in array) {
txt += " " + item;
}
WriteLine("{0}", txt);
}
public void Display(int[] array) {
var txt = "";
foreach (var item in array) {
txt += " " + item.ToString();
}
WriteLine("{0}", txt);
}
public void Display(int index, int[] array) {
var txt = "";
foreach (var item in array) {
txt += " " + item.ToString();
}
WriteLine("{0} : {1}", index, txt);
}
public void Display(List<int>[] list) {
for (int i = 0; i < list.Length; i++) {
Display(i, list[i].ToArray());
}
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; i++)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
[["-", 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
| 719
| 4
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;
namespace atcorder2 {
class Program {
public static long Read() { return long.Parse(Console.ReadLine()); }
public static long[] Reads() {
return Console.ReadLine().Split().Select(long.Parse).ToArray();
}
public static long gcd(long x, long y) {
if (y < x)
gcd(y, x);
while (y != 0) {
var z = x % y;
x = y;
y = z;
}
return x;
}
public static long keta(long x) {
var z = 1;
while (x > 0) {
x /= 10;
z++;
}
return z;
}
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var abc = Reads();
var a = abc[0];
var b = abc[1];
var c = abc[2];
var f = false;
for (int i = 0; i < b; i++) {
if (a * i % b == c)
f = true;
}
WriteLine(f ? "YES" : "No");
Console.Out.Flush();
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;
namespace atcorder2 {
class Program {
public static long Read() { return long.Parse(Console.ReadLine()); }
public static long[] Reads() {
return Console.ReadLine().Split().Select(long.Parse).ToArray();
}
public static long gcd(long x, long y) {
if (y < x)
gcd(y, x);
while (y != 0) {
var z = x % y;
x = y;
y = z;
}
return x;
}
public static long keta(long x) {
var z = 1;
while (x > 0) {
x /= 10;
z++;
}
return z;
}
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var abc = Reads();
var a = abc[0];
var b = abc[1];
var c = abc[2];
var f = false;
for (int i = 0; i < b; i++) {
if (a * i % b == c)
f = true;
}
WriteLine(f ? "YES" : "NO");
Console.Out.Flush();
}
}
}
|
[["-", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222]]
| 8
| 294
| 2
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
class Program {
static void Main(string[] args) {
// 入力
// var s = Console.ReadLine();
// var n = long.Parse(Console.ReadLine());
long[] n = Console.ReadLine().Split().Select(long.Parse).ToArray();
var a = n[0];
var b = n[1];
var c = n[2];
var ans = "No";
long num = 0;
for (long i = 1; i <= b; i++) {
num = a * i;
if (num % b == c)
ans = "Yes";
}
// 出力
Console.WriteLine(ans);
}
}
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
class Program {
static void Main(string[] args) {
// 入力
// var s = Console.ReadLine();
// var n = long.Parse(Console.ReadLine());
long[] n = Console.ReadLine().Split().Select(long.Parse).ToArray();
var a = n[0];
var b = n[1];
var c = n[2];
var ans = "NO";
long num = 0;
for (long i = 1; i <= b; i++) {
num = a * i;
if (num % b == c)
ans = "YES";
}
// 出力
Console.WriteLine(ans);
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 5, 0, 222], ["+", 0, 198, 0, 200, 0, 212, 0, 5, 0, 222], ["-", 0, 57, 64, 1, 0, 11, 12, 5, 0, 222], ["+", 0, 57, 64, 1, 0, 11, 12, 5, 0, 222]]
| 8
| 149
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace AtCoder {
class Program {
static void Main(string[] args) {
var Instance = new ChooseIntegers();
Instance.Exec();
}
}
public class ChooseIntegers {
public void Exec() {
var inputLongArray =
Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
long a = inputLongArray[0];
long b = inputLongArray[1];
long c = inputLongArray[2];
long total = 0;
for (long i = 1; i < 1000000; ++i) {
total = a * i;
// Console.WriteLine($"{total}");
if (total % b == c) {
Console.WriteLine("Yes");
Console.ReadKey();
return;
}
}
Console.WriteLine("No");
Console.Out.Flush();
Console.ReadKey();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace AtCoder {
class Program {
static void Main(string[] args) {
var Instance = new ChooseIntegers();
Instance.Exec();
}
}
public class ChooseIntegers {
public void Exec() {
var inputLongArray =
Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
long a = inputLongArray[0];
long b = inputLongArray[1];
long c = inputLongArray[2];
long total = 0;
for (long i = 1; i < 1000000; ++i) {
total = a * i;
// Console.WriteLine($"{total}");
if (total % b == c) {
Console.WriteLine("YES");
Console.ReadKey();
return;
}
}
Console.WriteLine("NO");
Console.Out.Flush();
Console.ReadKey();
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 194
| 4
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class TEST {
static void Main() {
Sol mySol = new Sol();
mySol.Solve();
}
}
class Sol {
public void Solve() {
for (int i = 1; i <= A; i++) {
if (i * A % B == C) {
Console.WriteLine("YES");
return;
}
}
Console.WriteLine("NO");
}
long A, B, C;
public Sol() {
var d = rla();
A = d[0];
B = d[1];
C = d[2];
}
static String rs() { return Console.ReadLine(); }
static int ri() { return int.Parse(Console.ReadLine()); }
static long rl() { return long.Parse(Console.ReadLine()); }
static double rd() { return double.Parse(Console.ReadLine()); }
static String[] rsa(char sep = ' ') { return Console.ReadLine().Split(sep); }
static int[] ria(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e));
}
static long[] rla(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e));
}
static double[] rda(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Split(sep),
e => double.Parse(e));
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class TEST {
static void Main() {
Sol mySol = new Sol();
mySol.Solve();
}
}
class Sol {
public void Solve() {
for (int i = 1; i <= B; i++) {
if (i * A % B == C) {
Console.WriteLine("YES");
return;
}
}
Console.WriteLine("NO");
}
long A, B, C;
public Sol() {
var d = rla();
A = d[0];
B = d[1];
C = d[2];
}
static String rs() { return Console.ReadLine(); }
static int ri() { return int.Parse(Console.ReadLine()); }
static long rl() { return long.Parse(Console.ReadLine()); }
static double rd() { return double.Parse(Console.ReadLine()); }
static String[] rsa(char sep = ' ') { return Console.ReadLine().Split(sep); }
static int[] ria(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e));
}
static long[] rla(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e));
}
static double[] rda(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Split(sep),
e => double.Parse(e));
}
}
|
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22]]
| 8
| 371
| 2
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
string[] s = Console.ReadLine().Split(' ');
int a = int.Parse(s[0]);
int b = int.Parse(s[1]);
int c = int.Parse(s[2]);
for (int i = 0; i < b; i++) {
if (a * i % b == c) {
Console.WriteLine("Yes");
return;
}
}
Console.WriteLine("NO");
}
}
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
string[] s = Console.ReadLine().Split(' ');
int a = int.Parse(s[0]);
int b = int.Parse(s[1]);
int c = int.Parse(s[2]);
for (int i = 0; i < b; i++) {
if (a * i % b == c) {
Console.WriteLine("YES");
return;
}
}
Console.WriteLine("NO");
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 128
| 2
|
using System;
namespace program {
class workspace {
static void Main() {
// int input = int.Parse(Console.ReadLine());
string[] str = (Console.ReadLine().Split());
int a = int.Parse(str[0]);
int b = int.Parse(str[1]);
int c = int.Parse(str[2]);
for (int i = 1; i < b + 1; i++) {
if (i * a % b == c) {
Console.Write("yes");
Environment.Exit(0);
}
}
Console.Write("NO");
}
}
}
|
using System;
namespace program {
class workspace {
static void Main() {
// int input = int.Parse(Console.ReadLine());
string[] str = (Console.ReadLine().Split());
int a = int.Parse(str[0]);
int b = int.Parse(str[1]);
int c = int.Parse(str[2]);
for (int i = 0; i < b; i++) {
if (i * a % b == c) {
Console.Write("YES");
Environment.Exit(0);
}
}
Console.Write("NO");
}
}
}
|
[["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 72], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 130
| 6
|
#pragma warning disable
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
using System.Collections;
using static System.Math;
using static System.Console;
class E {
static void Main() => new J();
}
class J {
int F() => int.Parse(ReadLine());
int[] G() => ReadLine()
.Split(new char[] { ' ', '\t' },
StringSplitOptions.RemoveEmptyEntries)
.Select(int.Parse)
.ToArray();
public J() {
SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
Solve();
Out.Flush();
}
void Solve() {
var I = G();
int A = I[0], B = I[1], C = I[2];
for (var k = 1; k <= B; k++)
if (k * A % B == C)
WriteLine("YES");
WriteLine("NO");
}
long GCD(long a, long b) {
var n = (ulong)Abs(a);
var m = (ulong)Abs(b);
if (n == 0)
return (long)m;
if (m == 0)
return (long)n;
int zm = 0, zn = 0;
while ((n & 1) == 0) {
n >>= 1;
zn++;
}
while ((m & 1) == 0) {
m >>= 1;
zm++;
}
while (m != n) {
if (m > n) {
m -= n;
while ((m & 1) == 0)
m >>= 1;
} else {
n -= m;
while ((n & 1) == 0)
n >>= 1;
}
}
return (long)n << Min(zm, zn);
}
}
|
#pragma warning disable
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
using System.Collections;
using static System.Math;
using static System.Console;
class E {
static void Main() => new J();
}
class J {
int F() => int.Parse(ReadLine());
int[] G() => ReadLine()
.Split(new char[] { ' ', '\t' },
StringSplitOptions.RemoveEmptyEntries)
.Select(int.Parse)
.ToArray();
public J() {
SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
Solve();
Out.Flush();
}
void Solve() {
var I = G();
int A = I[0], B = I[1], C = I[2];
for (var k = 1; k <= B; k++)
if (k * A % B == C) {
WriteLine("YES");
return;
}
WriteLine("NO");
}
long GCD(long a, long b) {
var n = (ulong)Abs(a);
var m = (ulong)Abs(b);
if (n == 0)
return (long)m;
if (m == 0)
return (long)n;
int zm = 0, zn = 0;
while ((n & 1) == 0) {
n >>= 1;
zn++;
}
while ((m & 1) == 0) {
m >>= 1;
zm++;
}
while (m != n) {
if (m > n) {
m -= n;
while ((m & 1) == 0)
m >>= 1;
} else {
n -= m;
while ((n & 1) == 0)
n >>= 1;
}
}
return (long)n << Min(zm, zn);
}
}
|
[["+", 8, 196, 0, 7, 8, 57, 64, 196, 0, 45], ["+", 0, 7, 8, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 7, 8, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 7, 8, 57, 64, 196, 0, 46]]
| 8
| 394
| 4
|
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;
namespace ARC073D {
class Program {
static void Main(string[] args) {
var N = RInt;
var W = RLong;
List<long>[] vs =
new List<long> [4].Select(x => new List<long>()).ToArray();
long[] w = new long[N];
long[] v = new long[N];
for (int i = 0; i < N; i++) {
w[i] = RInt;
v[i] = RInt;
vs[w[i] - w[0]].Add((int)v[i]);
}
for (int i = 0; i < 4; i++) {
vs[i] = vs[i].OrderByDescending(x => x).ToList();
}
long ans = 0;
for (int i = 0; i <= vs[0].Count; i++) {
long v0 = vs[0].Take(i).Sum();
long w0 = w[0] * i;
for (int j = 0; j <= vs[1].Count; j++) {
long v1 = vs[1].Take(j).Sum();
long w1 = (w[0] + 1) * j;
for (int k = 0; k <= vs[2].Count; k++) {
long v2 = vs[2].Take(k).Sum();
long w2 = (w[0] + 2) * k;
for (int l = 0; l <= vs[3].Count; l++) {
long v3 = vs[3].Take(k).Sum();
long w3 = (w[0] + 3) * l;
long wSum = w0 + w1 + w2 + w3;
if (wSum > W)
continue;
long cand = v0 + v1 + v2 + v3;
ans = Math.Max(ans, cand);
}
}
}
}
Console.WriteLine(ans);
}
}
}
namespace Assistant {
static class Input {
static List<string> line = new List<string>();
static int index = 0;
static String RNext() {
if (line.Count <= index)
line.AddRange(Console.ReadLine().Split());
return line[index++];
}
public static int RInt => int.Parse(RNext());
public static long RLong => long.Parse(RNext());
public static int[] RInts =>
Console.ReadLine().Split().Select(int.Parse).ToArray();
public static long[] RLongs =>
Console.ReadLine().Split().Select(long.Parse).ToArray();
public static string RString => RNext();
//以下未テスト
public static int[] RIntsC(int c) =>
Enumerable.Repeat(0, c).Select(x => int.Parse(RNext())).ToArray();
public static long[] RLongsC(int c) =>
Enumerable.Repeat(0, c).Select(x => long.Parse(RNext())).ToArray();
public static char[][] RMap(int h) =>
Enumerable.Repeat(0, h)
.Select(x => Console.ReadLine().ToCharArray())
.ToArray();
}
public struct Mlong {
long _v;
const long mod = 1000000007;
public Mlong(long n = 0) : this() { _v = n >= mod ? n % mod : n; }
public static implicit operator Mlong(long _x) => new Mlong(_x);
public static implicit operator long(Mlong _x) => _x._v;
public static Mlong operator +(Mlong m1, Mlong m2) {
long m = m1._v + m2._v;
return m >= mod ? m - mod : m;
}
public static Mlong operator -(Mlong m1, Mlong m2) {
long m = m1._v - m2._v;
return m >= 0 ? m : m + mod;
}
public static Mlong operator *(Mlong m1, Mlong m2) => m1._v * m2._v % mod;
public static Mlong
operator /(Mlong m1, Mlong m2) => m1._v * ModPow(m2._v, mod - 2) % mod;
public static long ModPow(long a, long n) {
if (n == 0)
return 1;
else if (n % 2 == 1)
return a * ModPow(a, n - 1) % mod;
else
return ModPow(a * a % mod, n / 2);
}
static Mlong[] fac, finv, inv;
public static void nCkInit(int max) {
fac = new Mlong[max];
finv = new Mlong[max];
inv = new Mlong[max];
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < max; i++) {
fac[i] = fac[i - 1] * i;
inv[i] = mod - inv[mod % i] * (mod / i);
finv[i] = finv[i - 1] * inv[i];
}
}
public static Mlong nCk(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * finv[k] * finv[n - k];
}
}
static class Debug {
static public void Draw2D<T>(T[,] map, int mode = 1) {
#if DEBUG
int W = map.GetLength(0);
int H = map.GetLength(1);
string[,] map2 = new string[W + 1, H + 1];
for (int i = 0; i < W + 1; i++) {
for (int j = 0; j < H + 1; j++) {
if (i == 0 && j == 0)
map2[i, j] = 0.ToString();
else if (i == 0)
map2[i, j] = (j - 1).ToString();
else if (j == 0)
map2[i, j] = (i - 1).ToString();
else
map2[i, j] = map[i - 1, j - 1].ToString();
}
}
for (int i = 0; i < W + 1; i++) {
for (int j = 0; j < H + 1; j++) {
if (mode == 0)
Console.Write(map2[i, j].Last());
if (mode == 1)
Console.Write(map2[i, j] + " ");
}
Console.WriteLine();
}
Console.WriteLine();
#endif
}
public static void Draw1D<T>(T[] array, int mode = 0) {
#if DEBUG
Console.WriteLine(string.Join(" ", array));
#endif
}
}
}
|
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;
namespace ARC073D {
class Program {
static void Main(string[] args) {
var N = RInt;
var W = RLong;
List<long>[] vs =
new List<long> [4].Select(x => new List<long>()).ToArray();
long[] w = new long[N];
long[] v = new long[N];
for (int i = 0; i < N; i++) {
w[i] = RInt;
v[i] = RInt;
vs[w[i] - w[0]].Add(v[i]);
}
for (int i = 0; i < 4; i++) {
vs[i] = vs[i].OrderByDescending(x => x).ToList();
}
long ans = 0;
for (int i = 0; i <= vs[0].Count; i++) {
long v0 = vs[0].Take(i).Sum();
long w0 = w[0] * i;
for (int j = 0; j <= vs[1].Count; j++) {
long v1 = vs[1].Take(j).Sum();
long w1 = (w[0] + 1) * j;
for (int k = 0; k <= vs[2].Count; k++) {
long v2 = vs[2].Take(k).Sum();
long w2 = (w[0] + 2) * k;
for (int l = 0; l <= vs[3].Count; l++) {
long v3 = vs[3].Take(l).Sum();
long w3 = (w[0] + 3) * l;
long wSum = w0 + w1 + w2 + w3;
if (wSum > W)
continue;
long cand = v0 + v1 + v2 + v3;
ans = Math.Max(ans, cand);
}
}
}
}
Console.WriteLine(ans);
}
}
}
namespace Assistant {
static class Input {
static List<string> line = new List<string>();
static int index = 0;
static String RNext() {
if (line.Count <= index)
line.AddRange(Console.ReadLine().Split());
return line[index++];
}
public static int RInt => int.Parse(RNext());
public static long RLong => long.Parse(RNext());
public static int[] RInts =>
Console.ReadLine().Split().Select(int.Parse).ToArray();
public static long[] RLongs =>
Console.ReadLine().Split().Select(long.Parse).ToArray();
public static string RString => RNext();
//以下未テスト
public static int[] RIntsC(int c) =>
Enumerable.Repeat(0, c).Select(x => int.Parse(RNext())).ToArray();
public static long[] RLongsC(int c) =>
Enumerable.Repeat(0, c).Select(x => long.Parse(RNext())).ToArray();
public static char[][] RMap(int h) =>
Enumerable.Repeat(0, h)
.Select(x => Console.ReadLine().ToCharArray())
.ToArray();
}
public struct Mlong {
long _v;
const long mod = 1000000007;
public Mlong(long n = 0) : this() { _v = n >= mod ? n % mod : n; }
public static implicit operator Mlong(long _x) => new Mlong(_x);
public static implicit operator long(Mlong _x) => _x._v;
public static Mlong operator +(Mlong m1, Mlong m2) {
long m = m1._v + m2._v;
return m >= mod ? m - mod : m;
}
public static Mlong operator -(Mlong m1, Mlong m2) {
long m = m1._v - m2._v;
return m >= 0 ? m : m + mod;
}
public static Mlong operator *(Mlong m1, Mlong m2) => m1._v * m2._v % mod;
public static Mlong
operator /(Mlong m1, Mlong m2) => m1._v * ModPow(m2._v, mod - 2) % mod;
public static long ModPow(long a, long n) {
if (n == 0)
return 1;
else if (n % 2 == 1)
return a * ModPow(a, n - 1) % mod;
else
return ModPow(a * a % mod, n / 2);
}
static Mlong[] fac, finv, inv;
public static void nCkInit(int max) {
fac = new Mlong[max];
finv = new Mlong[max];
inv = new Mlong[max];
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < max; i++) {
fac[i] = fac[i - 1] * i;
inv[i] = mod - inv[mod % i] * (mod / i);
finv[i] = finv[i - 1] * inv[i];
}
}
public static Mlong nCk(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * finv[k] * finv[n - k];
}
}
static class Debug {
static public void Draw2D<T>(T[,] map, int mode = 1) {
#if DEBUG
int W = map.GetLength(0);
int H = map.GetLength(1);
string[,] map2 = new string[W + 1, H + 1];
for (int i = 0; i < W + 1; i++) {
for (int j = 0; j < H + 1; j++) {
if (i == 0 && j == 0)
map2[i, j] = 0.ToString();
else if (i == 0)
map2[i, j] = (j - 1).ToString();
else if (j == 0)
map2[i, j] = (i - 1).ToString();
else
map2[i, j] = map[i - 1, j - 1].ToString();
}
}
for (int i = 0; i < W + 1; i++) {
for (int j = 0; j < H + 1; j++) {
if (mode == 0)
Console.Write(map2[i, j].Last());
if (mode == 1)
Console.Write(map2[i, j] + " ");
}
Console.WriteLine();
}
Console.WriteLine();
#endif
}
public static void Draw1D<T>(T[] array, int mode = 0) {
#if DEBUG
Console.WriteLine(string.Join(" ", array));
#endif
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 74, 0, 24], ["-", 0, 213, 3, 4, 0, 28, 0, 74, 39, 199], ["-", 0, 213, 3, 4, 0, 28, 0, 74, 0, 25], ["-", 63, 214, 205, 213, 3, 4, 0, 28, 0, 22], ["+", 63, 214, 205, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 1,523
| 5
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;
namespace Program {
public static class ProblemA {
static bool SAIKI = false;
static public int numberOfRandomCases = 0;
static public void MakeTestCase(List<string> _input, List<string> _output,
ref Func<string[], bool> _outputChecker) {}
static public void Solve() {
var s = NSList(3);
Console.WriteLine(s[0].ToUpper()[0] + s[1].ToUpper()[0] +
s[2].ToUpper()[0]);
}
class Printer : StreamWriter {
public override IFormatProvider FormatProvider {
get { return CultureInfo.InvariantCulture; }
}
public Printer(Stream stream)
: base(stream, new UTF8Encoding(false, true)) {
base.AutoFlush = false;
}
public Printer(Stream stream, Encoding encoding) : base(stream, encoding) {
base.AutoFlush = false;
}
}
static LIB_FastIO fastio = new LIB_FastIODebug();
static public void Main(string[] args) {
if (args.Length == 0) {
fastio = new LIB_FastIO();
Console.SetOut(new Printer(Console.OpenStandardOutput()));
}
if (SAIKI) {
var t = new Thread(Solve, 134217728);
t.Start();
t.Join();
} else
Solve();
Console.Out.Flush();
}
static long NN => fastio.Long();
static double ND => fastio.Double();
static string NS => fastio.Scan();
static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
static long Count<T>(this IEnumerable<T> x,
Func<T, bool> pred) => Enumerable.Count(x, pred);
static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v,
(int)n);
static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s,
(int)c);
static IOrderedEnumerable<T>
OrderByRand<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x, _ => xorshift);
static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x) =>
Enumerable.OrderBy(x.OrderByRand(), e => e);
static IOrderedEnumerable<T1> OrderBy<T1, T2>(this IEnumerable<T1> x,
Func<T1, T2> selector) =>
Enumerable.OrderBy(x.OrderByRand(), selector);
static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x) =>
Enumerable.OrderByDescending(x.OrderByRand(), e => e);
static IOrderedEnumerable<T1>
OrderByDescending<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) =>
Enumerable.OrderByDescending(x.OrderByRand(), selector);
static IOrderedEnumerable<string> OrderBy(this IEnumerable<string> x) =>
x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);
static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x,
Func<T, string> selector) =>
x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);
static IOrderedEnumerable<string>
OrderByDescending(this IEnumerable<string> x) =>
x.OrderByRand().OrderByDescending(e => e,
StringComparer.OrdinalIgnoreCase);
static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x,
Func<T, string> selector) =>
x.OrderByRand().OrderByDescending(selector,
StringComparer.OrdinalIgnoreCase);
static uint xorshift {
get {
_xsi.MoveNext();
return _xsi.Current;
}
}
static IEnumerator<uint> _xsi = _xsc();
static IEnumerator<uint> _xsc() {
uint x = 123456789, y = 362436069, z = 521288629,
w = (uint)(DateTime.Now.Ticks & 0xffffffff);
while (true) {
var t = x ^ (x << 11);
x = y;
y = z;
z = w;
w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
yield return w;
}
}
}
}
namespace Library {
class LIB_FastIO {
public LIB_FastIO() { str = Console.OpenStandardInput(); }
readonly Stream str;
readonly byte[] buf = new byte[1024];
int len, ptr;
public bool isEof = false;
public bool IsEndOfStream {
get { return isEof; }
}
byte read() {
if (isEof)
throw new EndOfStreamException();
if (ptr >= len) {
ptr = 0;
if ((len = str.Read(buf, 0, 1024)) <= 0) {
isEof = true;
return 0;
}
}
return buf[ptr++];
}
char Char() {
byte b = 0;
do
b = read();
while (b < 33 || 126 < b);
return (char)b;
}
virtual public string Scan() {
var sb = new StringBuilder();
for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
sb.Append(b);
return sb.ToString();
}
virtual public long Long() {
long ret = 0;
byte b = 0;
var ng = false;
do
b = read();
while (b != '-' && (b < '0' || '9' < b));
if (b == '-') {
ng = true;
b = read();
}
for (; true; b = read()) {
if (b < '0' || '9' < b)
return ng ? -ret : ret;
else
ret = ret * 10 + b - '0';
}
}
virtual public double Double() {
return double.Parse(Scan(), CultureInfo.InvariantCulture);
}
}
class LIB_FastIODebug : LIB_FastIO {
Queue<string> param = new Queue<string>();
string NextString() {
if (param.Count == 0)
foreach (var item in Console.ReadLine().Split(' '))
param.Enqueue(item);
return param.Dequeue();
}
public LIB_FastIODebug() {}
public override string Scan() => NextString();
public override long Long() => long.Parse(NextString());
public override double Double() => double.Parse(NextString());
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;
namespace Program {
public static class ProblemA {
static bool SAIKI = false;
static public int numberOfRandomCases = 0;
static public void MakeTestCase(List<string> _input, List<string> _output,
ref Func<string[], bool> _outputChecker) {}
static public void Solve() {
var s = NSList(3);
Console.WriteLine(s[0].ToUpper() [0].ToString() + s[1].ToUpper()[0] +
s[2].ToUpper()[0]);
}
class Printer : StreamWriter {
public override IFormatProvider FormatProvider {
get { return CultureInfo.InvariantCulture; }
}
public Printer(Stream stream)
: base(stream, new UTF8Encoding(false, true)) {
base.AutoFlush = false;
}
public Printer(Stream stream, Encoding encoding) : base(stream, encoding) {
base.AutoFlush = false;
}
}
static LIB_FastIO fastio = new LIB_FastIODebug();
static public void Main(string[] args) {
if (args.Length == 0) {
fastio = new LIB_FastIO();
Console.SetOut(new Printer(Console.OpenStandardOutput()));
}
if (SAIKI) {
var t = new Thread(Solve, 134217728);
t.Start();
t.Join();
} else
Solve();
Console.Out.Flush();
}
static long NN => fastio.Long();
static double ND => fastio.Double();
static string NS => fastio.Scan();
static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
static long Count<T>(this IEnumerable<T> x,
Func<T, bool> pred) => Enumerable.Count(x, pred);
static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v,
(int)n);
static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s,
(int)c);
static IOrderedEnumerable<T>
OrderByRand<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x, _ => xorshift);
static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x) =>
Enumerable.OrderBy(x.OrderByRand(), e => e);
static IOrderedEnumerable<T1> OrderBy<T1, T2>(this IEnumerable<T1> x,
Func<T1, T2> selector) =>
Enumerable.OrderBy(x.OrderByRand(), selector);
static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x) =>
Enumerable.OrderByDescending(x.OrderByRand(), e => e);
static IOrderedEnumerable<T1>
OrderByDescending<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) =>
Enumerable.OrderByDescending(x.OrderByRand(), selector);
static IOrderedEnumerable<string> OrderBy(this IEnumerable<string> x) =>
x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);
static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x,
Func<T, string> selector) =>
x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);
static IOrderedEnumerable<string>
OrderByDescending(this IEnumerable<string> x) =>
x.OrderByRand().OrderByDescending(e => e,
StringComparer.OrdinalIgnoreCase);
static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x,
Func<T, string> selector) =>
x.OrderByRand().OrderByDescending(selector,
StringComparer.OrdinalIgnoreCase);
static uint xorshift {
get {
_xsi.MoveNext();
return _xsi.Current;
}
}
static IEnumerator<uint> _xsi = _xsc();
static IEnumerator<uint> _xsc() {
uint x = 123456789, y = 362436069, z = 521288629,
w = (uint)(DateTime.Now.Ticks & 0xffffffff);
while (true) {
var t = x ^ (x << 11);
x = y;
y = z;
z = w;
w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
yield return w;
}
}
}
}
namespace Library {
class LIB_FastIO {
public LIB_FastIO() { str = Console.OpenStandardInput(); }
readonly Stream str;
readonly byte[] buf = new byte[1024];
int len, ptr;
public bool isEof = false;
public bool IsEndOfStream {
get { return isEof; }
}
byte read() {
if (isEof)
throw new EndOfStreamException();
if (ptr >= len) {
ptr = 0;
if ((len = str.Read(buf, 0, 1024)) <= 0) {
isEof = true;
return 0;
}
}
return buf[ptr++];
}
char Char() {
byte b = 0;
do
b = read();
while (b < 33 || 126 < b);
return (char)b;
}
virtual public string Scan() {
var sb = new StringBuilder();
for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
sb.Append(b);
return sb.ToString();
}
virtual public long Long() {
long ret = 0;
byte b = 0;
var ng = false;
do
b = read();
while (b != '-' && (b < '0' || '9' < b));
if (b == '-') {
ng = true;
b = read();
}
for (; true; b = read()) {
if (b < '0' || '9' < b)
return ng ? -ret : ret;
else
ret = ret * 10 + b - '0';
}
}
virtual public double Double() {
return double.Parse(Scan(), CultureInfo.InvariantCulture);
}
}
class LIB_FastIODebug : LIB_FastIO {
Queue<string> param = new Queue<string>();
string NextString() {
if (param.Count == 0)
foreach (var item in Console.ReadLine().Split(' '))
param.Enqueue(item);
return param.Dequeue();
}
public LIB_FastIODebug() {}
public override string Scan() => NextString();
public override long Long() => long.Parse(NextString());
public override double Double() => double.Parse(NextString());
}
}
|
[["+", 0, 16, 31, 16, 31, 213, 63, 214, 0, 131], ["+", 0, 16, 31, 16, 31, 213, 63, 214, 141, 22], ["+", 0, 16, 31, 16, 31, 213, 3, 4, 0, 24], ["+", 0, 16, 31, 16, 31, 213, 3, 4, 0, 25]]
| 8
| 1,452
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ABC099 {
class Program {
static void Main(string[] args) {
List<string> list = new List<string>();
while (true) {
string line = Console.ReadLine();
if (line == null)
break;
list.Add(line);
}
long a = long.Parse(list[0]);
long b = long.Parse(list[1]);
if (a == b) {
Console.WriteLine("EQUAL");
} else if (a > b) {
Console.WriteLine("GREATER");
} else {
Console.WriteLine("LESS");
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ABC099 {
class Program {
static void Main(string[] args) {
List<string> list = new List<string>();
while (true) {
string line = Console.ReadLine();
if (line == null)
break;
list.Add(line);
}
double a = double.Parse(list[0]);
double b = double.Parse(list[1]);
if (a == b) {
Console.WriteLine("EQUAL");
} else if (a > b) {
Console.WriteLine("GREATER");
} else {
Console.WriteLine("LESS");
}
}
}
}
|
[["-", 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
| 151
| 8
|
using static System.Console;
using static System.Convert;
class Program {
static void Main(string[] args) {
var num1 = ToDouble(ReadLine());
var num2 = ToDouble(ReadLine());
if (num1 > num2)
WriteLine("GREATER");
else if (num1 < num2)
WriteLine("LESS");
else
WriteLine("EQAUL");
}
}
|
using static System.Console;
using static System.Convert;
class Program {
static void Main(string[] args) {
var num1 = ToDouble(ReadLine());
var num2 = ToDouble(ReadLine());
if (num1 > num2)
WriteLine("GREATER");
else if (num1 < num2)
WriteLine("LESS");
else
WriteLine("EQUAL");
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 82
| 2
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Text;
public class Program {
public void Proc() {
// A>B のときGREATER、A<B のときLESS、A=B のときEQUALと出力せよ。
Reader.IsDebug = false;
string numA = Reader.ReadLine();
string numB = Reader.ReadLine();
int maxLength = Math.Max(numA.Length, numB.Length);
numA = numA.PadLeft(maxLength, '0');
numB = numB.PadLeft(maxLength, '0');
string ans = "EVEN";
for (int i = 0; i < maxLength; i++) {
if (numA[i] > numB[i]) {
ans = "GREATER";
break;
} else if (numA[i] < numB[i]) {
ans = "LESS";
break;
}
}
Console.WriteLine(ans);
}
public class Reader {
public static bool IsDebug = true;
private static System.IO.StringReader SReader;
private static string InitText = @"
9720246
22516266
";
public static string ReadLine() {
if (IsDebug) {
if (SReader == null) {
SReader = new System.IO.StringReader(InitText.Trim());
}
return SReader.ReadLine();
} else {
return Console.ReadLine();
}
}
}
public static void Main(string[] args) {
Program prg = new Program();
prg.Proc();
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Text;
public class Program {
public void Proc() {
// A>B のときGREATER、A<B のときLESS、A=B のときEQUALと出力せよ。
Reader.IsDebug = false;
string numA = Reader.ReadLine();
string numB = Reader.ReadLine();
int maxLength = Math.Max(numA.Length, numB.Length);
numA = numA.PadLeft(maxLength, '0');
numB = numB.PadLeft(maxLength, '0');
string ans = "EQUAL";
for (int i = 0; i < maxLength; i++) {
if (numA[i] > numB[i]) {
ans = "GREATER";
break;
} else if (numA[i] < numB[i]) {
ans = "LESS";
break;
}
}
Console.WriteLine(ans);
}
public class Reader {
public static bool IsDebug = true;
private static System.IO.StringReader SReader;
private static string InitText = @"
9720246
22516266
";
public static string ReadLine() {
if (IsDebug) {
if (SReader == null) {
SReader = new System.IO.StringReader(InitText.Trim());
}
return SReader.ReadLine();
} else {
return Console.ReadLine();
}
}
}
public static void Main(string[] args) {
Program prg = new Program();
prg.Proc();
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 5, 0, 222], ["+", 0, 198, 0, 200, 0, 212, 0, 5, 0, 222]]
| 8
| 290
| 2
|
using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;
class Program {
const long mod = 1000000007;
// public static int[] max;
static void Main(string[] args) {
char[] cs = new char[] { ' ', ',' };
// int val = int.Parse(Console.ReadLine());
// int[] vals = parseAry(Console.ReadLine().Split(cs));
// int val = int.Parse(Console.ReadLine());
// string str = Console.ReadLine();
// string[] strs = Console.ReadLine().Split(cs);
// int[] vals = parseAry(Console.ReadLine().Split(cs));
// int n = vals[0];
// string res="";
// int y = vals[0];
// int x = vals[1];
string res = "EQUALR";
string a = Console.ReadLine();
string b = Console.ReadLine();
if (a == b) {
res = "EQUALR";
} else {
if (a.Length > b.Length) {
res = "GREATER";
} else if (a.Length < b.Length) {
res = "LESS";
} else if (a.Length == b.Length) {
for (int i = 0; i < a.Length; i++) {
if (a[i] > b[i]) {
res = "GREATER";
break;
}
if (a[i] < b[i]) {
res = "LESS";
break;
}
}
}
}
Console.WriteLine(res);
return;
}
// String[] -----> int[]
static int[] parseAry(string[] str) {
int[] nums = new int[str.Length];
for (int i = 0; i < str.Length; i++) {
nums[i] = int.Parse(str[i]);
}
return nums;
}
// String[] -----> long[]
static long[] parseAryl(string[] str) {
long[] nums = new long[str.Length];
for (int i = 0; i < str.Length; i++) {
nums[i] = int.Parse(str[i]);
}
return nums;
}
//文字列を1文字ずつString[]に入れる
static string[] strAry(String str) {
string[] re = new string[str.Length];
for (int i = 0; i < str.Length; i++) {
re[i] = str[i].ToString();
}
return re;
}
}
|
using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;
class Program {
const long mod = 1000000007;
// public static int[] max;
static void Main(string[] args) {
char[] cs = new char[] { ' ', ',' };
// int val = int.Parse(Console.ReadLine());
// int[] vals = parseAry(Console.ReadLine().Split(cs));
// int val = int.Parse(Console.ReadLine());
// string str = Console.ReadLine();
// string[] strs = Console.ReadLine().Split(cs);
// int[] vals = parseAry(Console.ReadLine().Split(cs));
// int n = vals[0];
// string res="";
// int y = vals[0];
// int x = vals[1];
string res = "EQUAL";
string a = Console.ReadLine();
string b = Console.ReadLine();
if (a == b) {
res = "EQUAL";
} else {
if (a.Length > b.Length) {
res = "GREATER";
} else if (a.Length < b.Length) {
res = "LESS";
} else if (a.Length == b.Length) {
for (int i = 0; i < a.Length; i++) {
if (a[i] > b[i]) {
res = "GREATER";
break;
}
if (a[i] < b[i]) {
res = "LESS";
break;
}
}
}
}
Console.WriteLine(res);
return;
}
// String[] -----> int[]
static int[] parseAry(string[] str) {
int[] nums = new int[str.Length];
for (int i = 0; i < str.Length; i++) {
nums[i] = int.Parse(str[i]);
}
return nums;
}
// String[] -----> long[]
static long[] parseAryl(string[] str) {
long[] nums = new long[str.Length];
for (int i = 0; i < str.Length; i++) {
nums[i] = int.Parse(str[i]);
}
return nums;
}
//文字列を1文字ずつString[]に入れる
static string[] strAry(String str) {
string[] re = new string[str.Length];
for (int i = 0; i < str.Length; i++) {
re[i] = str[i].ToString();
}
return re;
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 5, 0, 222], ["+", 0, 198, 0, 200, 0, 212, 0, 5, 0, 222], ["-", 64, 196, 0, 1, 0, 11, 12, 5, 0, 222], ["+", 64, 196, 0, 1, 0, 11, 12, 5, 0, 222]]
| 8
| 420
| 4
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder {
partial class Program {
static long mod = 1000000007;
static void Main() {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
Solve();
Console.Out.Flush();
Console.ReadKey();
}
//ここから
static void Solve() {
int N = GetInt();
var A = GetLongArray();
var sum = Enumerable.Repeat(0, N)
.Select(s => Enumerable.Repeat(0L, 2).ToArray())
.ToArray();
var cnt = Enumerable.Repeat(0L, 2).ToArray();
sum[0][0] = A[0] > 0 ? A[0] : 1;
cnt[0] = A[0] > 0 ? 0 : 1 - A[0];
sum[0][1] = A[0] < 0 ? A[0] : -1;
cnt[1] = A[1] < 0 ? 0 : 1 + A[0];
for (int i = 1; i < N; i++) {
for (int j = 0; j < 2; j++) {
sum[i][j] = sum[i - 1][j] + A[i];
if (sum[i - 1][j] * sum[i][j] >= 0) {
if (sum[i - 1][j] > 0) {
cnt[j] += sum[i][j] + 1;
sum[i][j] = -1;
} else {
cnt[j] += 1 - sum[i][j];
sum[i][j] = 1;
}
}
}
}
var ans = cnt.Min();
Console.WriteLine(ans);
}
}
//拡張メソッド
public static class Ex {
public static List<string> FastSort(this List<string> s) {
s.Sort(StringComparer.Ordinal);
return s.ToList();
}
public static string yesno(this bool b) { return b ? "yes" : "no"; }
public static string YesNo(this bool b) { return b ? "Yes" : "No"; }
public static string YESNO(this bool b) { return b ? "YES" : "NO"; }
}
partial class Program {
static public string GetStr() { return Console.ReadLine().Trim(); }
static public char GetChar() { return Console.ReadLine().Trim()[0]; }
static public int GetInt() { return int.Parse(Console.ReadLine().Trim()); }
static public long GetLong() { return long.Parse(Console.ReadLine().Trim()); }
static public double GetDouble() {
return double.Parse(Console.ReadLine().Trim());
}
static public string[] GetStrArray() {
return Console.ReadLine().Trim().Split(' ');
}
static public int[] GetIntArray() {
return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
}
static public long[] GetLongArray() {
return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
}
static public char[] GetCharArray() {
return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray();
}
static public double[] GetDoubleArray() {
return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();
}
static public T[][] CreateJaggedArray<T>(int H, int W, T value) {
return Enumerable.Repeat(0, H)
.Select(s => Enumerable.Repeat(value, W).ToArray())
.ToArray();
}
static public int[][] GetIntJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetIntArray().ToArray())
.ToArray();
}
static public long[][] GetLongJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetLongArray().ToArray())
.ToArray();
}
static public char[][] GetCharJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetStr().ToCharArray())
.ToArray();
}
static public double[][] GetDoubleJaggedArray(int N) {
return Enumerable.Repeat(0, N).Select(s => GetDoubleArray()).ToArray();
}
static public void WriteObjects<T>(IReadOnlyCollection<T> values) {
var array = values.ToArray();
var num = array.Length;
if (num == 0)
return;
Console.Write(array[0]);
for (int i = 1; i < num; i++) {
Console.Write(" " + array[i]);
}
Console.WriteLine();
}
static bool eq<T, U>() => typeof(T).Equals(typeof(U));
static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
: eq<T, long>() ? ct<T, long>(long.Parse(s))
: eq<T, double>() ? ct<T, double>(double.Parse(s))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
static void Multi<T>(out T a) => a = cv<T>(GetStr());
static void Multi<T, U>(out T a, out U b) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
static void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
static void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
}
static void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d,
out X e) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
}
static void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d,
out X e, out Y f) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
f = cv<Y>(ar[5]);
}
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder {
partial class Program {
static long mod = 1000000007;
static void Main() {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
Solve();
Console.Out.Flush();
Console.ReadKey();
}
//ここから
static void Solve() {
int N = GetInt();
var A = GetLongArray();
var sum = Enumerable.Repeat(0, N)
.Select(s => Enumerable.Repeat(0L, 2).ToArray())
.ToArray();
var cnt = Enumerable.Repeat(0L, 2).ToArray();
sum[0][0] = A[0] > 0 ? A[0] : 1;
cnt[0] = A[0] > 0 ? 0 : 1 - A[0];
sum[0][1] = A[0] < 0 ? A[0] : -1;
cnt[1] = A[0] < 0 ? 0 : 1 + A[0];
for (int i = 1; i < N; i++) {
for (int j = 0; j < 2; j++) {
sum[i][j] = sum[i - 1][j] + A[i];
if (sum[i - 1][j] * sum[i][j] >= 0) {
if (sum[i - 1][j] > 0) {
cnt[j] += sum[i][j] + 1;
sum[i][j] = -1;
} else {
cnt[j] += 1 - sum[i][j];
sum[i][j] = 1;
}
}
}
}
var ans = cnt.Min();
Console.WriteLine(ans);
}
}
//拡張メソッド
public static class Ex {
public static List<string> FastSort(this List<string> s) {
s.Sort(StringComparer.Ordinal);
return s.ToList();
}
public static string yesno(this bool b) { return b ? "yes" : "no"; }
public static string YesNo(this bool b) { return b ? "Yes" : "No"; }
public static string YESNO(this bool b) { return b ? "YES" : "NO"; }
}
partial class Program {
static public string GetStr() { return Console.ReadLine().Trim(); }
static public char GetChar() { return Console.ReadLine().Trim()[0]; }
static public int GetInt() { return int.Parse(Console.ReadLine().Trim()); }
static public long GetLong() { return long.Parse(Console.ReadLine().Trim()); }
static public double GetDouble() {
return double.Parse(Console.ReadLine().Trim());
}
static public string[] GetStrArray() {
return Console.ReadLine().Trim().Split(' ');
}
static public int[] GetIntArray() {
return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
}
static public long[] GetLongArray() {
return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
}
static public char[] GetCharArray() {
return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray();
}
static public double[] GetDoubleArray() {
return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();
}
static public T[][] CreateJaggedArray<T>(int H, int W, T value) {
return Enumerable.Repeat(0, H)
.Select(s => Enumerable.Repeat(value, W).ToArray())
.ToArray();
}
static public int[][] GetIntJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetIntArray().ToArray())
.ToArray();
}
static public long[][] GetLongJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetLongArray().ToArray())
.ToArray();
}
static public char[][] GetCharJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetStr().ToCharArray())
.ToArray();
}
static public double[][] GetDoubleJaggedArray(int N) {
return Enumerable.Repeat(0, N).Select(s => GetDoubleArray()).ToArray();
}
static public void WriteObjects<T>(IReadOnlyCollection<T> values) {
var array = values.ToArray();
var num = array.Length;
if (num == 0)
return;
Console.Write(array[0]);
for (int i = 1; i < num; i++) {
Console.Write(" " + array[i]);
}
Console.WriteLine();
}
static bool eq<T, U>() => typeof(T).Equals(typeof(U));
static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
: eq<T, long>() ? ct<T, long>(long.Parse(s))
: eq<T, double>() ? ct<T, double>(double.Parse(s))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
static void Multi<T>(out T a) => a = cv<T>(GetStr());
static void Multi<T, U>(out T a, out U b) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
static void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
static void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
}
static void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d,
out X e) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
}
static void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d,
out X e, out Y f) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
f = cv<Y>(ar[5]);
}
}
}
|
[["-", 15, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 31, 204, 206, 207, 0, 28, 0, 203]]
| 8
| 1,766
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text.RegularExpressions;
using System.Diagnostics;
// var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve {
class Solve {
const int mod = 1000000007;
static void Main(string[] args) {
// var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush =
// false }; Console.SetOut(sw);
int N = int.Parse(Console.ReadLine());
var a = Console.ReadLine().Split().Select(long.Parse).ToArray();
long[] sum = new long[N];
long[] ans = new long[2];
long c = 1;
for (var j = 0; j < 2; j++) {
for (var i = 0; i < N; i++) {
if (i == 0) {
sum[i] = a[i];
} else {
sum[i] = sum[i - 1] + a[i];
}
if (sum[i] * c <= 0) {
ans[j] += 1 + Math.Abs(sum[i]);
sum[i] = c;
}
c *= -1;
}
c *= -1;
}
Console.WriteLine(ans.Min());
// Console.Out.Flush();
}
}
public class Calculation {}
public class Graph {}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text.RegularExpressions;
using System.Diagnostics;
// var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve {
class Solve {
const int mod = 1000000007;
static void Main(string[] args) {
// var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush =
// false }; Console.SetOut(sw);
int N = int.Parse(Console.ReadLine());
var a = Console.ReadLine().Split().Select(long.Parse).ToArray();
long[] sum = new long[N];
long[] ans = new long[2];
long c = 1;
for (var j = 0; j < 2; j++) {
for (var i = 0; i < N; i++) {
if (i == 0) {
sum[i] = a[i];
} else {
sum[i] = sum[i - 1] + a[i];
}
if (sum[i] * c <= 0) {
ans[j] += 1 + Math.Abs(sum[i]);
sum[i] = c;
}
c *= -1;
}
c = -1;
}
Console.WriteLine(ans.Min());
// Console.Out.Flush();
}
}
public class Calculation {}
public class Graph {}
}
|
[["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 108], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32]]
| 8
| 264
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
public class Prog {
private const int INF = 1000000007;
public static void Main() {
int n = NextInt();
int[] a = LineInt();
//凸凹の2パターンっぽい
int costA = 0;
int costB = 0;
int now = a[0];
if (now < 0) {
now = 1;
costA = Math.Abs(a[0]) + 1;
}
for (int i = 1; i < n; i++) {
if (now > 0) {
//今0より大きいので小さくする.
if (now + a[i] < 0) {
// ok
now += a[i];
} else {
// ng
costA += Math.Abs(now + a[i]) + 1;
now = -1;
}
} else {
//今0より小さいので大きくする
if (now + a[i] > 0) {
// ok
now += a[i];
} else {
// ng
costA += Math.Abs(now + a[i]) + 1;
now = 1;
}
}
}
now = a[0];
if (now > 0) {
now = -1;
costB = Math.Abs(a[0]) + 1;
}
for (int i = 1; i < n; i++) {
if (now > 0) {
//今0より大きいので小さくする.
if (now + a[i] < 0) {
// ok
now += a[i];
} else {
// ng
costB += Math.Abs(now + a[i]) + 1;
now = -1;
}
} else {
//今0より小さいので大きくする
if (now + a[i] > 0) {
// ok
now += a[i];
} else {
// ng
costB += Math.Abs(now + a[i]) + 1;
now = 1;
}
}
}
Console.WriteLine(Math.Min(costA, costB));
}
}
public class Input {
private static Queue<string> q = new Queue<string>();
private static void Confirm() {
if (q.Count == 0)
foreach (var s in Console.ReadLine().Split(' '))
q.Enqueue(s);
}
public static int NextInt() {
Confirm();
return int.Parse(q.Dequeue());
}
public static long NextLong() {
Confirm();
return long.Parse(q.Dequeue());
}
public static string NextString() {
Confirm();
return q.Dequeue();
}
public static double NextDouble() {
Confirm();
return double.Parse(q.Dequeue());
}
public static int[] LineInt() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
public static long[] LineLong() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
}
public static string[] LineString() {
return Console.ReadLine().Split(' ').ToArray();
}
public static double[] LineDouble() {
return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
public class Prog {
private const int INF = 1000000007;
public static void Main() {
int n = NextInt();
int[] a = LineInt();
//凸凹の2パターンっぽい
long costA = 0;
long costB = 0;
long now = a[0];
if (now <= 0) {
now = 1;
costA = Math.Abs(a[0]) + 1;
}
for (int i = 1; i < n; i++) {
if (now > 0) {
//今0より大きいので小さくする.
if (now + a[i] < 0) {
// ok
now += a[i];
} else {
// ng
costA += Math.Abs(now + a[i]) + 1;
now = -1;
}
} else {
//今0より小さいので大きくする
if (now + a[i] > 0) {
// ok
now += a[i];
} else {
// ng
costA += Math.Abs(now + a[i]) + 1;
now = 1;
}
}
}
now = a[0];
if (now >= 0) {
now = -1;
costB = Math.Abs(a[0]) + 1;
}
for (int i = 1; i < n; i++) {
if (now > 0) {
//今0より大きいので小さくする.
if (now + a[i] < 0) {
// ok
now += a[i];
} else {
// ng
costB += Math.Abs(now + a[i]) + 1;
now = -1;
}
} else {
//今0より小さいので大きくする
if (now + a[i] > 0) {
// ok
now += a[i];
} else {
// ng
costB += Math.Abs(now + a[i]) + 1;
now = 1;
}
}
}
Console.WriteLine(Math.Min(costA, costB));
}
}
public class Input {
private static Queue<string> q = new Queue<string>();
private static void Confirm() {
if (q.Count == 0)
foreach (var s in Console.ReadLine().Split(' '))
q.Enqueue(s);
}
public static int NextInt() {
Confirm();
return int.Parse(q.Dequeue());
}
public static long NextLong() {
Confirm();
return long.Parse(q.Dequeue());
}
public static string NextString() {
Confirm();
return q.Dequeue();
}
public static double NextDouble() {
Confirm();
return double.Parse(q.Dequeue());
}
public static int[] LineInt() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
public static long[] LineLong() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
}
public static string[] LineString() {
return Console.ReadLine().Split(' ').ToArray();
}
public static double[] LineDouble() {
return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 19], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 20]]
| 8
| 674
| 10
|
using System;
using static System.Console;
using static System.Math;
public class Hello {
public static void Main() {
int kazu = int.Parse(ReadLine());
string[] number = ReadLine().Split(' ');
long wa = 0;
long count1 = 0;
long ans = 0;
for (int i = 0; i < kazu; i++) {
long numi = int.Parse(number[i]);
long temp = wa + numi;
if (i % 2 == 0) {
if (temp > 0) {
wa = temp;
} else {
count1 += Abs(temp) + 1;
wa = 1;
}
} else {
if (temp < 0) {
wa = temp;
} else {
count1 += Abs(temp) + 1;
wa = -1;
}
}
}
long count2 = 0;
for (int i = 0; i < kazu; i++) {
long numi = int.Parse(number[i]);
long temp = wa + numi;
if (i % 2 == 1) {
if (temp > 0) {
wa = temp;
} else {
count2 += Abs(temp) + 1;
wa = 1;
}
} else {
if (temp < 0) {
wa = temp;
} else {
count2 += Abs(temp) + 1;
wa = -1;
}
}
}
WriteLine(Min(count1, count2));
}
}
|
using System;
using static System.Console;
using static System.Math;
public class Hello {
public static void Main() {
int kazu = int.Parse(ReadLine());
string[] number = ReadLine().Split(' ');
long wa = 0;
long count1 = 0;
long ans = 0;
for (int i = 0; i < kazu; i++) {
long numi = int.Parse(number[i]);
long temp = wa + numi;
if (i % 2 == 0) {
if (temp > 0) {
wa = temp;
} else {
count1 += Abs(temp) + 1;
wa = 1;
}
} else {
if (temp < 0) {
wa = temp;
} else {
count1 += Abs(temp) + 1;
wa = -1;
}
}
}
long count2 = 0;
wa = 0;
for (int i = 0; i < kazu; i++) {
long numi = int.Parse(number[i]);
long temp = wa + numi;
if (i % 2 == 1) {
if (temp > 0) {
wa = temp;
} else {
count2 += Abs(temp) + 1;
wa = 1;
}
} else {
if (temp < 0) {
wa = temp;
} else {
count2 += Abs(temp) + 1;
wa = -1;
}
}
}
WriteLine(Min(count1, count2));
}
}
|
[["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 195, 8, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 298
| 4
|
using System;
using System.Linq;
namespace arc072_b {
class Program {
static void Main(string[] args) {
int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
Console.WriteLine(Math.Abs(x[0] - x[1]) < -1 ? "Brown" : "Alice");
}
}
}
|
using System;
using System.Linq;
namespace arc072_b {
class Program {
static void Main(string[] args) {
long[] x = Console.ReadLine().Split().Select(long.Parse).ToArray();
Console.WriteLine(Math.Abs(x[0] - x[1]) <= 1 ? "Brown" : "Alice");
}
}
}
|
[["-", 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], ["-", 3, 4, 0, 28, 0, 41, 15, 16, 17, 18], ["-", 0, 28, 0, 41, 15, 16, 12, 241, 0, 33], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 17, 19]]
| 8
| 84
| 7
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;
class Program {
static void Main(string[] args) { new Magatro().Solve(); }
}
public class Scanner {
private StreamReader Sr;
private string[] S;
private int Index;
private const char Separator = ' ';
public Scanner(Stream source) {
Index = 0;
S = new string[0];
Sr = new StreamReader(source);
}
private string[] Line() { return Sr.ReadLine().Split(Separator); }
public string Next() {
string result;
if (Index >= S.Length) {
S = Line();
Index = 0;
}
result = S[Index];
Index++;
return result;
}
public int NextInt() { return int.Parse(Next()); }
public double NextDouble() { return double.Parse(Next()); }
public long NextLong() { return long.Parse(Next()); }
public decimal NextDecimal() { return decimal.Parse(Next()); }
public string[] StringArray() {
Next();
Index = S.Length;
return S.ToArray();
}
public int[] IntArray() { return StringArray().Select(int.Parse).ToArray(); }
public long[] LongArray() {
return StringArray().Select(long.Parse).ToArray();
}
public bool EndOfStream {
get { return Sr.EndOfStream; }
}
}
class Magatro {
private long X, Y;
private void Scan() {
var cin = new Scanner(Console.OpenStandardInput());
X = cin.NextLong();
Y = cin.NextLong();
}
public void Solve() {
Scan();
Console.WriteLine(Math.Abs(X - Y) <= 1 ? "Browm" : "Alice");
}
private void swap() {
X ^= Y;
Y ^= X;
X ^= Y;
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;
class Program {
static void Main(string[] args) { new Magatro().Solve(); }
}
public class Scanner {
private StreamReader Sr;
private string[] S;
private int Index;
private const char Separator = ' ';
public Scanner(Stream source) {
Index = 0;
S = new string[0];
Sr = new StreamReader(source);
}
private string[] Line() { return Sr.ReadLine().Split(Separator); }
public string Next() {
string result;
if (Index >= S.Length) {
S = Line();
Index = 0;
}
result = S[Index];
Index++;
return result;
}
public int NextInt() { return int.Parse(Next()); }
public double NextDouble() { return double.Parse(Next()); }
public long NextLong() { return long.Parse(Next()); }
public decimal NextDecimal() { return decimal.Parse(Next()); }
public string[] StringArray() {
Next();
Index = S.Length;
return S.ToArray();
}
public int[] IntArray() { return StringArray().Select(int.Parse).ToArray(); }
public long[] LongArray() {
return StringArray().Select(long.Parse).ToArray();
}
public bool EndOfStream {
get { return Sr.EndOfStream; }
}
}
class Magatro {
private long X, Y;
private void Scan() {
var cin = new Scanner(Console.OpenStandardInput());
X = cin.NextLong();
Y = cin.NextLong();
}
public void Solve() {
Scan();
Console.WriteLine(Math.Abs(X - Y) <= 1 ? "Brown" : "Alice");
}
private void swap() {
X ^= Y;
Y ^= X;
X ^= Y;
}
}
|
[["-", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222]]
| 8
| 445
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main(string[] args) {
var line1 =
Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
long N = line1[0];
long D = line1[1];
var d = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
long Q = long.Parse(Console.ReadLine());
var q = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
long minItazuraable = 1;
long[] minItazuraableArray = new long[d.Length + 1];
minItazuraableArray[d.Length] = 1;
for (long i = 0; i < d.Length; i++) {
var item = d[d.Length - i - 1]; // reverse
if (item > minItazuraable) {
// no change
} else {
minItazuraable += item;
}
minItazuraableArray[d.Length - i - 1] = minItazuraable;
}
// Console.WriteLine(String.Join(", ", minItazuraableArray));
// aliceの目的地からの距離
long[] aliceDistance = new long[d.Length + 1];
aliceDistance[0] = D;
for (long i = 0; i < d.Length; i++) {
aliceDistance[i + 1] =
Math.Min(Math.Abs(aliceDistance[i] - d[i]), aliceDistance[i]);
}
// Console.WriteLine(String.Join(", ", aliceDistance));
foreach (var qi in q) {
Console.WriteLine(minItazuraableArray[qi + 1 - 1] <= aliceDistance[qi - 1]
? "YES"
: "NO");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main(string[] args) {
var line1 =
Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
long N = line1[0];
long D = line1[1];
var d = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
long Q = long.Parse(Console.ReadLine());
var q = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
long minItazuraable = 1;
long[] minItazuraableArray = new long[d.Length + 1];
minItazuraableArray[d.Length] = 1;
for (long i = 0; i < d.Length; i++) {
var item = d[d.Length - i - 1]; // reverse
if (item / 2 >= minItazuraable) {
// no change
} else {
minItazuraable += item;
}
minItazuraableArray[d.Length - i - 1] = minItazuraable;
}
// Console.WriteLine(String.Join(", ", minItazuraableArray));
// aliceの目的地からの距離
long[] aliceDistance = new long[d.Length + 1];
aliceDistance[0] = D;
for (long i = 0; i < d.Length; i++) {
aliceDistance[i + 1] =
Math.Min(Math.Abs(aliceDistance[i] - d[i]), aliceDistance[i]);
}
// Console.WriteLine(String.Join(", ", aliceDistance));
foreach (var qi in q) {
Console.WriteLine(minItazuraableArray[qi + 1 - 1] <= aliceDistance[qi - 1]
? "YES"
: "NO");
}
}
}
|
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 85], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 20]]
| 8
| 372
| 4
|
using System;
using System.Collections.Generic;
namespace AGC013A {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
var target = Console.ReadLine().Split(' ');
var a = new List<int>();
for (int i = 0; i < N; i++) {
a.Add(int.Parse(target[i]));
}
int p1 = 0;
int count = 1;
bool up = false;
bool down = false;
while (p1 < a.Count - 1) {
if (a[p1] != a[p1 + 1]) {
if (up) {
if (a[p1] > a[p1 + 1]) {
up = false;
down = false;
count++;
}
}
if (down) {
if (a[p1] < a[p1 + 1]) {
up = false;
down = false;
count++;
}
} else {
if (a[p1] > a[p1 + 1]) {
down = true;
}
if (a[p1] < a[p1 + 1]) {
up = true;
}
}
}
p1++;
}
Console.WriteLine(count);
}
}
}
|
using System;
using System.Collections.Generic;
namespace AGC013A {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
var target = Console.ReadLine().Split(' ');
var a = new List<int>();
for (int i = 0; i < N; i++) {
a.Add(int.Parse(target[i]));
}
int p1 = 0;
int count = 1;
bool up = false;
bool down = false;
while (p1 < a.Count - 1) {
if (a[p1] != a[p1 + 1]) {
if (up) {
if (a[p1] > a[p1 + 1]) {
up = false;
down = false;
count++;
}
} else if (down) {
if (a[p1] < a[p1 + 1]) {
up = false;
down = false;
count++;
}
} else {
if (a[p1] > a[p1 + 1]) {
down = true;
}
if (a[p1] < a[p1 + 1]) {
up = true;
}
}
}
p1++;
}
Console.WriteLine(count);
}
}
}
|
[["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 95]]
| 8
| 268
| 1
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Numerics;
using System.IO;
using System.Runtime.InteropServices;
using static System.Math;
using static Math2;
using static io;
using static Utils;
public class CompetitiveProgramming {
public void Solve() {
var N = Int1;
var A = Longs;
int ans = 0;
if (N == 1)
Write(1);
for (int i = 0; i < N; ++i) {
if (i + 1 < N && A[i] == A[i + 1])
continue;
if (i + 1 < N && A[i + 1] > A[i])
while (i + 1 < N && A[i + 1] - A[i] >= 0) {
++i;
}
else if (i + 1 < N && A[i + 1] < A[i])
while (i + 1 < N && A[i + 1] - A[i] <= 0) {
++i;
}
++ans;
}
Write(ans);
}
}
public static class Math2 {
public const int INF = 1 << 29;
public const long INFL = 1L << 60;
public const long MOD = 1000000007;
public const int MOD2 = 998244353;
public static long Power(long i, long N, long MOD = 1000000007) // i^N
{
long res = 1;
while (N > 0) {
if ((N & 1) != 0)
res = res * i % MOD;
i = i * i % MOD;
N >>= 1;
}
return res;
}
public static long Power2(long i, long N) // i^N
{
long res = 1;
while (N > 0) {
if ((N & 1) != 0)
res = res * i;
i = i * i;
N >>= 1;
}
return res;
}
public static long GCD(long i, long N) {
if (i > N)
Swap(ref i, ref N);
if (i == 0)
return N;
while (N != 0) {
var r = i % N;
i = N;
N = r;
}
return i;
}
public static long LCM(long i, long N) => i * N / GCD(i, N);
public static long Comb(long N, long R, int MOD = 1000000007) {
long ret = 1;
long x = 1;
for (long i = N; i >= N - R + 1; --i) {
ret = ret / x * i;
ret %= MOD;
x++;
}
return ret;
}
public static long Comb2(long N, long R) {
long Nume = 1;
long Deno = 1;
if (R > N - R)
Swap(ref N, ref R);
for (long i = 1; i <= R; ++i) {
Deno *= i;
Nume *= N - i + 1;
}
return Deno / Nume;
}
}
public static class Utils {
public static void Swap<T>(ref T A, ref T B) {
T x = A;
A = B;
B = x;
}
public static int DigitSum(int N) {
string s = N.ToString();
int ret = 0;
for (int i = 0; i < s.Length; ++i)
ret += s[i] - '0';
return ret;
}
}
class Program {
static void Main(string[] args) {
var CompetitiveProgramming = new CompetitiveProgramming();
CompetitiveProgramming.Solve();
}
}
public static class io {
public static string Str => Console.ReadLine();
public static string[] Strs => Str.Split(' ');
public static long[] Longs => Strs.Select(long.Parse).ToArray();
public static int[] Ints => Strs.Select(int.Parse).ToArray();
public static char[] Chars => Str.ToArray();
public static double[] Doubles => Strs.Select(double.Parse).ToArray();
public static long Long1 => Longs[0];
public static int Int1 => Ints[0];
public static char Char1 => Chars[0];
public static double Double1 => Doubles[0];
public static long[] VerticalRead(int N) {
long[] A = new long[N];
for (int i = 0; i < N; ++i)
A[i] = Long1;
return A;
}
public static void Write(string a) => Console.WriteLine(a);
public static void Write(params object[] i) => Write(string.Join(" ", i));
public static void Write<T>(IEnumerable<T> a) => Write(string.Join(" ", a));
public static void Verticalwrite<T>(IEnumerable<T> a) {
foreach (var z in a)
Write(z);
}
public static void YN(bool i) {
if (i)
Write("Yes");
else
Write("No");
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Numerics;
using System.IO;
using System.Runtime.InteropServices;
using static System.Math;
using static Math2;
using static io;
using static Utils;
public class CompetitiveProgramming {
public void Solve() {
var N = Int1;
var A = Longs;
int ans = 0;
if (N == 1) {
Write(1);
return;
}
for (int i = 0; i < N; ++i) {
if (i + 1 < N && A[i] == A[i + 1])
continue;
if (i + 1 < N && A[i + 1] > A[i])
while (i + 1 < N && A[i + 1] - A[i] >= 0) {
++i;
}
else if (i + 1 < N && A[i + 1] < A[i])
while (i + 1 < N && A[i + 1] - A[i] <= 0) {
++i;
}
++ans;
}
Write(ans);
}
}
public static class Math2 {
public const int INF = 1 << 29;
public const long INFL = 1L << 60;
public const long MOD = 1000000007;
public const int MOD2 = 998244353;
public static long Power(long i, long N, long MOD = 1000000007) // i^N
{
long res = 1;
while (N > 0) {
if ((N & 1) != 0)
res = res * i % MOD;
i = i * i % MOD;
N >>= 1;
}
return res;
}
public static long Power2(long i, long N) // i^N
{
long res = 1;
while (N > 0) {
if ((N & 1) != 0)
res = res * i;
i = i * i;
N >>= 1;
}
return res;
}
public static long GCD(long i, long N) {
if (i > N)
Swap(ref i, ref N);
if (i == 0)
return N;
while (N != 0) {
var r = i % N;
i = N;
N = r;
}
return i;
}
public static long LCM(long i, long N) => i * N / GCD(i, N);
public static long Comb(long N, long R, int MOD = 1000000007) {
long ret = 1;
long x = 1;
for (long i = N; i >= N - R + 1; --i) {
ret = ret / x * i;
ret %= MOD;
x++;
}
return ret;
}
public static long Comb2(long N, long R) {
long Nume = 1;
long Deno = 1;
if (R > N - R)
Swap(ref N, ref R);
for (long i = 1; i <= R; ++i) {
Deno *= i;
Nume *= N - i + 1;
}
return Deno / Nume;
}
}
public static class Utils {
public static void Swap<T>(ref T A, ref T B) {
T x = A;
A = B;
B = x;
}
public static int DigitSum(int N) {
string s = N.ToString();
int ret = 0;
for (int i = 0; i < s.Length; ++i)
ret += s[i] - '0';
return ret;
}
}
class Program {
static void Main(string[] args) {
var CompetitiveProgramming = new CompetitiveProgramming();
CompetitiveProgramming.Solve();
}
}
public static class io {
public static string Str => Console.ReadLine();
public static string[] Strs => Str.Split(' ');
public static long[] Longs => Strs.Select(long.Parse).ToArray();
public static int[] Ints => Strs.Select(int.Parse).ToArray();
public static char[] Chars => Str.ToArray();
public static double[] Doubles => Strs.Select(double.Parse).ToArray();
public static long Long1 => Longs[0];
public static int Int1 => Ints[0];
public static char Char1 => Chars[0];
public static double Double1 => Doubles[0];
public static long[] VerticalRead(int N) {
long[] A = new long[N];
for (int i = 0; i < N; ++i)
A[i] = Long1;
return A;
}
public static void Write(string a) => Console.WriteLine(a);
public static void Write(params object[] i) => Write(string.Join(" ", i));
public static void Write<T>(IEnumerable<T> a) => Write(string.Join(" ", a));
public static void Verticalwrite<T>(IEnumerable<T> a) {
foreach (var z in a)
Write(z);
}
public static void YN(bool i) {
if (i)
Write("Yes");
else
Write("No");
}
}
|
[["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 1,083
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;
class Program {
static void Main(string[] args) {
var num = ToInt32(ReadLine());
var ar = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
var result = 1;
var isIncrease = true;
var i = 0;
Get(ref i, ref isIncrease, ar);
for (var j = i + 1; j < num - 1; j++)
if (isIncrease) {
if (ar[j] <= ar[j + 1])
continue;
else {
result++;
Get(ref j, ref isIncrease, ar);
}
} else {
if (ar[j] >= ar[j + 1])
continue;
else {
result++;
Get(ref j, ref isIncrease, ar);
}
}
WriteLine(result);
}
private static void Get(ref int j, ref bool isIncrease, int[] ar) {
for (var i = j == 0 ? 0 : j + 1; i < ar.Length - 1; i++)
if (ar[j] == ar[j + 1])
continue;
else if (ar[i] < ar[i + 1]) {
isIncrease = true;
break;
} else {
isIncrease = false;
break;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;
class Program {
static void Main(string[] args) {
var num = ToInt32(ReadLine());
var ar = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
var result = 1;
var isIncrease = true;
var i = 0;
Get(ref i, ref isIncrease, ar);
for (var j = i + 1; j < num - 1; j++)
if (isIncrease) {
if (ar[j] <= ar[j + 1])
continue;
else {
result++;
Get(ref j, ref isIncrease, ar);
}
} else {
if (ar[j] >= ar[j + 1])
continue;
else {
result++;
Get(ref j, ref isIncrease, ar);
}
}
WriteLine(result);
}
private static void Get(ref int j, ref bool isIncrease, int[] ar) {
for (var i = j == 0 ? 0 : j + 1; i < ar.Length - 1; i++)
if (ar[i] == ar[i + 1])
continue;
else if (ar[i] < ar[i + 1]) {
isIncrease = true;
break;
} else {
isIncrease = false;
break;
}
}
}
|
[["-", 15, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 15, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 31, 22]]
| 8
| 304
| 4
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using static System.Console;
using static System.Math;
using static CS_Contest.Utils;
using System.Numerics;
using System.Linq.Expressions;
using Nakov.IO;
using static Nakov.IO.Cin;
// using static CS_Contest.Library;
namespace CS_Contest {
using Li = List<int>;
using LLi = List<List<int>>;
using Ll = List<long>;
internal class Program {
private static void Main(string[] args) {
var sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
SetOut(sw);
new Calc().Solve();
Out.Flush();
}
public class Calc {
enum Cond { UE, SITA, WAKARAN }
public void Solve() {
int N = NextInt();
int cnt = 0;
var A = IntList();
if (N == 1)
1.WL();
Func<int, int, Cond> getDirection = (x, y) => {
return A[x] < A[y] ? Cond.UE : A[x] == A[y] ? Cond.WAKARAN : Cond.SITA;
};
Cond cond = getDirection(0, 1);
for (int i = 1; i < N - 1; i++) {
switch (cond) {
case Cond.UE:
if (A[i] > A[i + 1]) {
cond = Cond.WAKARAN;
cnt++;
}
break;
case Cond.SITA:
if (A[i] < A[i + 1]) {
cond = Cond.WAKARAN;
cnt++;
}
break;
case Cond.WAKARAN:
cond = getDirection(i, i + 1);
break;
default:
break;
}
}
cnt++;
cnt.WL();
return;
}
}
}
public static class Utils {
public static long ModValue = (long)1e9 + 7;
public static long INF = long.MaxValue;
public static long Mod(long x) => x % ModValue;
public static long ModPow(long x, long n) {
long tmp = 1;
while (n != 0) {
if (n % 2 == 1) {
tmp = Mod(tmp * x);
}
x = Mod(x * x);
n /= 2;
}
return tmp;
}
public static long DivMod(long x,
long y) => Mod(x * ModPow(y, (long)(1e9 + 5)));
public static void WL(this object obj) => WriteLine(obj);
public static void WL(this string obj) => WriteLine(obj);
public static void
WL<T>(this IEnumerable<T> list) => list.ToList().ForEach(x => x.WL());
public static Li IntList() => ReadLine().Split().Select(int.Parse).ToList();
public static Ll LongList() => ReadLine().Split().Select(long.Parse).ToList();
public static string
StringJoin<T>(this IEnumerable<T> l,
string separator = "") => string.Join(separator, l);
public static long GCD(long m, long n) {
long tmp;
if (m < n) {
tmp = n;
n = m;
m = tmp;
}
while (m % n != 0) {
tmp = n;
n = m % n;
m = tmp;
}
return n;
}
public static long LCM(long m, long n) => m * (n / GCD(m, n));
public static void REP(int n, Action<int> act) {
for (var i = 0; i < n; i++) {
act(i);
}
}
public static IEnumerable<int> ToImos(this IEnumerable<int> ie) {
var s = 0;
List<int> rt = new Li();
foreach (var item in ie) {
s += item;
rt.Add(s);
}
return rt;
}
public static void ForeachWithIndex<T>(IEnumerable<T> ie,
Action<int, T> action) {
int i = 0;
foreach (var item in ie) {
action(i, item);
i++;
}
}
public static int ManhattanDistance(int x1, int y1, int x2,
int y2) => Abs(x2 - x1) + Abs(y2 - y1);
public static Queue<T> ToQueue<T>(this IEnumerable<T> iEnumerable) {
var rt = new Queue<T>();
foreach (var item in iEnumerable) {
rt.Enqueue(item);
}
return rt;
}
public static Dictionary<TKey, int> CountUp<TKey>(this IEnumerable<TKey> l) {
var dic = new Dictionary<TKey, int>();
foreach (var item in l) {
if (dic.ContainsKey(item))
dic[item]++;
else
dic.Add(item, 1);
}
return dic;
}
public static int Count<T>(this IEnumerable<T> l,
T target) => l.Count(x => x.Equals(target));
public static int UpperBound<T>(this IEnumerable<T> list, T target)
where T : IComparable {
var idx = list.ToList().BinarySearch(target);
idx = idx < 0 ? ~idx : (idx + 1);
return Min(idx, list.Count());
}
public static int LowerBound<T>(this IEnumerable<T> list, T target)
where T : IComparable {
var idx = list.ToList().BinarySearch(target);
idx = idx < 0 ? ~idx : idx;
return Max(0, idx - 1);
}
}
}
namespace Nakov.IO {
using System;
using System.Text;
using System.Globalization;
public static class Cin {
public static string NextToken() {
StringBuilder tokenChars = new StringBuilder();
bool tokenFinished = false;
bool skipWhiteSpaceMode = true;
while (!tokenFinished) {
int nextChar = Console.Read();
if (nextChar == -1) {
tokenFinished = true;
} else {
char ch = (char)nextChar;
if (char.IsWhiteSpace(ch)) {
if (!skipWhiteSpaceMode) {
tokenFinished = true;
if (ch == '\r' && (Environment.NewLine == "\r\n")) {
Console.Read();
}
}
} else {
skipWhiteSpaceMode = false;
tokenChars.Append(ch);
}
}
}
string token = tokenChars.ToString();
return token;
}
public static int NextInt() {
string token = Cin.NextToken();
return int.Parse(token);
}
public static long NextLong() {
string token = Cin.NextToken();
return long.Parse(token);
}
public static double NextDouble(bool acceptAnyDecimalSeparator = true) {
string token = Cin.NextToken();
if (acceptAnyDecimalSeparator) {
token = token.Replace(',', '.');
double result = double.Parse(token, CultureInfo.InvariantCulture);
return result;
} else {
double result = double.Parse(token);
return result;
}
}
public static decimal NextDecimal(bool acceptAnyDecimalSeparator = true) {
string token = Cin.NextToken();
if (acceptAnyDecimalSeparator) {
token = token.Replace(',', '.');
decimal result = decimal.Parse(token, CultureInfo.InvariantCulture);
return result;
} else {
decimal result = decimal.Parse(token);
return result;
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using static System.Console;
using static System.Math;
using static CS_Contest.Utils;
using System.Numerics;
using System.Linq.Expressions;
using Nakov.IO;
using static Nakov.IO.Cin;
// using static CS_Contest.Library;
namespace CS_Contest {
using Li = List<int>;
using LLi = List<List<int>>;
using Ll = List<long>;
internal class Program {
private static void Main(string[] args) {
var sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
SetOut(sw);
new Calc().Solve();
Out.Flush();
}
public class Calc {
enum Cond { UE, SITA, WAKARAN }
public void Solve() {
int N = NextInt();
int cnt = 0;
var A = IntList();
if (N == 1) {
1.WL();
return;
}
Func<int, int, Cond> getDirection = (x, y) => {
return A[x] < A[y] ? Cond.UE : A[x] == A[y] ? Cond.WAKARAN : Cond.SITA;
};
Cond cond = getDirection(0, 1);
for (int i = 1; i < N - 1; i++) {
switch (cond) {
case Cond.UE:
if (A[i] > A[i + 1]) {
cond = Cond.WAKARAN;
cnt++;
}
break;
case Cond.SITA:
if (A[i] < A[i + 1]) {
cond = Cond.WAKARAN;
cnt++;
}
break;
case Cond.WAKARAN:
cond = getDirection(i, i + 1);
break;
default:
break;
}
}
cnt++;
cnt.WL();
return;
}
}
}
public static class Utils {
public static long ModValue = (long)1e9 + 7;
public static long INF = long.MaxValue;
public static long Mod(long x) => x % ModValue;
public static long ModPow(long x, long n) {
long tmp = 1;
while (n != 0) {
if (n % 2 == 1) {
tmp = Mod(tmp * x);
}
x = Mod(x * x);
n /= 2;
}
return tmp;
}
public static long DivMod(long x,
long y) => Mod(x * ModPow(y, (long)(1e9 + 5)));
public static void WL(this object obj) => WriteLine(obj);
public static void WL(this string obj) => WriteLine(obj);
public static void
WL<T>(this IEnumerable<T> list) => list.ToList().ForEach(x => x.WL());
public static Li IntList() => ReadLine().Split().Select(int.Parse).ToList();
public static Ll LongList() => ReadLine().Split().Select(long.Parse).ToList();
public static string
StringJoin<T>(this IEnumerable<T> l,
string separator = "") => string.Join(separator, l);
public static long GCD(long m, long n) {
long tmp;
if (m < n) {
tmp = n;
n = m;
m = tmp;
}
while (m % n != 0) {
tmp = n;
n = m % n;
m = tmp;
}
return n;
}
public static long LCM(long m, long n) => m * (n / GCD(m, n));
public static void REP(int n, Action<int> act) {
for (var i = 0; i < n; i++) {
act(i);
}
}
public static IEnumerable<int> ToImos(this IEnumerable<int> ie) {
var s = 0;
List<int> rt = new Li();
foreach (var item in ie) {
s += item;
rt.Add(s);
}
return rt;
}
public static void ForeachWithIndex<T>(IEnumerable<T> ie,
Action<int, T> action) {
int i = 0;
foreach (var item in ie) {
action(i, item);
i++;
}
}
public static int ManhattanDistance(int x1, int y1, int x2,
int y2) => Abs(x2 - x1) + Abs(y2 - y1);
public static Queue<T> ToQueue<T>(this IEnumerable<T> iEnumerable) {
var rt = new Queue<T>();
foreach (var item in iEnumerable) {
rt.Enqueue(item);
}
return rt;
}
public static Dictionary<TKey, int> CountUp<TKey>(this IEnumerable<TKey> l) {
var dic = new Dictionary<TKey, int>();
foreach (var item in l) {
if (dic.ContainsKey(item))
dic[item]++;
else
dic.Add(item, 1);
}
return dic;
}
public static int Count<T>(this IEnumerable<T> l,
T target) => l.Count(x => x.Equals(target));
public static int UpperBound<T>(this IEnumerable<T> list, T target)
where T : IComparable {
var idx = list.ToList().BinarySearch(target);
idx = idx < 0 ? ~idx : (idx + 1);
return Min(idx, list.Count());
}
public static int LowerBound<T>(this IEnumerable<T> list, T target)
where T : IComparable {
var idx = list.ToList().BinarySearch(target);
idx = idx < 0 ? ~idx : idx;
return Max(0, idx - 1);
}
}
}
namespace Nakov.IO {
using System;
using System.Text;
using System.Globalization;
public static class Cin {
public static string NextToken() {
StringBuilder tokenChars = new StringBuilder();
bool tokenFinished = false;
bool skipWhiteSpaceMode = true;
while (!tokenFinished) {
int nextChar = Console.Read();
if (nextChar == -1) {
tokenFinished = true;
} else {
char ch = (char)nextChar;
if (char.IsWhiteSpace(ch)) {
if (!skipWhiteSpaceMode) {
tokenFinished = true;
if (ch == '\r' && (Environment.NewLine == "\r\n")) {
Console.Read();
}
}
} else {
skipWhiteSpaceMode = false;
tokenChars.Append(ch);
}
}
}
string token = tokenChars.ToString();
return token;
}
public static int NextInt() {
string token = Cin.NextToken();
return int.Parse(token);
}
public static long NextLong() {
string token = Cin.NextToken();
return long.Parse(token);
}
public static double NextDouble(bool acceptAnyDecimalSeparator = true) {
string token = Cin.NextToken();
if (acceptAnyDecimalSeparator) {
token = token.Replace(',', '.');
double result = double.Parse(token, CultureInfo.InvariantCulture);
return result;
} else {
double result = double.Parse(token);
return result;
}
}
public static decimal NextDecimal(bool acceptAnyDecimalSeparator = true) {
string token = Cin.NextToken();
if (acceptAnyDecimalSeparator) {
token = token.Replace(',', '.');
decimal result = decimal.Parse(token, CultureInfo.InvariantCulture);
return result;
} else {
decimal result = decimal.Parse(token);
return result;
}
}
}
}
|
[["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 1,572
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main(string[] args) {
Console.ReadLine();
string[] arrStr = Console.ReadLine().Split(' ');
List<int> lstInt = new List<int>();
for (int i = 0; i < arrStr.Length; i++) {
lstInt.Add(int.Parse(arrStr[i]));
}
int intSplit = 0;
int intUpDownFlg = 0; // 1 ならUp, -1 ならDown
for (int i = 1; i < lstInt.Count; i++) {
switch (intUpDownFlg) {
case 1:
if (lstInt[i - 1] > lstInt[i]) {
intSplit++;
intUpDownFlg = 0;
}
break;
case -1:
if (lstInt[i - 1] < lstInt[i]) {
intSplit++;
intUpDownFlg = 0;
}
break;
case 0:
if (lstInt[i - 1] > lstInt[i]) {
intUpDownFlg = -1;
}
if (lstInt[i - 1] < lstInt[i]) {
intUpDownFlg = 1;
}
break;
default:
break;
}
}
Console.WriteLine(intSplit.ToString());
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main(string[] args) {
Console.ReadLine();
string[] arrStr = Console.ReadLine().Split(' ');
List<int> lstInt = new List<int>();
for (int i = 0; i < arrStr.Length; i++) {
lstInt.Add(int.Parse(arrStr[i]));
}
int intSplit = 1;
int intUpDownFlg = 0; // 1 ならUp, -1 ならDown
for (int i = 1; i < lstInt.Count; i++) {
switch (intUpDownFlg) {
case 1:
if (lstInt[i - 1] > lstInt[i]) {
intSplit++;
intUpDownFlg = 0;
}
break;
case -1:
if (lstInt[i - 1] < lstInt[i]) {
intSplit++;
intUpDownFlg = 0;
}
break;
case 0:
if (lstInt[i - 1] > lstInt[i]) {
intUpDownFlg = -1;
}
if (lstInt[i - 1] < lstInt[i]) {
intUpDownFlg = 1;
}
break;
default:
break;
}
}
Console.WriteLine(intSplit.ToString());
}
}
|
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203]]
| 8
| 266
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;
class Program {
public static void Main() {
var input = Console.ReadLine().Split();
int a = int.Parse(input[0]);
int b = int.Parse(input[1]);
int c = int.Parse(input[2]);
if (b - a == c - b) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;
class Program {
public static void Main() {
var input = Console.ReadLine().Split();
int a = int.Parse(input[0]);
int b = int.Parse(input[1]);
int c = int.Parse(input[2]);
if (b - a == c - b) {
Console.WriteLine("YES");
} else {
Console.WriteLine("NO");
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 118
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class AtCoderA {
static void Main() {
var sc = new Scanner();
int a = sc.NextInt();
int b = sc.NextInt();
int c = sc.NextInt();
string answer = (b - a == c - b) ? "Yes" : "No";
Console.WriteLine(answer);
}
class Scanner {
private string[] _line;
private int _index;
private const char Separator = ' ';
public Scanner() {
_line = new string[0];
_index = 0;
}
public string Next() {
while (_index >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_index = 0;
}
return _line[_index++];
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
public decimal NextDecimal() => decimal.Parse(Next());
public char NextChar() => Next()[0];
public char[] NextCharArray() => Next().ToCharArray();
public string[] Array() {
_line = Console.ReadLine().Split(Separator);
_index = _line.Length;
return _line;
}
public int[] IntArray() => Array().Select(int.Parse).ToArray();
public long[] LongArray() => Array().Select(long.Parse).ToArray();
public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class AtCoderA {
static void Main() {
var sc = new Scanner();
int a = sc.NextInt();
int b = sc.NextInt();
int c = sc.NextInt();
string answer = (b - a == c - b) ? "YES" : "NO";
Console.WriteLine(answer);
}
class Scanner {
private string[] _line;
private int _index;
private const char Separator = ' ';
public Scanner() {
_line = new string[0];
_index = 0;
}
public string Next() {
while (_index >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_index = 0;
}
return _line[_index++];
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
public decimal NextDecimal() => decimal.Parse(Next());
public char NextChar() => Next()[0];
public char[] NextCharArray() => Next().ToCharArray();
public string[] Array() {
_line = Console.ReadLine().Split(Separator);
_index = _line.Length;
return _line;
}
public int[] IntArray() => Array().Select(int.Parse).ToArray();
public long[] LongArray() => Array().Select(long.Parse).ToArray();
public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
}
}
|
[["-", 0, 200, 0, 212, 0, 41, 64, 5, 0, 222], ["+", 0, 200, 0, 212, 0, 41, 64, 5, 0, 222], ["-", 0, 200, 0, 212, 0, 41, 75, 5, 0, 222], ["+", 0, 200, 0, 212, 0, 41, 75, 5, 0, 222]]
| 8
| 389
| 4
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCorder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
var a = cin.ReadInt;
var b = cin.ReadInt;
var c = cin.ReadInt;
if (b - a == c - b) {
WriteLine("Yes");
} else {
WriteLine("No");
}
}
public long C(int X, int Y) {
if (Y == 0 || Y == X) {
return 1;
}
if (X < Y) {
return 0;
}
var Pascal = new long[X + 1, X + 1];
for (int i = 0; i <= X; i++) {
Pascal[i, 0] = 1L;
Pascal[i, i] = 1L;
}
for (int i = 2; i <= X; i++) {
for (int j = 1; j < i; j++) {
Pascal[i, j] = Pascal[i - 1, j] + Pascal[i - 1, j - 1];
}
}
return Pascal[X, Y];
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
}
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCorder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
var a = cin.ReadInt;
var b = cin.ReadInt;
var c = cin.ReadInt;
if (b - a == c - b) {
WriteLine("YES");
} else {
WriteLine("NO");
}
}
public long C(int X, int Y) {
if (Y == 0 || Y == X) {
return 1;
}
if (X < Y) {
return 0;
}
var Pascal = new long[X + 1, X + 1];
for (int i = 0; i <= X; i++) {
Pascal[i, 0] = 1L;
Pascal[i, i] = 1L;
}
for (int i = 2; i <= X; i++) {
for (int j = 1; j < i; j++) {
Pascal[i, j] = Pascal[i - 1, j] + Pascal[i - 1, j - 1];
}
}
return Pascal[X, Y];
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 628
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC058A___ι_l {
class Program {
static void Main(string[] args) {
string input = Console.ReadLine();
string[] pillars = input.Split(' ');
int a = int.Parse(pillars[0]);
int b = int.Parse(pillars[1]);
int c = int.Parse(pillars[2]);
string result = "No";
bool isBeauty = (2 * b - a - c == 0);
if (isBeauty) {
result = "Yes";
}
Console.WriteLine(result);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC058A___ι_l {
class Program {
static void Main(string[] args) {
string input = Console.ReadLine();
string[] pillars = input.Split(' ');
int a = int.Parse(pillars[0]);
int b = int.Parse(pillars[1]);
int c = int.Parse(pillars[2]);
string result = "NO";
bool isBeauty = (2 * b - a - c == 0);
if (isBeauty) {
result = "YES";
}
Console.WriteLine(result);
}
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 5, 0, 222], ["+", 0, 198, 0, 200, 0, 212, 0, 5, 0, 222], ["-", 64, 196, 0, 1, 0, 11, 12, 5, 0, 222], ["+", 64, 196, 0, 1, 0, 11, 12, 5, 0, 222]]
| 8
| 149
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ziyuutyou {
class Program {
static void Main(string[] args) {
var hasira = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
if (hasira[1] - hasira[0] == hasira[2] - hasira[1]) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ziyuutyou {
class Program {
static void Main(string[] args) {
var hasira = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
if (hasira[1] - hasira[0] == hasira[2] - hasira[1]) {
Console.WriteLine("YES");
} else {
Console.WriteLine("NO");
}
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 104
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main(string[] args) {
string[] arrStr = Console.ReadLine().Split(' ');
List<int> lstInt = new List<int>();
for (int i = 0; i < arrStr.Length; i++) {
lstInt.Add(int.Parse(arrStr[i]));
}
if (lstInt[1] - lstInt[0] == lstInt[2] - lstInt[1]) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main(string[] args) {
string[] arrStr = Console.ReadLine().Split(' ');
List<int> lstInt = new List<int>();
for (int i = 0; i < arrStr.Length; i++) {
lstInt.Add(int.Parse(arrStr[i]));
}
if (lstInt[1] - lstInt[0] == lstInt[2] - lstInt[1]) {
Console.WriteLine("YES");
} else {
Console.WriteLine("NO");
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 152
| 4
|
using System;
using System.Linq;
class Prog {
public static void Main() {
var ipt = Console.ReadLine()
.Split(' ')
.Select(i => Int32.Parse(i.ToString()))
.ToArray();
if (ipt[2] - ipt[1] == ipt[2] - ipt[1]) {
Console.WriteLine("YES");
} else {
Console.WriteLine("NO");
}
}
}
|
using System;
using System.Linq;
class Prog {
public static void Main() {
var ipt = Console.ReadLine()
.Split(' ')
.Select(i => Int32.Parse(i.ToString()))
.ToArray();
if (ipt[2] - ipt[1] == ipt[1] - ipt[0]) {
Console.WriteLine("YES");
} else {
Console.WriteLine("NO");
}
}
}
|
[["-", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 12, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 12, 16, 12, 204, 206, 207, 0, 28, 0, 203]]
| 8
| 101
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace abc058 {
public class Program {
public static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
int a = Convert.ToInt32(str[0]);
int b = Convert.ToInt32(str[1]);
int c = Convert.ToInt32(str[2]);
Console.WriteLine(b - a == c - b ? "YES" : "No");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace abc058 {
public class Program {
public static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
int a = Convert.ToInt32(str[0]);
int b = Convert.ToInt32(str[1]);
int c = Convert.ToInt32(str[2]);
Console.WriteLine(b - a == c - b ? "YES" : "NO");
}
}
}
|
[["-", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222]]
| 8
| 126
| 2
|
using System;
using System.Linq;
class B {
static void Main() {
char[] Ar = Console.ReadLine().ToCharArray();
char[] Br = Console.ReadLine().ToCharArray();
string ans = "";
int i = Br.Length;
for (int j = 0; j < i; j++) {
ans += Ar[j].ToString();
ans += Br[j].ToString();
}
if (Ar.Length - i == 1) {
ans += Ar[Ar.Length].ToString();
}
Console.WriteLine(ans);
}
}
|
using System;
using System.Linq;
class B {
static void Main() {
char[] Ar = Console.ReadLine().ToCharArray();
char[] Br = Console.ReadLine().ToCharArray();
string ans = "";
int i = Br.Length;
for (int j = 0; j < i; j++) {
ans += Ar[j].ToString();
ans += Br[j].ToString();
}
if (Ar.Length - i == 1) {
ans += Ar[Ar.Length - 1].ToString();
}
Console.WriteLine(ans);
}
}
|
[["+", 205, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 205, 204, 206, 207, 0, 28, 0, 16, 12, 203]]
| 8
| 132
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
class MainClass {
public static void Main(string[] args) {
//入力
var O = Console.ReadLine().ToCharArray();
var E = Console.ReadLine().ToCharArray();
var ans = new List<char>();
for (var i = 0; i < O.Length; i++) {
ans.Add(O[i]);
if (i > E.Length)
break;
ans.Add(E[i]);
}
ans.ForEach(Console.Write);
Console.WriteLine("");
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class MainClass {
public static void Main(string[] args) {
//入力
var O = Console.ReadLine().ToCharArray();
var E = Console.ReadLine().ToCharArray();
var ans = new List<char>();
for (var i = 0; i < O.Length; i++) {
ans.Add(O[i]);
if (i >= E.Length)
break;
ans.Add(E[i]);
}
ans.ForEach(Console.Write);
Console.WriteLine("");
}
}
|
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 20]]
| 8
| 134
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;
namespace Atcoder01 {
/*class Program
{
//ABC96B
static void Main()
{
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int N = int.Parse(Console.ReadLine());
Array.Sort(input);
int Ans = input[0] + input[1];
var ans = input.Max();
for (int i = 0; i < N; i++)
{
ans = ans * 2;
}
Console.WriteLine(ans + Ans);
}
}*/
// ABC94B
/*class Program
{
static void Main()
{
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int[] gate = Console.ReadLine().Split().Select(int.Parse).ToArray();
int N = input[0];
int M = input[1];
int X = input[2];
int cost1 = 0;
int cost2 = 0;
for (int i = 0;i<X;i++)
{
if (gate.Contains(i))
{
cost1++;
}
}
for (int i = X;i<= N+1;i++)
{
if (gate.Contains(i))
{
cost2++;
}
}
List<int> Answer = new List<int>();
Answer.Add(cost1);
Answer.Add(cost2);
Console.WriteLine(Answer.Min());
}
}*/
// ABC93B
/*class Program
{
static void Main()
{
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int A = input[0];
int B = input[1];
int K = input[2];
List<BigInteger> array = new List<BigInteger>();
List<BigInteger> answer = new List<BigInteger>();
for (BigInteger i = A;i<=B;i++)
{
array.Add(i);
}
for(BigInteger i =A;i<A+K;i++)
{
answer.Add(i);
}
for (BigInteger i = B; i > B-K;i--)
{
answer.Add(i);
}
answer.Sort();
IEnumerable<BigInteger> result = answer.Distinct();
foreach (BigInteger aa in result)
{
if (array.Contains(aa)) {
Console.WriteLine(aa);
}
}
}*/
/*static void Main()
{
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int A = input[0];
int B = input[1];
int K = input[2];
List<int> ans1 = new List<int>();
for (int i=A;i<A+K;i++)
{
ans1.Add(i);
}
for (int i =B-K+1;i<=B;i++)
{
ans1.Add(i);
}
ans1.Sort();
IEnumerable<int> result = ans1.Distinct();
foreach (BigInteger aa in result)
{
if (A<=aa && aa<=B) {
Console.WriteLine(aa);
}
}
}
}*/
// ABC92B
/*class Program
{
static void Main()
{
int N = int.Parse(Console.ReadLine());
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int D = input[0];
int X = input[1];
List<int> chocolate = new List<int>();
for (int i=0;i<N; i++)
{
var temp = int.Parse(Console.ReadLine());
chocolate.Add(temp);
}
int count = 0;
foreach (int n in chocolate)
{
int day = 0;
while (true)
{
var haveday = n * day + 1;
if (haveday <= D)
{
count++;
}
else
{
break;
}
day++;
}
}
Console.WriteLine(count + X);
}
}*/
// ABC89B
/*class Program
{
static void Main()
{
int N = int.Parse(Console.ReadLine());
bool flag = false;
char[] arare = Console.ReadLine().ToCharArray();
foreach (char n in arare)
{
if (n == 'Y')
{
flag = true;
}
}
if (flag == true)
{
Console.WriteLine("Four");
}
else
{
Console.WriteLine("Three");
}
}
}*/
// ABC86B
/*class Program
{
static void Main()
{
var input = Console.ReadLine().Split();
var a = input[0] + input[1];
int Ans = Convert.ToInt32(a.ToString());
double mm = Math.Sqrt((double)Ans);
if (mm == (int)mm)
{
Console.WriteLine("Yes");
}
else
{
Console.WriteLine("No");
}
}
}*/
// ABC84B
/*class Program
{
static void Main()
{
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int A = input[0];
int B = input[1];
var S = Console.ReadLine();
if (S.Length == A + B + 1)
{
for (int i = 0; i < S.Length; i++)
{
if (A == i)
{
if (S[i] == '-')
{
var temp1 = S.Substring(0, i);
if (temp1.All(char.IsDigit))
{
temp1 = S.Substring(i + 1, S.Length - (i+1));
if (temp1.All(char.IsDigit))
{
Console.WriteLine("Yes");
}
else
{
Console.WriteLine("No");
}
}
else
{
Console.WriteLine("No");
}
}
else
{
Console.WriteLine("No");
}
}
}
}
else
{
Console.WriteLine("No");
}
}
}*/
// ABC79B
/*class Program
{
static void Main()
{
int N = int.Parse(Console.ReadLine());
List<BigInteger> ryka = new List<BigInteger>();
ryka.Add(2);
ryka.Add(1);
int count = 2;
while (count <= N)
{
var temp = ryka[count - 2] + ryka[count - 1];
ryka.Add(temp);
count++;
}
Console.WriteLine(ryka[N]);
}
}*/
// ABC78B
/*class Program
{
static void Main()
{
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int X = input[0];
int Y = input[1];
int Z = input[2];
int M = X / Y;
while (true)
{
var temp = Y * M + (M + 1) * Z;
if (temp <= X)
{
Console.WriteLine(M);
break;
}
else
{
M--;
}
}
}
}*/
/*class Program
{
static void Main()
{
int N = int.Parse(Console.ReadLine());
int Answer = 0;
while(true)
{
var ans = Math.Sqrt(N);
if (ans == (int)ans)
{
Answer = N;
break;
}
N--;
}
Console.WriteLine(Answer);
}
}*/
// ABC76B
/*class Program
{
static void Main()
{
int Ans = 1;
int N = int.Parse(Console.ReadLine());
int K = int.Parse(Console.ReadLine());
for(int i = 0; i < N; i++)
{
var A = Ans * 2;
var B = Ans + K;
if (A < B)
{
Ans = A;
}
else
{
Ans = B;
}
}
Console.WriteLine(Ans);
}
}*/
// ABC75B
/*class Program
{
/*static void Main()
{
List<string> map = new List<string>();
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
for (int i = 0;i< input[0];i++)
{
var temp = Console.ReadLine();
map.Add(temp);
}
int[] dx = { 1, 0, -1, 0, 1, -1, -1, 1 };
int[] dy = { 0, 1, 0, -1, 1, 1, -1, -1 };
List<int> temp1 = new List<int>();
for(int i =0;i<input[0];i++)
{
for (int j =0;j<input[1];j++)
{
int count = 0;
if (map[i][j] == '#')
{
temp1.Add(99);
}
else
{
for (int x = 0;x < 8;x++)
{
var X = i + dx[x];
var Y = j + dy[x];
if (X < 0 || X >= input[1]) { }
else if (Y < 0 || Y >= input[0]) { }
else
{
if (map[X][Y] == '#')
{
count++;
}
}
temp1.Add(count);
}
}
}
}
}*/
/*static void Main()
{
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
List<string> map = new List<string>();
int H = input[0];
int W = input[1];
List<int[]> ans = new List<int[]>();
int[] temp1 = new int[W];
for (int i = 0; i <= H; i++)
{
ans.Add(temp1);
}
int[] dx = { 1, 0, -1, 0, 1, -1, -1, 1 };
int[] dy = { 0, 1, 0, -1, 1, 1, -1, -1 };
for (int i = 0; i < H; i++)
{
var temp = Console.ReadLine();
map.Add(temp);
}
for (int i =0;i<H; i++)
{
for (int j =0;j<W;j++)
{
if (map[i][j] != '#')
{
int count = 0;
for (int d = 0; d < 8; d++)
{
var X = i + dx[d];
var Y = j + dy[d];
if (0 <= X && X < W && 0 <= Y && Y < H)
{
if (map[X][Y] == '#')
{
count++;
}
}
}
ans[i][j] = count;
}
else
{
ans[i][j] = '#';
}
}
}
Console.WriteLine();
}*/
// }
// ABC73B
/*class Program
{
static void Main()
{
List<int[]> ans = new List<int[]>();
int N = int.Parse(Console.ReadLine());
for (int i = 0;i <N;i++)
{
var temp = Console.ReadLine().Split().Select(int.Parse).ToArray();
ans.Add(temp);
}
int aa = 0;
foreach (int[] m in ans)
{
var answer = Math.Abs(m[0] - m[1])+1;
aa += answer;
}
Console.WriteLine(aa);
} if (A == C && B == D)
{
Console.WriteLine("1");
}
} */
// ABC70B
/*class Program
{
static void Main()
{
int[] N = Console.ReadLine().Split().Select(int.Parse).ToArray();
int A = N[0];
int B = N[1];
int C = N[2];
int D = N[3];
if (A == 26 && B == 83 && C == 13 && D == 27)
{
Console.WriteLine("1");
}
else if (C <= B && D >= A)
{
if (C <= A)
{
Console.WriteLine(Math.Abs(A - B));
}
else if (B >= D && C >= A)
{
Console.WriteLine(Math.Abs(D - C));
}
else if (C >= A)
{
Console.WriteLine(Math.Abs(B - C));
}
}
else
{
Console.WriteLine("0");
}
}
}*/
// ABC66B
/*class Program
{
static void Main()
{
var Ans = 0;
string N = Console.ReadLine();
bool flag = false;
while (true)
{
var temp = N.Length / 2;
string str = N.Substring(0, temp);
string str2 = N.Substring(temp , N.Length - temp);
if (str.Equals(str2) && flag == true)
{
Ans = str.Length + str2.Length;
break;
}
else
{
flag = true;
N = N.Remove(N.Length-1);
}
}
Console.WriteLine(Ans);
}
}*/
// ABC65B
/*class Program
{
static void Main()
{
int N = int.Parse(Console.ReadLine());
List<int> temp = new List<int>();
for (int i = 0; i < N; i++)
{
var a = int.Parse(Console.ReadLine());
temp.Add(a);
}
var ans = temp[0];
int count = 1;
bool flag = false;
bool flag2 = false;
if (ans == 2)
{
flag2 = true;
flag = true;
}
if (flag2 != true) {
while (true)
{
ans = temp[ans - 1];
count++;
if (ans == 2)
{
flag = true;
break;
}
if (count > N)
{
break;
}
}
}
if (flag == true)
{
Console.WriteLine(count);
}
else
{
Console.WriteLine("-1");
}
}
}*/
// ABC64B
/*class Program
{
static void Main()
{
int N = int.Parse(Console.ReadLine());
int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
var Max = a.Max();
var Min = a.Min();
Console.WriteLine(Max - Min);
}
}*/
// ABC63B
/*class Program
{
static void Main()
{
string S = Console.ReadLine();
var length = S.Length;
var count = S.Distinct();
var ans = count.Count();
if (length == ans)
{
Console.WriteLine("yes");
}
else
{
Console.WriteLine("no");
}
}
}*/
// ABC62B
/*class Program
{
static void Main()
{
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int H = input[0];
int W = input[1];
List<string> array = new List<string>();
for (int i = 0; i < H; i++)
{
var temp = Console.ReadLine();
array.Add(temp);
}
string row = "";
for (int i = 0;i<W+2; i++)
{
row += "#";
}
List<string> answer = new List<string>();
foreach (string n in array)
{
var o = "#" + n + "#";
answer.Add(o);
}
Console.WriteLine(row);
foreach (string m in answer)
{
Console.WriteLine(m);
}
Console.WriteLine(row);
}
}*/
// ABC60B
/*class Program
{
static void Main()
{
}
}*/
// ABC133A
/*class Program
{
static void Main()
{
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int N = input[0];
int A = input[1];
int B = input[2];
var ans1 = A * N;
var ans2 = B;
if (ans1 >= ans2) { Console.WriteLine(ans2); }
else { Console.WriteLine(ans1); }
}
}*/
// ABC133B
/*class Program
{
static void Main()
{
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int N = input[0];
int D = input[1];
List<int[]> array = new List<int[]>();
for (int i =0;i<N;i++)
{
int[] temp = Console.ReadLine().Split().Select(int.Parse).ToArray();
array.Add(temp);
}
double ans = 0;
double ans2 = 0;
int count = 0;
for (int i=0;i<N;i++)
{
for (int j =i;j<N;j++)
{
ans = 0;
for (int d = 0; d < D; d++)
{
ans += Math.Abs(array[i][d] - array[j][d]) *
Math.Abs(array[i][d] - array[j][d]);
}
ans2 = Math.Sqrt(ans);
if (ans2 == (int)ans2)
{
count++;
}
}
}
Console.WriteLine(count-N);
}
}*/
// ABC133C
/*class Program
{
static void Main()
{
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int L = input[0];
int R = input[1];
bool flag = false;
int Answer = 2019;
int count = 1;
for (int i = L; i <= R; i++)
{
for (int j =i+1;j<=R;j++)
{
var ans = (i * j) % 2019;
if (ans < Answer && ans != 0)
{
Answer = ans;
}
}
}
Console.WriteLine(Answer);
}
}*/
/*static void Main()
{
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int L = input[0];
int R = input[1];
bool flag = false;
int Answer = 2019;
for (int i = L; i < R; i++)
{
var ans = i * (i + 1) % 2019;
if (ans < Answer && ans !=0)
{
Answer = ans;
}
}
}*/
// ABC60B
/*class Program
{
static void Main()
{
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int A = input[0];
int B = input[1];
int C = input[2];
int count = 1;
int Asum = 0;
bool tem = false;
while (true)
{
Asum += A * count;
if (Asum % B == C)
{
tem = true;
break;
}
if(count == A*B)
{
break;
}
count++;
}
if (tem == true)
{
Console.WriteLine("Yes");
}
else
{
Console.WriteLine("No");
}
}
}*/
// ABC59B
/*class Program
{
static void Main()
{
BigInteger A = BigInteger.Parse(Console.ReadLine());
BigInteger B = BigInteger.Parse(Console.ReadLine());
if (A > B)
{
Console.WriteLine("GREATER");
}
else if (B > A)
{
Console.WriteLine("LESS");
}
else
{
Console.WriteLine("EQUAL");
}
}
}*/
// ABC58B
class Program {
static void Main() {
var O = Console.ReadLine();
var E = Console.ReadLine();
List<char> Ans = new List<char>();
int length = O.Length + E.Length;
int count = 1;
int Ocount = 0;
int Ecount = 0;
while (count < length) {
if (count % 2 == 1) {
Ans.Add(O[Ocount]);
Ocount++;
} else {
Ans.Add(E[Ecount]);
Ecount++;
}
count++;
}
foreach (char ans in Ans) {
Console.Write(ans);
}
Console.WriteLine();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;
namespace Atcoder01 {
/*class Program
{
//ABC96B
static void Main()
{
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int N = int.Parse(Console.ReadLine());
Array.Sort(input);
int Ans = input[0] + input[1];
var ans = input.Max();
for (int i = 0; i < N; i++)
{
ans = ans * 2;
}
Console.WriteLine(ans + Ans);
}
}*/
// ABC94B
/*class Program
{
static void Main()
{
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int[] gate = Console.ReadLine().Split().Select(int.Parse).ToArray();
int N = input[0];
int M = input[1];
int X = input[2];
int cost1 = 0;
int cost2 = 0;
for (int i = 0;i<X;i++)
{
if (gate.Contains(i))
{
cost1++;
}
}
for (int i = X;i<= N+1;i++)
{
if (gate.Contains(i))
{
cost2++;
}
}
List<int> Answer = new List<int>();
Answer.Add(cost1);
Answer.Add(cost2);
Console.WriteLine(Answer.Min());
}
}*/
// ABC93B
/*class Program
{
static void Main()
{
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int A = input[0];
int B = input[1];
int K = input[2];
List<BigInteger> array = new List<BigInteger>();
List<BigInteger> answer = new List<BigInteger>();
for (BigInteger i = A;i<=B;i++)
{
array.Add(i);
}
for(BigInteger i =A;i<A+K;i++)
{
answer.Add(i);
}
for (BigInteger i = B; i > B-K;i--)
{
answer.Add(i);
}
answer.Sort();
IEnumerable<BigInteger> result = answer.Distinct();
foreach (BigInteger aa in result)
{
if (array.Contains(aa)) {
Console.WriteLine(aa);
}
}
}*/
/*static void Main()
{
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int A = input[0];
int B = input[1];
int K = input[2];
List<int> ans1 = new List<int>();
for (int i=A;i<A+K;i++)
{
ans1.Add(i);
}
for (int i =B-K+1;i<=B;i++)
{
ans1.Add(i);
}
ans1.Sort();
IEnumerable<int> result = ans1.Distinct();
foreach (BigInteger aa in result)
{
if (A<=aa && aa<=B) {
Console.WriteLine(aa);
}
}
}
}*/
// ABC92B
/*class Program
{
static void Main()
{
int N = int.Parse(Console.ReadLine());
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int D = input[0];
int X = input[1];
List<int> chocolate = new List<int>();
for (int i=0;i<N; i++)
{
var temp = int.Parse(Console.ReadLine());
chocolate.Add(temp);
}
int count = 0;
foreach (int n in chocolate)
{
int day = 0;
while (true)
{
var haveday = n * day + 1;
if (haveday <= D)
{
count++;
}
else
{
break;
}
day++;
}
}
Console.WriteLine(count + X);
}
}*/
// ABC89B
/*class Program
{
static void Main()
{
int N = int.Parse(Console.ReadLine());
bool flag = false;
char[] arare = Console.ReadLine().ToCharArray();
foreach (char n in arare)
{
if (n == 'Y')
{
flag = true;
}
}
if (flag == true)
{
Console.WriteLine("Four");
}
else
{
Console.WriteLine("Three");
}
}
}*/
// ABC86B
/*class Program
{
static void Main()
{
var input = Console.ReadLine().Split();
var a = input[0] + input[1];
int Ans = Convert.ToInt32(a.ToString());
double mm = Math.Sqrt((double)Ans);
if (mm == (int)mm)
{
Console.WriteLine("Yes");
}
else
{
Console.WriteLine("No");
}
}
}*/
// ABC84B
/*class Program
{
static void Main()
{
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int A = input[0];
int B = input[1];
var S = Console.ReadLine();
if (S.Length == A + B + 1)
{
for (int i = 0; i < S.Length; i++)
{
if (A == i)
{
if (S[i] == '-')
{
var temp1 = S.Substring(0, i);
if (temp1.All(char.IsDigit))
{
temp1 = S.Substring(i + 1, S.Length - (i+1));
if (temp1.All(char.IsDigit))
{
Console.WriteLine("Yes");
}
else
{
Console.WriteLine("No");
}
}
else
{
Console.WriteLine("No");
}
}
else
{
Console.WriteLine("No");
}
}
}
}
else
{
Console.WriteLine("No");
}
}
}*/
// ABC79B
/*class Program
{
static void Main()
{
int N = int.Parse(Console.ReadLine());
List<BigInteger> ryka = new List<BigInteger>();
ryka.Add(2);
ryka.Add(1);
int count = 2;
while (count <= N)
{
var temp = ryka[count - 2] + ryka[count - 1];
ryka.Add(temp);
count++;
}
Console.WriteLine(ryka[N]);
}
}*/
// ABC78B
/*class Program
{
static void Main()
{
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int X = input[0];
int Y = input[1];
int Z = input[2];
int M = X / Y;
while (true)
{
var temp = Y * M + (M + 1) * Z;
if (temp <= X)
{
Console.WriteLine(M);
break;
}
else
{
M--;
}
}
}
}*/
/*class Program
{
static void Main()
{
int N = int.Parse(Console.ReadLine());
int Answer = 0;
while(true)
{
var ans = Math.Sqrt(N);
if (ans == (int)ans)
{
Answer = N;
break;
}
N--;
}
Console.WriteLine(Answer);
}
}*/
// ABC76B
/*class Program
{
static void Main()
{
int Ans = 1;
int N = int.Parse(Console.ReadLine());
int K = int.Parse(Console.ReadLine());
for(int i = 0; i < N; i++)
{
var A = Ans * 2;
var B = Ans + K;
if (A < B)
{
Ans = A;
}
else
{
Ans = B;
}
}
Console.WriteLine(Ans);
}
}*/
// ABC75B
/*class Program
{
/*static void Main()
{
List<string> map = new List<string>();
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
for (int i = 0;i< input[0];i++)
{
var temp = Console.ReadLine();
map.Add(temp);
}
int[] dx = { 1, 0, -1, 0, 1, -1, -1, 1 };
int[] dy = { 0, 1, 0, -1, 1, 1, -1, -1 };
List<int> temp1 = new List<int>();
for(int i =0;i<input[0];i++)
{
for (int j =0;j<input[1];j++)
{
int count = 0;
if (map[i][j] == '#')
{
temp1.Add(99);
}
else
{
for (int x = 0;x < 8;x++)
{
var X = i + dx[x];
var Y = j + dy[x];
if (X < 0 || X >= input[1]) { }
else if (Y < 0 || Y >= input[0]) { }
else
{
if (map[X][Y] == '#')
{
count++;
}
}
temp1.Add(count);
}
}
}
}
}*/
/*static void Main()
{
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
List<string> map = new List<string>();
int H = input[0];
int W = input[1];
List<int[]> ans = new List<int[]>();
int[] temp1 = new int[W];
for (int i = 0; i <= H; i++)
{
ans.Add(temp1);
}
int[] dx = { 1, 0, -1, 0, 1, -1, -1, 1 };
int[] dy = { 0, 1, 0, -1, 1, 1, -1, -1 };
for (int i = 0; i < H; i++)
{
var temp = Console.ReadLine();
map.Add(temp);
}
for (int i =0;i<H; i++)
{
for (int j =0;j<W;j++)
{
if (map[i][j] != '#')
{
int count = 0;
for (int d = 0; d < 8; d++)
{
var X = i + dx[d];
var Y = j + dy[d];
if (0 <= X && X < W && 0 <= Y && Y < H)
{
if (map[X][Y] == '#')
{
count++;
}
}
}
ans[i][j] = count;
}
else
{
ans[i][j] = '#';
}
}
}
Console.WriteLine();
}*/
// }
// ABC73B
/*class Program
{
static void Main()
{
List<int[]> ans = new List<int[]>();
int N = int.Parse(Console.ReadLine());
for (int i = 0;i <N;i++)
{
var temp = Console.ReadLine().Split().Select(int.Parse).ToArray();
ans.Add(temp);
}
int aa = 0;
foreach (int[] m in ans)
{
var answer = Math.Abs(m[0] - m[1])+1;
aa += answer;
}
Console.WriteLine(aa);
} if (A == C && B == D)
{
Console.WriteLine("1");
}
} */
// ABC70B
/*class Program
{
static void Main()
{
int[] N = Console.ReadLine().Split().Select(int.Parse).ToArray();
int A = N[0];
int B = N[1];
int C = N[2];
int D = N[3];
if (A == 26 && B == 83 && C == 13 && D == 27)
{
Console.WriteLine("1");
}
else if (C <= B && D >= A)
{
if (C <= A)
{
Console.WriteLine(Math.Abs(A - B));
}
else if (B >= D && C >= A)
{
Console.WriteLine(Math.Abs(D - C));
}
else if (C >= A)
{
Console.WriteLine(Math.Abs(B - C));
}
}
else
{
Console.WriteLine("0");
}
}
}*/
// ABC66B
/*class Program
{
static void Main()
{
var Ans = 0;
string N = Console.ReadLine();
bool flag = false;
while (true)
{
var temp = N.Length / 2;
string str = N.Substring(0, temp);
string str2 = N.Substring(temp , N.Length - temp);
if (str.Equals(str2) && flag == true)
{
Ans = str.Length + str2.Length;
break;
}
else
{
flag = true;
N = N.Remove(N.Length-1);
}
}
Console.WriteLine(Ans);
}
}*/
// ABC65B
/*class Program
{
static void Main()
{
int N = int.Parse(Console.ReadLine());
List<int> temp = new List<int>();
for (int i = 0; i < N; i++)
{
var a = int.Parse(Console.ReadLine());
temp.Add(a);
}
var ans = temp[0];
int count = 1;
bool flag = false;
bool flag2 = false;
if (ans == 2)
{
flag2 = true;
flag = true;
}
if (flag2 != true) {
while (true)
{
ans = temp[ans - 1];
count++;
if (ans == 2)
{
flag = true;
break;
}
if (count > N)
{
break;
}
}
}
if (flag == true)
{
Console.WriteLine(count);
}
else
{
Console.WriteLine("-1");
}
}
}*/
// ABC64B
/*class Program
{
static void Main()
{
int N = int.Parse(Console.ReadLine());
int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
var Max = a.Max();
var Min = a.Min();
Console.WriteLine(Max - Min);
}
}*/
// ABC63B
/*class Program
{
static void Main()
{
string S = Console.ReadLine();
var length = S.Length;
var count = S.Distinct();
var ans = count.Count();
if (length == ans)
{
Console.WriteLine("yes");
}
else
{
Console.WriteLine("no");
}
}
}*/
// ABC62B
/*class Program
{
static void Main()
{
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int H = input[0];
int W = input[1];
List<string> array = new List<string>();
for (int i = 0; i < H; i++)
{
var temp = Console.ReadLine();
array.Add(temp);
}
string row = "";
for (int i = 0;i<W+2; i++)
{
row += "#";
}
List<string> answer = new List<string>();
foreach (string n in array)
{
var o = "#" + n + "#";
answer.Add(o);
}
Console.WriteLine(row);
foreach (string m in answer)
{
Console.WriteLine(m);
}
Console.WriteLine(row);
}
}*/
// ABC60B
/*class Program
{
static void Main()
{
}
}*/
// ABC133A
/*class Program
{
static void Main()
{
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int N = input[0];
int A = input[1];
int B = input[2];
var ans1 = A * N;
var ans2 = B;
if (ans1 >= ans2) { Console.WriteLine(ans2); }
else { Console.WriteLine(ans1); }
}
}*/
// ABC133B
/*class Program
{
static void Main()
{
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int N = input[0];
int D = input[1];
List<int[]> array = new List<int[]>();
for (int i =0;i<N;i++)
{
int[] temp = Console.ReadLine().Split().Select(int.Parse).ToArray();
array.Add(temp);
}
double ans = 0;
double ans2 = 0;
int count = 0;
for (int i=0;i<N;i++)
{
for (int j =i;j<N;j++)
{
ans = 0;
for (int d = 0; d < D; d++)
{
ans += Math.Abs(array[i][d] - array[j][d]) *
Math.Abs(array[i][d] - array[j][d]);
}
ans2 = Math.Sqrt(ans);
if (ans2 == (int)ans2)
{
count++;
}
}
}
Console.WriteLine(count-N);
}
}*/
// ABC133C
/*class Program
{
static void Main()
{
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int L = input[0];
int R = input[1];
bool flag = false;
int Answer = 2019;
int count = 1;
for (int i = L; i <= R; i++)
{
for (int j =i+1;j<=R;j++)
{
var ans = (i * j) % 2019;
if (ans < Answer && ans != 0)
{
Answer = ans;
}
}
}
Console.WriteLine(Answer);
}
}*/
/*static void Main()
{
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int L = input[0];
int R = input[1];
bool flag = false;
int Answer = 2019;
for (int i = L; i < R; i++)
{
var ans = i * (i + 1) % 2019;
if (ans < Answer && ans !=0)
{
Answer = ans;
}
}
}*/
// ABC60B
/*class Program
{
static void Main()
{
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int A = input[0];
int B = input[1];
int C = input[2];
int count = 1;
int Asum = 0;
bool tem = false;
while (true)
{
Asum += A * count;
if (Asum % B == C)
{
tem = true;
break;
}
if(count == A*B)
{
break;
}
count++;
}
if (tem == true)
{
Console.WriteLine("Yes");
}
else
{
Console.WriteLine("No");
}
}
}*/
// ABC59B
/*class Program
{
static void Main()
{
BigInteger A = BigInteger.Parse(Console.ReadLine());
BigInteger B = BigInteger.Parse(Console.ReadLine());
if (A > B)
{
Console.WriteLine("GREATER");
}
else if (B > A)
{
Console.WriteLine("LESS");
}
else
{
Console.WriteLine("EQUAL");
}
}
}*/
// ABC58B
class Program {
static void Main() {
var O = Console.ReadLine();
var E = Console.ReadLine();
List<char> Ans = new List<char>();
int length = O.Length + E.Length;
int count = 1;
int Ocount = 0;
int Ecount = 0;
while (count <= length) {
if (count % 2 == 1) {
Ans.Add(O[Ocount]);
Ocount++;
} else {
Ans.Add(E[Ecount]);
Ecount++;
}
count++;
}
foreach (char ans in Ans) {
Console.Write(ans);
}
Console.WriteLine();
}
}
}
|
[["-", 0, 195, 8, 196, 0, 52, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 19]]
| 8
| 230
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main() {
var o = Console.ReadLine();
var e = Console.ReadLine();
var res = "";
for (int i = 0; i < o.Length; i++) {
res += o[i];
if (i >= e.Length - 1) {
continue;
}
res += e[i];
}
Console.WriteLine(res);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main() {
var o = Console.ReadLine();
var e = Console.ReadLine();
var res = "";
for (int i = 0; i < o.Length; i++) {
res += o[i];
if (i > e.Length - 1) {
continue;
}
res += e[i];
}
Console.WriteLine(res);
}
}
|
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 20], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47]]
| 8
| 103
| 2
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
return;
}
public void Solve(ConsoleInput cin) {
var O = cin.ReadLine;
var E = cin.ReadLine;
long OLen = O.Length;
long ELen = E.Length;
char[] OChrAry = O.ToCharArray();
char[] EChrAry = E.ToCharArray();
long diff = OLen - ELen;
if (diff == 1) {
char[] passwd = new char[ELen * 2 + 1];
for (long i = 0; i < ELen; i++) {
passwd[i * 2] = OChrAry[i];
passwd[i * 2 + 1] = EChrAry[i];
}
passwd[ELen * 2 + 1] = OChrAry[OLen];
WriteLine(passwd);
} else if (diff == 0) {
char[] passwd = new char[ELen * 2];
for (long i = 0; i < ELen; i++) {
passwd[i * 2] = OChrAry[i];
passwd[i * 2 + 1] = EChrAry[i];
}
WriteLine(passwd);
}
}
}
public static class Extensions {
public static string Reverse(this string sourse) {
char[] chrAry = sourse.ToCharArray();
Array.Reverse(chrAry);
return new string(chrAry);
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
return;
}
public void Solve(ConsoleInput cin) {
var O = cin.ReadLine;
var E = cin.ReadLine;
long OLen = O.Length;
long ELen = E.Length;
char[] OChrAry = O.ToCharArray();
char[] EChrAry = E.ToCharArray();
long diff = OLen - ELen;
if (diff == 1) {
char[] passwd = new char[ELen * 2 + 1];
for (long i = 0; i < ELen; i++) {
passwd[i * 2] = OChrAry[i];
passwd[i * 2 + 1] = EChrAry[i];
}
passwd[ELen * 2] = OChrAry[OLen - 1];
WriteLine(passwd);
} else if (diff == 0) {
char[] passwd = new char[ELen * 2];
for (long i = 0; i < ELen; i++) {
passwd[i * 2] = OChrAry[i];
passwd[i * 2 + 1] = EChrAry[i];
}
WriteLine(passwd);
}
}
}
public static class Extensions {
public static string Reverse(this string sourse) {
char[] chrAry = sourse.ToCharArray();
Array.Reverse(chrAry);
return new string(chrAry);
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
[["-", 31, 204, 206, 207, 0, 28, 0, 16, 17, 72], ["-", 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
| 678
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main(string[] args) {
string strOdd = Console.ReadLine();
string strEven = Console.ReadLine();
int intStringCount = strOdd.Length + strEven.Length;
string strOutput = string.Empty;
for (int i = 0; i < intStringCount; i++) {
// 偶数(Even)
if (i % 2 == 0) {
strOutput += strEven[i / 2];
}
// 奇数(Odd)
else {
strOutput += strOdd[i / 2];
}
}
Console.WriteLine(strOutput);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main(string[] args) {
string strOdd = Console.ReadLine();
string strEven = Console.ReadLine();
int intStringCount = strOdd.Length + strEven.Length;
string strOutput = string.Empty;
for (int i = 0; i < intStringCount; i++) {
// 偶数(Even)
if (i % 2 == 1) {
strOutput += strEven[i / 2];
}
// 奇数(Odd)
else {
strOutput += strOdd[i / 2];
}
}
Console.WriteLine(strOutput);
}
}
|
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203]]
| 8
| 134
| 2
|
using System;
namespace ABC058C {
class Program {
static void Main(string[] args) {
int n = Int32.Parse(Console.ReadLine());
string[] s = new string[n];
for (int i = 0; i < n; i++) {
s[i] = Console.ReadLine();
}
string tmp = String.Empty;
for (int i = 0; i < s[0].Length; i++) {
bool contain = true;
for (int j = 1; j < n; j++) {
int idx = s[j].IndexOf(s[0][i]);
if (idx < 0) {
contain = false;
break;
} else {
s[j].Remove(idx, 1);
}
}
if (contain) {
tmp += s[0][i];
}
}
if (tmp != String.Empty) {
char[] res = tmp.ToCharArray();
Array.Sort(res);
Console.WriteLine(res);
} else {
Console.WriteLine();
}
}
}
}
|
using System;
namespace ABC058C {
class Program {
static void Main(string[] args) {
int n = Int32.Parse(Console.ReadLine());
string[] s = new string[n];
for (int i = 0; i < n; i++) {
s[i] = Console.ReadLine();
}
string tmp = String.Empty;
for (int i = 0; i < s[0].Length; i++) {
bool contain = true;
for (int j = 1; j < n; j++) {
int idx = s[j].IndexOf(s[0][i]);
if (idx < 0) {
contain = false;
break;
} else {
s[j] = s[j].Remove(idx, 1);
}
}
if (contain) {
tmp += s[0][i];
}
}
if (tmp != String.Empty) {
char[] res = tmp.ToCharArray();
Array.Sort(res);
Console.WriteLine(res);
} else {
Console.WriteLine();
}
}
}
}
|
[["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 11, 12, 213, 63, 214, 205, 204, 205, 22], ["+", 12, 213, 63, 214, 205, 204, 206, 207, 0, 70], ["+", 63, 214, 205, 204, 206, 207, 0, 28, 0, 22], ["+", 12, 213, 63, 214, 205, 204, 206, 207, 0, 73]]
| 8
| 231
| 5
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoderBeginner {
class Program {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
string[] xAxis = Console.ReadLine().Split(' ');
string[] yAxis = Console.ReadLine().Split(' ');
Console.WriteLine((Sum(input[0], xAxis) * Sum(input[1], yAxis)));
}
const int MOD = 1000000007;
static long Sum(string _input, string[] _tmp) {
int _num = int.Parse(_input);
long sum = 0;
for (int i = 0; i < _num; i++) {
sum += long.Parse(_tmp[i]) * (2 * i - _num + 1);
}
return sum % MOD;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoderBeginner {
class Program {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
string[] xAxis = Console.ReadLine().Split(' ');
string[] yAxis = Console.ReadLine().Split(' ');
Console.WriteLine((calc(input[0], xAxis) * calc(input[1], yAxis)) % MOD);
}
const int MOD = 1000000007;
static long calc(string _input, string[] _tmp) {
int _num = int.Parse(_input);
long sum = 0;
for (int i = 0; i < _num; i++) {
sum += long.Parse(_tmp[i]) * (2 * i - _num + 1);
}
return sum % MOD;
}
}
}
|
[["-", 0, 28, 0, 23, 0, 16, 31, 213, 63, 22], ["+", 0, 16, 31, 23, 0, 16, 31, 213, 63, 22], ["-", 0, 28, 0, 23, 0, 16, 12, 213, 63, 22], ["+", 0, 16, 31, 23, 0, 16, 12, 213, 63, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 109], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["-", 8, 201, 0, 235, 8, 201, 0, 195, 141, 22], ["+", 8, 201, 0, 235, 8, 201, 0, 195, 141, 22]]
| 8
| 205
| 8
|
using System;
class Program {
static void Main(string[] args) {
string[] xInputMax = "6 5".Split(' ');
// string[] xInputMax = Console.ReadLine().Split(' ');
int xMaxX = int.Parse(xInputMax[0]);
int xMaxY = int.Parse(xInputMax[1]);
long xSumX = SumAreaLength(Console.ReadLine(), xMaxX);
long xSumY = SumAreaLength(Console.ReadLine(), xMaxY);
long xDivisor = 1000000007;
Console.WriteLine(((xSumX % xDivisor) * (xSumY % xDivisor)) % xDivisor);
}
static long SumAreaLength(string xInputString, int xMaxCount) {
string[] xInput = xInputString.Split(' ');
long xSum = 0;
for (int i = 0; i < xMaxCount; ++i) {
xSum += long.Parse(xInput[i]) * (2 * i - xMaxCount + 1);
}
return xSum;
}
}
|
using System;
class Program {
static void Main(string[] args) {
string[] xInputMax = Console.ReadLine().Split(' ');
int xMaxX = int.Parse(xInputMax[0]);
int xMaxY = int.Parse(xInputMax[1]);
long xSumX = SumAreaLength(Console.ReadLine(), xMaxX);
long xSumY = SumAreaLength(Console.ReadLine(), xMaxY);
long xDivisor = 1000000007;
Console.WriteLine(((xSumX % xDivisor) * (xSumY % xDivisor)) % xDivisor);
}
static long SumAreaLength(string xInputString, int xMaxCount) {
string[] xInput = xInputString.Split(' ');
long xSum = 0;
for (int i = 0; i < xMaxCount; ++i) {
xSum += long.Parse(xInput[i]) * (2 * i - xMaxCount + 1);
}
return xSum;
}
}
|
[["-", 0, 212, 0, 213, 63, 214, 205, 5, 0, 62], ["-", 0, 212, 0, 213, 63, 214, 205, 5, 0, 222], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 205, 22], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["+", 0, 213, 63, 214, 205, 213, 3, 4, 0, 25]]
| 8
| 187
| 8
|
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
class Program {
public void Proc() {
int[] inpt =
Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
string ans = "No";
if (inpt[2] >= inpt[0] && inpt[2] <= inpt[1]) {
ans = "Yes";
}
Console.WriteLine(ans);
}
public class Reader {
public static bool IsDebug = true;
private static String PlainInput = @"
";
private static System.IO.StringReader Sr = null;
public static string ReadLine() {
if (IsDebug) {
if (Sr == null) {
Sr = new System.IO.StringReader(PlainInput.Trim());
}
return Sr.ReadLine();
} else {
return Console.ReadLine();
}
}
}
static void Main() {
Program prg = new Program();
prg.Proc();
}
}
|
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
class Program {
public void Proc() {
Reader.IsDebug = false;
int[] inpt =
Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
string ans = "No";
if (inpt[2] >= inpt[0] && inpt[2] <= inpt[1]) {
ans = "Yes";
}
Console.WriteLine(ans);
}
public class Reader {
public static bool IsDebug = true;
private static String PlainInput = @"
";
private static System.IO.StringReader Sr = null;
public static string ReadLine() {
if (IsDebug) {
if (Sr == null) {
Sr = new System.IO.StringReader(PlainInput.Trim());
}
return Sr.ReadLine();
} else {
return Console.ReadLine();
}
}
}
static void Main() {
Program prg = new Program();
prg.Proc();
}
}
|
[["+", 8, 196, 0, 1, 0, 11, 31, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 11, 31, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 11, 31, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 1, 0, 11, 12, 211, 0, 147], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 215
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder_Cs {
class Program {
static void Main(string[] args) {
int[] line =
Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
string ans = "no";
if (line[2] >= line[0] && line[2] <= line[1]) {
ans = "yes";
}
Console.WriteLine($"{ans}");
Console.ReadLine();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder_Cs {
class Program {
static void Main(string[] args) {
int[] line =
Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
string ans = "No";
if (line[2] >= line[0] && line[2] <= line[1]) {
ans = "Yes";
}
Console.WriteLine($"{ans}");
Console.ReadLine();
}
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 5, 0, 222], ["+", 0, 198, 0, 200, 0, 212, 0, 5, 0, 222], ["-", 64, 196, 0, 1, 0, 11, 12, 5, 0, 222], ["+", 64, 196, 0, 1, 0, 11, 12, 5, 0, 222]]
| 8
| 133
| 4
|
using System;
using System.Linq;
class A61 {
public static void Main(string[] args) {
int[] input =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
if (input[0] <= input[2] && input[1] >= input[2]) {
Console.WriteLine("YES");
} else {
Console.WriteLine("NO");
}
}
}
|
using System;
using System.Linq;
class A61 {
public static void Main(string[] args) {
int[] input =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
if (input[0] <= input[2] && input[1] >= input[2]) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 103
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace atcorder {
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
int a = Convert.ToInt32(str[0]);
int b = Convert.ToInt32(str[0]);
int c = Convert.ToInt32(str[0]);
Console.WriteLine(c >= a && c <= b ? "Yes" : "No");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace atcorder {
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
int a = Convert.ToInt32(str[0]);
int b = Convert.ToInt32(str[1]);
int c = Convert.ToInt32(str[2]);
Console.WriteLine(c >= a && c <= b ? "Yes" : "No");
}
}
}
|
[["-", 0, 28, 0, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 28, 0, 204, 206, 207, 0, 28, 0, 203]]
| 8
| 124
| 4
|
using System;
using System.Collections.Generic;
namespace AtCorderPractice {
class MainClass {
public static void Main(string[] args) {
var _ = LnInts();
var N = _[0];
var M = _[1];
var cities = new int[N];
for (int i = 0; i < M; i++) {
var roadBetween = LnInts();
cities[roadBetween[0]]++;
cities[roadBetween[1]]++;
}
foreach (var v in cities)
Console.WriteLine(v);
}
public static string[] LnStrs() {
var vs = Console.ReadLine().Trim().Split(
new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
return vs;
}
public static string LnStr() {
var vs = Console.ReadLine().Trim();
return vs;
}
public static int[] LnInts() {
var vs = Console.ReadLine().Trim().Split(
new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
var ins = new int[vs.Length];
for (int i = 0; i < vs.Length; i++)
ins[i] = int.Parse(vs[i]);
return ins;
}
public static int LnInt() {
var vs = Console.ReadLine().Trim();
return int.Parse(vs);
}
}
}
|
using System;
using System.Collections.Generic;
namespace AtCorderPractice {
class MainClass {
public static void Main(string[] args) {
var _ = LnInts();
var N = _[0];
var M = _[1];
var cities = new int[N];
for (int i = 0; i < M; i++) {
var roadBetween = LnInts();
cities[roadBetween[0] - 1]++;
cities[roadBetween[1] - 1]++;
}
foreach (var v in cities)
Console.WriteLine(v);
}
public static string[] LnStrs() {
var vs = Console.ReadLine().Trim().Split(
new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
return vs;
}
public static string LnStr() {
var vs = Console.ReadLine().Trim();
return vs;
}
public static int[] LnInts() {
var vs = Console.ReadLine().Trim().Split(
new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
var ins = new int[vs.Length];
for (int i = 0; i < vs.Length; i++)
ins[i] = int.Parse(vs[i]);
return ins;
}
public static int LnInt() {
var vs = Console.ReadLine().Trim();
return int.Parse(vs);
}
}
}
|
[["+", 0, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 0, 204, 206, 207, 0, 28, 0, 16, 12, 203]]
| 8
| 296
| 4
|
using System;
using System.Linq;
using System.Collections.Generic;
class MainClass {
public static void Main(string[] args) {
var list = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
var N = list[0];
var M = list[1];
var lista = new List<long>();
for (var i = 0; i < M; i++) {
var temp = Console.ReadLine().Split(' ').Select(long.Parse);
lista.Add(temp.ElementAt(0));
lista.Add(temp.ElementAt(1));
}
var ie = lista.GroupBy(g => g)
.Select(x => new { no = x.Key, count = x.Count() })
.OrderBy(e => e.no)
.ToList();
var c = 0;
for (var i = 1; i <= M; i++) {
if (!ie.Select(x => x.no).Contains(i)) {
Console.WriteLine(0);
} else {
Console.WriteLine(ie[c].count);
c++;
}
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
class MainClass {
public static void Main(string[] args) {
var list = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
var N = list[0];
var M = list[1];
var lista = new List<long>();
for (var i = 0; i < M; i++) {
var temp = Console.ReadLine().Split(' ').Select(long.Parse);
lista.Add(temp.ElementAt(0));
lista.Add(temp.ElementAt(1));
}
var ie = lista.GroupBy(g => g)
.Select(x => new { no = x.Key, count = x.Count() })
.OrderBy(e => e.no)
.ToList();
var c = 0;
for (var i = 1; i <= N; i++) {
if (!ie.Select(x => x.no).Contains(i)) {
Console.WriteLine(0);
} else {
Console.WriteLine(ie[c].count);
c++;
}
}
}
}
|
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22]]
| 8
| 262
| 2
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace ABC061 {
class B {
static void Main(string[] args) {
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int N = input[0];
int M = input[1];
Dictionary<int, int> dict = new Dictionary<int, int>();
int a = 0;
int b = 0;
for (int i = 0; i < M; i++) {
input = Console.ReadLine().Split().Select(int.Parse).ToArray();
a = input[0];
b = input[1];
if (!dict.ContainsKey(a)) {
dict.Add(a, 0);
}
if (!dict.ContainsKey(b)) {
dict.Add(b, 0);
}
if (dict.ContainsKey(a)) {
dict[a]++;
}
if (dict.ContainsKey(b)) {
dict[b]++;
}
}
var res = dict.OrderBy(x => x.Key);
for (int i = 1; i <= N; i++) {
if (!dict.ContainsKey(b))
Console.WriteLine(0);
else
Console.WriteLine(dict[i]);
}
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
/* Dictionaryの練習 */
namespace ABC061 {
class B {
static void Main(string[] args) {
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int N = input[0];
int M = input[1];
Dictionary<int, int> dict = new Dictionary<int, int>();
int a = 0;
int b = 0;
for (int i = 0; i < M; i++) {
input = Console.ReadLine().Split().Select(int.Parse).ToArray();
a = input[0];
b = input[1];
if (!dict.ContainsKey(a)) {
dict.Add(a, 0);
}
if (!dict.ContainsKey(b)) {
dict.Add(b, 0);
}
if (dict.ContainsKey(a)) {
dict[a]++;
}
if (dict.ContainsKey(b)) {
dict[b]++;
}
}
var res = dict.OrderBy(x => x.Key);
for (int i = 1; i <= N; i++) {
if (!dict.ContainsKey(i))
Console.WriteLine(0);
else
Console.WriteLine(dict[i]);
}
}
}
}
|
[["-", 15, 241, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 15, 241, 0, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 291
| 2
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
class Solver {
Scanner sc = new Scanner();
public void Solve() {
var N = sc.nextInt();
var M = sc.nextInt();
var dic = new Dictionary<int, int>();
for (int i = 0; i < M * 2; i++) {
var a = sc.nextInt();
if (dic.ContainsKey(a)) {
dic[a]++;
} else {
dic.Add(a, 1);
}
}
for (int i = 0; i < N; i++) {
if (dic.ContainsKey(i + 1)) {
WriteLine(0);
continue;
}
WriteLine(dic[i + 1]);
}
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
class Program {
static void Main(string[] args) {
Solver s = new Solver();
s.Solve();
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
class Solver {
Scanner sc = new Scanner();
public void Solve() {
var N = sc.nextInt();
var M = sc.nextInt();
var dic = new Dictionary<int, int>();
for (int i = 0; i < M * 2; i++) {
var a = sc.nextInt();
if (dic.ContainsKey(a)) {
dic[a]++;
} else {
dic.Add(a, 1);
}
}
for (int i = 0; i < N; i++) {
if (!dic.ContainsKey(i + 1)) {
WriteLine(0);
continue;
}
WriteLine(dic[i + 1]);
}
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
class Program {
static void Main(string[] args) {
Solver s = new Solver();
s.Solve();
}
}
|
[["+", 0, 7, 8, 196, 0, 57, 15, 241, 0, 111]]
| 8
| 552
| 1
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp64 {
class Program {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int N = int.Parse(input[0]);
int M = int.Parse(input[1]);
int[] A = new int[N];
for (int i = 0; i < N; i++) {
A[i] = 0;
}
for (int m = 0; m < M; m++) {
string[] input2 = Console.ReadLine().Split(' ');
int a = int.Parse(input[0]);
int b = int.Parse(input[1]);
A[a - 1]++;
A[b - 1]++;
}
for (int i = 0; i <= N; i++) {
Console.WriteLine(A[i]);
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp64 {
class Program {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int N = int.Parse(input[0]);
int M = int.Parse(input[1]);
int[] A = new int[N];
for (int i = 0; i < N; i++) {
A[i] = 0;
}
for (int m = 0; m < M; m++) {
string[] input2 = Console.ReadLine().Split(' ');
int a = int.Parse(input2[0]);
int b = int.Parse(input2[1]);
A[a - 1]++;
A[b - 1]++;
}
for (int i = 0; i < N; i++) {
Console.WriteLine(A[i]);
}
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18]]
| 8
| 226
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CountingRoads {
public class Program {
public static void Main(String[] args) {
// N個の都市とM番目の道路
string nm = Console.ReadLine();
// 都市数
int n = int.Parse(nm.Split(' ')[0]);
// 道路
int m = int.Parse(nm.Split(' ')[1]);
int[] countArray = new int[n];
for (int i = 0; i < n; i++) {
string ab = Console.ReadLine();
// 都市a
int a = int.Parse(ab.Split(' ')[0]);
// 都市b
int b = int.Parse(ab.Split(' ')[1]);
countArray[a - 1] = countArray[a - 1] + 1;
countArray[b - 1] = countArray[b - 1] + 1;
}
for (int i = 0; i < n; i++) {
Console.WriteLine(countArray[i]);
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CountingRoads {
public class Program {
public static void Main(String[] args) {
// N個の都市とM番目の道路
string nm = Console.ReadLine();
// 都市数
int n = int.Parse(nm.Split(' ')[0]);
// 道路
int m = int.Parse(nm.Split(' ')[1]);
int[] countArray = new int[n];
for (int i = 0; i < m; i++) {
string ab = Console.ReadLine();
// 都市a
int a = int.Parse(ab.Split(' ')[0]);
// 都市b
int b = int.Parse(ab.Split(' ')[1]);
countArray[a - 1] = countArray[a - 1] + 1;
countArray[b - 1] = countArray[b - 1] + 1;
}
for (int i = 0; i < n; i++) {
Console.WriteLine(countArray[i]);
}
}
}
}
|
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22]]
| 8
| 236
| 2
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder {
class Program {
static public long[] Sarray() {
return ReadLine().Split().Select(long.Parse).ToArray();
}
static public List<long> Slist() {
return ReadLine().Split().Select(long.Parse).ToList();
}
static long Mod = (long)1e9 + 7;
static void Main(string[] args) {
// SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
var NK = Sarray();
var N = NK[0];
var K = NK[1];
var num = new long[(long)1e5 + 1];
for (var i = 0; i < N; ++i) {
var ab = Sarray();
var a = ab[0];
var b = ab[1];
num[a] += b;
}
var acc = 0L;
for (var i = 0; i <= N; ++i) {
acc += num[i];
if (K <= acc) {
WriteLine(i);
return;
}
}
// Out.Flush();
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder {
class Program {
static public long[] Sarray() {
return ReadLine().Split().Select(long.Parse).ToArray();
}
static public List<long> Slist() {
return ReadLine().Split().Select(long.Parse).ToList();
}
static long Mod = (long)1e9 + 7;
static void Main(string[] args) {
// SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
var NK = Sarray();
var N = NK[0];
var K = NK[1];
var num = new long[(long)1e5 + 1];
for (var i = 0; i < N; ++i) {
var ab = Sarray();
var a = ab[0];
var b = ab[1];
num[a] += b;
}
var acc = 0L;
for (var i = 0; i < num.Length; ++i) {
acc += num[i];
if (K <= acc) {
WriteLine(i);
return;
}
}
// Out.Flush();
}
}
}
|
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 8, 196, 0, 7, 15, 16, 12, 214, 205, 22], ["+", 8, 196, 0, 7, 15, 16, 12, 214, 0, 131], ["+", 8, 196, 0, 7, 15, 16, 12, 214, 141, 22]]
| 8
| 256
| 6
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
namespace Brown {
using static Ex;
public class Solve {
public static void Main(string[] args) { new abc061_c(); }
}
public class abc061_c {
long n, k, a, b;
public abc061_c() {
(n, k) = ReadLongArray().ToTpl2();
var arr = new long[(int)1e5 + 1];
for (long i = 0; i < n; i++) {
(a, b) = ReadLongArray().ToTpl2();
arr[a] += b;
}
for (long i = 1; i <= (int)1e5; i++) {
arr[i] += arr[i - 1];
if (arr[i] > k) {
i.Cw();
return;
}
}
}
}
public class abc136_d {
public abc136_d() {
var s = Read.ToArray();
// var s = Read.Select(v => v == 'L' ? -1 : 1).ToArray();
var arr = new int[s.Length];
}
}
public class abc144_d {
public abc144_d() {}
}
public class abc149_d {
int n, k;
public abc149_d() {
(n, k) = ReadIntArray().ToTpl2();
var score = ReadIntArray();
var t = Read.Select(c => {
switch (c) {
case 'r':
return 2;
case 's':
return 0;
case 'p':
return 1;
};
return 0;
})
.ToArray();
long ans = 0;
var arr = new int[n];
for (int i = 0; i < n; i++) {
var c = t[i];
if (i >= k && (c == arr[i - k])) {
for (int a = 0; a < 3; a++) {
if (a == c)
continue;
if ((i + k < n) && a == t[i + k])
continue;
c = a;
break;
}
} else {
ans += score[c];
}
arr[i] = c;
}
ans.Cw();
}
}
public class abc_ {
public abc_() {}
}
public static class Ex {
public static void Cw(this object s) { Console.WriteLine(s); }
public static bool Mins<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) > 0) {
a = b;
return true;
}
return false;
}
public static bool Maxs<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) < 0) {
a = b;
return true;
}
return false;
}
public static void Swap<T>(ref T a, ref T b) {
var t = b;
b = a;
a = t;
}
public static void Swap<T>(List<T> list, int i, int j) {
T tmp = list[j];
list[j] = list[i];
list[i] = tmp;
}
public static long Lcm(int x, int y) { return x / Gcd(x, y) * y; }
public static long Gcd(long m, long n) {
if (n == 0)
return m;
return Gcd(n, m % n);
}
public static List<string> FastSort(this List<string> s) {
s.Sort(StringComparer.Ordinal);
return s.ToList();
}
public static void yesno(this bool b) { (b ? "yes" : "no").Cw(); }
public static void YesNo(this bool b) { (b ? "Yes" : "No").Cw(); }
public static void YESNO(this bool b) { (b ? "YES" : "NO").Cw(); }
public static string Read {
get { return Console.ReadLine().Trim(); }
}
public static int ReadInt {
get { return int.Parse(Read); }
}
public static long ReadLong {
get { return long.Parse(Read); }
}
public static double ReadDouble {
get { return double.Parse(Read); }
}
public static string[] ReadArray() { return Read.Split(' '); }
public static int[] ReadIntArray() {
return Read.Split(' ').Select(int.Parse).ToArray();
}
public static long[] ReadLongArray() {
return Read.Split(' ').Select(long.Parse).ToArray();
}
public static string[] ReadArray(long N) {
var v = new string[N];
for (long i = 0; i < N; ++i)
v[i] = Read;
return v;
}
public static int[] ReadIntArray(long N) {
var v = new int[N];
for (long i = 0; i < N; ++i)
v[i] = ReadInt;
return v;
}
public static long[] ReadLongArray(long N) {
var v = new long[N];
for (long i = 0; i < N; ++i)
v[i] = ReadLong;
return v;
}
public static (T, T) ToTpl2<T>(this T[] v) { return (v[0], v[1]); }
public static (T, T, T) ToTpl3<T>(this T[] v) { return (v[0], v[1], v[2]); }
public static (T, T, T, T) ToTpl4<T>(this T[] v) {
return (v[0], v[1], v[2], v[3]);
}
public static (T, T, T, T, T) ToTpl5<T>(this T[] v) {
return (v[0], v[1], v[2], v[3], v[4]);
}
}
}
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
namespace Brown {
using static Ex;
public class Solve {
public static void Main(string[] args) { new abc061_c(); }
}
public class abc061_c {
long n, k, a, b;
public abc061_c() {
(n, k) = ReadLongArray().ToTpl2();
var arr = new long[(int)1e5 + 1];
for (long i = 0; i < n; i++) {
(a, b) = ReadLongArray().ToTpl2();
arr[a] += b;
}
for (long i = 1; i <= (int)1e5; i++) {
arr[i] += arr[i - 1];
if (arr[i] >= k) {
i.Cw();
return;
}
}
}
}
public class abc136_d {
public abc136_d() {
var s = Read.ToArray();
// var s = Read.Select(v => v == 'L' ? -1 : 1).ToArray();
var arr = new int[s.Length];
}
}
public class abc144_d {
public abc144_d() {}
}
public class abc149_d {
int n, k;
public abc149_d() {
(n, k) = ReadIntArray().ToTpl2();
var score = ReadIntArray();
var t = Read.Select(c => {
switch (c) {
case 'r':
return 2;
case 's':
return 0;
case 'p':
return 1;
};
return 0;
})
.ToArray();
long ans = 0;
var arr = new int[n];
for (int i = 0; i < n; i++) {
var c = t[i];
if (i >= k && (c == arr[i - k])) {
for (int a = 0; a < 3; a++) {
if (a == c)
continue;
if ((i + k < n) && a == t[i + k])
continue;
c = a;
break;
}
} else {
ans += score[c];
}
arr[i] = c;
}
ans.Cw();
}
}
public class abc_ {
public abc_() {}
}
public static class Ex {
public static void Cw(this object s) { Console.WriteLine(s); }
public static bool Mins<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) > 0) {
a = b;
return true;
}
return false;
}
public static bool Maxs<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) < 0) {
a = b;
return true;
}
return false;
}
public static void Swap<T>(ref T a, ref T b) {
var t = b;
b = a;
a = t;
}
public static void Swap<T>(List<T> list, int i, int j) {
T tmp = list[j];
list[j] = list[i];
list[i] = tmp;
}
public static long Lcm(int x, int y) { return x / Gcd(x, y) * y; }
public static long Gcd(long m, long n) {
if (n == 0)
return m;
return Gcd(n, m % n);
}
public static List<string> FastSort(this List<string> s) {
s.Sort(StringComparer.Ordinal);
return s.ToList();
}
public static void yesno(this bool b) { (b ? "yes" : "no").Cw(); }
public static void YesNo(this bool b) { (b ? "Yes" : "No").Cw(); }
public static void YESNO(this bool b) { (b ? "YES" : "NO").Cw(); }
public static string Read {
get { return Console.ReadLine().Trim(); }
}
public static int ReadInt {
get { return int.Parse(Read); }
}
public static long ReadLong {
get { return long.Parse(Read); }
}
public static double ReadDouble {
get { return double.Parse(Read); }
}
public static string[] ReadArray() { return Read.Split(' '); }
public static int[] ReadIntArray() {
return Read.Split(' ').Select(int.Parse).ToArray();
}
public static long[] ReadLongArray() {
return Read.Split(' ').Select(long.Parse).ToArray();
}
public static string[] ReadArray(long N) {
var v = new string[N];
for (long i = 0; i < N; ++i)
v[i] = Read;
return v;
}
public static int[] ReadIntArray(long N) {
var v = new int[N];
for (long i = 0; i < N; ++i)
v[i] = ReadInt;
return v;
}
public static long[] ReadLongArray(long N) {
var v = new long[N];
for (long i = 0; i < N; ++i)
v[i] = ReadLong;
return v;
}
public static (T, T) ToTpl2<T>(this T[] v) { return (v[0], v[1]); }
public static (T, T, T) ToTpl3<T>(this T[] v) { return (v[0], v[1], v[2]); }
public static (T, T, T, T) ToTpl4<T>(this T[] v) {
return (v[0], v[1], v[2], v[3]);
}
public static (T, T, T, T, T) ToTpl5<T>(this T[] v) {
return (v[0], v[1], v[2], v[3], v[4]);
}
}
}
|
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 20]]
| 8
| 1,287
| 2
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atcoder {
class Program {
static void Main(string[] args) {
// test1
long[] vs = new long[100001];
int[] NK = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
for (int i = 0; i < NK[0]; i++) {
int[] ab = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
vs[ab[0]] += ab[1];
}
long K = NK[1];
for (int i = 0; i < vs.Length; i++) {
K -= vs[i];
if (K <= 0) {
Console.WriteLine(i);
break;
}
}
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atcoder {
class Program {
static void Main(string[] args) {
// test3
long[] vs = new long[100001];
var NK = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
for (int i = 0; i < NK[0]; i++) {
int[] ab = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
vs[ab[0]] += ab[1];
}
long K = NK[1];
for (int i = 0; i < vs.Length; i++) {
K -= vs[i];
if (K <= 0) {
Console.WriteLine(i);
break;
}
}
;
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 0, 197, 0, 198, 39, 224, 225, 226, 0, 70], ["-", 0, 197, 0, 198, 39, 224, 225, 226, 0, 73], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 8, 201, 0, 195, 8, 196, 0, 260, 0, 35]]
| 8
| 203
| 7
|
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 Hello {
static public int mod = 1000000007;
public static void Main() {
// 方針
//
int[] n = inta();
var dic = new SortedDictionary<int, int>();
for (int i = 0; i < n[0]; i++) {
int[] temp = inta();
if (dic.ContainsKey(temp[0])) {
dic[temp[0]] += temp[1];
} else {
dic.Add(temp[0], temp[1]);
}
}
foreach (var k in dic) {
n[1] -= k.Value;
if (n[1] <= 0) {
WriteLine(k.Key);
break;
}
}
}
static int ncr(int n, int r) {
r = Min(r, n - r);
long nn = 1;
for (int i = n - r + 1; i <= n; i++) {
nn = nn * i % mod;
}
long rr = 1;
for (int i = 1; i <= r; i++) {
rr = rr * i % mod;
}
rr = square((int)rr, mod - 2);
nn = nn * rr % mod;
return (int)nn;
}
// 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(long a,long b,long m){var list = new List<int>();int
// temp = 1;long n2 = a;list.Add(1);int count = 1;while(temp <
// b){list.Add((int)n2);temp*=2;count++;n2 = n2*n2%m;}long ret = 1;while(b >
// 0){if(temp <= b){b -= temp;ret =
// ret*list[count]%1000000007;}count--;temp/=2;}return(int)ret;} 各種読取
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 int[] inta() {
string[] read_str_array = ReadLine().Split(' ');
int[] return_int_array = new int[read_str_array.Length];
for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
}
return return_int_array;
}
static int[,] inta2(int num_array, int in_array) {
int[,] int_array2 = new int[num_array, in_array];
for (int i = 0; i < num_array; i++) {
int[] temp_array = inta();
for (int j = 0; j < in_array; j++) {
int_array2[i, j] = temp_array[j];
}
}
return int_array2;
}
static long[] longa() {
string[] read_str_array = ReadLine().Split(' ');
long[] return_long_array = new long[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_long_array[countup_i] = long.Parse(read_str_array[countup_i]);
}
return return_long_array;
}
static double[] doublea() {
string[] read_str_array = ReadLine().Split(' ');
double[] return_double_array = new double[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_double_array[countup_i] = long.Parse(read_str_array[countup_i]);
}
return return_double_array;
}
// -----------------------------
static long divideup(long divided, long divid) {
long temp_divide = divided / divid;
if (divided % divid > 0) {
temp_divide++;
}
return temp_divide;
}
static long GCD(long a, long b) {
if (a < b) {
long temp = a;
a = b;
b = temp;
}
if (a % b == 0) {
return b;
} else {
long temp = b;
b = a % b;
a = temp;
return GCD(a, b);
}
}
static long LCM(long a, long b) { return a * b / GCD(a, b); }
}
//知見
// (string) hogestr -> (char[]) hoge
// char hoge = hogestr.ToCharArray();
// (char[]) hoge -> (string) hogestr
// string hoge = new string(hoge);
// Hashtable × Dictionary ○
// Dictionary hoge<string,int>
// hoge.ContainsKey(string) -> return boolean
// hoge[string] -> return int
// hoge[int] -> CE
// Dictionary hoge<int1,int2>
// hoge<int1,int2>: hoge[int1] -> return int2
// KeyValuePair<int,int> k <-> k.Key == int1 / k.Value == int2
// SortedDictionary() > SortedList() ???
// キュー -> 幅優先 ???
// var queue = new Queue<int>(); queue.Enqueue() queue.Dequeue()
// スタック -> 深さ優先 ???
// var stack = new Stack<int>(); stack.Push(hoge) stack.Pop() stackPeek()
// stack.Count
// if (list?.Count > 0) リストが空でもnullでもない
// ソート
// list.Sort(StringComparer.Ordinal); listの(辞書順?)ソート
// StringComparer.Ordinal とは
// Array.Sort(list1,list2);
// 出力
// foreach(var a int list){ WriteLine(a); } より
// WriteLine(string.Join("\n", list)); が速い
// var sw = new StreamWriter(Console.OpenStandardOutput()){AutoFlush = false};
// Console.SetOut(sw);
// foreach(var k in list[num-1]){
// WriteLine(k);
// }
// Console.Out.Flush();
|
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 Hello {
static public int mod = 1000000007;
public static void Main() {
// 方針
//
long[] n = longa();
var dic = new SortedDictionary<int, long>();
for (int i = 0; i < n[0]; i++) {
int[] temp = inta();
if (dic.ContainsKey(temp[0])) {
dic[temp[0]] += temp[1];
} else {
dic.Add(temp[0], temp[1]);
}
}
foreach (var k in dic) {
n[1] -= k.Value;
if (n[1] <= 0) {
WriteLine(k.Key);
break;
}
}
}
static int ncr(int n, int r) {
r = Min(r, n - r);
long nn = 1;
for (int i = n - r + 1; i <= n; i++) {
nn = nn * i % mod;
}
long rr = 1;
for (int i = 1; i <= r; i++) {
rr = rr * i % mod;
}
rr = square((int)rr, mod - 2);
nn = nn * rr % mod;
return (int)nn;
}
// 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(long a,long b,long m){var list = new List<int>();int
// temp = 1;long n2 = a;list.Add(1);int count = 1;while(temp <
// b){list.Add((int)n2);temp*=2;count++;n2 = n2*n2%m;}long ret = 1;while(b >
// 0){if(temp <= b){b -= temp;ret =
// ret*list[count]%1000000007;}count--;temp/=2;}return(int)ret;} 各種読取
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 int[] inta() {
string[] read_str_array = ReadLine().Split(' ');
int[] return_int_array = new int[read_str_array.Length];
for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
}
return return_int_array;
}
static int[,] inta2(int num_array, int in_array) {
int[,] int_array2 = new int[num_array, in_array];
for (int i = 0; i < num_array; i++) {
int[] temp_array = inta();
for (int j = 0; j < in_array; j++) {
int_array2[i, j] = temp_array[j];
}
}
return int_array2;
}
static long[] longa() {
string[] read_str_array = ReadLine().Split(' ');
long[] return_long_array = new long[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_long_array[countup_i] = long.Parse(read_str_array[countup_i]);
}
return return_long_array;
}
static double[] doublea() {
string[] read_str_array = ReadLine().Split(' ');
double[] return_double_array = new double[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_double_array[countup_i] = long.Parse(read_str_array[countup_i]);
}
return return_double_array;
}
// -----------------------------
static long divideup(long divided, long divid) {
long temp_divide = divided / divid;
if (divided % divid > 0) {
temp_divide++;
}
return temp_divide;
}
static long GCD(long a, long b) {
if (a < b) {
long temp = a;
a = b;
b = temp;
}
if (a % b == 0) {
return b;
} else {
long temp = b;
b = a % b;
a = temp;
return GCD(a, b);
}
}
static long LCM(long a, long b) { return a * b / GCD(a, b); }
}
//知見
// (string) hogestr -> (char[]) hoge
// char hoge = hogestr.ToCharArray();
// (char[]) hoge -> (string) hogestr
// string hoge = new string(hoge);
// Hashtable × Dictionary ○
// Dictionary hoge<string,int>
// hoge.ContainsKey(string) -> return boolean
// hoge[string] -> return int
// hoge[int] -> CE
// Dictionary hoge<int1,int2>
// hoge<int1,int2>: hoge[int1] -> return int2
// KeyValuePair<int,int> k <-> k.Key == int1 / k.Value == int2
// SortedDictionary() > SortedList() ???
// キュー -> 幅優先 ???
// var queue = new Queue<int>(); queue.Enqueue() queue.Dequeue()
// スタック -> 深さ優先 ???
// var stack = new Stack<int>(); stack.Push(hoge) stack.Pop() stackPeek()
// stack.Count
// if (list?.Count > 0) リストが空でもnullでもない
// ソート
// list.Sort(StringComparer.Ordinal); listの(辞書順?)ソート
// StringComparer.Ordinal とは
// Array.Sort(list1,list2);
// 出力
// foreach(var a int list){ WriteLine(a); } より
// WriteLine(string.Join("\n", list)); が速い
// var sw = new StreamWriter(Console.OpenStandardOutput()){AutoFlush = false};
// Console.SetOut(sw);
// foreach(var k in list[num-1]){
// WriteLine(k);
// }
// Console.Out.Flush();
|
[["-", 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, 212, 0, 230, 39, 236, 237, 238, 0, 199], ["+", 0, 212, 0, 230, 39, 236, 237, 238, 0, 199]]
| 8
| 944
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApp11 {
class Class40 {
static void Main() {
var I = Console.ReadLine().Split().Select(long.Parse).ToArray();
var N = I[0];
var K = I[1];
Dictionary<long, long> Table = new Dictionary<long, long>();
for (int i = 0; i < N; i++) {
var read = Console.ReadLine().Split().Select(long.Parse).ToArray();
if (Table.Keys.Contains(read[0])) {
Table[read[0]] += read[1];
} else {
Table[read[0]] = read[1];
}
}
long sum = 0;
foreach (long L in Table.Keys) {
sum += Table[L];
if (sum >= K) {
Console.WriteLine(L);
return;
}
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApp11 {
class Class40 {
static void Main() {
var I = Console.ReadLine().Split().Select(long.Parse).ToArray();
var N = I[0];
var K = I[1];
SortedDictionary<long, long> Table = new SortedDictionary<long, long>();
for (int i = 0; i < N; i++) {
var read = Console.ReadLine().Split().Select(long.Parse).ToArray();
if (Table.Keys.Contains(read[0])) {
Table[read[0]] += read[1];
} else {
Table[read[0]] = read[1];
}
}
long sum = 0;
foreach (long L in Table.Keys) {
sum += Table[L];
if (sum >= K) {
Console.WriteLine(L);
return;
}
}
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 39, 236, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 39, 236, 141, 22], ["-", 0, 200, 0, 212, 0, 230, 39, 236, 141, 22], ["+", 0, 200, 0, 212, 0, 230, 39, 236, 141, 22]]
| 8
| 213
| 4
|
using System;
using CompLib.Util;
public class Program {
public void Solve() {
var sc = new Scanner();
int n = sc.NextInt();
int k = sc.NextInt();
int[] a = new int[n];
int[] b = new int[n];
for (int i = 0; i < n; i++) {
a[i] = sc.NextInt();
b[i] = sc.NextInt();
}
int[] cnt = new int[100001];
for (int i = 0; i < n; i++) {
cnt[a[i]] += b[i];
}
for (int i = 1; i < 100001; i++) {
if (cnt[i] >= k) {
Console.WriteLine(i);
return;
}
k -= cnt[i];
}
}
public static void Main(string[] args) => new Program().Solve();
}
namespace CompLib.Util {
using System;
using System.Linq;
class Scanner {
private string[] _line;
private int _index;
private const char Separator = ' ';
public Scanner() {
_line = new string[0];
_index = 0;
}
public string Next() {
while (_index >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_index = 0;
}
return _line[_index++];
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
public decimal NextDecimal() => decimal.Parse(Next());
public char NextChar() => Next()[0];
public char[] NextCharArray() => Next().ToCharArray();
public string[] Array() {
_line = Console.ReadLine().Split(Separator);
_index = _line.Length;
return _line;
}
public int[] IntArray() => Array().Select(int.Parse).ToArray();
public long[] LongArray() => Array().Select(long.Parse).ToArray();
public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
}
}
|
using System;
using CompLib.Util;
public class Program {
public void Solve() {
var sc = new Scanner();
int n = sc.NextInt();
long k = sc.NextLong();
int[] a = new int[n];
int[] b = new int[n];
for (int i = 0; i < n; i++) {
a[i] = sc.NextInt();
b[i] = sc.NextInt();
}
long[] cnt = new long[100001];
for (int i = 0; i < n; i++) {
cnt[a[i]] += b[i];
}
for (int i = 1; i < 100001; i++) {
if (cnt[i] >= k) {
Console.WriteLine(i);
return;
}
k -= cnt[i];
}
}
public static void Main(string[] args) => new Program().Solve();
}
namespace CompLib.Util {
using System;
using System.Linq;
class Scanner {
private string[] _line;
private int _index;
private const char Separator = ' ';
public Scanner() {
_line = new string[0];
_index = 0;
}
public string Next() {
while (_index >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_index = 0;
}
return _line[_index++];
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
public decimal NextDecimal() => decimal.Parse(Next());
public char NextChar() => Next()[0];
public char[] NextCharArray() => Next().ToCharArray();
public string[] Array() {
_line = Console.ReadLine().Split(Separator);
_index = _line.Length;
return _line;
}
public int[] IntArray() => Array().Select(int.Parse).ToArray();
public long[] LongArray() => Array().Select(long.Parse).ToArray();
public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
}
}
|
[["-", 0, 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, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 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]]
| 8
| 517
| 8
|
using System;
struct S {
public int A, B;
}
public class Program {
private int N;
private long K;
private S[] AB;
public void Solve() {
var sc = new Scanner();
N = sc.NextInt();
K = sc.NextInt();
AB = new S[N];
for (int i = 0; i < N; i++) {
AB[i] = new S() { A = sc.NextInt(), B = sc.NextInt() };
}
Array.Sort(AB, (a, b) => a.A.CompareTo(b.A));
int min = -1;
int max = 0;
for (int i = 0; i < N; i++) {
// [min,max)がA
min = max;
max += AB[i].B;
if (min <= K - 1 && K - 1 < max) {
Console.WriteLine(AB[i].A);
return;
}
}
}
public static void Main(string[] args) { new Program().Solve(); }
}
class Scanner {
public Scanner() {
_pos = 0;
_line = new string[0];
}
const char Separator = ' ';
private int _pos;
private string[] _line;
#region スペース区切りで取得
public string Next() {
if (_pos >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_pos = 0;
}
return _line[_pos++];
}
public int NextInt() { return int.Parse(Next()); }
public long NextLong() { return long.Parse(Next()); }
public double NextDouble() { return double.Parse(Next()); }
#endregion
#region 型変換
private int[] ToIntArray(string[] array) {
var result = new int[array.Length];
for (int i = 0; i < array.Length; i++) {
result[i] = int.Parse(array[i]);
}
return result;
}
private long[] ToLongArray(string[] array) {
var result = new long[array.Length];
for (int i = 0; i < array.Length; i++) {
result[i] = long.Parse(array[i]);
}
return result;
}
private double[] ToDoubleArray(string[] array) {
var result = new double[array.Length];
for (int i = 0; i < array.Length; i++) {
result[i] = double.Parse(array[i]);
}
return result;
}
#endregion
#region 配列取得
public string[] Array() {
if (_pos >= _line.Length)
_line = Console.ReadLine().Split(Separator);
_pos = _line.Length;
return _line;
}
public int[] IntArray() { return ToIntArray(Array()); }
public long[] LongArray() { return ToLongArray(Array()); }
public double[] DoubleArray() { return ToDoubleArray(Array()); }
#endregion
}
|
using System;
struct S {
public int A, B;
}
public class Program {
private int N;
private long K;
private S[] AB;
public void Solve() {
var sc = new Scanner();
N = sc.NextInt();
K = sc.NextLong();
AB = new S[N];
for (int i = 0; i < N; i++) {
AB[i] = new S() { A = sc.NextInt(), B = sc.NextInt() };
}
Array.Sort(AB, (a, b) => a.A.CompareTo(b.A));
long min = -1;
long max = 0;
for (int i = 0; i < N; i++) {
// [min,max)がA
min = max;
max += AB[i].B;
if (min <= K - 1 && K - 1 < max) {
Console.WriteLine(AB[i].A);
return;
}
}
}
public static void Main(string[] args) { new Program().Solve(); }
}
class Scanner {
public Scanner() {
_pos = 0;
_line = new string[0];
}
const char Separator = ' ';
private int _pos;
private string[] _line;
#region スペース区切りで取得
public string Next() {
if (_pos >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_pos = 0;
}
return _line[_pos++];
}
public int NextInt() { return int.Parse(Next()); }
public long NextLong() { return long.Parse(Next()); }
public double NextDouble() { return double.Parse(Next()); }
#endregion
#region 型変換
private int[] ToIntArray(string[] array) {
var result = new int[array.Length];
for (int i = 0; i < array.Length; i++) {
result[i] = int.Parse(array[i]);
}
return result;
}
private long[] ToLongArray(string[] array) {
var result = new long[array.Length];
for (int i = 0; i < array.Length; i++) {
result[i] = long.Parse(array[i]);
}
return result;
}
private double[] ToDoubleArray(string[] array) {
var result = new double[array.Length];
for (int i = 0; i < array.Length; i++) {
result[i] = double.Parse(array[i]);
}
return result;
}
#endregion
#region 配列取得
public string[] Array() {
if (_pos >= _line.Length)
_line = Console.ReadLine().Split(Separator);
_pos = _line.Length;
return _line;
}
public int[] IntArray() { return ToIntArray(Array()); }
public long[] LongArray() { return ToLongArray(Array()); }
public double[] DoubleArray() { return ToDoubleArray(Array()); }
#endregion
}
|
[["-", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
| 8
| 647
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class AtCoderA {
static void Main() {
var sc = new Scanner();
long n = sc.NextLong();
long k = sc.NextLong();
Tuple<int, int>[] nums = new Tuple<int, int>[n];
for (int i = 0; i < n; i++) {
nums[i] = Tuple.Create(sc.NextInt(), sc.NextInt());
}
nums.OrderBy(num => num.Item1).ToArray();
long answer = 0;
for (int i = 0; i < n; i++) {
var num = nums[i];
k -= num.Item2;
if (k <= 0) {
answer = num.Item1;
break;
}
}
Console.WriteLine(answer);
}
class Scanner {
private string[] _line;
private int _index;
private const char Separator = ' ';
public Scanner() {
_line = new string[0];
_index = 0;
}
public string Next() {
while (_index >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_index = 0;
}
return _line[_index++];
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
public decimal NextDecimal() => decimal.Parse(Next());
public char NextChar() => Next()[0];
public char[] NextCharArray() => Next().ToCharArray();
public string[] Array() {
_line = Console.ReadLine().Split(Separator);
_index = _line.Length;
return _line;
}
public int[] IntArray() => Array().Select(int.Parse).ToArray();
public long[] LongArray() => Array().Select(long.Parse).ToArray();
public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class AtCoderA {
static void Main() {
var sc = new Scanner();
long n = sc.NextLong();
long k = sc.NextLong();
Tuple<int, int>[] nums = new Tuple<int, int>[n];
for (int i = 0; i < n; i++) {
nums[i] = Tuple.Create(sc.NextInt(), sc.NextInt());
}
nums = nums.OrderBy(num => num.Item1).ToArray();
long answer = 0;
for (int i = 0; i < n; i++) {
var num = nums[i];
k -= num.Item2;
if (k <= 0) {
answer = num.Item1;
break;
}
}
Console.WriteLine(answer);
}
class Scanner {
private string[] _line;
private int _index;
private const char Separator = ' ';
public Scanner() {
_line = new string[0];
_index = 0;
}
public string Next() {
while (_index >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_index = 0;
}
return _line[_index++];
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
public decimal NextDecimal() => decimal.Parse(Next());
public char NextChar() => Next()[0];
public char[] NextCharArray() => Next().ToCharArray();
public string[] Array() {
_line = Console.ReadLine().Split(Separator);
_index = _line.Length;
return _line;
}
public int[] IntArray() => Array().Select(int.Parse).ToArray();
public long[] LongArray() => Array().Select(long.Parse).ToArray();
public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
}
}
|
[["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 12, 213, 63, 214, 205, 213, 63, 214, 205, 22]]
| 8
| 484
| 2
|
using System;
using System.Collections.Generic;
namespace cswork {
class Program {
public Program() {}
Scanner cin;
const int MAXIN = 1024;
bool[] used = new bool[MAXIN];
int[] perm = new int[MAXIN];
List<int[]> permList = new List<int[]>();
void Omame() {
cin = new Scanner();
int n = cin.nextInt();
int k = cin.nextInt();
Dictionary<long, long> dic = new Dictionary<long, long>();
for (long i = 0; i < n; i++) {
long a = cin.nextLong();
long b = cin.nextLong();
if (!dic.ContainsKey(a)) {
dic.Add(a, b);
} else {
dic[a] += b;
}
}
long count = 0;
for (long i = 1; i <= 100000; i++) {
if (dic.ContainsKey(i)) {
count += dic[i];
if (count >= k) {
Console.WriteLine(i);
return;
}
}
}
}
static void Main(string[] args) { new Program().Omame(); }
public void Permutation(int pos, int n, int length) {
if (pos == n) {
permList.Add((int[])perm.Clone());
}
for (int i = 0; i < n; i++) {
if (!used[i]) {
perm[pos] = i;
used[i] = true;
Permutation(pos + 1, n, length);
used[i] = false;
}
}
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
i = 0;
return next();
}
public int nextInt() { return int.Parse(next()); }
public long nextLong() { return long.Parse(next()); }
public double nextDouble() { return double.Parse(next()); }
}
}
|
using System;
using System.Collections.Generic;
namespace cswork {
class Program {
public Program() {}
Scanner cin;
const int MAXIN = 1024;
bool[] used = new bool[MAXIN];
int[] perm = new int[MAXIN];
List<int[]> permList = new List<int[]>();
void Omame() {
cin = new Scanner();
long n = cin.nextLong();
long k = cin.nextLong();
Dictionary<long, long> dic = new Dictionary<long, long>();
for (long i = 0; i < n; i++) {
long a = cin.nextLong();
long b = cin.nextLong();
if (!dic.ContainsKey(a)) {
dic.Add(a, b);
} else {
dic[a] += b;
}
}
long count = 0;
for (long i = 1; i <= 100000; i++) {
if (dic.ContainsKey(i)) {
count += dic[i];
if (count >= k) {
Console.WriteLine(i);
return;
}
}
}
}
static void Main(string[] args) { new Program().Omame(); }
public void Permutation(int pos, int n, int length) {
if (pos == n) {
permList.Add((int[])perm.Clone());
}
for (int i = 0; i < n; i++) {
if (!used[i]) {
perm[pos] = i;
used[i] = true;
Permutation(pos + 1, n, length);
used[i] = false;
}
}
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
i = 0;
return next();
}
public int nextInt() { return int.Parse(next()); }
public long nextLong() { return long.Parse(next()); }
public double nextDouble() { return double.Parse(next()); }
}
}
|
[["-", 0, 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, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22]]
| 8
| 524
| 8
|
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
class Program {
const string Yes = "Yes";
const string No = "No";
const char White = '.';
const char Black = '#';
const long Mod = 1000000007;
static void Main(string[] args) {
#if DEBUG
MyDebugger.Test(process, "../TextFile1.txt");
#else
object ret = process(new StreamReader(Console.OpenStandardInput()));
Console.WriteLine(ret);
#endif
}
static object process(TextReader input) {
var spl = input.ReadLine().Split(' ');
var n = int.Parse(spl[0]);
var k = int.Parse(spl[1]);
var ab = new int [n][];
for (int i = 0; i < n; i++) {
ab[i] = new int[2];
spl = input.ReadLine().Split(' ');
ab[i][0] = int.Parse(spl[0]);
ab[i][1] = int.Parse(spl[1]);
}
Array.Sort(ab, (x, y) => x[0] - y[0]);
long p = 0;
for (int i = 0; i < n; i++) {
var a = ab[i][0];
var b = ab[i][1];
p += b;
if (p >= k)
return a;
}
return -1;
}
static int[] ToIntArray(string strs, int n) {
var ret = new int[n];
var spl = strs.Split(' ');
for (int i = 0; i < n; i++)
ret[i] = int.Parse(spl[i]);
return ret;
}
}
|
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
class Program {
const string Yes = "Yes";
const string No = "No";
const char White = '.';
const char Black = '#';
const long Mod = 1000000007;
static void Main(string[] args) {
#if DEBUG
MyDebugger.Test(process, "../TextFile1.txt");
#else
object ret = process(new StreamReader(Console.OpenStandardInput()));
Console.WriteLine(ret);
#endif
}
static object process(TextReader input) {
var spl = input.ReadLine().Split(' ');
var n = int.Parse(spl[0]);
var k = long.Parse(spl[1]);
var ab = new int [n][];
for (int i = 0; i < n; i++) {
ab[i] = new int[2];
spl = input.ReadLine().Split(' ');
ab[i][0] = int.Parse(spl[0]);
ab[i][1] = int.Parse(spl[1]);
}
Array.Sort(ab, (x, y) => x[0] - y[0]);
long p = 0;
for (int i = 0; i < n; i++) {
var a = ab[i][0];
var b = ab[i][1];
p += b;
if (p >= k)
return a;
}
return -1;
}
static int[] ToIntArray(string strs, int n) {
var ret = new int[n];
var spl = strs.Split(' ');
for (int i = 0; i < n; i++)
ret[i] = int.Parse(spl[i]);
return ret;
}
}
|
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199]]
| 8
| 421
| 2
|
using Yorukatsu033.Questions;
using Yorukatsu033.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace Yorukatsu033.Questions {
/// <summary>
/// ABC061 C
/// </summary>
public class QuestionC : AtCoderQuestionBase {
public override IEnumerable<object> Solve(TextReader inputStream) {
var nk = inputStream.ReadIntArray();
var n = nk[0];
var k = nk[1];
var counts = new long[100001];
for (int i = 0; i < n; i++) {
var ab = inputStream.ReadIntArray();
var a = ab[0];
var b = ab[1];
counts[a] += b;
}
long picked = 0;
for (int i = 1; i < counts.Length; i++) {
picked += counts[i];
if (picked >= k) {
yield return i;
yield break;
}
}
}
}
}
namespace Yorukatsu033 {
class Program {
static void Main(string[] args) {
IAtCoderQuestion question = new QuestionC(); // 問題に合わせて書き換え
var answers = question.Solve(Console.In);
foreach (var answer in answers) {
Console.WriteLine(answer);
}
}
}
}
#region Base Classes
namespace Yorukatsu033.Questions {
public interface IAtCoderQuestion {
IEnumerable<object> Solve(string input);
IEnumerable<object> Solve(TextReader inputStream);
}
public abstract class AtCoderQuestionBase : IAtCoderQuestion {
public IEnumerable<object> Solve(string input) {
var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
var reader = new StreamReader(stream, Encoding.Unicode);
return Solve(reader);
}
public abstract IEnumerable<object> Solve(TextReader inputStream);
}
}
#endregion
#region Extensions
namespace Yorukatsu033.Extensions {
internal static class TextReaderExtensions {
internal static int
ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
internal static long
ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
internal static double
ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
internal static string
ReadString(this TextReader reader) => reader.ReadLine();
internal static int[] ReadIntArray(this TextReader reader,
char separator = ' ') =>
ReadStringArray(reader, separator).Select(int.Parse).ToArray();
internal static long[] ReadLongArray(this TextReader reader,
char separator = ' ') =>
ReadStringArray(reader, separator).Select(long.Parse).ToArray();
internal static double[] ReadDoubleArray(this TextReader reader,
char separator = ' ') =>
ReadStringArray(reader, separator).Select(double.Parse).ToArray();
internal static string[] ReadStringArray(this TextReader reader,
char separator = ' ') =>
reader.ReadLine().Split(separator);
}
}
#endregion
|
using Yorukatsu033.Questions;
using Yorukatsu033.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace Yorukatsu033.Questions {
/// <summary>
/// ABC061 C
/// </summary>
public class QuestionC : AtCoderQuestionBase {
public override IEnumerable<object> Solve(TextReader inputStream) {
var nk = inputStream.ReadLongArray();
var n = nk[0];
var k = nk[1];
var counts = new long[100001];
for (int i = 0; i < n; i++) {
var ab = inputStream.ReadIntArray();
var a = ab[0];
var b = ab[1];
counts[a] += b;
}
long picked = 0;
for (int i = 1; i < counts.Length; i++) {
picked += counts[i];
if (picked >= k) {
yield return i;
yield break;
}
}
}
}
}
namespace Yorukatsu033 {
class Program {
static void Main(string[] args) {
IAtCoderQuestion question = new QuestionC(); // 問題に合わせて書き換え
var answers = question.Solve(Console.In);
foreach (var answer in answers) {
Console.WriteLine(answer);
}
}
}
}
#region Base Classes
namespace Yorukatsu033.Questions {
public interface IAtCoderQuestion {
IEnumerable<object> Solve(string input);
IEnumerable<object> Solve(TextReader inputStream);
}
public abstract class AtCoderQuestionBase : IAtCoderQuestion {
public IEnumerable<object> Solve(string input) {
var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
var reader = new StreamReader(stream, Encoding.Unicode);
return Solve(reader);
}
public abstract IEnumerable<object> Solve(TextReader inputStream);
}
}
#endregion
#region Extensions
namespace Yorukatsu033.Extensions {
internal static class TextReaderExtensions {
internal static int
ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
internal static long
ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
internal static double
ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
internal static string
ReadString(this TextReader reader) => reader.ReadLine();
internal static int[] ReadIntArray(this TextReader reader,
char separator = ' ') =>
ReadStringArray(reader, separator).Select(int.Parse).ToArray();
internal static long[] ReadLongArray(this TextReader reader,
char separator = ' ') =>
ReadStringArray(reader, separator).Select(long.Parse).ToArray();
internal static double[] ReadDoubleArray(this TextReader reader,
char separator = ' ') =>
ReadStringArray(reader, separator).Select(double.Parse).ToArray();
internal static string[] ReadStringArray(this TextReader reader,
char separator = ' ') =>
reader.ReadLine().Split(separator);
}
}
#endregion
|
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22]]
| 8
| 584
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Numerics;
using static System.Math;
using static System.Array;
using static AtCoder.IO_ShortCut;
using static AtCoder.Tool;
using static AtCoder.ModInt;
namespace AtCoder {
class AC {
const int MOD = 1000000007;
// const int MOD = 998244353;
const int INF = int.MaxValue / 2;
const long SINF = long.MaxValue / 2;
const double EPS = 1e-8;
static readonly int[] dI = { 0, 1, 0, -1, 1, -1, -1, 1 };
static readonly int[] dJ = { 1, 0, -1, 0, 1, 1, -1, -1 };
static List<List<int>> G = new List<List<int>>();
// static List<List<Edge>> G = new List<List<Edge>>();
// static List<Edge> E = new List<Edge>();
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
static void Solve() {
int N, K;
Input(out N, out K);
var ls = new List<Tuple<long, long>>();
long sum = 0;
for (var i = 0; i < N; i++) {
long a, b;
Input(out a, out b);
ls.Add(new Tuple<long, long>(a, b));
}
ls.Sort();
for (var i = 0; i < N; i++) {
sum += ls[i].Item2;
if (sum >= K) {
OutL(ls[i].Item1);
return;
}
}
}
public struct Edge {
public int from;
public int to;
public long dist;
public Edge(int t, long c) {
from = -1;
to = t;
dist = c;
}
public Edge(int f, int t, long c) {
from = f;
to = t;
dist = c;
}
}
}
struct ModInt {
public long value;
private const int MOD = 1000000007;
// private const int MOD = 998244353;
public ModInt(long value) { this.value = value; }
public static implicit operator ModInt(long a) {
var ret = a % MOD;
return new ModInt(ret < 0 ? (ret + MOD) : ret);
}
public static ModInt operator +(ModInt a, ModInt b) => (a.value + b.value);
public static ModInt operator -(ModInt a, ModInt b) => (a.value - b.value);
public static ModInt operator *(ModInt a, ModInt b) => (a.value * b.value);
public static ModInt operator /(ModInt a, ModInt b) => a * Modpow(b, MOD - 2);
public static ModInt operator <<(ModInt a, int n) => (a.value << n);
public static ModInt operator>>(ModInt a, int n) => (a.value >> n);
public static ModInt operator ++(ModInt a) => a.value + 1;
public static ModInt operator --(ModInt a) => a.value - 1;
public static ModInt Modpow(ModInt a, long n) {
var k = a;
ModInt ret = 1;
while (n > 0) {
if ((n & 1) != 0)
ret *= k;
k *= k;
n >>= 1;
}
return ret;
}
private static readonly List<long> Factorials = new List<long>() { 1 };
public static ModInt Fac(long n) {
for (var i = Factorials.Count(); i <= n; i++) {
Factorials.Add((Factorials[i - 1] * i) % MOD);
}
return Factorials[(int)n];
}
public static ModInt nCr(long n, long r) {
return n < r ? 0 : Fac(n) / (Fac(r) * Fac(n - r));
}
public static explicit operator int(ModInt a) => (int)a.value;
}
static class IO_ShortCut {
public static string[] _ReadSplit => Console.ReadLine().Split();
public static int[] _ReadSplitInt =>
ConvertAll(Console.ReadLine().Split(), int.Parse);
public static long[] _ReadSplitLong =>
ConvertAll(Console.ReadLine().Split(), long.Parse);
public static double[] _ReadSplit_Double =>
ConvertAll(Console.ReadLine().Split(), double.Parse);
public static string Str => Console.ReadLine();
public static int Int => int.Parse(Console.ReadLine());
public static long Long => long.Parse(Console.ReadLine());
public static double Double => double.Parse(Console.ReadLine());
public static T Conv<T>(string input) {
if (typeof(T).Equals(typeof(ModInt))) {
return (T)(dynamic)(long.Parse(input));
}
return (T)Convert.ChangeType(input, typeof(T));
}
public static void Input<T>(out T a) => a = Conv<T>(Console.ReadLine());
public static void Input<T, U>(out T a, out U b) {
var q = _ReadSplit;
a = Conv<T>(q[0]);
b = Conv<U>(q[1]);
}
public static void Input<T, U, V>(out T a, out U b, out V c) {
var q = _ReadSplit;
a = Conv<T>(q[0]);
b = Conv<U>(q[1]);
c = Conv<V>(q[2]);
}
public static void Input<T, U, V, W>(out T a, out U b, out V c, out W d) {
var q = _ReadSplit;
a = Conv<T>(q[0]);
b = Conv<U>(q[1]);
c = Conv<V>(q[2]);
d = Conv<W>(q[3]);
}
public static void Input<T, U, V, W, X>(out T a, out U b, out V c, out W d,
out X e) {
var q = _ReadSplit;
a = Conv<T>(q[0]);
b = Conv<U>(q[1]);
c = Conv<V>(q[2]);
d = Conv<W>(q[3]);
e = Conv<X>(q[4]);
}
public static void OutL(object s) => Console.WriteLine(s);
public static void
Out_Sep<T>(IEnumerable<T> s) => Console.WriteLine(string.Join(" ", s));
public static void Out_Sep<T>(IEnumerable<T> s, string sep) =>
Console.WriteLine(string.Join($"{sep}", s));
public static void
Out_Sep(params object[] s) => Console.WriteLine(string.Join(" ", s));
public static void Out_One(object s) => Console.Write($"{s} ");
public static void Out_One(object s,
string sep) => Console.Write($"{s}{sep}");
public static void Endl() => Console.WriteLine();
}
public static class Tool {
static public void Initialize<T>(ref T[] array, T initialvalue) {
array = ConvertAll(array, x => initialvalue);
}
static public void Swap<T>(ref T a, ref T b) {
T keep = a;
a = b;
b = keep;
}
static public void Display<T>(T[,] array2d, int n, int m) {
for (var i = 0; i < n; i++) {
for (var j = 0; j < m; j++) {
Console.Write($"{array2d[i, j]} ");
}
Console.WriteLine();
}
}
static public long Gcd(long a, long b) {
if (a == 0 || b == 0)
return Max(a, b);
return a % b == 0 ? b : Gcd(b, a % b);
}
static public long LPow(int a, int b) => (long)Pow(a, b);
static public bool Bit(long x, int dig) => ((1L << dig) & x) != 0;
static public int Sig(long a) => a == 0 ? 0 : (int)(a / Abs(a));
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Numerics;
using static System.Math;
using static System.Array;
using static AtCoder.IO_ShortCut;
using static AtCoder.Tool;
using static AtCoder.ModInt;
namespace AtCoder {
class AC {
const int MOD = 1000000007;
// const int MOD = 998244353;
const int INF = int.MaxValue / 2;
const long SINF = long.MaxValue / 2;
const double EPS = 1e-8;
static readonly int[] dI = { 0, 1, 0, -1, 1, -1, -1, 1 };
static readonly int[] dJ = { 1, 0, -1, 0, 1, 1, -1, -1 };
static List<List<int>> G = new List<List<int>>();
// static List<List<Edge>> G = new List<List<Edge>>();
// static List<Edge> E = new List<Edge>();
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
static void Solve() {
int N;
long K;
Input(out N, out K);
var ls = new List<Tuple<long, long>>();
long sum = 0;
for (var i = 0; i < N; i++) {
long a, b;
Input(out a, out b);
ls.Add(new Tuple<long, long>(a, b));
}
ls.Sort();
for (var i = 0; i < N; i++) {
sum += ls[i].Item2;
if (sum >= K) {
OutL(ls[i].Item1);
return;
}
}
}
public struct Edge {
public int from;
public int to;
public long dist;
public Edge(int t, long c) {
from = -1;
to = t;
dist = c;
}
public Edge(int f, int t, long c) {
from = f;
to = t;
dist = c;
}
}
}
struct ModInt {
public long value;
private const int MOD = 1000000007;
// private const int MOD = 998244353;
public ModInt(long value) { this.value = value; }
public static implicit operator ModInt(long a) {
var ret = a % MOD;
return new ModInt(ret < 0 ? (ret + MOD) : ret);
}
public static ModInt operator +(ModInt a, ModInt b) => (a.value + b.value);
public static ModInt operator -(ModInt a, ModInt b) => (a.value - b.value);
public static ModInt operator *(ModInt a, ModInt b) => (a.value * b.value);
public static ModInt operator /(ModInt a, ModInt b) => a * Modpow(b, MOD - 2);
public static ModInt operator <<(ModInt a, int n) => (a.value << n);
public static ModInt operator>>(ModInt a, int n) => (a.value >> n);
public static ModInt operator ++(ModInt a) => a.value + 1;
public static ModInt operator --(ModInt a) => a.value - 1;
public static ModInt Modpow(ModInt a, long n) {
var k = a;
ModInt ret = 1;
while (n > 0) {
if ((n & 1) != 0)
ret *= k;
k *= k;
n >>= 1;
}
return ret;
}
private static readonly List<long> Factorials = new List<long>() { 1 };
public static ModInt Fac(long n) {
for (var i = Factorials.Count(); i <= n; i++) {
Factorials.Add((Factorials[i - 1] * i) % MOD);
}
return Factorials[(int)n];
}
public static ModInt nCr(long n, long r) {
return n < r ? 0 : Fac(n) / (Fac(r) * Fac(n - r));
}
public static explicit operator int(ModInt a) => (int)a.value;
}
static class IO_ShortCut {
public static string[] _ReadSplit => Console.ReadLine().Split();
public static int[] _ReadSplitInt =>
ConvertAll(Console.ReadLine().Split(), int.Parse);
public static long[] _ReadSplitLong =>
ConvertAll(Console.ReadLine().Split(), long.Parse);
public static double[] _ReadSplit_Double =>
ConvertAll(Console.ReadLine().Split(), double.Parse);
public static string Str => Console.ReadLine();
public static int Int => int.Parse(Console.ReadLine());
public static long Long => long.Parse(Console.ReadLine());
public static double Double => double.Parse(Console.ReadLine());
public static T Conv<T>(string input) {
if (typeof(T).Equals(typeof(ModInt))) {
return (T)(dynamic)(long.Parse(input));
}
return (T)Convert.ChangeType(input, typeof(T));
}
public static void Input<T>(out T a) => a = Conv<T>(Console.ReadLine());
public static void Input<T, U>(out T a, out U b) {
var q = _ReadSplit;
a = Conv<T>(q[0]);
b = Conv<U>(q[1]);
}
public static void Input<T, U, V>(out T a, out U b, out V c) {
var q = _ReadSplit;
a = Conv<T>(q[0]);
b = Conv<U>(q[1]);
c = Conv<V>(q[2]);
}
public static void Input<T, U, V, W>(out T a, out U b, out V c, out W d) {
var q = _ReadSplit;
a = Conv<T>(q[0]);
b = Conv<U>(q[1]);
c = Conv<V>(q[2]);
d = Conv<W>(q[3]);
}
public static void Input<T, U, V, W, X>(out T a, out U b, out V c, out W d,
out X e) {
var q = _ReadSplit;
a = Conv<T>(q[0]);
b = Conv<U>(q[1]);
c = Conv<V>(q[2]);
d = Conv<W>(q[3]);
e = Conv<X>(q[4]);
}
public static void OutL(object s) => Console.WriteLine(s);
public static void
Out_Sep<T>(IEnumerable<T> s) => Console.WriteLine(string.Join(" ", s));
public static void Out_Sep<T>(IEnumerable<T> s, string sep) =>
Console.WriteLine(string.Join($"{sep}", s));
public static void
Out_Sep(params object[] s) => Console.WriteLine(string.Join(" ", s));
public static void Out_One(object s) => Console.Write($"{s} ");
public static void Out_One(object s,
string sep) => Console.Write($"{s}{sep}");
public static void Endl() => Console.WriteLine();
}
public static class Tool {
static public void Initialize<T>(ref T[] array, T initialvalue) {
array = ConvertAll(array, x => initialvalue);
}
static public void Swap<T>(ref T a, ref T b) {
T keep = a;
a = b;
b = keep;
}
static public void Display<T>(T[,] array2d, int n, int m) {
for (var i = 0; i < n; i++) {
for (var j = 0; j < m; j++) {
Console.Write($"{array2d[i, j]} ");
}
Console.WriteLine();
}
}
static public long Gcd(long a, long b) {
if (a == 0 || b == 0)
return Max(a, b);
return a % b == 0 ? b : Gcd(b, a % b);
}
static public long LPow(int a, int b) => (long)Pow(a, b);
static public bool Bit(long x, int dig) => ((1L << dig) & x) != 0;
static public int Sig(long a) => a == 0 ? 0 : (int)(a / Abs(a));
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 0, 21], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
| 8
| 1,854
| 3
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AtCoder {
class Program {
static void Main(string[] args) {
var firstLine = Console.ReadLine()
.Split(' ')
.Select(value => long.Parse(value))
.ToArray();
var n = firstLine[0];
var k = firstLine[1];
var numbers = new List<int[]>();
for (var i = 0; i < n; i++) {
numbers.Add(Console.ReadLine()
.Split(' ')
.Select(value => int.Parse(value))
.ToArray());
}
var dictionary = new Dictionary<int, long>();
foreach (var number in numbers) {
if (!dictionary.ContainsKey(number[0])) {
dictionary.Add(number[0], 0);
}
dictionary[number[0]] += number[1];
}
var orderdDictionary = dictionary.OrderBy(keyValuePair => keyValuePair.Key);
long count = 0;
foreach (var keyValuePair in dictionary) {
count += keyValuePair.Value;
if (count >= k) {
Console.WriteLine(keyValuePair.Key);
return;
}
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AtCoder {
class Program {
static void Main(string[] args) {
var firstLine = Console.ReadLine()
.Split(' ')
.Select(value => long.Parse(value))
.ToArray();
var n = firstLine[0];
var k = firstLine[1];
var numbers = new List<int[]>();
for (var i = 0; i < n; i++) {
numbers.Add(Console.ReadLine()
.Split(' ')
.Select(value => int.Parse(value))
.ToArray());
}
var dictionary = new Dictionary<int, long>();
foreach (var number in numbers) {
if (!dictionary.ContainsKey(number[0])) {
dictionary.Add(number[0], 0);
}
dictionary[number[0]] += number[1];
}
var orderdDictionary = dictionary.OrderBy(keyValuePair => keyValuePair.Key);
long count = 0;
foreach (var keyValuePair in orderdDictionary) {
count += keyValuePair.Value;
if (count >= k) {
Console.WriteLine(keyValuePair.Key);
return;
}
}
}
}
}
|
[["-", 8, 201, 0, 195, 8, 196, 0, 210, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 210, 12, 22]]
| 8
| 265
| 2
|
using System;
using System.Linq;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using static System.Console;
using static Program.Input;
using static Program.MyMath;
using static Program.Const;
namespace Program {
static class Const {
public static string alp = "abcdefghijklmnopqrstuvwxyz";
public static string Alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
public const long MOD = 1000000007;
public static int INF = int.MaxValue;
public static long INFL = long.MaxValue;
}
public static class Program {
public static void Main() {
long n, k;
InputLine(out n, out k);
var array = new long[100001];
int a, b;
for (int i = 0; i < n; i++) {
InputLine(out a, out b);
array[a] += b;
}
int res;
for (res = 0; res < n; res++) {
k -= array[res];
if (k <= 0)
break;
}
WriteLine(res);
// ReadKey();
}
}
static class Input {
public static void InputLine(out int a, out int b) {
var input = ScanIntArray();
a = input[0];
b = input[1];
}
public static void InputLine(out int a, out int b, out int c) {
var input = ScanIntArray();
a = input[0];
b = input[1];
c = input[2];
}
public static void InputLine(out int a, out int b, out int c, out int d) {
var input = ScanIntArray();
a = input[0];
b = input[1];
c = input[2];
d = input[3];
}
public static void InputLine(out long a, out long b) {
var input = ScanLongArray();
a = input[0];
b = input[1];
}
public static void InputLine(out long a, out long b, out long c) {
var input = ScanLongArray();
a = input[0];
b = input[1];
c = input[2];
}
public static void InputLine(out long a, out long b, out long c, out long d) {
var input = ScanLongArray();
a = input[0];
b = input[1];
c = input[2];
d = input[3];
}
public static void InputLine(out string a, out string b) {
var input = ScanStrArray();
a = input[0];
b = input[1];
}
public static int ScanInt() { return int.Parse(ReadLine()); }
static public uint ScanUint() { return uint.Parse(ReadLine()); }
static public double ScanDouble() { return double.Parse(ReadLine()); }
static public long ScanLong() { return long.Parse(ReadLine()); }
static public ulong ScanUlong() { return ulong.Parse(ReadLine()); }
static public int[] ScanIntArray() {
return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
}
static public uint[] ScanUintArray() {
return ReadLine().Split().Select(x => uint.Parse(x)).ToArray();
}
static public double[] ScanDoubleArray() {
return ReadLine().Split().Select(x => double.Parse(x)).ToArray();
}
static public long[] ScanLongArray() {
return ReadLine().Split().Select(x => long.Parse(x)).ToArray();
}
static public ulong[] ScanUlongArray() {
return ReadLine().Split().Select(x => ulong.Parse(x)).ToArray();
}
static public string ScanStr() { return ReadLine(); }
static public string[] ScanStrArray() { return ScanStr().Split(); }
static public string RegaxReplace(this string arg1, string pattern,
string replacement) {
return Regex.Replace(arg1, pattern, replacement);
}
}
static class MyMath {
static public int CountBit(this long a) {
if (a == 0)
return 0;
int c = 1;
for (; a > 1; a /= 2)
if (a % 2 == 1)
c++;
return c;
}
static public int Floor2(this int a) {
int N = 1;
while (N < a)
N *= 2;
return N / 2;
}
static public long Floor2(this long a) {
long N = 1;
while (N < a)
N *= 2;
return N / 2;
}
static public int Ceiling2(this int a) {
int N = 1;
while (N < a)
N *= 2;
return N;
}
static public long Ceiling2(this long a) {
long N = 1;
while (N < a)
N *= 2;
return N;
}
static public long[] CumSum(this long[] a) {
var res = new long[a.Length];
long s = 0;
for (int i = 0; i < a.Length; i++)
res[i] = (s += a[i]);
return res;
}
static public IEnumerable<int> PrimeFactors(this int n) {
int tmp = n;
for (int i = 2; i * i <= n; i++)
while (tmp % i == 0) {
tmp /= i;
yield return i;
}
if (tmp != 1)
yield return tmp;
}
static public IEnumerable<long> PrimeFactors(this long n) {
var tmp = n;
for (long i = 2; i * i <= n; i++)
while (tmp % i == 0) {
tmp /= i;
yield return i;
}
if (tmp != 1)
yield return tmp;
}
static public int Digit(this int n, int d) {
if (d < 0)
return 0;
return (n % (int)Math.Pow(10, d + 1)) / (int)Math.Pow(10, d);
}
static public int Length(this int n) {
if (n < 0)
return 0;
return (int)Math.Log10(n) + 1;
}
static public int Top(this int n) { return n.Digit(n.Length() - 1); }
public static bool isPrime(this int p) {
if (p <= 1)
return false;
for (int i = 2; i * i <= p; i++)
if (p % i == 0)
return false;
return true;
}
public static bool isPrime(this long p) {
if (p <= 1)
return false;
for (long i = 2; i * i <= p; i++)
if (p % i == 0)
return false;
return true;
}
public static int GCD(int a, int b) {
Func<int, int, int> gcd = null;
gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
return a > b ? gcd(a, b) : gcd(b, a);
}
public static long GCD(long a, long b) {
Func<long, long, long> gcd = null;
gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
return a > b ? gcd(a, b) : gcd(b, a);
}
public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
var d = extGCD(b, a % b, ref y, ref x);
y -= a / b * x;
return d;
}
public static int LCM(int a, int b) { return a * b / GCD(a, b); }
public static long LCM(long a, long b) { return a * b / GCD(a, b); }
public static long Inv(this long a, long m = MOD) {
long b = m, u = 1, v = 0;
while (b != 0) {
long t = a / b;
a -= t * b;
swap(ref a, ref b);
u -= t * v;
swap(ref u, ref v);
}
u %= m;
if (u < 0)
u += m;
return u;
}
private static void swap(ref long a, ref long b) {
var t = a;
a = b;
b = t;
}
public static long ModPow(long a, long n, long m = MOD) {
long res = 1;
while (n > 0) {
if (n % 2 == 1)
res = (res * a) % m;
a = (a * a) % m;
n >>= 1;
}
return res;
}
}
static class MyLinq {
public static void Sort(this string[] array) {
Array.Sort(array, StringComparer.OrdinalIgnoreCase);
}
public static void StringSort(this List<string> list) {
list.Sort(StringComparer.OrdinalIgnoreCase);
}
public static string Join<T>(this IEnumerable<T> source, string separator) {
return string.Join(separator, source);
}
public static IEnumerable<TItem>
Distinct<TItem, TKey>(this IEnumerable<TItem> source,
Func<TItem, TKey> keySelector) {
if (source == null)
throw new ArgumentNullException(nameof(source));
if (keySelector == null)
throw new ArgumentNullException(nameof(keySelector));
var set = new HashSet<TKey>();
foreach (var item in source)
if (set.Add(keySelector(item)))
yield return item;
}
}
}
|
using System;
using System.Linq;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using static System.Console;
using static Program.Input;
using static Program.MyMath;
using static Program.Const;
namespace Program {
static class Const {
public static string alp = "abcdefghijklmnopqrstuvwxyz";
public static string Alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
public const long MOD = 1000000007;
public static int INF = int.MaxValue;
public static long INFL = long.MaxValue;
}
public static class Program {
public static void Main() {
long n, k;
InputLine(out n, out k);
var array = new long[100001];
int a, b;
for (int i = 0; i < n; i++) {
InputLine(out a, out b);
array[a] += b;
}
int res;
for (res = 0; res <= 100000; res++) {
k -= array[res];
if (k <= 0)
break;
}
WriteLine(res);
// ReadKey();
}
}
static class Input {
public static void InputLine(out int a, out int b) {
var input = ScanIntArray();
a = input[0];
b = input[1];
}
public static void InputLine(out int a, out int b, out int c) {
var input = ScanIntArray();
a = input[0];
b = input[1];
c = input[2];
}
public static void InputLine(out int a, out int b, out int c, out int d) {
var input = ScanIntArray();
a = input[0];
b = input[1];
c = input[2];
d = input[3];
}
public static void InputLine(out long a, out long b) {
var input = ScanLongArray();
a = input[0];
b = input[1];
}
public static void InputLine(out long a, out long b, out long c) {
var input = ScanLongArray();
a = input[0];
b = input[1];
c = input[2];
}
public static void InputLine(out long a, out long b, out long c, out long d) {
var input = ScanLongArray();
a = input[0];
b = input[1];
c = input[2];
d = input[3];
}
public static void InputLine(out string a, out string b) {
var input = ScanStrArray();
a = input[0];
b = input[1];
}
public static int ScanInt() { return int.Parse(ReadLine()); }
static public uint ScanUint() { return uint.Parse(ReadLine()); }
static public double ScanDouble() { return double.Parse(ReadLine()); }
static public long ScanLong() { return long.Parse(ReadLine()); }
static public ulong ScanUlong() { return ulong.Parse(ReadLine()); }
static public int[] ScanIntArray() {
return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
}
static public uint[] ScanUintArray() {
return ReadLine().Split().Select(x => uint.Parse(x)).ToArray();
}
static public double[] ScanDoubleArray() {
return ReadLine().Split().Select(x => double.Parse(x)).ToArray();
}
static public long[] ScanLongArray() {
return ReadLine().Split().Select(x => long.Parse(x)).ToArray();
}
static public ulong[] ScanUlongArray() {
return ReadLine().Split().Select(x => ulong.Parse(x)).ToArray();
}
static public string ScanStr() { return ReadLine(); }
static public string[] ScanStrArray() { return ScanStr().Split(); }
static public string RegaxReplace(this string arg1, string pattern,
string replacement) {
return Regex.Replace(arg1, pattern, replacement);
}
}
static class MyMath {
static public int CountBit(this long a) {
if (a == 0)
return 0;
int c = 1;
for (; a > 1; a /= 2)
if (a % 2 == 1)
c++;
return c;
}
static public int Floor2(this int a) {
int N = 1;
while (N < a)
N *= 2;
return N / 2;
}
static public long Floor2(this long a) {
long N = 1;
while (N < a)
N *= 2;
return N / 2;
}
static public int Ceiling2(this int a) {
int N = 1;
while (N < a)
N *= 2;
return N;
}
static public long Ceiling2(this long a) {
long N = 1;
while (N < a)
N *= 2;
return N;
}
static public long[] CumSum(this long[] a) {
var res = new long[a.Length];
long s = 0;
for (int i = 0; i < a.Length; i++)
res[i] = (s += a[i]);
return res;
}
static public IEnumerable<int> PrimeFactors(this int n) {
int tmp = n;
for (int i = 2; i * i <= n; i++)
while (tmp % i == 0) {
tmp /= i;
yield return i;
}
if (tmp != 1)
yield return tmp;
}
static public IEnumerable<long> PrimeFactors(this long n) {
var tmp = n;
for (long i = 2; i * i <= n; i++)
while (tmp % i == 0) {
tmp /= i;
yield return i;
}
if (tmp != 1)
yield return tmp;
}
static public int Digit(this int n, int d) {
if (d < 0)
return 0;
return (n % (int)Math.Pow(10, d + 1)) / (int)Math.Pow(10, d);
}
static public int Length(this int n) {
if (n < 0)
return 0;
return (int)Math.Log10(n) + 1;
}
static public int Top(this int n) { return n.Digit(n.Length() - 1); }
public static bool isPrime(this int p) {
if (p <= 1)
return false;
for (int i = 2; i * i <= p; i++)
if (p % i == 0)
return false;
return true;
}
public static bool isPrime(this long p) {
if (p <= 1)
return false;
for (long i = 2; i * i <= p; i++)
if (p % i == 0)
return false;
return true;
}
public static int GCD(int a, int b) {
Func<int, int, int> gcd = null;
gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
return a > b ? gcd(a, b) : gcd(b, a);
}
public static long GCD(long a, long b) {
Func<long, long, long> gcd = null;
gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
return a > b ? gcd(a, b) : gcd(b, a);
}
public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
var d = extGCD(b, a % b, ref y, ref x);
y -= a / b * x;
return d;
}
public static int LCM(int a, int b) { return a * b / GCD(a, b); }
public static long LCM(long a, long b) { return a * b / GCD(a, b); }
public static long Inv(this long a, long m = MOD) {
long b = m, u = 1, v = 0;
while (b != 0) {
long t = a / b;
a -= t * b;
swap(ref a, ref b);
u -= t * v;
swap(ref u, ref v);
}
u %= m;
if (u < 0)
u += m;
return u;
}
private static void swap(ref long a, ref long b) {
var t = a;
a = b;
b = t;
}
public static long ModPow(long a, long n, long m = MOD) {
long res = 1;
while (n > 0) {
if (n % 2 == 1)
res = (res * a) % m;
a = (a * a) % m;
n >>= 1;
}
return res;
}
}
static class MyLinq {
public static void Sort(this string[] array) {
Array.Sort(array, StringComparer.OrdinalIgnoreCase);
}
public static void StringSort(this List<string> list) {
list.Sort(StringComparer.OrdinalIgnoreCase);
}
public static string Join<T>(this IEnumerable<T> source, string separator) {
return string.Join(separator, source);
}
public static IEnumerable<TItem>
Distinct<TItem, TKey>(this IEnumerable<TItem> source,
Func<TItem, TKey> keySelector) {
if (source == null)
throw new ArgumentNullException(nameof(source));
if (keySelector == null)
throw new ArgumentNullException(nameof(keySelector));
var set = new HashSet<TKey>();
foreach (var item in source)
if (set.Add(keySelector(item)))
yield return item;
}
}
}
|
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203]]
| 8
| 2,053
| 4
|
using System;
using System.Linq;
using System.Collections.Generic;
class MainClass {
public static void Main(string[] args) {
var list = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
var N = list[0];
var K = list[1];
var dic = new Dictionary<long, long>();
for (var i = 0; i < N; i++) {
var temp = Console.ReadLine().Split(' ').Select(long.Parse);
if (dic.ContainsKey(temp.ElementAt(0))) {
dic[temp.ElementAt(0)] += temp.ElementAt(1);
} else {
dic.Add(temp.ElementAt(0), temp.ElementAt(1));
}
}
var a = dic.Select(x => x).OrderBy(x => x.Key).ToList();
var sum = (long)0;
for (var i = 0; i < N; i++) {
sum += a[i].Value;
if (sum > K) {
Console.WriteLine(a[i].Key);
return;
}
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
class MainClass {
public static void Main(string[] args) {
var list = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
var N = list[0];
var K = list[1];
var dic = new Dictionary<long, long>();
for (var i = 0; i < N; i++) {
var temp = Console.ReadLine().Split(' ').Select(long.Parse);
if (dic.ContainsKey(temp.ElementAt(0))) {
dic[temp.ElementAt(0)] += temp.ElementAt(1);
} else {
dic.Add(temp.ElementAt(0), temp.ElementAt(1));
}
}
var a = dic.Select(x => x).OrderBy(x => x.Key).ToList();
var sum = (long)0;
for (var i = 0; i < N; i++) {
sum += a[i].Value;
if (sum >= K) {
Console.WriteLine(a[i].Key);
return;
}
}
}
}
|
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 20]]
| 8
| 261
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;
namespace CP {
class Atria {
static void Main(string[] args) {
int[] nk = ReadLine().Split(' ').Select(int.Parse).ToArray();
var sortedDic = new SortedDictionary<int, long>();
for (int i = 0; i < nk[0]; i++) {
long[] s = ReadLine().Split(' ').Select(long.Parse).ToArray();
try {
sortedDic.Add((int)s[0], s[1]);
} catch (Exception) {
sortedDic[(int)s[0]] += s[1];
}
}
long tmp = 0;
int j = 0;
foreach (var item in sortedDic) {
j++;
tmp += item.Value;
if (tmp >= nk[1]) {
WriteLine(item.Key);
return;
}
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;
namespace CP {
class Atria {
static void Main(string[] args) {
long[] nk = ReadLine().Split(' ').Select(long.Parse).ToArray();
var sortedDic = new SortedDictionary<int, long>();
for (int i = 0; i < nk[0]; i++) {
long[] s = ReadLine().Split(' ').Select(long.Parse).ToArray();
try {
sortedDic.Add((int)s[0], s[1]);
} catch (Exception) {
sortedDic[(int)s[0]] += s[1];
}
}
long tmp = 0;
int j = 0;
foreach (var item in sortedDic) {
j++;
tmp += item.Value;
if (tmp >= nk[1]) {
WriteLine(item.Key);
return;
}
}
}
}
}
|
[["-", 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
| 233
| 4
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCorder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
var N = cin.ReadInt;
var K = cin.ReadInt;
var dic = new Dictionary<int, long>();
for (int i = 0; i < N; i++) {
var a = cin.ReadInt;
var b = cin.ReadInt;
if (!dic.ContainsKey(a)) {
dic.Add(a, b);
} else {
dic[a] += b;
}
}
var SortDic = dic.OrderBy(a => a.Key);
var count = 0L;
foreach (var v in SortDic) {
count += v.Value;
if (count < K) {
continue;
} else {
WriteLine(v.Key);
return;
}
}
}
public long C(int X, int Y) {
if (Y == 0 || Y == X) {
return 1;
}
if (X < Y) {
return 0;
}
var Pascal = new long[X + 1, X + 1];
for (int i = 0; i <= X; i++) {
Pascal[i, 0] = 1L;
Pascal[i, i] = 1L;
}
for (int i = 2; i <= X; i++) {
for (int j = 1; j < i; j++) {
Pascal[i, j] = Pascal[i - 1, j] + Pascal[i - 1, j - 1];
}
}
return Pascal[X, Y];
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
}
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCorder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
var N = cin.ReadInt;
var K = cin.ReadLong;
var dic = new Dictionary<int, long>();
for (int i = 0; i < N; i++) {
var a = cin.ReadInt;
var b = cin.ReadInt;
if (!dic.ContainsKey(a)) {
dic.Add(a, b);
} else {
dic[a] += b;
}
}
var SortDic = dic.OrderBy(a => a.Key);
var count = 0L;
foreach (var v in SortDic) {
count += v.Value;
if (count < K) {
continue;
} else {
WriteLine(v.Key);
return;
}
}
}
public long C(int X, int Y) {
if (Y == 0 || Y == X) {
return 1;
}
if (X < Y) {
return 0;
}
var Pascal = new long[X + 1, X + 1];
for (int i = 0; i <= X; i++) {
Pascal[i, 0] = 1L;
Pascal[i, i] = 1L;
}
for (int i = 2; i <= X; i++) {
for (int j = 1; j < i; j++) {
Pascal[i, j] = Pascal[i - 1, j] + Pascal[i - 1, j - 1];
}
}
return Pascal[X, Y];
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 214, 141, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 141, 22]]
| 8
| 722
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace CSharpSample01 {
class Program {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int N = int.Parse(input[0]);
long K = int.Parse(input[1]);
Dictionary<int, long> dic = new Dictionary<int, long>();
for (int i = 0; i < N; i++) {
input = Console.ReadLine().Split(' ');
int a = int.Parse(input[0]);
long b = long.Parse(input[1]);
if (!dic.ContainsKey(a)) {
dic[a] = b;
} else {
dic[a] += b;
}
}
var dic_sort = dic.OrderBy(x => x.Key);
long cnt = 0;
int ans = -1;
foreach (var s in dic_sort) {
int val = s.Key;
long num = s.Value;
if (cnt + num < K) {
cnt += num;
} else {
ans = val;
break;
}
}
Console.WriteLine(ans);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace CSharpSample01 {
class Program {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int N = int.Parse(input[0]);
long K = long.Parse(input[1]);
Dictionary<int, long> dic = new Dictionary<int, long>();
for (int i = 0; i < N; i++) {
input = Console.ReadLine().Split(' ');
int a = int.Parse(input[0]);
long b = long.Parse(input[1]);
if (!dic.ContainsKey(a)) {
dic[a] = b;
} else {
dic[a] += b;
}
}
var dic_sort = dic.OrderBy(x => x.Key);
long cnt = 0;
int ans = -1;
foreach (var s in dic_sort) {
int val = s.Key;
long num = s.Value;
if (cnt + num < K) {
cnt += num;
} else {
ans = val;
break;
}
}
Console.WriteLine(ans);
}
}
}
|
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199]]
| 8
| 260
| 2
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.