buggy_code
stringlengths 11
625k
| fixed_code
stringlengths 17
625k
| bug_type
stringlengths 2
4.45k
| language
int64 0
8
| token_count
int64 5
200k
| change_count
int64 0
100
|
|---|---|---|---|---|---|
using System;
using System.Collections.Generic;
using System.Linq;
public static class Solution {
public static void Main() {
var vals = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
var X = Math.Abs(vals[0]);
var K = vals[1];
var D = vals[2];
if (K % 2 != 0) {
X = Math.Abs(X - D);
K--;
}
var k = Math.Min(X / D / 2 * 2, K);
X -= k * D;
K -= k;
if (k > 0) {
X = Math.Min(X, Math.Abs(X - 2 * D));
}
Console.WriteLine(X);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
public static class Solution {
public static void Main() {
var vals = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
var X = Math.Abs(vals[0]);
var K = vals[1];
var D = vals[2];
if (K % 2 != 0) {
X = Math.Abs(X - D);
K--;
}
var k = Math.Min(X / D / 2 * 2, K);
X -= k * D;
K -= k;
if (K > 0) {
X = Math.Min(X, Math.Abs(X - 2 * D));
}
Console.WriteLine(X);
}
}
|
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22]]
| 8
| 172
| 2
|
using System;
using System.CodeDom;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
namespace AtCoder {
public static class Ex {
public static bool IsNullOrEmpty(this string s) {
return string.IsNullOrEmpty(s);
}
public static List<string> FastSort(this List<string> s) {
s.Sort(StringComparer.OrdinalIgnoreCase);
return s.ToList();
}
public static void yesno(this bool b) { Console.WriteLine(b ? "yes" : "no"); }
public static void YesNo(this bool b) { Console.WriteLine(b ? "Yes" : "No"); }
public static void YESNO(this bool b) { Console.WriteLine(b ? "YES" : "NO"); }
public static int PopCount(this int bits) {
bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff);
}
}
partial class AtCoder {
public string GetStr() { return Console.ReadLine().Trim(); }
public char GetChar() { return Console.ReadLine().Trim()[0]; }
public int GetInt() { return int.Parse(Console.ReadLine().Trim()); }
public long GetLong() { return long.Parse(Console.ReadLine().Trim()); }
public double GetDouble() { return double.Parse(Console.ReadLine().Trim()); }
public string[] GetStrArray() { return Console.ReadLine().Trim().Split(' '); }
public int[] GetIntArray() {
return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
}
public long[] GetLongArray() {
return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
}
public char[] GetCharArray() {
return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray();
}
public double[] GetDoubleArray() {
return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();
}
public T[][] CreateJaggedArray<T>(int H, int W, T value) {
return Enumerable.Repeat(0, H)
.Select(s => Enumerable.Repeat(value, W).ToArray())
.ToArray();
}
public int[][] GetIntJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetIntArray().ToArray())
.ToArray();
}
public long[][] GetLongJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetLongArray().ToArray())
.ToArray();
}
public char[][] GetCharJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetStr().ToCharArray())
.ToArray();
}
public double[][] GetDoubleJaggedArray(int N) {
return Enumerable.Repeat(0, N).Select(s => GetDoubleArray()).ToArray();
}
Dictionary<int, List<int>> GetUnweightedAdjacencyList(int N, int M,
bool isDirected,
bool isNode_0indexed) {
var dic = new Dictionary<int, List<int>>();
foreach (var e in Enumerable.Range(0, N)) {
dic.Add(e, new List<int>());
}
for (int i = 0; i < M; i++) {
var input = GetIntArray();
var a = isNode_0indexed ? input[0] : input[0] - 1;
var b = isNode_0indexed ? input[1] : input[1] - 1;
dic[a].Add(b);
if (isDirected == false)
dic[b].Add(a);
}
return dic;
}
Dictionary<int, List<Edge>> GetWeightedAdjacencyList(int N, int M,
bool isDirected,
bool isNode_0indexed) {
var dic = new Dictionary<int, List<Edge>>();
foreach (var e in Enumerable.Range(0, N)) {
dic.Add(e, new List<Edge>());
}
for (int i = 0; i < M; i++) {
var input = GetIntArray();
var a = isNode_0indexed ? input[0] : input[0] - 1;
var b = isNode_0indexed ? input[1] : input[1] - 1;
var c = input[2];
dic[a].Add(new Edge(b, c));
if (isDirected == false)
dic[b].Add(new Edge(a, c));
}
return dic;
}
bool eq<T, U>() => typeof(T).Equals(typeof(U));
T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
: eq<T, long>() ? ct<T, long>(long.Parse(s))
: eq<T, double>() ? ct<T, double>(double.Parse(s))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
void Multi<T>(out T a) => a = cv<T>(GetStr());
void Multi<T, U>(out T a, out U b) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
}
void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
}
void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e,
out Y f) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
f = cv<Y>(ar[5]);
}
int[] dx = new int[] { 1, 0, -1, 0, 1, 1, -1, -1 };
int[] dy = new int[] { 0, 1, 0, -1, 1, -1, 1, -1 };
}
class Pair : IComparable<Pair> {
public Pair(int node, long cost) {
Node = node;
Cost = cost;
}
public int Node { get; set; }
public long Cost { get; set; }
public int CompareTo(Pair p) { return p.Cost > Cost ? 1 : -1; }
}
class Edge {
public Edge(int to, long length) {
To = to;
Length = length;
}
public int To { get; set; }
public long Length { get; set; }
}
class Comparable : IComparable<Comparable> {
public Comparable(int value) { Value = value; }
public int Value { get; set; }
public int CompareTo(Comparable c) {
var a = Math.Abs(Value);
var b = Math.Abs(c.Value);
return a > b ? 1 : a == b ? 0 : -1;
}
}
class Comparer<T> : IComparer<T> {
public int Compare(T t1, T t2) { return 1; }
}
partial class Program {
static void Main() {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
new AtCoder().Solve();
Console.Out.Flush();
Console.Read();
}
}
public partial class AtCoder {
public void Solve() {
long X, K, D;
Multi(out X, out K, out D);
var mod1 = X % D;
var num1 = Math.Abs((X - mod1) / D);
var num2 = num1 + 1;
if (num1 > K)
Console.WriteLine(Math.Abs(X) - D * K);
else if (num1 == K || (K - num1) % 2 == 0)
Console.WriteLine(Math.Abs(mod1));
else
Console.WriteLine(Math.Abs(Math.Abs(X - D * num2)));
}
}
}
|
using System;
using System.CodeDom;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
namespace AtCoder {
public static class Ex {
public static bool IsNullOrEmpty(this string s) {
return string.IsNullOrEmpty(s);
}
public static List<string> FastSort(this List<string> s) {
s.Sort(StringComparer.OrdinalIgnoreCase);
return s.ToList();
}
public static void yesno(this bool b) { Console.WriteLine(b ? "yes" : "no"); }
public static void YesNo(this bool b) { Console.WriteLine(b ? "Yes" : "No"); }
public static void YESNO(this bool b) { Console.WriteLine(b ? "YES" : "NO"); }
public static int PopCount(this int bits) {
bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff);
}
}
partial class AtCoder {
public string GetStr() { return Console.ReadLine().Trim(); }
public char GetChar() { return Console.ReadLine().Trim()[0]; }
public int GetInt() { return int.Parse(Console.ReadLine().Trim()); }
public long GetLong() { return long.Parse(Console.ReadLine().Trim()); }
public double GetDouble() { return double.Parse(Console.ReadLine().Trim()); }
public string[] GetStrArray() { return Console.ReadLine().Trim().Split(' '); }
public int[] GetIntArray() {
return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
}
public long[] GetLongArray() {
return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
}
public char[] GetCharArray() {
return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray();
}
public double[] GetDoubleArray() {
return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();
}
public T[][] CreateJaggedArray<T>(int H, int W, T value) {
return Enumerable.Repeat(0, H)
.Select(s => Enumerable.Repeat(value, W).ToArray())
.ToArray();
}
public int[][] GetIntJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetIntArray().ToArray())
.ToArray();
}
public long[][] GetLongJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetLongArray().ToArray())
.ToArray();
}
public char[][] GetCharJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetStr().ToCharArray())
.ToArray();
}
public double[][] GetDoubleJaggedArray(int N) {
return Enumerable.Repeat(0, N).Select(s => GetDoubleArray()).ToArray();
}
Dictionary<int, List<int>> GetUnweightedAdjacencyList(int N, int M,
bool isDirected,
bool isNode_0indexed) {
var dic = new Dictionary<int, List<int>>();
foreach (var e in Enumerable.Range(0, N)) {
dic.Add(e, new List<int>());
}
for (int i = 0; i < M; i++) {
var input = GetIntArray();
var a = isNode_0indexed ? input[0] : input[0] - 1;
var b = isNode_0indexed ? input[1] : input[1] - 1;
dic[a].Add(b);
if (isDirected == false)
dic[b].Add(a);
}
return dic;
}
Dictionary<int, List<Edge>> GetWeightedAdjacencyList(int N, int M,
bool isDirected,
bool isNode_0indexed) {
var dic = new Dictionary<int, List<Edge>>();
foreach (var e in Enumerable.Range(0, N)) {
dic.Add(e, new List<Edge>());
}
for (int i = 0; i < M; i++) {
var input = GetIntArray();
var a = isNode_0indexed ? input[0] : input[0] - 1;
var b = isNode_0indexed ? input[1] : input[1] - 1;
var c = input[2];
dic[a].Add(new Edge(b, c));
if (isDirected == false)
dic[b].Add(new Edge(a, c));
}
return dic;
}
bool eq<T, U>() => typeof(T).Equals(typeof(U));
T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
: eq<T, long>() ? ct<T, long>(long.Parse(s))
: eq<T, double>() ? ct<T, double>(double.Parse(s))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
void Multi<T>(out T a) => a = cv<T>(GetStr());
void Multi<T, U>(out T a, out U b) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
}
void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
}
void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e,
out Y f) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
f = cv<Y>(ar[5]);
}
int[] dx = new int[] { 1, 0, -1, 0, 1, 1, -1, -1 };
int[] dy = new int[] { 0, 1, 0, -1, 1, -1, 1, -1 };
}
class Pair : IComparable<Pair> {
public Pair(int node, long cost) {
Node = node;
Cost = cost;
}
public int Node { get; set; }
public long Cost { get; set; }
public int CompareTo(Pair p) { return p.Cost > Cost ? 1 : -1; }
}
class Edge {
public Edge(int to, long length) {
To = to;
Length = length;
}
public int To { get; set; }
public long Length { get; set; }
}
class Comparable : IComparable<Comparable> {
public Comparable(int value) { Value = value; }
public int Value { get; set; }
public int CompareTo(Comparable c) {
var a = Math.Abs(Value);
var b = Math.Abs(c.Value);
return a > b ? 1 : a == b ? 0 : -1;
}
}
class Comparer<T> : IComparer<T> {
public int Compare(T t1, T t2) { return 1; }
}
partial class Program {
static void Main() {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
new AtCoder().Solve();
Console.Out.Flush();
Console.Read();
}
}
public partial class AtCoder {
public void Solve() {
long X, K, D;
Multi(out X, out K, out D);
var mod1 = X % D;
var num1 = Math.Abs((X - mod1) / D);
var num2 = num1 + 1;
if (num1 > K)
Console.WriteLine(Math.Abs(X) - D * K);
else if (num1 == K || (K - num1) % 2 == 0)
Console.WriteLine(Math.Abs(mod1));
else
Console.WriteLine(Math.Abs(Math.Abs(X) - D * num2));
}
}
}
|
[["+", 0, 28, 0, 16, 31, 213, 3, 4, 0, 25], ["-", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25]]
| 8
| 2,194
| 2
|
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
namespace AtCoder {
static class Program_D {
class Solver {
int ri => sc.Integer();
long rl => sc.Long();
double rd => sc.Double();
string rs => sc.Scan();
public StreamScanner sc = new StreamScanner(Console.OpenStandardInput());
public void Solve() {
var x = rl;
var k = rl;
var d = rl;
var div = x / d;
var mod = x % d;
if (div >= k) {
Wl(x - k * d);
return;
}
var nokori = k - div;
if (nokori % 2 == 0) {
Wl(Math.Abs(mod));
} else {
Wl(Math.Abs(mod - d));
}
}
// ----------------------------------------------------------------------------
static public void Swap<T>(ref T a, ref T b) {
var tmp = a;
a = b;
b = tmp;
}
string Rl() { return Console.ReadLine(); }
void Wl(UInt64 val) { Console.WriteLine(val); }
void Wl(Int64 val) { Console.WriteLine(val); }
void Wl(uint val) { Console.WriteLine(val); }
void Wl(int val) { Console.WriteLine(val); }
void Wl(double val) { Console.WriteLine(val); }
void Wl(string mes) { Console.WriteLine(mes); }
public int Int() { return int.Parse(Console.ReadLine()); }
public int[] Ints(int subtract) {
return Console.ReadLine()
.Split(' ')
.Select(s => int.Parse(s) - subtract)
.ToArray();
}
public Int64[] Int64s(Int64 subtract) {
return Console.ReadLine()
.Split(' ')
.Select(s => Int64.Parse(s) - subtract)
.ToArray();
}
public UInt64[] UInt64s(UInt64 subtract) {
return Console.ReadLine()
.Split(' ')
.Select(s => UInt64.Parse(s) - subtract)
.ToArray();
}
}
static void Main(string[] args) {
Console.SetOut(
new Printer(Console.OpenStandardOutput()) { AutoFlush = false });
new Solver().Solve();
Console.Out.Flush();
}
}
public class Printer : StreamWriter {
public override IFormatProvider FormatProvider =>
CultureInfo.InvariantCulture;
public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) {}
}
public class StreamScanner {
public StreamScanner(Stream stream) { str = stream; }
public readonly Stream str;
private readonly byte[] buf = new byte[1024];
private int len, ptr;
public bool isEof = false;
private byte read() {
if (isEof)
return 0;
if (ptr >= len) {
ptr = 0;
if ((len = str.Read(buf, 0, 1024)) <= 0) {
isEof = true;
return 0;
}
}
return buf[ptr++];
}
public char Char() {
byte b = 0;
do
b = read();
while ((b < 33 || 126 < b) && !isEof);
return (char)b;
}
public string Scan() {
var sb = new StringBuilder();
for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
sb.Append(b);
return sb.ToString();
}
public string ScanLine() {
var sb = new StringBuilder();
for (var b = Char(); b != '\n' && b != 0; b = (char)read())
if (b != '\r')
sb.Append(b);
return sb.ToString();
}
public long Long() { return isEof ? long.MinValue : long.Parse(Scan()); }
public int Integer() { return isEof ? int.MinValue : int.Parse(Scan()); }
public double Double() {
return isEof ? double.NaN
: double.Parse(Scan(), CultureInfo.InvariantCulture);
}
}
struct ModInt {
const int MOD = 1000000007;
long Data;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ModInt(long data) {
if ((Data = data % MOD) < 0)
Data += MOD;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator long(ModInt modInt) => modInt.Data;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator ModInt(long val) => new ModInt(val);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ModInt operator +(ModInt a, ModInt b) {
long res = a.Data + b.Data;
return new ModInt() { Data = res >= MOD ? res - MOD : res };
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ModInt operator +(ModInt a, long b) => a.Data + b;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ModInt operator -(ModInt a, ModInt b) {
long res = a.Data - b.Data;
return new ModInt() { Data = res < 0 ? res + MOD : res };
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ModInt operator -(ModInt a, long b) => a.Data - b;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ModInt operator *(ModInt a, ModInt b) => new ModInt() {
Data = a.Data * b.Data % MOD
};
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ModInt operator /(ModInt a, ModInt b) => a.Data * GetInverse(b);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override string ToString() => Data.ToString();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static long GetInverse(long a) {
long div;
long p = MOD;
long x1 = 1, y1 = 0, x2 = 0, y2 = 1;
while (true) {
if (p == 1)
return x2;
div = a / p;
x1 -= x2 * div;
y1 -= y2 * div;
a %= p;
if (a == 1)
return x1;
div = p / a;
x2 -= x1 * div;
y2 -= y1 * div;
p %= a;
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
namespace AtCoder {
static class Program_D {
class Solver {
int ri => sc.Integer();
long rl => sc.Long();
double rd => sc.Double();
string rs => sc.Scan();
public StreamScanner sc = new StreamScanner(Console.OpenStandardInput());
public void Solve() {
var x = Math.Abs(rl);
var k = rl;
var d = rl;
var div = x / d;
var mod = x % d;
if (div >= k) {
Wl(x - k * d);
return;
}
var nokori = k - div;
if (nokori % 2 == 0) {
Wl(Math.Abs(mod));
} else {
Wl(Math.Abs(mod - d));
}
}
// ----------------------------------------------------------------------------
static public void Swap<T>(ref T a, ref T b) {
var tmp = a;
a = b;
b = tmp;
}
string Rl() { return Console.ReadLine(); }
void Wl(UInt64 val) { Console.WriteLine(val); }
void Wl(Int64 val) { Console.WriteLine(val); }
void Wl(uint val) { Console.WriteLine(val); }
void Wl(int val) { Console.WriteLine(val); }
void Wl(double val) { Console.WriteLine(val); }
void Wl(string mes) { Console.WriteLine(mes); }
public int Int() { return int.Parse(Console.ReadLine()); }
public int[] Ints(int subtract) {
return Console.ReadLine()
.Split(' ')
.Select(s => int.Parse(s) - subtract)
.ToArray();
}
public Int64[] Int64s(Int64 subtract) {
return Console.ReadLine()
.Split(' ')
.Select(s => Int64.Parse(s) - subtract)
.ToArray();
}
public UInt64[] UInt64s(UInt64 subtract) {
return Console.ReadLine()
.Split(' ')
.Select(s => UInt64.Parse(s) - subtract)
.ToArray();
}
}
static void Main(string[] args) {
Console.SetOut(
new Printer(Console.OpenStandardOutput()) { AutoFlush = false });
new Solver().Solve();
Console.Out.Flush();
}
}
public class Printer : StreamWriter {
public override IFormatProvider FormatProvider =>
CultureInfo.InvariantCulture;
public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) {}
}
public class StreamScanner {
public StreamScanner(Stream stream) { str = stream; }
public readonly Stream str;
private readonly byte[] buf = new byte[1024];
private int len, ptr;
public bool isEof = false;
private byte read() {
if (isEof)
return 0;
if (ptr >= len) {
ptr = 0;
if ((len = str.Read(buf, 0, 1024)) <= 0) {
isEof = true;
return 0;
}
}
return buf[ptr++];
}
public char Char() {
byte b = 0;
do
b = read();
while ((b < 33 || 126 < b) && !isEof);
return (char)b;
}
public string Scan() {
var sb = new StringBuilder();
for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
sb.Append(b);
return sb.ToString();
}
public string ScanLine() {
var sb = new StringBuilder();
for (var b = Char(); b != '\n' && b != 0; b = (char)read())
if (b != '\r')
sb.Append(b);
return sb.ToString();
}
public long Long() { return isEof ? long.MinValue : long.Parse(Scan()); }
public int Integer() { return isEof ? int.MinValue : int.Parse(Scan()); }
public double Double() {
return isEof ? double.NaN
: double.Parse(Scan(), CultureInfo.InvariantCulture);
}
}
struct ModInt {
const int MOD = 1000000007;
long Data;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ModInt(long data) {
if ((Data = data % MOD) < 0)
Data += MOD;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator long(ModInt modInt) => modInt.Data;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator ModInt(long val) => new ModInt(val);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ModInt operator +(ModInt a, ModInt b) {
long res = a.Data + b.Data;
return new ModInt() { Data = res >= MOD ? res - MOD : res };
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ModInt operator +(ModInt a, long b) => a.Data + b;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ModInt operator -(ModInt a, ModInt b) {
long res = a.Data - b.Data;
return new ModInt() { Data = res < 0 ? res + MOD : res };
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ModInt operator -(ModInt a, long b) => a.Data - b;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ModInt operator *(ModInt a, ModInt b) => new ModInt() {
Data = a.Data * b.Data % MOD
};
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ModInt operator /(ModInt a, ModInt b) => a.Data * GetInverse(b);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override string ToString() => Data.ToString();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static long GetInverse(long a) {
long div;
long p = MOD;
long x1 = 1, y1 = 0, x2 = 0, y2 = 1;
while (true) {
if (p == 1)
return x2;
div = a / p;
x1 -= x2 * div;
y1 -= y2 * div;
a %= p;
if (a == 1)
return x1;
div = p / a;
x2 -= x1 * div;
y2 -= y1 * div;
p %= a;
}
}
}
}
|
[["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25]]
| 8
| 1,366
| 5
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;
class program {
static public int mod = 1000000007;
static void Main() {
var nk = inta();
int n = nk[0], k = nk[1];
var p = inta();
var isp = new bool[n];
var c = inta();
var roopsum = new List<long>();
var roopct = new List<int>();
var roop = new List<List<int>>();
roop.Add(new List<int>());
var roopmx = new List<List<long>>();
roopmx.Add(new List<long>());
int ct = 0;
for (int i = 0; i < n; i++)
if (!isp[i]) {
long sum = 0;
var pre = i;
var mx = int.MinValue;
roopmx.Add(new List<long>());
roopmx[ct].Add(0);
roop.Add(new List<int>());
for (int j = 0; j <= n; j++) {
pre = p[pre] - 1;
if (isp[pre]) {
roopmx[ct].Add(mx);
roopsum.Add(sum);
roopct.Add(j);
break;
} else {
isp[pre] = true;
roop[ct].Add(c[pre]);
sum += c[pre];
mx = Max(mx, c[pre]);
}
}
ct++;
}
for (int i = 0; i < ct; i++) {
for (int j = 1; j < roopct[i]; j++)
roopmx[i].Add(roopmx[i][0]);
for (int j = 0; j < roopct[i]; j++)
if (roop[i][j] > 0) {
long sum = roop[i][j];
for (int h = 1; h < roopct[i]; h++) {
int hj = h + j;
sum += hj < roopct[i] ? roop[i][hj] : roop[i][hj - roopct[i]];
if (sum > roopmx[i][h + 1])
roopmx[i][h + 1] = sum;
if (roopmx[i][h] > roopmx[i][h + 1])
roopmx[i][h + 1] = roopmx[i][h];
}
}
}
long ans = long.MinValue;
for (int i = 0; i < ct; i++) {
if (roopsum[i] > 0) {
ans = Max(ans, (k / roopct[i]) * roopsum[i] + roopmx[i][k % roopct[i]]);
if (k > roopct[i])
ans = Max(ans,
((k / roopct[i]) - 1) * roopsum[i] + roopmx[i][roopct[i]]);
} else {
if (k > roopct[i])
ans = Max(ans, roopmx[i][roopct[i]]);
else
ans = Max(ans, roopmx[i][k]);
}
}
WriteLine(ans);
}
static int pow(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 string rstr() { return ReadLine(); }
static int rint() { return int.Parse(ReadLine()); }
static long rlong() { return long.Parse(ReadLine()); }
static string[] stra() { return ReadLine().Split(' '); }
static char[] chara() {
string[] a = stra();
string b = "";
for (int i = 0; i < a.Length; i++) {
b += a[i];
}
return b.ToCharArray();
}
static int[] inta() {
string[] read_str_array = ReadLine().Split(' ');
int[] return_int_array = new int[read_str_array.Length];
for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
}
return return_int_array;
}
static long[] longa() {
string[] read_str_array = ReadLine().Split(' ');
long[] return_long_array = new long[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_long_array[countup_i] = long.Parse(read_str_array[countup_i]);
}
return return_long_array;
}
static double[] doublea() {
string[] read_str_array = ReadLine().Split(' ');
double[] return_double_array = new double[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_double_array[countup_i] = double.Parse(read_str_array[countup_i]);
}
return return_double_array;
}
static long GCD(long a, long b) {
if (a < b) {
long temp = a;
a = b;
b = temp;
}
if (a % b == 0) {
return b;
} else {
long temp = b;
b = a % b;
a = temp;
return GCD(a, b);
}
}
static long LCM(long a, long b) { return a * b / GCD(a, b); }
static void WriteArray2(int[,] a, int b, int c) {
for (int i = 0; i < b; i++) {
for (int j = 0; j < c; j++) {
if (j != 0)
Write(" ");
Write(a[i, j]);
}
WriteLine();
}
}
static void WriteArray(int[] a, int b) {
for (int i = 0; i < b; i++) {
Write(" ");
Write(a[i]);
}
WriteLine();
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;
class program {
static public int mod = 1000000007;
static void Main() {
var nk = inta();
int n = nk[0], k = nk[1];
var p = inta();
var isp = new bool[n];
var c = inta();
var roopsum = new List<long>();
var roopct = new List<int>();
var roop = new List<List<int>>();
roop.Add(new List<int>());
var roopmx = new List<List<long>>();
roopmx.Add(new List<long>());
int ct = 0;
for (int i = 0; i < n; i++)
if (!isp[i]) {
long sum = 0;
var pre = i;
var mx = int.MinValue;
roopmx.Add(new List<long>());
roopmx[ct].Add(0);
roop.Add(new List<int>());
for (int j = 0; j <= n; j++) {
pre = p[pre] - 1;
if (isp[pre]) {
roopmx[ct].Add(mx);
roopsum.Add(sum);
roopct.Add(j);
break;
} else {
isp[pre] = true;
roop[ct].Add(c[pre]);
sum += c[pre];
mx = Max(mx, c[pre]);
}
}
ct++;
}
for (int i = 0; i < ct; i++) {
for (int j = 1; j < roopct[i]; j++)
roopmx[i].Add(roopmx[i][1]);
for (int j = 0; j < roopct[i]; j++)
if (roop[i][j] > 0) {
long sum = roop[i][j];
for (int h = 1; h < roopct[i]; h++) {
int hj = h + j;
sum += hj < roopct[i] ? roop[i][hj] : roop[i][hj - roopct[i]];
if (sum > roopmx[i][h + 1])
roopmx[i][h + 1] = sum;
if (roopmx[i][h] > roopmx[i][h + 1])
roopmx[i][h + 1] = roopmx[i][h];
}
}
}
long ans = long.MinValue;
for (int i = 0; i < ct; i++) {
if (roopsum[i] > 0) {
ans = Max(ans, (k / roopct[i]) * roopsum[i] + roopmx[i][k % roopct[i]]);
if (k > roopct[i])
ans = Max(ans,
((k / roopct[i]) - 1) * roopsum[i] + roopmx[i][roopct[i]]);
} else {
if (k > roopct[i])
ans = Max(ans, roopmx[i][roopct[i]]);
else
ans = Max(ans, roopmx[i][k]);
}
}
WriteLine(ans);
}
static int pow(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 string rstr() { return ReadLine(); }
static int rint() { return int.Parse(ReadLine()); }
static long rlong() { return long.Parse(ReadLine()); }
static string[] stra() { return ReadLine().Split(' '); }
static char[] chara() {
string[] a = stra();
string b = "";
for (int i = 0; i < a.Length; i++) {
b += a[i];
}
return b.ToCharArray();
}
static int[] inta() {
string[] read_str_array = ReadLine().Split(' ');
int[] return_int_array = new int[read_str_array.Length];
for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
}
return return_int_array;
}
static long[] longa() {
string[] read_str_array = ReadLine().Split(' ');
long[] return_long_array = new long[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_long_array[countup_i] = long.Parse(read_str_array[countup_i]);
}
return return_long_array;
}
static double[] doublea() {
string[] read_str_array = ReadLine().Split(' ');
double[] return_double_array = new double[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_double_array[countup_i] = double.Parse(read_str_array[countup_i]);
}
return return_double_array;
}
static long GCD(long a, long b) {
if (a < b) {
long temp = a;
a = b;
b = temp;
}
if (a % b == 0) {
return b;
} else {
long temp = b;
b = a % b;
a = temp;
return GCD(a, b);
}
}
static long LCM(long a, long b) { return a * b / GCD(a, b); }
static void WriteArray2(int[,] a, int b, int c) {
for (int i = 0; i < b; i++) {
for (int j = 0; j < c; j++) {
if (j != 0)
Write(" ");
Write(a[i, j]);
}
WriteLine();
}
}
static void WriteArray(int[] a, int b) {
for (int i = 0; i < b; i++) {
Write(" ");
Write(a[i]);
}
WriteLine();
}
}
|
[["-", 0, 28, 0, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 28, 0, 204, 206, 207, 0, 28, 0, 203]]
| 8
| 1,399
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
class B {
static void Main() {
var n = int.Parse(Console.ReadLine());
var ss = new int [n]
.Select(_ => Console.ReadLine())
.OrderBy(s => s.Length)
.ToArray();
var r = 0L;
var nodes = new List<int[]> { new int[26] };
var ends = new List<int[]> { new int[26] };
foreach (var s in ss) {
var id = 0;
for (int i = s.Length - 1; i >= 0; i--) {
if (i == 0)
ends[id][s[i] - 'a']++;
else
for (int j = 0; j < 26; j++) {
if (ends[id][j] == 0)
continue;
var c = (char)('a' + j);
if (s.IndexOf(c, 0, i + 1) >= 0)
r += ends[id][j];
}
var nid = nodes[id][s[i]];
if (nid == 0) {
nodes[id][s[i] - 'a'] = nid = nodes.Count;
nodes.Add(new int[26]);
ends.Add(new int[26]);
}
id = nid;
}
}
Console.WriteLine(r);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class B {
static void Main() {
var n = int.Parse(Console.ReadLine());
var ss = new int [n]
.Select(_ => Console.ReadLine())
.OrderBy(s => s.Length)
.ToArray();
var r = 0L;
var nodes = new List<int[]> { new int[26] };
var ends = new List<int[]> { new int[26] };
foreach (var s in ss) {
var id = 0;
for (int i = s.Length - 1; i >= 0; i--) {
if (i == 0)
ends[id][s[i] - 'a']++;
else
for (int j = 0; j < 26; j++) {
if (ends[id][j] == 0)
continue;
var c = (char)('a' + j);
if (s.IndexOf(c, 0, i + 1) >= 0)
r += ends[id][j];
}
var nid = nodes[id][s[i] - 'a'];
if (nid == 0) {
nodes[id][s[i] - 'a'] = nid = nodes.Count;
nodes.Add(new int[26]);
ends.Add(new int[26]);
}
id = nid;
}
}
Console.WriteLine(r);
}
}
|
[["+", 0, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 206, 207, 0, 28, 0, 16, 12, 252, 0, 104], ["+", 206, 207, 0, 28, 0, 16, 12, 252, 0, 253]]
| 8
| 318
| 4
|
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
namespace CSharp_Shell {
public static class Program {
public static void Main() {
int a = int.Parse(Console.ReadLine());
string b;
if (a <= 30) {
b = "Yes";
} else {
b = "No";
}
Console.WriteLine(b);
}
}
}
|
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
namespace CSharp_Shell {
public static class Program {
public static void Main() {
int a = int.Parse(Console.ReadLine());
string b;
if (30 <= a) {
b = "Yes";
} else {
b = "No";
}
Console.WriteLine(b);
}
}
}
|
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 19], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 19], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22]]
| 8
| 85
| 4
|
using System;
using System.Collections.Generic;
class IDONTKNOWCSHARP {
public static void Main() {
int temp = int.Parse(Console.ReadLine());
if (temp >= 30)
Console.WriteLine("Yes");
Console.WriteLine("No");
}
}
|
using System;
using System.Collections.Generic;
class IDONTKNOWCSHARP {
public static void Main() {
int temp = int.Parse(Console.ReadLine());
if (temp >= 30)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95]]
| 8
| 60
| 1
|
using System;
namespace ABC_174_A_Csharp_ver {
class Program {
static void Main(string[] args) {
int X = int.Parse(Console.ReadLine());
if (X >= 25)
Console.WriteLine("Yes\n");
else
Console.WriteLine("No\n");
Console.ReadKey();
}
}
}
|
using System;
namespace ABC_174_A_Csharp_ver {
class Program {
static void Main(string[] args) {
int X = int.Parse(Console.ReadLine());
if (X >= 30)
Console.WriteLine("Yes\n");
else
Console.WriteLine("No\n");
Console.ReadKey();
}
}
}
|
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203]]
| 8
| 69
| 2
|
using System;
using System.IO;
class Program {
static void Main(string[] args) {
var scan = new Scanner();
var writer =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(writer);
Console.WriteLine(Solve(scan));
Console.Out.Flush();
}
static object Solve(Scanner scan) {
var X = scan.NextInt();
return X > 30 ? "Yes" : "No";
}
}
class Scanner {
string[] s;
int i;
public Scanner() {
s = new string[0];
i = 0;
}
public string Next() {
if (i < s.Length)
return s[i++];
string str = Console.ReadLine();
while (str == "")
str = Console.ReadLine();
s = str.Split(' ', StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return Next();
i = 0;
return s[i++];
}
public int NextInt() => int.Parse(Next());
}
|
using System;
using System.IO;
class Program {
static void Main(string[] args) {
var scan = new Scanner();
var writer =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(writer);
Console.WriteLine(Solve(scan));
Console.Out.Flush();
}
static object Solve(Scanner scan) {
var X = scan.NextInt();
return X >= 30 ? "Yes" : "No";
}
}
class Scanner {
string[] s;
int i;
public Scanner() {
s = new string[0];
i = 0;
}
public string Next() {
if (i < s.Length)
return s[i++];
string str = Console.ReadLine();
while (str == "")
str = Console.ReadLine();
s = str.Split(' ', StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return Next();
i = 0;
return s[i++];
}
public int NextInt() => int.Parse(Next());
}
|
[["-", 8, 196, 0, 37, 0, 41, 15, 16, 17, 47], ["+", 8, 196, 0, 37, 0, 41, 15, 16, 17, 20]]
| 8
| 235
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1 {
class Program {
static void Main(string[] args) {
var input = int.Parse(Console.ReadLine());
if (input >= 30) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("NO");
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1 {
class Program {
static void Main() {
int input = int.Parse(Console.ReadLine());
if (input >= 30) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
[["-", 0, 195, 54, 55, 0, 220, 39, 224, 39, 199], ["-", 54, 55, 0, 220, 39, 224, 225, 226, 0, 70], ["-", 54, 55, 0, 220, 39, 224, 225, 226, 0, 73], ["-", 8, 201, 0, 195, 54, 55, 0, 220, 141, 22], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 89
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace KCLC {
class Program {
static void Main() {
int Input = int.Parse(Console.ReadLine());
if (Input <= 30) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace KCLC {
class Program {
static void Main() {
int Input = int.Parse(Console.ReadLine());
if (Input >= 30) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 19], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 20]]
| 8
| 73
| 2
|
using System;
using System.Linq;
namespace Program {
class A {
static void Main(string[] args) {
var n = int.Parse(Console.ReadLine());
if (-40 <= n && n <= 40) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
using System;
using System.Linq;
namespace Program {
class A {
static void Main(string[] args) {
var n = int.Parse(Console.ReadLine());
if (30 <= n) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
[["-", 0, 57, 15, 16, 31, 16, 31, 241, 0, 33], ["-", 0, 57, 15, 16, 31, 16, 31, 241, 0, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 203], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 19], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203]]
| 8
| 75
| 7
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp3 {
class Program {
static void Main() {
var a = int.Parse(Console.ReadLine());
if (a >= 30) {
Console.WriteLine("yes");
} else {
Console.WriteLine("no");
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp3 {
class Program {
static void Main() {
var a = int.Parse(Console.ReadLine());
if (a >= 30) {
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
| 85
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC174 {
class Program {
static void Main(string[] args) {
long X;
X = long.Parse(Console.ReadLine());
String A = "";
A = 30 <= X ? "YES" : "No";
Console.WriteLine(A);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC174 {
class Program {
static void Main(string[] args) {
long X;
X = long.Parse(Console.ReadLine());
String A = "";
A = 30 <= X ? "Yes" : "No";
Console.WriteLine(A);
}
}
}
|
[["-", 0, 1, 0, 11, 12, 41, 64, 5, 0, 222], ["+", 0, 1, 0, 11, 12, 41, 64, 5, 0, 222]]
| 8
| 89
| 2
|
using System;
class Program {
static void Main(string[] args) {
int X = int.Parse(Console.ReadLine());
if (X >= 30) {
Console.WriteLine("yes");
} else {
Console.WriteLine("no");
}
}
}
|
using System;
class Program {
static void Main(string[] args) {
int X = int.Parse(Console.ReadLine());
if (X >= 30) {
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
| 61
| 4
|
using System;
using System.Collections.Generic;
class Program {
static void Main() {
string[] X = Console.ReadLine().Split(' ');
int x = int.Parse(X[0]);
if (x == 30) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
|
using System;
using System.Collections.Generic;
class Program {
static void Main() {
string[] X = Console.ReadLine().Split(' ');
int x = int.Parse(X[0]);
if (x >= 30) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
|
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 20]]
| 8
| 81
| 2
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class TEST {
static void Main() {
Sol mySol = new Sol();
mySol.Solve();
}
}
class Sol {
public void Solve() {
var N = ri();
Console.WriteLine(N == 30 ? "Yes" : "No");
}
public Sol() {}
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() {
var N = ri();
Console.WriteLine(N >= 30 ? "Yes" : "No");
}
public Sol() {}
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));
}
}
|
[["-", 3, 4, 0, 28, 0, 41, 15, 16, 17, 60], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 17, 20]]
| 8
| 312
| 2
|
using System;
using System.IO;
class Program {
static void Main(string[] args) {
var scan = new Scanner();
var writer =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(writer);
Console.WriteLine(Solve(scan));
Console.Out.Flush();
}
static object Solve(Scanner scan) {
int N = scan.NextInt(), D = scan.NextInt();
var count = 0;
for (int i = 0; i < N; i++) {
var X = scan.NextLong();
var Y = scan.NextLong();
if (Math.Sqrt(X * X + Y * Y) < D)
count++;
}
return count;
}
}
class Scanner {
string[] s;
int i;
public Scanner() {
s = new string[0];
i = 0;
}
public string Next() {
if (i < s.Length)
return s[i++];
string str = Console.ReadLine();
while (str == "")
str = Console.ReadLine();
s = str.Split(' ', StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return Next();
i = 0;
return s[i++];
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
}
|
using System;
using System.IO;
class Program {
static void Main(string[] args) {
var scan = new Scanner();
var writer =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(writer);
Console.WriteLine(Solve(scan));
Console.Out.Flush();
}
static object Solve(Scanner scan) {
int N = scan.NextInt(), D = scan.NextInt();
var count = 0;
for (int i = 0; i < N; i++) {
var X = scan.NextLong();
var Y = scan.NextLong();
if (Math.Sqrt(X * X + Y * Y) <= D)
count++;
}
return count;
}
}
class Scanner {
string[] s;
int i;
public Scanner() {
s = new string[0];
i = 0;
}
public string Next() {
if (i < s.Length)
return s[i++];
string str = Console.ReadLine();
while (str == "")
str = Console.ReadLine();
s = str.Split(' ', StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return Next();
i = 0;
return s[i++];
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
}
|
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 19]]
| 8
| 307
| 2
|
using System;
using System.Linq;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
var basis = Console.ReadLine().Split();
int n = int.Parse(basis[0]);
int d = int.Parse(basis[1]);
int result = 0;
for (int i = 0; i < n; i++) {
long[] XY = Console.ReadLine().Split().Select(long.Parse).ToArray();
var x = XY[0];
var y = XY[1];
if (x * x + y * y <= d * d)
result += 1;
}
Console.WriteLine(result);
}
}
}
|
using System;
using System.Linq;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
var basis = Console.ReadLine().Split();
int n = int.Parse(basis[0]);
long d = long.Parse(basis[1]);
int result = 0;
for (int i = 0; i < n; i++) {
long[] XY = Console.ReadLine().Split().Select(long.Parse).ToArray();
var x = XY[0];
var y = XY[1];
if (x * x + y * y <= d * d)
result += 1;
}
Console.WriteLine(result);
}
}
}
|
[["-", 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
| 154
| 4
|
using System;
using System.Globalization;
using System.Threading;
namespace atcoder1 {
class Program {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int N = int.Parse(input[0]);
int D = int.Parse(input[1]);
double result = 0;
int count = 0;
for (int i = 0; i < N; i++) {
string[] input2 = Console.ReadLine().Split(' ');
int x = int.Parse(input2[0]);
int y = int.Parse(input2[1]);
x = x * x;
y = y * y;
x = x + y;
result = Math.Sqrt(x);
if (result <= D)
count++;
}
Console.WriteLine(count);
}
}
}
|
using System;
using System.Globalization;
using System.Threading;
namespace atcoder1 {
class Program {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int N = int.Parse(input[0]);
int D = int.Parse(input[1]);
double result = 0;
int count = 0;
for (int i = 0; i < N; i++) {
string[] input2 = Console.ReadLine().Split(' ');
long x = long.Parse(input2[0]);
long y = long.Parse(input2[1]);
x = x * x;
y = y * y;
x = x + y;
result = Math.Sqrt(x);
if (result <= D)
count++;
}
Console.WriteLine(count);
}
}
}
|
[["-", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 7, 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
| 189
| 8
|
using System;
public class Hello {
public static void Main() {
string[] line = Console.ReadLine().Trim().Split(' ');
var n = int.Parse(line[0]);
var d = int.Parse(line[1]);
var count = 0;
for (int i = 0; i < n; i++) {
line = Console.ReadLine().Trim().Split(' ');
var x = int.Parse(line[0]);
var y = int.Parse(line[1]);
if (x * x + y * y <= d * d)
count++;
}
Console.WriteLine(count);
}
}
|
using System;
public class Hello {
public static void Main() {
string[] line = Console.ReadLine().Trim().Split(' ');
var n = int.Parse(line[0]);
var d = long.Parse(line[1]);
var count = 0;
for (int i = 0; i < n; i++) {
line = Console.ReadLine().Trim().Split(' ');
var x = long.Parse(line[0]);
var y = long.Parse(line[1]);
if (x * x + y * y <= d * d)
count++;
}
Console.WriteLine(count);
}
}
|
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199]]
| 8
| 154
| 6
|
using System;
namespace q1 {
class q2 {
static void Main() {
string[] kosuumae = Console.ReadLine().Split();
int kosuua = int.Parse(kosuumae[0]);
int kosuub = int.Parse(kosuumae[1]);
int kotae = 0;
for (int ruupu = 0; ruupu < kosuua; ruupu++) {
string[] x = Console.ReadLine().Split();
int x0 = int.Parse(x[0]);
int x1 = int.Parse(x[1]);
double a = Math.Sqrt(x0 * x0 + x1 * x1);
if (a <= kosuub) {
kotae = kotae + 1;
} else {
}
}
Console.WriteLine(kotae);
}
}
}
|
using System;
namespace q1 {
class q2 {
static void Main() {
string[] kosuumae = Console.ReadLine().Split();
int kosuua = int.Parse(kosuumae[0]);
int kosuub = int.Parse(kosuumae[1]);
int kotae = 0;
for (int ruupu = 0; ruupu < kosuua; ruupu++) {
string[] x = Console.ReadLine().Split();
long x0 = long.Parse(x[0]);
long x1 = long.Parse(x[1]);
double a = Math.Sqrt(x0 * x0 + x1 * x1);
if (a <= kosuub) {
kotae = kotae + 1;
} else {
}
}
Console.WriteLine(kotae);
}
}
}
|
[["-", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 7, 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
| 161
| 8
|
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
class Test {
public static void Main() {
var ss = Console.ReadLine().Split(' ');
var n = int.Parse(ss[0]);
var d = int.Parse(ss[1]);
int ans = 0;
for (int i = 0; i < n; i++) {
var ii = Console.ReadLine().Split(' ');
var x1 = int.Parse(ii[0]);
var x2 = int.Parse(ii[1]);
var dd = Math.Sqrt(x1 * x1 + x2 * x2);
if (dd <= d)
ans++;
}
Console.Write(ans);
}
}
|
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
class Test {
public static void Main() {
var ss = Console.ReadLine().Split(' ');
var n = int.Parse(ss[0]);
var d = int.Parse(ss[1]);
int ans = 0;
for (int i = 0; i < n; i++) {
var ii = Console.ReadLine().Split(' ');
var x1 = long.Parse(ii[0]);
var x2 = long.Parse(ii[1]);
var dd = Math.Sqrt((x1 * x1) + (x2 * x2));
if (dd <= d)
ans++;
}
Console.Write(ans);
}
}
|
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 25], ["+", 3, 4, 0, 28, 0, 16, 12, 23, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 12, 23, 0, 25]]
| 8
| 174
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main(string[] args) {
long[] a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
long kosuu = 0;
for (int i = 0; i < a[0]; i++) {
long[] b = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
double c = Math.Pow(b[0], 2) + Math.Pow(b[1], 2);
if (c < Math.Pow(a[1], 2)) {
kosuu += 1;
}
}
Console.WriteLine(kosuu);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main(string[] args) {
long[] a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
long kosuu = 0;
for (int i = 0; i < a[0]; i++) {
long[] b = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
double c = Math.Pow(b[0], 2) + Math.Pow(b[1], 2);
if (c <= Math.Pow(a[1], 2)) {
kosuu += 1;
}
}
Console.WriteLine(kosuu);
}
}
|
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 19]]
| 8
| 180
| 2
|
using System;
using System.Collections.Generic;
class Program {
static void Main() {
string[] ND = Console.ReadLine().Split(' ');
long n = long.Parse(ND[0]);
long d = long.Parse(ND[1]);
long[] x = new long[n];
long[] y = new long[n];
long xy = 0;
int count = 0;
for (int i = 0; i < n; i++) {
string[] XY = Console.ReadLine().Split(' ');
x[i] = long.Parse(XY[0]);
y[i] = long.Parse(XY[1]);
x[i] = x[i] * x[i];
y[i] = y[i] * y[i];
xy = x[i] + y[i];
double root = Math.Sqrt(xy);
if (root >= d) {
count++;
}
}
Console.WriteLine(count);
}
}
|
using System;
using System.Collections.Generic;
class Program {
static void Main() {
string[] ND = Console.ReadLine().Split(' ');
long n = long.Parse(ND[0]);
long d = long.Parse(ND[1]);
long[] x = new long[n];
long[] y = new long[n];
long xy = 0;
int count = 0;
for (int i = 0; i < n; i++) {
string[] XY = Console.ReadLine().Split(' ');
x[i] = long.Parse(XY[0]);
y[i] = long.Parse(XY[1]);
x[i] = x[i] * x[i];
y[i] = y[i] * y[i];
xy = x[i] + y[i];
double root = Math.Sqrt(xy);
if (root <= d) {
count++;
}
}
Console.WriteLine(count);
}
}
|
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 20], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 19]]
| 8
| 231
| 2
|
using System;
using CompLib.Util;
public class Program {
public void Solve() {
var sc = new Scanner();
int n = sc.NextInt();
int d = sc.NextInt();
long[] x = new long[n];
long[] y = new long[n];
for (int i = 0; i < n; i++) {
x[i] = sc.NextInt();
y[i] = sc.NextInt();
}
int ans = 0;
for (int i = 0; i < n; i++) {
long d2 = x[i] * x[i] + y[i] * y[i];
if (d2 <= d * d)
ans++;
}
Console.WriteLine(ans);
}
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() {
if (_index >= _line.Length) {
string s;
do {
s = Console.ReadLine();
} while (s.Length == 0);
_line = s.Split(Separator);
_index = 0;
}
return _line[_index++];
}
public string ReadLine() {
_index = _line.Length;
return Console.ReadLine();
}
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() {
string s = Console.ReadLine();
_line = s.Length == 0 ? new string[0] : s.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 d = sc.NextInt();
long[] x = new long[n];
long[] y = new long[n];
for (int i = 0; i < n; i++) {
x[i] = sc.NextInt();
y[i] = sc.NextInt();
}
int ans = 0;
for (int i = 0; i < n; i++) {
long d2 = x[i] * x[i] + y[i] * y[i];
if (d2 <= d * d)
ans++;
}
Console.WriteLine(ans);
}
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() {
if (_index >= _line.Length) {
string s;
do {
s = Console.ReadLine();
} while (s.Length == 0);
_line = s.Split(Separator);
_index = 0;
}
return _line[_index++];
}
public string ReadLine() {
_index = _line.Length;
return Console.ReadLine();
}
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() {
string s = Console.ReadLine();
_line = s.Length == 0 ? new string[0] : s.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]]
| 8
| 552
| 2
|
using System;
public class Hello {
public static void Main() {
// Your code here!
int result = 0;
var line = System.Console.ReadLine().Split();
var data = Array.ConvertAll(line, int.Parse);
for (var i = 0; i < data[0]; i++) {
var targetData = System.Console.ReadLine().Split();
var target = Array.ConvertAll(targetData, int.Parse);
var a = target[0] * target[0];
var b = target[1] * target[1];
var answer = a + b;
double answer2 = Math.Sqrt(answer);
if (answer2 <= data[1]) {
result = result + 1;
}
}
System.Console.WriteLine(result);
}
}
|
using System;
public class Hello {
public static void Main() {
// Your code here!
int result = 0;
var line = System.Console.ReadLine().Split();
var data = Array.ConvertAll(line, int.Parse);
for (var i = 0; i < data[0]; i++) {
var targetData = System.Console.ReadLine().Split();
var target = Array.ConvertAll(targetData, double.Parse);
double a = target[0] * target[0];
double b = target[1] * target[1];
double answer = a + b;
double answer2 = Math.Sqrt(answer);
// System.Console.WriteLine(answer2);
if (answer2 <= data[1]) {
result = result + 1;
}
}
System.Console.WriteLine(result);
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 0, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199]]
| 8
| 168
| 8
|
using System;
class main {
static void Main(string[] args) {
string[] s = Console.ReadLine().Split(" ");
int cnt = int.Parse(s[0]);
int dist = int.Parse(s[1]);
int ans = 0;
for (int i = 0; i < cnt - 1; i++) {
string[] s2 = Console.ReadLine().Split(" ");
double x = int.Parse(s2[0]);
double y = int.Parse(s2[1]);
if (CalcSqrt(x, y) <= dist)
ans++;
}
Console.WriteLine(ans);
}
public static double CalcSqrt(double x, double y) {
return Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2));
}
}
|
using System;
class main {
static void Main(string[] args) {
string[] s = Console.ReadLine().Split(" ");
int cnt = int.Parse(s[0]);
int dist = int.Parse(s[1]);
int ans = 0;
for (int i = 1; i <= cnt; i++) {
string[] s2 = Console.ReadLine().Split(" ");
double x = int.Parse(s2[0]);
double y = int.Parse(s2[1]);
if (CalcSqrt(x, y) <= dist)
ans++;
}
Console.WriteLine(ans);
}
public static double CalcSqrt(double x, double y) {
return Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2));
}
}
|
[["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203]]
| 8
| 188
| 6
|
using System;
using static System.Console;
using static System.Math;
using System.Numerics;
using System.Collections.Generic;
using System.Linq;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
var s = myRead.readIntArray();
var d = s[1] * s[1];
var ans = 0;
for (int i = 0; i < s[0]; i++) {
var k = myRead.readIntArray();
if ((k[0] * k[0] + k[1] * k[1]) <= d)
ans++;
}
WriteLine(ans);
Out.Flush();
}
}
public static class myRead {
public static int readInt() { return int.Parse(ReadLine()); }
public static long readLong() { return long.Parse(ReadLine()); }
public static string reatStr() { return ReadLine(); }
public static int[] readIntArray() {
return ReadLine().Split(' ').Select(int.Parse).ToArray();
}
public static long[] readLongArray() {
return ReadLine().Split(' ').Select(long.Parse).ToArray();
}
public static string[] readStrArray() { return ReadLine().Split(' '); }
}
public static class MyMath {
public static long Factorical(long n) {
return n <= 1 ? 1L : n * Factorical(n - 1);
}
public static long Permutation(long n, long m) {
return m == 0 ? 1L
: (m == n) ? Permutation(n, m - 1)
: n * Permutation(n - 1, m - 1);
}
public static long Combination(long n, long m) {
return n - m > m ? Permutation(n, m) / Factorical(m)
: Permutation(n, n - m) / Factorical(n - m);
}
public static long Gcd(long n, long m) {
return n % m == 0 ? m : Gcd(m, n % m);
}
public static long Lcm(long n, long m) { return n * m / Gcd(n, m); }
public static long Pow(long n, long m) {
return (m == 1 || m == 0) ? 1L : n * Pow(n, m - 1);
}
}
}
|
using System;
using static System.Console;
using static System.Math;
using System.Numerics;
using System.Collections.Generic;
using System.Linq;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
var s = myRead.readLongArray();
var d = s[1] * s[1];
var ans = 0;
for (int i = 0; i < s[0]; i++) {
var k = myRead.readLongArray();
if ((k[0] * k[0] + k[1] * k[1]) <= d)
ans++;
}
WriteLine(ans);
Out.Flush();
}
}
public static class myRead {
public static int readInt() { return int.Parse(ReadLine()); }
public static long readLong() { return long.Parse(ReadLine()); }
public static string reatStr() { return ReadLine(); }
public static int[] readIntArray() {
return ReadLine().Split(' ').Select(int.Parse).ToArray();
}
public static long[] readLongArray() {
return ReadLine().Split(' ').Select(long.Parse).ToArray();
}
public static string[] readStrArray() { return ReadLine().Split(' '); }
}
public static class MyMath {
public static long Factorical(long n) {
return n <= 1 ? 1L : n * Factorical(n - 1);
}
public static long Permutation(long n, long m) {
return m == 0 ? 1L
: (m == n) ? Permutation(n, m - 1)
: n * Permutation(n - 1, m - 1);
}
public static long Combination(long n, long m) {
return n - m > m ? Permutation(n, m) / Factorical(m)
: Permutation(n, n - m) / Factorical(n - m);
}
public static long Gcd(long n, long m) {
return n % m == 0 ? m : Gcd(m, n % m);
}
public static long Lcm(long n, long m) { return n * m / Gcd(n, m); }
public static long Pow(long n, long m) {
return (m == 1 || m == 0) ? 1L : n * Pow(n, m - 1);
}
}
}
|
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22]]
| 8
| 512
| 4
|
using System;
using System.Linq;
namespace ConsoleApp3 {
internal class Program {
private static void Main(string[] args) {
var input1 = Console.ReadLine().Split(" ");
var count = int.Parse(input1.First());
var distance = int.Parse(input1.Last());
var result =
Enumerable.Range(0, count)
.Select(_ => {
var inputN = Console.ReadLine().Split(" ");
return (X: int.Parse(inputN.First()),
Y: int.Parse(inputN.Last()));
})
.Count(ab => (ab.X * ab.X + ab.Y * ab.Y) <= distance * distance);
Console.WriteLine(result);
}
}
}
|
using System;
using System.Linq;
namespace ConsoleApp3 {
internal class Program {
private static void Main(string[] args) {
var input1 = Console.ReadLine().Split(" ");
var count = int.Parse(input1.First());
var distance = long.Parse(input1.Last());
var result =
Enumerable.Range(0, count)
.Select(_ => {
var inputN = Console.ReadLine().Split(" ");
return (X: long.Parse(inputN.First()),
Y: long.Parse(inputN.Last()));
})
.Count(ab => (ab.X * ab.X + ab.Y * ab.Y) <= distance * distance);
Console.WriteLine(result);
}
}
}
|
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["-", 0, 288, 0, 28, 0, 213, 63, 214, 205, 199], ["+", 0, 288, 0, 28, 0, 213, 63, 214, 205, 199]]
| 8
| 172
| 6
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
namespace contest_Csharp {
class Program {
public static (long m, long s)[,] dp;
static void Main(string[] args) {
checked {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var vals =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
var N = vals[0];
var D = vals[1];
var ans = 0;
for (int i = 0; i < N; i++) {
var p =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
if (p[0] * p[0] + p[1] * p[1] <= D * D)
ans++;
}
Console.WriteLine(ans);
Console.Out.Flush();
}
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
namespace contest_Csharp {
class Program {
public static (long m, long s)[,] dp;
static void Main(string[] args) {
checked {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var vals =
Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
var N = vals[0];
var D = vals[1];
var ans = 0;
for (long i = 0; i < N; i++) {
var p =
Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
if (p[0] * p[0] + p[1] * p[1] <= D * D)
ans++;
}
Console.WriteLine(ans);
Console.Out.Flush();
}
}
}
}
|
[["-", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["+", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["-", 0, 287, 0, 196, 0, 7, 10, 198, 39, 199], ["+", 0, 287, 0, 196, 0, 7, 10, 198, 39, 199]]
| 8
| 235
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
public static class Solution {
public static void Main() {
var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var N = vals[0];
var D = vals[1];
var count = 0;
for (int i = 0; i < N; i++) {
vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var x = vals[0];
var y = vals[1];
if (x * x + y * y <= D * D) {
count++;
}
}
Console.WriteLine(count);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
public static class Solution {
public static void Main() {
var vals = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
var N = vals[0];
var D = vals[1];
var count = 0;
for (int i = 0; i < N; i++) {
vals = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
var x = vals[0];
var y = vals[1];
if (x * x + y * y <= D * D) {
count++;
}
}
Console.WriteLine(count);
}
}
|
[["-", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199]]
| 8
| 161
| 4
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
class Program {
static void Main(string[] args) {
// var exStdIn = new System.IO.StreamReader( "stdin.txt"
// );System.Console.SetIn( exStdIn );
var nd = Console.ReadLine().Split().Select(int.Parse).ToArray();
int n = nd[0], d = nd[1];
int ans = 0;
for (int i = 0; i < n; i++) {
var xy = Console.ReadLine().Split().Select(int.Parse).ToArray();
if (xy[0] * xy[0] + xy[1] * xy[1] <= d * d)
ans++;
}
Console.Write(ans);
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
class Program {
static void Main(string[] args) {
// var exStdIn = new System.IO.StreamReader( "stdin.txt"
// );System.Console.SetIn( exStdIn );
var nd = Console.ReadLine().Split().Select(long.Parse).ToArray();
long n = nd[0], d = nd[1];
int ans = 0;
for (int i = 0; i < n; i++) {
var xy = Console.ReadLine().Split().Select(long.Parse).ToArray();
if (xy[0] * xy[0] + xy[1] * xy[1] <= d * d)
ans++;
}
Console.Write(ans);
}
}
|
[["-", 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
| 197
| 6
|
using System;
using System.IO;
class Program {
static void Main(string[] args) {
var scan = new Scanner();
var writer =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(writer);
Console.WriteLine(Solve(scan));
Console.Out.Flush();
}
static object Solve(Scanner scan) {
int K = scan.NextInt();
var temp = 0;
for (int i = 1; i < K; i++) {
temp = (10 * temp + 7) % K;
if (temp == 0)
return i;
}
return -1;
}
}
class Scanner {
string[] s;
int i;
public Scanner() {
s = new string[0];
i = 0;
}
public string Next() {
if (i < s.Length)
return s[i++];
string str = Console.ReadLine();
while (str == "")
str = Console.ReadLine();
s = str.Split(' ', StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return Next();
i = 0;
return s[i++];
}
public int NextInt() => int.Parse(Next());
}
|
using System;
using System.IO;
class Program {
static void Main(string[] args) {
var scan = new Scanner();
var writer =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(writer);
Console.WriteLine(Solve(scan));
Console.Out.Flush();
}
static object Solve(Scanner scan) {
int K = scan.NextInt();
var temp = 0;
for (int i = 1; i <= K; i++) {
temp = (10 * temp + 7) % K;
if (temp == 0)
return i;
}
return -1;
}
}
class Scanner {
string[] s;
int i;
public Scanner() {
s = new string[0];
i = 0;
}
public string Next() {
if (i < s.Length)
return s[i++];
string str = Console.ReadLine();
while (str == "")
str = Console.ReadLine();
s = str.Split(' ', StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return Next();
i = 0;
return s[i++];
}
public int NextInt() => int.Parse(Next());
}
|
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19]]
| 8
| 268
| 2
|
using System;
namespace _174.c {
internal class Program {
private static void Main(string[] args) {
var k = int.Parse(Console.ReadLine());
var a = 7;
var ans = -1;
for (var i = 0; i < k; i++) {
if (a % k == 0) {
ans = i + 1;
break;
}
a = a * 10 + 7;
}
Console.WriteLine(ans.ToString());
}
}
}
|
using System;
namespace _174.c {
internal class Program {
private static void Main(string[] args) {
var k = int.Parse(Console.ReadLine());
long a = 7;
var ans = -1;
for (var i = 0; i < k; i++) {
if (a % k == 0) {
ans = i + 1;
break;
}
a = (a % k) * 10 + 7;
}
Console.WriteLine(ans.ToString());
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 11, 12, 16, 31, 16, 31, 23, 0, 24], ["+", 12, 16, 31, 16, 31, 23, 0, 16, 17, 109], ["+", 12, 16, 31, 16, 31, 23, 0, 16, 12, 22], ["+", 0, 11, 12, 16, 31, 16, 31, 23, 0, 25]]
| 8
| 104
| 6
|
using System;
using System.Collections.Generic;
class C {
static void Main(string[] args) {
var input1Line = Console.ReadLine();
var k = int.Parse(input1Line);
var intList = new List<int>();
intList.Add(7 % k);
for (int i = 1; i < k; i++) {
var lastInt = intList[i - 1];
intList.Add((lastInt * 10 + 7) % k);
}
for (int i = 0; i < k; i++) {
if (intList[i] == 0) {
Console.WriteLine(i);
return;
}
}
Console.WriteLine(-1);
}
}
|
using System;
using System.Collections.Generic;
class C {
static void Main(string[] args) {
var input1Line = Console.ReadLine();
var k = int.Parse(input1Line);
var intList = new List<int>();
intList.Add(7 % k);
for (int i = 1; i < k; i++) {
var lastInt = intList[i - 1];
intList.Add((lastInt * 10 + 7) % k);
}
for (int i = 0; i < k; i++) {
if (intList[i] == 0) {
Console.WriteLine(i + 1);
return;
}
}
Console.WriteLine(-1);
}
}
|
[["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
| 8
| 149
| 2
|
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Numerics;
namespace AtCoder {
class Program {
private static void Main(string[] args) {
var k = Scanner.Integer();
var l = k % 7 == 0 ? 9 * k / 7 : 9 * k;
var largeCalc = new LargeCalc();
var value = largeCalc.Surplus(10, k, k, 1).First();
Console.WriteLine(value != -1 ? value + 1 : -1);
}
#region Utility
static readonly StreamScanner Scanner =
new StreamScanner(Console.OpenStandardInput());
/// <summary> 一括出力 </summary>
private static void OutAllLine(IEnumerable<int> items) {
var sb = new StringBuilder();
foreach (var result in items) {
sb.Append(result.ToString() + "\n");
}
sb = sb.Remove(sb.Length - 1, 1);
Console.WriteLine(sb);
}
#endregion
}
public class LargeCalc {
public IEnumerable<int> Surplus(long baseNum, long power, int division,
long require) {
long value = 1;
for (int i = 0; i < power; i++) {
value = value * baseNum % division;
if (value == require) {
yield return i;
}
if (value == 0 && require != 0) {
break;
}
}
yield return -1;
}
}
#region Utility Class
public class StreamScanner {
public StreamScanner(Stream stream) { str = stream; }
private readonly Stream str;
private readonly byte[] buf = new byte[1024];
private int len, ptr;
public bool isEof = false;
public bool IsEndOfStream {
get { return isEof; }
}
private 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++];
}
public char Char() {
byte b = 0;
do
b = read();
while (b < 33 || 126 < b);
return (char)b;
}
public string Scan() {
var sb = new StringBuilder();
for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
sb.Append(b);
return sb.ToString();
}
public string ScanIncludeSpace() {
var sb = new StringBuilder();
for (var b = Char(); b >= 32 && b <= 126; b = (char)read())
sb.Append(b);
return sb.ToString();
}
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';
}
}
public int Integer() { return (int)Long(); }
public double Double() {
return double.Parse(Scan(), CultureInfo.InvariantCulture);
}
/// <summary> 数値読み込み </summary>
public List<long> ArrayLong(int count = 0) {
var scan = new List<long>();
for (int i = 0; i < count; i++) {
scan.Add(Long());
}
return scan;
}
/// <summary> 数値読み込み </summary>
public List<int> ArrayInt(int count = 0) {
var scan = new List<int>();
for (int i = 0; i < count; i++) {
scan.Add(Integer());
}
return scan;
}
}
public class Primer {
/// <summary> 素数判定 </summary>
public static bool IsPrime(int num) {
if (num < 2) {
return false;
}
if (num == 2) {
return true;
}
if (num % 2 == 0) {
return false;
}
double sqrtNum = Math.Sqrt(num);
for (int i = 3; i <= sqrtNum; i += 2) {
if (num % i == 0) {
return false;
}
}
return true;
}
public static IEnumerable<int> GetPrimeFactors(int n) {
int i = 2;
int tmp = n;
while (i * i <= n) //※1
{
if (tmp % i == 0) {
tmp /= i;
yield return i;
} else {
i++;
}
}
if (tmp != 1)
yield return tmp;
}
}
public class Mod109 {
public const int _7 = 1000000007;
public const int _9 = 1000000009;
public const int _3 = 998244353;
private readonly int ModValue;
public Mod109(int modValue = Mod109._7) { ModValue = modValue; }
/// <summary> 和 </summary>
public long Addition(IEnumerable<long> nums) {
return nums.Aggregate<long, long>(
0, (current, num) => ModifyPositive((current + num) % ModValue));
}
/// <summary> 差 </summary>
public long Subtraction(IEnumerable<long> nums) {
return nums.Aggregate<long, long>(
0, (current, num) => ModifyPositive((current - num) % ModValue));
}
/// <summary> 積 </summary>
public long Multiplication(IEnumerable<long> nums) {
return nums.Aggregate<long, long>(
1, (current, num) => ModifyPositive((current * num) % ModValue));
}
private long ModifyPositive(long value) {
return value < 0 ? (value + ModValue) : value;
}
}
public class BitArrayMaker {
public List<int> Integer(int bitValue, int length) {
var list = new List<int>();
for (int i = 0; i < length; i++) {
if (bitValue % 2 == 1) {
list.Add(i);
}
bitValue /= 2;
}
return list;
}
public bool[] Boolean(int bitValue, int length) {
var list = new bool[length];
for (int i = 0; i < length; i++) {
list[i] = bitValue % 2 == 1;
bitValue /= 2;
}
return list;
}
}
#endregion
}
|
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Numerics;
namespace AtCoder {
class Program {
private static void Main(string[] args) {
var k = Scanner.Integer();
var l = k % 7 == 0 ? 9 * k / 7 : 9 * k;
var largeCalc = new LargeCalc();
var value = largeCalc.Surplus(10, k, l, 1).First();
Console.WriteLine(value != -1 ? value + 1 : -1);
}
#region Utility
static readonly StreamScanner Scanner =
new StreamScanner(Console.OpenStandardInput());
/// <summary> 一括出力 </summary>
private static void OutAllLine(IEnumerable<int> items) {
var sb = new StringBuilder();
foreach (var result in items) {
sb.Append(result.ToString() + "\n");
}
sb = sb.Remove(sb.Length - 1, 1);
Console.WriteLine(sb);
}
#endregion
}
public class LargeCalc {
public IEnumerable<int> Surplus(long baseNum, long power, int division,
long require) {
long value = 1;
for (int i = 0; i < power; i++) {
value = value * baseNum % division;
if (value == require) {
yield return i;
}
if (value == 0 && require != 0) {
break;
}
}
yield return -1;
}
}
#region Utility Class
public class StreamScanner {
public StreamScanner(Stream stream) { str = stream; }
private readonly Stream str;
private readonly byte[] buf = new byte[1024];
private int len, ptr;
public bool isEof = false;
public bool IsEndOfStream {
get { return isEof; }
}
private 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++];
}
public char Char() {
byte b = 0;
do
b = read();
while (b < 33 || 126 < b);
return (char)b;
}
public string Scan() {
var sb = new StringBuilder();
for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
sb.Append(b);
return sb.ToString();
}
public string ScanIncludeSpace() {
var sb = new StringBuilder();
for (var b = Char(); b >= 32 && b <= 126; b = (char)read())
sb.Append(b);
return sb.ToString();
}
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';
}
}
public int Integer() { return (int)Long(); }
public double Double() {
return double.Parse(Scan(), CultureInfo.InvariantCulture);
}
/// <summary> 数値読み込み </summary>
public List<long> ArrayLong(int count = 0) {
var scan = new List<long>();
for (int i = 0; i < count; i++) {
scan.Add(Long());
}
return scan;
}
/// <summary> 数値読み込み </summary>
public List<int> ArrayInt(int count = 0) {
var scan = new List<int>();
for (int i = 0; i < count; i++) {
scan.Add(Integer());
}
return scan;
}
}
public class Primer {
/// <summary> 素数判定 </summary>
public static bool IsPrime(int num) {
if (num < 2) {
return false;
}
if (num == 2) {
return true;
}
if (num % 2 == 0) {
return false;
}
double sqrtNum = Math.Sqrt(num);
for (int i = 3; i <= sqrtNum; i += 2) {
if (num % i == 0) {
return false;
}
}
return true;
}
public static IEnumerable<int> GetPrimeFactors(int n) {
int i = 2;
int tmp = n;
while (i * i <= n) //※1
{
if (tmp % i == 0) {
tmp /= i;
yield return i;
} else {
i++;
}
}
if (tmp != 1)
yield return tmp;
}
}
public class Mod109 {
public const int _7 = 1000000007;
public const int _9 = 1000000009;
public const int _3 = 998244353;
private readonly int ModValue;
public Mod109(int modValue = Mod109._7) { ModValue = modValue; }
/// <summary> 和 </summary>
public long Addition(IEnumerable<long> nums) {
return nums.Aggregate<long, long>(
0, (current, num) => ModifyPositive((current + num) % ModValue));
}
/// <summary> 差 </summary>
public long Subtraction(IEnumerable<long> nums) {
return nums.Aggregate<long, long>(
0, (current, num) => ModifyPositive((current - num) % ModValue));
}
/// <summary> 積 </summary>
public long Multiplication(IEnumerable<long> nums) {
return nums.Aggregate<long, long>(
1, (current, num) => ModifyPositive((current * num) % ModValue));
}
private long ModifyPositive(long value) {
return value < 0 ? (value + ModValue) : value;
}
}
public class BitArrayMaker {
public List<int> Integer(int bitValue, int length) {
var list = new List<int>();
for (int i = 0; i < length; i++) {
if (bitValue % 2 == 1) {
list.Add(i);
}
bitValue /= 2;
}
return list;
}
public bool[] Boolean(int bitValue, int length) {
var list = new bool[length];
for (int i = 0; i < length; i++) {
list[i] = bitValue % 2 == 1;
bitValue /= 2;
}
return list;
}
}
#endregion
}
|
[["-", 63, 214, 205, 213, 3, 4, 0, 28, 0, 22], ["+", 63, 214, 205, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 1,332
| 2
|
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
class CompetitiveProgrammingProgram {
static long Gcd(long a, long b) {
long[] v = new long[] { a, b };
while (v[1] != 0) {
v = new long[] { v[1], v[0] % v[1] };
}
return v[0];
}
static long Lcm(long a, long b) { return a / Gcd(a, b) * b; }
class Node<T> {
private int m_height;
private Node<T> m_parent;
public T Item { get; private set; }
public Node(T item) {
m_height = 0;
m_parent = this;
Item = item;
}
public Node<T> Find() {
if (m_parent == this) {
return this;
}
Node<T> parent = m_parent.Find();
m_parent = parent;
return parent;
}
public static void Unite(Node<T> a, Node<T> b) {
Node<T> p = a.Find();
Node<T> q = b.Find();
if (p.m_height < q.m_height) {
p.m_parent = q;
q.m_height = Math.Max(p.m_height + 1, q.m_height);
} else {
q.m_parent = p;
p.m_height = Math.Max(q.m_height + 1, p.m_height);
}
}
}
static void Main(string[] args) {
int K = int.Parse(Console.ReadLine());
int a = 7;
int ans = 1;
while (a != 0) {
a = a * 10 + 7;
a %= K;
ans++;
if (ans > 10 * K) {
ans = -1;
break;
}
}
Console.WriteLine(ans);
}
}
|
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
class CompetitiveProgrammingProgram {
static long Gcd(long a, long b) {
long[] v = new long[] { a, b };
while (v[1] != 0) {
v = new long[] { v[1], v[0] % v[1] };
}
return v[0];
}
static long Lcm(long a, long b) { return a / Gcd(a, b) * b; }
class Node<T> {
private int m_height;
private Node<T> m_parent;
public T Item { get; private set; }
public Node(T item) {
m_height = 0;
m_parent = this;
Item = item;
}
public Node<T> Find() {
if (m_parent == this) {
return this;
}
Node<T> parent = m_parent.Find();
m_parent = parent;
return parent;
}
public static void Unite(Node<T> a, Node<T> b) {
Node<T> p = a.Find();
Node<T> q = b.Find();
if (p.m_height < q.m_height) {
p.m_parent = q;
q.m_height = Math.Max(p.m_height + 1, q.m_height);
} else {
q.m_parent = p;
p.m_height = Math.Max(q.m_height + 1, p.m_height);
}
}
}
static void Main(string[] args) {
int K = int.Parse(Console.ReadLine());
int a = 7;
a %= K;
int ans = 1;
while (a != 0) {
a = a * 10 + 7;
a %= K;
ans++;
if (ans > 10 * K) {
ans = -1;
break;
}
}
Console.WriteLine(ans);
}
}
|
[["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 132], ["+", 0, 195, 8, 196, 0, 1, 0, 11, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 398
| 4
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
int K = int.Parse(Console.ReadLine());
if (K % 2 == 0 || K % 5 == 0) {
Console.WriteLine(-1);
} else {
if (K % 7 == 0) {
K = K / 7;
}
if (K == 1) {
Console.WriteLine(1);
} else {
long ans = 1;
long tmp = 10;
while (tmp != 1) {
tmp = 10 * tmp % K;
ans++;
}
Console.WriteLine(ans);
}
}
}
}
// dotnet run --project test
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
int K = int.Parse(Console.ReadLine());
if (K % 2 == 0 || K % 5 == 0) {
Console.WriteLine(-1);
} else {
if (K % 7 == 0) {
K = K / 7;
}
if (K == 1) {
Console.WriteLine(1);
} else {
K = K * 9;
long ans = 1;
long tmp = 10;
while (tmp != 1) {
tmp = 10 * tmp % K;
ans++;
}
Console.WriteLine(ans);
}
}
}
}
// dotnet run --project test
|
[["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["+", 75, 196, 0, 57, 75, 196, 0, 1, 0, 35]]
| 8
| 147
| 6
|
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Numerics;
using System.IO;
using System.Net;
using System.Diagnostics;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Runtime.Remoting;
namespace Practice {
class Program {
static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
private const int MOD = 1000000007;
private const int MAX = 1000001;
static long[] fac = new long[MAX];
static long[] finv = new long[MAX];
static long[] inv = new long[MAX];
static Dictionary<long, long> primeDic = new Dictionary<long, long>();
static void Solve() {
var k = Input.NextLong();
if (k == 1) {
Console.WriteLine(1);
return;
}
if (k % 2 == 0) {
Console.WriteLine(-1);
return;
}
int ans = -1;
long[] mod = new long[5 * MAX];
mod[0] = 7 % k;
for (int i = 1; i < mod.Length; i++) {
mod[i] = mod[i - 1] * 10 % k;
}
long pre = 7 % k;
for (int i = 1; i < 5 * MAX; i++) {
long calc = pre % k;
calc += mod[i - 1] % k * 10 % k;
calc %= k;
if (calc == 0) {
ans = i + 1;
break;
}
pre = calc;
}
Console.WriteLine(ans);
}
#region よく使う便利関数
private static void TrialDivision(long m) {
for (long i = 2; i * i <= m; i++) {
long ex = 0;
while (m % i == 0) {
ex++;
m /= i;
}
if (ex >= 1) {
primeDic.Add(i, ex);
}
}
if (m >= 2) {
primeDic.Add(m, 1);
}
// note まぁ1は違うよね
}
private static Dictionary<long, int> Factorize(long n) {
var dic = new Dictionary<long, int>();
for (long i = 2; i * i <= n; ++i) {
while (n % i == 0) {
if (!dic.ContainsKey(i)) {
dic.Add(i, 0);
}
dic[i]++;
n /= i;
}
}
if (n != 1) {
dic.Add(n, 1);
}
return dic;
}
static void COMinit() {
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 % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
static long COM(long n, long k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
static class Input {
static char[] separator = { ' ' };
public static bool IsEof { get; set; }
static Queue<string> q { get; set; }
static Input() {
IsEof = false;
q = new Queue<string>();
}
/// <summary>
/// 入力予約
/// </summary>
/// <param name="items"></param>
public static void SetText(IEnumerable<string> items) {
foreach (var item in items) {
SetText(item);
}
}
/// <summary>
/// 入力予約
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static bool SetText(string s) {
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
q.Enqueue(elem);
}
return true;
}
/// <summary>
/// 内部queueに入力からの値をsplitして格納する
/// </summary>
/// <returns></returns>
static bool read() {
var s = Console.ReadLine();
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
q.Enqueue(elem);
}
if (!q.Any())
return read();
return true;
}
/// <summary>
/// 次のstringを一つ読み込む
/// </summary>
/// <returns></returns>
public static string Next() {
if (!q.Any()) {
if (!read()) {
IsEof = true;
return "";
}
}
return q.Dequeue();
}
public static int NextInt() => int.Parse(Next());
public static long NextLong() => long.Parse(Next());
public static double NextDouble() => double.Parse(Next());
public static List<string>
Next(int n) => Enumerable.Range(0, n).Select(_ => Next()).ToList();
public static List<int>
NextInt(int n) => Next(n).Select(x => int.Parse(x)).ToList();
public static List<long>
NextLong(int n) => Next(n).Select(x => long.Parse(x)).ToList();
public static List<double>
NextDouble(int n) => Next(n).Select(x => double.Parse(x)).ToList();
public static List<string>
NextLine() => Console.ReadLine()
.Trim()
.Split(separator, StringSplitOptions.RemoveEmptyEntries)
.ToList();
public static List<int>
NextIntLine() => NextLine().Select(x => int.Parse(x)).ToList();
public static List<long>
NextLongLine() => NextLine().Select(x => long.Parse(x)).ToList();
public static List<double>
NextDoubleLine() => NextLine().Select(x => double.Parse(x)).ToList();
}
private static bool isPrime(long x) {
if (x == 2) {
return true;
}
if (x < 2 || x % 2 == 0) {
return false;
}
long i = 3;
while (i * i <= x) {
if (x % i == 0) {
return false;
}
i = i + 2;
}
return true;
}
private static long lcm(long x, long y) { return x / gcd(x, y) * y; }
private static long gcd(long x, long y) { return y > 0 ? gcd(y, x % y) : x; }
private static long pow(long x, long n) {
if (n == 0) {
return 1;
}
long res = pow(x * x % MOD, n / 2);
if (n % 2 == 1) {
res = res * x % MOD;
}
return res;
}
private static void Swap<T>(ref T x, ref T y) {
T t = x;
x = y;
y = t;
}
/// <summary>
/// 指定した値以上の先頭のインデクスを返す
/// </summary>
/// <typeparam name="T">比較する値の型</typeparam>
/// <param name="arr">対象の配列(※ソート済みであること)</param>
/// <param name="start">開始インデクス [inclusive]</param>
/// <param name="end">終了インデクス [exclusive]</param>
/// <param name="value">検索する値</param>
/// <param name="comparer">比較関数(インターフェイス)</param>
/// <returns>指定した値以上の先頭のインデクス</returns>
public static int LowerBound<T>(IReadOnlyList<T> arr, int start, int end,
T value, IComparer<T> comparer) {
int low = start;
int high = end;
int mid;
while (low < high) {
mid = ((high - low) >> 1) + low;
if (comparer.Compare(arr[mid], value) < 0)
low = mid + 1;
else
high = mid;
}
return low;
}
//引数省略のオーバーロード
public static int LowerBound<T>(IReadOnlyList<T> arr, T value)
where T : IComparable {
return LowerBound(arr, 0, arr.Count, value, Comparer<T>.Default);
}
/// <summary>
/// 指定した値より大きい先頭のインデクスを返す
/// </summary>
/// <typeparam name="T">比較する値の型</typeparam>
/// <param name="arr">対象の配列(※ソート済みであること)</param>
/// <param name="start">開始インデクス [inclusive]</param>
/// <param name="end">終了インデクス [exclusive]</param>
/// <param name="value">検索する値</param>
/// <param name="comparer">比較関数(インターフェイス)</param>
/// <returns>指定した値より大きい先頭のインデクス</returns>
public static int UpperBound<T>(IReadOnlyList<T> arr, int start, int end,
T value, IComparer<T> comparer) {
int low = start;
int high = end;
int mid;
while (low < high) {
mid = ((high - low) >> 1) + low;
if (comparer.Compare(arr[mid], value) <= 0)
low = mid + 1;
else
high = mid;
}
return low;
}
//引数省略のオーバーロード
public static int UpperBound<T>(IReadOnlyList<T> arr, T value) {
return UpperBound(arr, 0, arr.Count, value, Comparer<T>.Default);
}
#endregion
}
public class DisjointSet {
private int[] rank;
private int[] p;
private int[] size;
public DisjointSet(int n) {
rank = new int[n];
p = new int[n];
size = new int[n];
for (int i = 0; i < n; ++i) {
MakeSet(i);
}
}
public void MakeSet(int x) {
p[x] = x;
rank[x] = 0;
size[x] = 1;
}
public bool IsSame(int x, int y) { return FindSet(x) == FindSet(y); }
public void Unite(int x, int y) { Link(FindSet(x), FindSet(y)); }
public void Link(int x, int y) {
if (rank[x] > rank[y]) {
p[y] = x;
size[x] += size[y];
size[y] = 0;
} else {
p[x] = y;
size[y] += size[x];
size[x] = 0;
if (rank[x] == rank[y]) {
rank[y]++;
}
}
}
public int FindSet(int x) {
if (x != p[x]) {
p[x] = FindSet(p[x]);
}
return p[x];
}
public int Size(int x) {
int root = FindSet(x);
return size[root];
}
}
public class PriorityQueue<T>
where T : IComparable {
private IComparer<T> _comparer = null;
private int _type = 0;
private T[] _heap;
private int _sz = 0;
private int _count = 0;
/// <summary>
/// Priority Queue with custom comparer
/// </summary>
public PriorityQueue(int maxSize, IComparer<T> comparer) {
_heap = new T[maxSize];
_comparer = comparer;
}
/// <summary>
/// Priority queue
/// </summary>
/// <param name="maxSize">max size</param>
/// <param name="type">0: asc, 1:desc</param>
public PriorityQueue(int maxSize, int type = 0) {
_heap = new T[maxSize];
_type = type;
}
private int Compare(T x, T y) {
if (_comparer != null)
return _comparer.Compare(x, y);
return _type == 0 ? x.CompareTo(y) : y.CompareTo(x);
}
public void Push(T x) {
_count++;
// node number
var i = _sz++;
while (i > 0) {
// parent node number
var p = (i - 1) / 2;
if (Compare(_heap[p], x) <= 0)
break;
_heap[i] = _heap[p];
i = p;
}
_heap[i] = x;
}
public T Pop() {
_count--;
T ret = _heap[0];
T x = _heap[--_sz];
int i = 0;
while (i * 2 + 1 < _sz) {
// children
int a = i * 2 + 1;
int b = i * 2 + 2;
if (b < _sz && Compare(_heap[b], _heap[a]) < 0)
a = b;
if (Compare(_heap[a], x) >= 0)
break;
_heap[i] = _heap[a];
i = a;
}
_heap[i] = x;
return ret;
}
public int Count() { return _count; }
public T Peek() { return _heap[0]; }
public bool Contains(T x) {
for (int i = 0; i < _sz; i++)
if (x.Equals(_heap[i]))
return true;
return false;
}
public void Clear() {
while (this.Count() > 0)
this.Pop();
}
public IEnumerator<T> GetEnumerator() {
var ret = new List<T>();
while (this.Count() > 0) {
ret.Add(this.Pop());
}
foreach (var r in ret) {
this.Push(r);
yield return r;
}
}
public T[] ToArray() {
T[] array = new T[_sz];
int i = 0;
foreach (var r in this) {
array[i++] = r;
}
return array;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Numerics;
using System.IO;
using System.Net;
using System.Diagnostics;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Runtime.Remoting;
namespace Practice {
class Program {
static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
private const int MOD = 1000000007;
private const int MAX = 1000001;
static long[] fac = new long[MAX];
static long[] finv = new long[MAX];
static long[] inv = new long[MAX];
static Dictionary<long, long> primeDic = new Dictionary<long, long>();
static void Solve() {
var k = Input.NextLong();
if (k == 1 || k == 7) {
Console.WriteLine(1);
return;
}
if (k % 2 == 0) {
Console.WriteLine(-1);
return;
}
int ans = -1;
long[] mod = new long[5 * MAX];
mod[0] = 7 % k;
for (int i = 1; i < mod.Length; i++) {
mod[i] = mod[i - 1] * 10 % k;
}
long pre = 7 % k;
for (int i = 1; i < 5 * MAX; i++) {
long calc = pre % k;
calc += mod[i - 1] % k * 10 % k;
calc %= k;
if (calc == 0) {
ans = i + 1;
break;
}
pre = calc;
}
Console.WriteLine(ans);
}
#region よく使う便利関数
private static void TrialDivision(long m) {
for (long i = 2; i * i <= m; i++) {
long ex = 0;
while (m % i == 0) {
ex++;
m /= i;
}
if (ex >= 1) {
primeDic.Add(i, ex);
}
}
if (m >= 2) {
primeDic.Add(m, 1);
}
// note まぁ1は違うよね
}
private static Dictionary<long, int> Factorize(long n) {
var dic = new Dictionary<long, int>();
for (long i = 2; i * i <= n; ++i) {
while (n % i == 0) {
if (!dic.ContainsKey(i)) {
dic.Add(i, 0);
}
dic[i]++;
n /= i;
}
}
if (n != 1) {
dic.Add(n, 1);
}
return dic;
}
static void COMinit() {
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 % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
static long COM(long n, long k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
static class Input {
static char[] separator = { ' ' };
public static bool IsEof { get; set; }
static Queue<string> q { get; set; }
static Input() {
IsEof = false;
q = new Queue<string>();
}
/// <summary>
/// 入力予約
/// </summary>
/// <param name="items"></param>
public static void SetText(IEnumerable<string> items) {
foreach (var item in items) {
SetText(item);
}
}
/// <summary>
/// 入力予約
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static bool SetText(string s) {
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
q.Enqueue(elem);
}
return true;
}
/// <summary>
/// 内部queueに入力からの値をsplitして格納する
/// </summary>
/// <returns></returns>
static bool read() {
var s = Console.ReadLine();
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
q.Enqueue(elem);
}
if (!q.Any())
return read();
return true;
}
/// <summary>
/// 次のstringを一つ読み込む
/// </summary>
/// <returns></returns>
public static string Next() {
if (!q.Any()) {
if (!read()) {
IsEof = true;
return "";
}
}
return q.Dequeue();
}
public static int NextInt() => int.Parse(Next());
public static long NextLong() => long.Parse(Next());
public static double NextDouble() => double.Parse(Next());
public static List<string>
Next(int n) => Enumerable.Range(0, n).Select(_ => Next()).ToList();
public static List<int>
NextInt(int n) => Next(n).Select(x => int.Parse(x)).ToList();
public static List<long>
NextLong(int n) => Next(n).Select(x => long.Parse(x)).ToList();
public static List<double>
NextDouble(int n) => Next(n).Select(x => double.Parse(x)).ToList();
public static List<string>
NextLine() => Console.ReadLine()
.Trim()
.Split(separator, StringSplitOptions.RemoveEmptyEntries)
.ToList();
public static List<int>
NextIntLine() => NextLine().Select(x => int.Parse(x)).ToList();
public static List<long>
NextLongLine() => NextLine().Select(x => long.Parse(x)).ToList();
public static List<double>
NextDoubleLine() => NextLine().Select(x => double.Parse(x)).ToList();
}
private static bool isPrime(long x) {
if (x == 2) {
return true;
}
if (x < 2 || x % 2 == 0) {
return false;
}
long i = 3;
while (i * i <= x) {
if (x % i == 0) {
return false;
}
i = i + 2;
}
return true;
}
private static long lcm(long x, long y) { return x / gcd(x, y) * y; }
private static long gcd(long x, long y) { return y > 0 ? gcd(y, x % y) : x; }
private static long pow(long x, long n) {
if (n == 0) {
return 1;
}
long res = pow(x * x % MOD, n / 2);
if (n % 2 == 1) {
res = res * x % MOD;
}
return res;
}
private static void Swap<T>(ref T x, ref T y) {
T t = x;
x = y;
y = t;
}
/// <summary>
/// 指定した値以上の先頭のインデクスを返す
/// </summary>
/// <typeparam name="T">比較する値の型</typeparam>
/// <param name="arr">対象の配列(※ソート済みであること)</param>
/// <param name="start">開始インデクス [inclusive]</param>
/// <param name="end">終了インデクス [exclusive]</param>
/// <param name="value">検索する値</param>
/// <param name="comparer">比較関数(インターフェイス)</param>
/// <returns>指定した値以上の先頭のインデクス</returns>
public static int LowerBound<T>(IReadOnlyList<T> arr, int start, int end,
T value, IComparer<T> comparer) {
int low = start;
int high = end;
int mid;
while (low < high) {
mid = ((high - low) >> 1) + low;
if (comparer.Compare(arr[mid], value) < 0)
low = mid + 1;
else
high = mid;
}
return low;
}
//引数省略のオーバーロード
public static int LowerBound<T>(IReadOnlyList<T> arr, T value)
where T : IComparable {
return LowerBound(arr, 0, arr.Count, value, Comparer<T>.Default);
}
/// <summary>
/// 指定した値より大きい先頭のインデクスを返す
/// </summary>
/// <typeparam name="T">比較する値の型</typeparam>
/// <param name="arr">対象の配列(※ソート済みであること)</param>
/// <param name="start">開始インデクス [inclusive]</param>
/// <param name="end">終了インデクス [exclusive]</param>
/// <param name="value">検索する値</param>
/// <param name="comparer">比較関数(インターフェイス)</param>
/// <returns>指定した値より大きい先頭のインデクス</returns>
public static int UpperBound<T>(IReadOnlyList<T> arr, int start, int end,
T value, IComparer<T> comparer) {
int low = start;
int high = end;
int mid;
while (low < high) {
mid = ((high - low) >> 1) + low;
if (comparer.Compare(arr[mid], value) <= 0)
low = mid + 1;
else
high = mid;
}
return low;
}
//引数省略のオーバーロード
public static int UpperBound<T>(IReadOnlyList<T> arr, T value) {
return UpperBound(arr, 0, arr.Count, value, Comparer<T>.Default);
}
#endregion
}
public class DisjointSet {
private int[] rank;
private int[] p;
private int[] size;
public DisjointSet(int n) {
rank = new int[n];
p = new int[n];
size = new int[n];
for (int i = 0; i < n; ++i) {
MakeSet(i);
}
}
public void MakeSet(int x) {
p[x] = x;
rank[x] = 0;
size[x] = 1;
}
public bool IsSame(int x, int y) { return FindSet(x) == FindSet(y); }
public void Unite(int x, int y) { Link(FindSet(x), FindSet(y)); }
public void Link(int x, int y) {
if (rank[x] > rank[y]) {
p[y] = x;
size[x] += size[y];
size[y] = 0;
} else {
p[x] = y;
size[y] += size[x];
size[x] = 0;
if (rank[x] == rank[y]) {
rank[y]++;
}
}
}
public int FindSet(int x) {
if (x != p[x]) {
p[x] = FindSet(p[x]);
}
return p[x];
}
public int Size(int x) {
int root = FindSet(x);
return size[root];
}
}
public class PriorityQueue<T>
where T : IComparable {
private IComparer<T> _comparer = null;
private int _type = 0;
private T[] _heap;
private int _sz = 0;
private int _count = 0;
/// <summary>
/// Priority Queue with custom comparer
/// </summary>
public PriorityQueue(int maxSize, IComparer<T> comparer) {
_heap = new T[maxSize];
_comparer = comparer;
}
/// <summary>
/// Priority queue
/// </summary>
/// <param name="maxSize">max size</param>
/// <param name="type">0: asc, 1:desc</param>
public PriorityQueue(int maxSize, int type = 0) {
_heap = new T[maxSize];
_type = type;
}
private int Compare(T x, T y) {
if (_comparer != null)
return _comparer.Compare(x, y);
return _type == 0 ? x.CompareTo(y) : y.CompareTo(x);
}
public void Push(T x) {
_count++;
// node number
var i = _sz++;
while (i > 0) {
// parent node number
var p = (i - 1) / 2;
if (Compare(_heap[p], x) <= 0)
break;
_heap[i] = _heap[p];
i = p;
}
_heap[i] = x;
}
public T Pop() {
_count--;
T ret = _heap[0];
T x = _heap[--_sz];
int i = 0;
while (i * 2 + 1 < _sz) {
// children
int a = i * 2 + 1;
int b = i * 2 + 2;
if (b < _sz && Compare(_heap[b], _heap[a]) < 0)
a = b;
if (Compare(_heap[a], x) >= 0)
break;
_heap[i] = _heap[a];
i = a;
}
_heap[i] = x;
return ret;
}
public int Count() { return _count; }
public T Peek() { return _heap[0]; }
public bool Contains(T x) {
for (int i = 0; i < _sz; i++)
if (x.Equals(_heap[i]))
return true;
return false;
}
public void Clear() {
while (this.Count() > 0)
this.Pop();
}
public IEnumerator<T> GetEnumerator() {
var ret = new List<T>();
while (this.Count() > 0) {
ret.Add(this.Pop());
}
foreach (var r in ret) {
this.Push(r);
yield return r;
}
}
public T[] ToArray() {
T[] array = new T[_sz];
int i = 0;
foreach (var r in this) {
array[i++] = r;
}
return array;
}
}
}
|
[["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203]]
| 8
| 2,700
| 4
|
using System;
using System.Numerics;
using System.Text;
using static ConsoleReader;
class Program {
static void Main(string[] args) {
var k = Read<int>();
var mod = k % 10;
var res = 0L;
var count = 0;
while (true) {
var lastResDig = res % 10;
var nextDig = 0;
while (nextDig < 10) {
if ((mod * nextDig + lastResDig) % 10 == 7)
break;
nextDig++;
}
if (nextDig == 10) {
Console.WriteLine(-1);
break;
}
count++;
res = (res + k * nextDig) / 10;
// Console.WriteLine($"{nextDig} : {res}");
if (res == 0)
break;
}
Console.WriteLine(count);
// Console.WriteLine(res);
// var num = new BigInteger(7);
// var max = 1_000_000_000;
// for (var i = 1; i < max; i++)
//{
// if (num % k == 0)
// {
// Console.WriteLine(i);
// return;
// }
// num = num * 10 + 7;
//}
// Console.WriteLine(-1);
// var num = 777777777777;
// var div = 2;
// while (div <= Math.Sqrt(num) + 1)
//{
// if (num % div == 0)
// {
// Console.Write($"{div} ");
// num = num / div;
// }
// else
// {
// div++;
// }
//}
// if (num > 1) Console.Write(num);
// for (var div = 2; div < num / 2; div++)
//{
// if (num % div == 0) Console.Write($"{div} ");
//}
}
}
public static class IntExtentions {
public static void Times(this int n, Action<int> action) {
for (var i = 0; i < n; i++) {
action(i);
}
}
public static void Times(this(int n, int m) dimensions,
Action<int, int> action) {
var (n, m) = dimensions;
n.Times(i => m.Times(j => action(i, j)));
}
}
public static class ConsoleReader {
public static T Read<T>()
where T : IConvertible {
var inputBuffer = new StringBuilder();
int currChar;
while ((currChar = Console.Read()) != -1) {
if (!char.IsWhiteSpace((char)currChar)) {
inputBuffer.Append((char)currChar);
} else if (inputBuffer.Length != 0) {
break;
}
}
return (T)Convert.ChangeType(inputBuffer.ToString(), typeof(T));
}
public static T[] ReadArray<T>(int count)
where T : IConvertible {
if (count < 0) {
throw new ArgumentOutOfRangeException(nameof(count),
$"'{nameof(count)}' must be >= 0");
}
var result = new T[count];
for (var i = 0; i < count; i++) {
result[i] = Read<T>();
}
return result;
}
}
|
using System;
using System.Numerics;
using System.Text;
using static ConsoleReader;
class Program {
static void Main(string[] args) {
var k = Read<int>();
var mod = k % 10;
var res = 0L;
var count = 0;
while (true) {
var lastResDig = res % 10;
var nextDig = 0;
while (nextDig < 10) {
if ((mod * nextDig + lastResDig) % 10 == 7)
break;
nextDig++;
}
if (nextDig == 10) {
Console.WriteLine(-1);
return;
}
count++;
res = (res + k * nextDig) / 10;
// Console.WriteLine($"{nextDig} : {res}");
if (res == 0)
break;
}
Console.WriteLine(count);
// Console.WriteLine(res);
// var num = new BigInteger(7);
// var max = 1_000_000_000;
// for (var i = 1; i < max; i++)
//{
// if (num % k == 0)
// {
// Console.WriteLine(i);
// return;
// }
// num = num * 10 + 7;
//}
// Console.WriteLine(-1);
// var num = 777777777777;
// var div = 2;
// while (div <= Math.Sqrt(num) + 1)
//{
// if (num % div == 0)
// {
// Console.Write($"{div} ");
// num = num / div;
// }
// else
// {
// div++;
// }
//}
// if (num > 1) Console.Write(num);
// for (var div = 2; div < num / 2; div++)
//{
// if (num % div == 0) Console.Write($"{div} ");
//}
}
}
public static class IntExtentions {
public static void Times(this int n, Action<int> action) {
for (var i = 0; i < n; i++) {
action(i);
}
}
public static void Times(this(int n, int m) dimensions,
Action<int, int> action) {
var (n, m) = dimensions;
n.Times(i => m.Times(j => action(i, j)));
}
}
public static class ConsoleReader {
public static T Read<T>()
where T : IConvertible {
var inputBuffer = new StringBuilder();
int currChar;
while ((currChar = Console.Read()) != -1) {
if (!char.IsWhiteSpace((char)currChar)) {
inputBuffer.Append((char)currChar);
} else if (inputBuffer.Length != 0) {
break;
}
}
return (T)Convert.ChangeType(inputBuffer.ToString(), typeof(T));
}
public static T[] ReadArray<T>(int count)
where T : IConvertible {
if (count < 0) {
throw new ArgumentOutOfRangeException(nameof(count),
$"'{nameof(count)}' must be >= 0");
}
var result = new T[count];
for (var i = 0; i < count; i++) {
result[i] = Read<T>();
}
return result;
}
}
|
[["-", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38]]
| 8
| 479
| 2
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
class Program {
static void Main(string[] args) {
// var exStdIn = new System.IO.StreamReader( "stdin.txt"
// );System.Console.SetIn( exStdIn );
long ans = -1;
long k = long.Parse(Console.ReadLine());
long tmp = 0;
for (int i = 0; i < k + 10; i++) {
tmp = (tmp * 10 + 7) % k;
if (tmp == 0)
ans = i + 1;
}
Console.WriteLine(ans);
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
class Program {
static void Main(string[] args) {
// var exStdIn = new System.IO.StreamReader( "stdin.txt"
// );System.Console.SetIn( exStdIn );
long ans = -1;
long k = long.Parse(Console.ReadLine());
long tmp = 0;
for (int i = 0; i < k + 10; i++) {
tmp = (tmp * 10 + 7) % k;
if (tmp == 0) {
ans = i + 1;
break;
}
}
Console.WriteLine(ans);
}
}
|
[["+", 0, 7, 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, 93, 0, 94], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 151
| 4
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P {
public static void Main() {
int n = int.Parse(Console.ReadLine());
var s = Console.ReadLine();
var ptra = 0;
var ptrb = n - 1;
int res = 0;
while (true) {
if (ptra < s.Length && s[ptra] == 'R')
ptra++;
if (0 <= ptrb && s[ptrb] == 'W')
ptrb--;
if (ptra >= ptrb)
break;
ptra++;
ptrb--;
res++;
}
Console.WriteLine(res);
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P {
public static void Main() {
int n = int.Parse(Console.ReadLine());
var s = Console.ReadLine();
var ptra = 0;
var ptrb = n - 1;
int res = 0;
while (true) {
while (ptra < s.Length && s[ptra] == 'R')
ptra++;
while (0 <= ptrb && s[ptrb] == 'W')
ptrb--;
if (ptra >= ptrb)
break;
ptra++;
ptrb--;
res++;
}
Console.WriteLine(res);
}
}
|
[["-", 8, 196, 0, 52, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 52, 8, 196, 0, 52, 0, 89]]
| 8
| 182
| 4
|
using static System.Math;
using System;
public class Hello {
public static void Main() {
var n = int.Parse(Console.ReadLine().Trim());
var s = Console.ReadLine().Trim();
getAns(n, s);
}
static void getAns(int n, string s) {
var rtow = s.Replace("R", "").Length;
var ans = rtow;
var wtor = 0;
for (int i = 0; i < n; i++) {
if (s[i] == 'W')
wtor++;
else
rtow--;
ans = Min(ans, Max(wtor, rtow));
}
Console.WriteLine(ans);
}
}
|
using static System.Math;
using System;
public class Hello {
public static void Main() {
var n = int.Parse(Console.ReadLine().Trim());
var s = Console.ReadLine().Trim();
getAns(n, s);
}
static void getAns(int n, string s) {
var rtow = n - s.Replace("R", "").Length;
var ans = rtow;
var wtor = 0;
for (int i = 0; i < n; i++) {
if (s[i] == 'W')
wtor++;
else
rtow--;
ans = Min(ans, Max(wtor, rtow));
}
Console.WriteLine(ans);
}
}
|
[["+", 0, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 33]]
| 8
| 154
| 2
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;
namespace ConsoleApp2 {
class Program {
static string C;
static int LW;
static int RR;
static int N;
static void Main(string[] args) {
N = int.Parse(Console.ReadLine());
// var NA = Console.ReadLine().Split(' ').Select(x =>
// long.Parse(x)).ToArray();
C = Console.ReadLine();
LW = -1;
RR = N;
var count = 0;
while (LW < RR) {
NextLW();
NextRR();
// if(fif && LW >= RR)
//{
// break;
//}
// else
//{
// fif = false;
//}
if (LW >= RR) {
break;
}
count++;
}
Console.WriteLine(count);
}
static void NextLW() {
LW++;
while (LW < N && C[LW] == 'R') {
LW++;
}
}
static void NextRR() {
RR--;
while (RR > 0 && C[RR] == 'L') {
RR--;
}
}
}
}
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;
namespace ConsoleApp2 {
class Program {
static string C;
static int LW;
static int RR;
static int N;
static void Main(string[] args) {
N = int.Parse(Console.ReadLine());
// var NA = Console.ReadLine().Split(' ').Select(x =>
// long.Parse(x)).ToArray();
C = Console.ReadLine();
LW = -1;
RR = N;
var count = 0;
while (LW < RR) {
NextLW();
NextRR();
// if(fif && LW >= RR)
//{
// break;
//}
// else
//{
// fif = false;
//}
if (LW >= RR) {
break;
}
count++;
}
Console.WriteLine(count);
}
static void NextLW() {
LW++;
while (LW < N && C[LW] == 'R') {
LW++;
}
}
static void NextRR() {
RR--;
while (RR >= 0 && C[RR] == 'W') {
RR--;
}
}
}
}
|
[["-", 8, 196, 0, 52, 15, 16, 31, 16, 17, 47], ["+", 8, 196, 0, 52, 15, 16, 31, 16, 17, 20], ["-", 0, 52, 15, 16, 12, 16, 12, 252, 0, 253], ["+", 0, 52, 15, 16, 12, 16, 12, 252, 0, 253]]
| 8
| 213
| 4
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace ABC {
class ProgramD {
static void Main(string[] args) {
var n = long.Parse(Console.ReadLine());
var s = Console.ReadLine().Select(x => x).ToArray();
var result = 0;
var j = s.Length - 1;
for (var i = 0; i < n; i++) {
if (s[i] == 'W') {
for (; j > i + result; j--) {
if (s[j] == 'R') {
s[i] = 'R';
s[j] = 'W';
result++;
break;
}
}
}
}
Console.WriteLine(result);
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace ABC {
class ProgramD {
static void Main(string[] args) {
var n = long.Parse(Console.ReadLine());
var s = Console.ReadLine().Select(x => x).ToArray();
var result = 0;
var j = s.Length - 1;
for (var i = 0; i < n; i++) {
if (s[i] == 'W') {
for (; j > i; j--) {
if (s[j] == 'R') {
s[i] = 'R';
s[j] = 'W';
result++;
// Console.WriteLine(string.Join(",", i, j));
// Console.WriteLine(string.Join("", s));
break;
}
}
}
}
Console.WriteLine(result);
}
}
}
|
[["-", 64, 196, 0, 7, 15, 16, 12, 16, 17, 72], ["-", 64, 196, 0, 7, 15, 16, 12, 16, 12, 22]]
| 8
| 168
| 2
|
using System.Linq;
using System.Text;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Security.Cryptography.X509Certificates;
using System.Diagnostics;
using System.Reflection.Metadata;
using System.Threading;
namespace AtCoder {
class Program {
struct Point {
public int x;
public int y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
}
const int BiggestMod = 1000000007;
public static void Main() {
var data = Console.ReadLine().Select(x => x == 'R').ToArray();
var numR = 0;
var numW = 0;
var compare = new int[2] { 0, 0 };
foreach (var load in data)
if (load)
numR++;
else
numW++;
for (int i = 0; i < numR; i++)
if (!data[i])
compare[0]++;
for (int i = numR; i < data.Length; i++)
if (data[i])
compare[1]++;
Console.WriteLine(Math.Max(compare[0], compare[1]));
}
}
}
|
using System.Linq;
using System.Text;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Security.Cryptography.X509Certificates;
using System.Diagnostics;
using System.Reflection.Metadata;
using System.Threading;
namespace AtCoder {
class Program {
struct Point {
public int x;
public int y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
}
const int BiggestMod = 1000000007;
public static void Main() {
Console.ReadLine();
var data = Console.ReadLine().Select(x => x == 'R').ToArray();
var numR = 0;
var numW = 0;
var compare = new int[2] { 0, 0 };
foreach (var load in data)
if (load)
numR++;
else
numW++;
for (int i = 0; i < numR; i++)
if (!data[i])
compare[0]++;
for (int i = numR; i < data.Length; i++)
if (data[i])
compare[1]++;
Console.WriteLine(Math.Max(compare[0], compare[1]));
}
}
}
|
[["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 261
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;
class MainClass : Scanner {
static void Main() {
var (N, K) = ReadTuple<int, int>();
var A = RLongs();
var (lb, ub) = (-1L, 1000000007L);
while (ub - lb > 1) {
var mid = (lb + ub) / 2;
if (check(mid, A, K))
lb = mid;
else
ub = mid;
}
WriteLine(ub);
}
static bool check(long size, long[] A, int K) {
int N = A.Length;
long count = 0;
for (int i = 0; i < N; i++) {
if (A[i] > size) {
long c = A[i] / size;
if (A[i] % size == 0)
c--;
count += c;
}
}
return count > K;
}
}
class Scanner {
public static string RString() => Console.ReadLine();
public static int RInt() => ReadTuple<int>();
public static long RLong() => ReadTuple<long>();
public static double RDouble() => ReadTuple<double>();
public static string[] RStrings() => Console.ReadLine().Split();
public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(),
int.Parse);
public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(),
long.Parse);
public static double[] RDoubles() =>
Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
public static int[] RInts(Func<string, int> func) =>
Console.ReadLine().Split().Select(func).ToArray();
public static long[] RLongs(Func<string, long> func) =>
Console.ReadLine().Split().Select(func).ToArray();
public static double[] RDoubles(Func<string, double> func) =>
Console.ReadLine().Split().Select(func).ToArray();
// public static string[] RStrings(Func<string, string> func) =>
// Console.ReadLine().Split().Select(func).ToArray();
public static T1 ReadTuple<T1>() {
var r = RString();
var r1 = (T1)Convert.ChangeType(r, typeof(T1));
return r1;
}
public static (T1, T2) ReadTuple<T1, T2>() {
var r = RStrings();
var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
return (r1, r2);
}
public static (T1, T2, T3) ReadTuple<T1, T2, T3>() {
var r = RStrings();
var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
return (r1, r2, r3);
}
public static (T1, T2, T3, T4) ReadTuple<T1, T2, T3, T4>() {
var r = RStrings();
var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
var r4 = (T4)Convert.ChangeType(r[3], typeof(T4));
return (r1, r2, r3, r4);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;
class MainClass : Scanner {
static void Main() {
var (N, K) = ReadTuple<int, int>();
var A = RLongs();
var (lb, ub) = (0L, 1000000007L);
while (ub - lb > 1) {
var mid = (lb + ub) / 2;
if (check(mid, A, K))
lb = mid;
else
ub = mid;
}
WriteLine(ub);
}
static bool check(long size, long[] A, int K) {
int N = A.Length;
long count = 0;
for (int i = 0; i < N; i++) {
if (A[i] > size) {
long c = A[i] / size;
if (A[i] % size == 0)
c--;
count += c;
}
}
return count > K;
}
}
class Scanner {
public static string RString() => Console.ReadLine();
public static int RInt() => ReadTuple<int>();
public static long RLong() => ReadTuple<long>();
public static double RDouble() => ReadTuple<double>();
public static string[] RStrings() => Console.ReadLine().Split();
public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(),
int.Parse);
public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(),
long.Parse);
public static double[] RDoubles() =>
Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
public static int[] RInts(Func<string, int> func) =>
Console.ReadLine().Split().Select(func).ToArray();
public static long[] RLongs(Func<string, long> func) =>
Console.ReadLine().Split().Select(func).ToArray();
public static double[] RDoubles(Func<string, double> func) =>
Console.ReadLine().Split().Select(func).ToArray();
// public static string[] RStrings(Func<string, string> func) =>
// Console.ReadLine().Split().Select(func).ToArray();
public static T1 ReadTuple<T1>() {
var r = RString();
var r1 = (T1)Convert.ChangeType(r, typeof(T1));
return r1;
}
public static (T1, T2) ReadTuple<T1, T2>() {
var r = RStrings();
var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
return (r1, r2);
}
public static (T1, T2, T3) ReadTuple<T1, T2, T3>() {
var r = RStrings();
var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
return (r1, r2, r3);
}
public static (T1, T2, T3, T4) ReadTuple<T1, T2, T3, T4>() {
var r = RStrings();
var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
var r4 = (T4)Convert.ChangeType(r[3], typeof(T4));
return (r1, r2, r3, r4);
}
}
|
[["-", 0, 212, 0, 288, 0, 28, 0, 241, 0, 33], ["-", 0, 212, 0, 288, 0, 28, 0, 241, 0, 203], ["+", 0, 200, 0, 212, 0, 288, 0, 28, 0, 203]]
| 8
| 820
| 3
|
using System;
using System.Linq;
namespace Program {
class D {
static void Main(string[] args) {
int ret = 1;
var NK = Console.ReadLine().Split().Select(int.Parse).ToArray();
int N = NK[0];
int K = NK[1];
var A = Console.ReadLine().Split().Select(int.Parse).ToArray();
int low = 1, high = 1;
for (int i = 0; i < N; i++) {
if (A[i] > high) {
high = A[i];
}
}
while (true) {
if (high - low <= 1) {
ret = high;
break;
}
int mid = Floor2(high, low);
int mintime = 0;
for (int i = 0; i < N; i++) {
mintime += (int)Math.Ceiling((double)A[i] / mid) - 1;
}
if (mintime <= K) {
high = mid;
} else {
low = mid;
}
}
Console.WriteLine(ret);
}
public static int Floor2(int a, int b) {
if ((a + b) % 2 == 0) {
return (a + b) / 2;
} else {
return (a + b - 1) / 2;
}
}
}
}
|
using System;
using System.Linq;
namespace Program {
class D {
static void Main(string[] args) {
int ret = 1;
var NK = Console.ReadLine().Split().Select(int.Parse).ToArray();
int N = NK[0];
int K = NK[1];
var A = Console.ReadLine().Split().Select(int.Parse).ToArray();
int low = 0, high = 1;
for (int i = 0; i < N; i++) {
if (A[i] > high) {
high = A[i];
}
}
while (true) {
if (high - low <= 1) {
ret = high;
break;
}
int mid = Floor2(high, low);
int mintime = 0;
for (int i = 0; i < N; i++) {
mintime += (int)Math.Ceiling((double)A[i] / mid) - 1;
}
if (mintime <= K) {
high = mid;
} else {
low = mid;
}
}
Console.WriteLine(ret);
}
public static int Floor2(int a, int b) {
if ((a + b) % 2 == 0) {
return (a + b) / 2;
} else {
return (a + b - 1) / 2;
}
}
}
}
|
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203]]
| 8
| 290
| 2
|
using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Collections;
namespace debug {
class main {
static void Main(string[] args) {
//問題クラスを展開
ProgramE a = new ProgramE();
a.main(); //実行する
}
}
// ABC170
class ProgramA {
public void main() {
//入力
int x = int.Parse(Console.ReadLine());
if (x >= 30)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
class ProgramB {
public void main() {
//入力
string[] s = Console.ReadLine().Split(' ');
long n = long.Parse(s[0]);
long d = long.Parse(s[1]);
long count = 0;
for (int i = 0; i < n; i++) {
string[] t = Console.ReadLine().Split(' ');
long x = long.Parse(t[0]);
long y = long.Parse(t[1]);
if (x * x + y * y <= d * d)
count++;
}
Console.WriteLine(count);
}
}
class ProgramC {
public void main() {
//入力
int k = int.Parse(Console.ReadLine());
if (k % 2 == 0) {
Console.WriteLine("-1");
return;
}
if (7 % k == 0) {
Console.WriteLine("1");
return;
}
int flag = 0;
long num = 7;
long count = 1;
while (flag == 0) {
count++;
num *= 10;
num += 7;
num %= k;
if (num == 0)
flag = 1;
if (count >= 10000000) {
Console.WriteLine("-1");
return;
}
}
Console.WriteLine(count);
}
}
class ProgramD {
public void main() {
//入力
long n = long.Parse(Console.ReadLine());
string s = Console.ReadLine();
int wc = 0;
int rc = 0;
for (int i = 0; i < n; i++) {
if (s[i] == 'R')
rc++;
else
wc++;
}
if (wc == 0) {
Console.WriteLine("0");
return;
}
int rw = 0;
int ww = 0;
for (int i = 0; i < rc; i++) {
if (s[i] == 'W')
rw++;
}
for (int i = rc; i < n; i++) {
if (s[i] == 'R')
ww++;
}
Console.WriteLine(Math.Min(rw, ww) + Math.Abs(rw - ww));
}
}
class ProgramE {
public void main() {
//入力
string[] s = Console.ReadLine().Split(' ');
long n = long.Parse(s[0]);
long k = long.Parse(s[1]);
long[] a = new long[n];
string[] t = Console.ReadLine().Split(' ');
for (int i = 0; i < n; i++)
a[i] = long.Parse(t[i]);
long min = 1;
long max = 1000000000;
while (min + 1 != max) {
long temp = (min + max) / 2;
long cut = 0;
for (int i = 0; i < n; i++) {
if (a[i] < temp)
continue;
if (a[i] % temp == 0)
cut += a[i] / temp - 1;
else
cut += a[i] / temp;
}
if (cut <= k)
max = temp;
else
min = temp;
}
Console.WriteLine(max);
}
}
}
|
using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Collections;
namespace debug {
class main {
static void Main(string[] args) {
//問題クラスを展開
ProgramE a = new ProgramE();
a.main(); //実行する
}
}
// ABC170
class ProgramA {
public void main() {
//入力
int x = int.Parse(Console.ReadLine());
if (x >= 30)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
class ProgramB {
public void main() {
//入力
string[] s = Console.ReadLine().Split(' ');
long n = long.Parse(s[0]);
long d = long.Parse(s[1]);
long count = 0;
for (int i = 0; i < n; i++) {
string[] t = Console.ReadLine().Split(' ');
long x = long.Parse(t[0]);
long y = long.Parse(t[1]);
if (x * x + y * y <= d * d)
count++;
}
Console.WriteLine(count);
}
}
class ProgramC {
public void main() {
//入力
int k = int.Parse(Console.ReadLine());
if (k % 2 == 0) {
Console.WriteLine("-1");
return;
}
if (7 % k == 0) {
Console.WriteLine("1");
return;
}
int flag = 0;
long num = 7;
long count = 1;
while (flag == 0) {
count++;
num *= 10;
num += 7;
num %= k;
if (num == 0)
flag = 1;
if (count >= 10000000) {
Console.WriteLine("-1");
return;
}
}
Console.WriteLine(count);
}
}
class ProgramD {
public void main() {
//入力
long n = long.Parse(Console.ReadLine());
string s = Console.ReadLine();
int wc = 0;
int rc = 0;
for (int i = 0; i < n; i++) {
if (s[i] == 'R')
rc++;
else
wc++;
}
if (wc == 0) {
Console.WriteLine("0");
return;
}
int rw = 0;
int ww = 0;
for (int i = 0; i < rc; i++) {
if (s[i] == 'W')
rw++;
}
for (int i = rc; i < n; i++) {
if (s[i] == 'R')
ww++;
}
Console.WriteLine(Math.Min(rw, ww) + Math.Abs(rw - ww));
}
}
class ProgramE {
public void main() {
//入力
string[] s = Console.ReadLine().Split(' ');
long n = long.Parse(s[0]);
long k = long.Parse(s[1]);
long[] a = new long[n];
string[] t = Console.ReadLine().Split(' ');
for (int i = 0; i < n; i++)
a[i] = long.Parse(t[i]);
long min = 0;
long max = 1000000000;
while (min + 1 != max) {
long temp = (min + max) / 2;
long cut = 0;
for (int i = 0; i < n; i++) {
if (a[i] < temp)
continue;
if (a[i] % temp == 0)
cut += a[i] / temp - 1;
else
cut += a[i] / temp;
}
if (cut <= k)
max = temp;
else
min = temp;
}
Console.WriteLine(max);
}
}
}
|
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203]]
| 8
| 826
| 2
|
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atcoder {
public class Program {
private static long mod = 1000000007;
private static long max = 999999999999;
static void Main(string[] args) {
var r = ReadSplit();
var n = r[0].Int();
var k = r[1].Long();
long ok = 1000000000;
long ng = -1;
var al = new long[n];
var r2 = ReadSplit();
for (int i = 0; i < n; i++) {
al[i] = r2[i].Long();
}
if (k == 0) {
WriteRead(al.Max());
return;
}
while (ok - ng > 1) {
long mid = (ok + ng) / 2;
if (mid == 0)
break;
long count = 0;
foreach (var item in al) {
count += item / mid;
if (item % mid == 0) {
count--;
}
}
if (count <= k) {
ok = mid;
} else {
ng = mid;
}
}
WriteRead(ok);
}
public static string Read() { return Console.ReadLine(); }
public static string[] ReadSplit() { return Console.ReadLine().Split(' '); }
public static void WriteRead(object str) {
Console.WriteLine(str);
Read();
}
public static void Write(object str) { Console.WriteLine(str); }
private static bool ChangeMin<T>(ref T a, T b)
where T : IComparable {
if (a.CompareTo(b) > 0) {
a = b;
return true;
}
return false;
}
private static bool ChangekMax<T>(ref T a, T b)
where T : IComparable {
if (b.CompareTo(a) > 0) {
a = b;
return true;
}
return false;
}
/*優先度付きキュー*/
class PriorityQueue<T>
where T : IComparable<T> {
public readonly T[] Array;
public readonly bool Greater;
public int Count { get; private set; } = 0;
public PriorityQueue(int capacity, bool greater = true) {
this.Array = new T[capacity];
this.Greater = greater;
}
public void Enqueue(T item) {
this.Array[this.Count] = item;
this.Count += 1;
this.UpHeap();
}
public T Dequeue() {
// 先頭要素を末尾にして再構成
this.Swap(0, this.Count - 1);
this.Count -= 1;
this.DownHeap();
return this.Array[this.Count];
}
private void UpHeap() {
var n = this.Count - 1;
while (n != 0) {
// 親要素の座標
var parent = (n - 1) / 2;
if (this.Compare(this.Array[n], this.Array[parent]) > 0) {
this.Swap(n, parent);
n = parent;
} else {
break;
}
}
}
private void DownHeap() {
var parent = 0;
while (true) {
var child = 2 * parent + 1;
if (child > this.Count - 1)
break;
if (child < this.Count - 1 &&
this.Compare(this.Array[child], this.Array[child + 1]) < 0) {
// 左より右の子のほうが大きい値の場合、右を入れ替え対象にする
child += 1;
}
if (this.Compare(this.Array[parent], this.Array[child]) < 0) {
this.Swap(parent, child);
parent = child;
} else {
break;
}
}
}
// aとbを比較する
private int Compare(T a, T b) {
var c = a.CompareTo(b);
if (!this.Greater) {
c = -c;
}
return c;
}
// aとbを入れ替える
private void Swap(int a, int b) {
var tmp = this.Array[a];
this.Array[a] = this.Array[b];
this.Array[b] = tmp;
}
}
private static bool NextPermutation(int[] array) {
var size = array.Length;
var ok = false;
// array[i]<array[i+1]を満たす最大のiを求める
int i = size - 2;
for (; 0 <= i; i--) {
if (array[i] < array[i + 1]) {
ok = true;
break;
}
}
//全ての要素が降順の場合、NextPermutationは存在しない
if (ok == false)
return false;
// array[i]<array[j]を満たす最大のjを求める
int j = size - 1;
for (;; j--) {
if (array[i] < array[j])
break;
}
// iとjの要素をswapする
var tmp = array[i];
array[i] = array[j];
array[j] = tmp;
// i以降の要素を反転させる
Array.Reverse(array, i + 1, size - (i + 1));
return true;
}
//要素数Nを引数として渡し、0~N-1でできた順列をすべて返す
static List<int[]> GetAllPermutation(int N) {
var res = new List<int[]>();
var array = Enumerable.Range(0, N).ToArray();
do {
var copy = new int[N];
array.CopyTo(copy, 0);
res.Add(copy);
} while (NextPermutation(array));
return res;
}
//配列arrayを引数として渡し,辞書順がarray以上の順列をすべて返す
static List<int[]> GetAllPermutation(int[] array) {
var size = array.Length;
var res = new List<int[]>();
do {
var copy = new int[size];
array.CopyTo(copy, 0);
res.Add(copy);
} while (NextPermutation(array));
return res;
}
}
}
public static class Extentions {
public static int Int(this object obj) { return int.Parse(obj.ToString()); }
public static long Long(this object obj) {
return long.Parse(obj.ToString());
}
public static decimal Decimal(this object obj) {
return decimal.Parse(obj.ToString());
}
public static double Double(this object obj) {
return double.Parse(obj.ToString());
}
public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key)
where T2 : struct {
T2 value;
if (d.TryGetValue(key, out value)) {
return value;
}
return new T2();
}
}
|
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atcoder {
public class Program {
private static long mod = 1000000007;
private static long max = 999999999999;
static void Main(string[] args) {
var r = ReadSplit();
var n = r[0].Int();
var k = r[1].Long();
long ok = 10000000000;
long ng = -1;
var al = new long[n];
var r2 = ReadSplit();
for (int i = 0; i < n; i++) {
al[i] = r2[i].Long();
}
if (k == 0) {
WriteRead(al.Max());
return;
}
while (ok - ng > 1) {
long mid = (ok + ng) / 2;
if (mid == 0)
break;
long count = 0;
foreach (var item in al) {
count += item / mid;
if (item % mid == 0) {
count--;
}
}
if (count <= k) {
ok = mid;
} else {
ng = mid;
}
}
WriteRead(ok);
}
public static string Read() { return Console.ReadLine(); }
public static string[] ReadSplit() { return Console.ReadLine().Split(' '); }
public static void WriteRead(object str) {
Console.WriteLine(str);
Read();
}
public static void Write(object str) { Console.WriteLine(str); }
private static bool ChangeMin<T>(ref T a, T b)
where T : IComparable {
if (a.CompareTo(b) > 0) {
a = b;
return true;
}
return false;
}
private static bool ChangekMax<T>(ref T a, T b)
where T : IComparable {
if (b.CompareTo(a) > 0) {
a = b;
return true;
}
return false;
}
/*優先度付きキュー*/
class PriorityQueue<T>
where T : IComparable<T> {
public readonly T[] Array;
public readonly bool Greater;
public int Count { get; private set; } = 0;
public PriorityQueue(int capacity, bool greater = true) {
this.Array = new T[capacity];
this.Greater = greater;
}
public void Enqueue(T item) {
this.Array[this.Count] = item;
this.Count += 1;
this.UpHeap();
}
public T Dequeue() {
// 先頭要素を末尾にして再構成
this.Swap(0, this.Count - 1);
this.Count -= 1;
this.DownHeap();
return this.Array[this.Count];
}
private void UpHeap() {
var n = this.Count - 1;
while (n != 0) {
// 親要素の座標
var parent = (n - 1) / 2;
if (this.Compare(this.Array[n], this.Array[parent]) > 0) {
this.Swap(n, parent);
n = parent;
} else {
break;
}
}
}
private void DownHeap() {
var parent = 0;
while (true) {
var child = 2 * parent + 1;
if (child > this.Count - 1)
break;
if (child < this.Count - 1 &&
this.Compare(this.Array[child], this.Array[child + 1]) < 0) {
// 左より右の子のほうが大きい値の場合、右を入れ替え対象にする
child += 1;
}
if (this.Compare(this.Array[parent], this.Array[child]) < 0) {
this.Swap(parent, child);
parent = child;
} else {
break;
}
}
}
// aとbを比較する
private int Compare(T a, T b) {
var c = a.CompareTo(b);
if (!this.Greater) {
c = -c;
}
return c;
}
// aとbを入れ替える
private void Swap(int a, int b) {
var tmp = this.Array[a];
this.Array[a] = this.Array[b];
this.Array[b] = tmp;
}
}
private static bool NextPermutation(int[] array) {
var size = array.Length;
var ok = false;
// array[i]<array[i+1]を満たす最大のiを求める
int i = size - 2;
for (; 0 <= i; i--) {
if (array[i] < array[i + 1]) {
ok = true;
break;
}
}
//全ての要素が降順の場合、NextPermutationは存在しない
if (ok == false)
return false;
// array[i]<array[j]を満たす最大のjを求める
int j = size - 1;
for (;; j--) {
if (array[i] < array[j])
break;
}
// iとjの要素をswapする
var tmp = array[i];
array[i] = array[j];
array[j] = tmp;
// i以降の要素を反転させる
Array.Reverse(array, i + 1, size - (i + 1));
return true;
}
//要素数Nを引数として渡し、0~N-1でできた順列をすべて返す
static List<int[]> GetAllPermutation(int N) {
var res = new List<int[]>();
var array = Enumerable.Range(0, N).ToArray();
do {
var copy = new int[N];
array.CopyTo(copy, 0);
res.Add(copy);
} while (NextPermutation(array));
return res;
}
//配列arrayを引数として渡し,辞書順がarray以上の順列をすべて返す
static List<int[]> GetAllPermutation(int[] array) {
var size = array.Length;
var res = new List<int[]>();
do {
var copy = new int[size];
array.CopyTo(copy, 0);
res.Add(copy);
} while (NextPermutation(array));
return res;
}
}
}
public static class Extentions {
public static int Int(this object obj) { return int.Parse(obj.ToString()); }
public static long Long(this object obj) {
return long.Parse(obj.ToString());
}
public static decimal Decimal(this object obj) {
return decimal.Parse(obj.ToString());
}
public static double Double(this object obj) {
return double.Parse(obj.ToString());
}
public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key)
where T2 : struct {
T2 value;
if (d.TryGetValue(key, out value)) {
return value;
}
return new T2();
}
}
|
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203]]
| 8
| 1,322
| 2
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;
using static Atcoder.IO;
namespace Atcoder {
class Program {
static StreamWriter sw =
new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
static void Main(string[] args) {
try {
SetOut(sw);
Solve.Answer();
Out.Flush();
} catch (Exception ex) {
WriteLine(ex.ToString());
Out.Flush();
}
}
}
public class Solve {
static long n;
static long k;
static long[] a;
public static void Answer() {
var nk = IO.RSLong;
n = nk[0];
k = nk[1];
a = IO.RSLong;
if (k == 0) {
WriteLine(a.Max());
return;
}
long ng = 1;
long ok = long.MaxValue - 1;
while (ok - ng > 1) {
long mid = (ok + ng) / 2;
if (IsOK(mid))
ok = mid;
else
ng = mid;
}
// WriteLine(ok);
WriteLine(ng);
}
public static bool IsOK(long mid) {
long totalCnt = 0;
for (int i = 0; i < n; i++) {
long cnt = (long)(a[i] / mid);
if (a[i] % mid == 0)
cnt--;
totalCnt += cnt;
}
return totalCnt <= k;
}
}
public class IO {
#region Input
public static int RInt => int.Parse(ReadLine());
public static long RLong => long.Parse(ReadLine());
public static double RDouble => double.Parse(ReadLine());
public static string[] RSString => ReadLine().Split();
public static int[] RSInt =>
ReadLine().Split().Select(s => int.Parse(s)).ToArray();
public static long[] RSLong =>
ReadLine().Split().Select(s => long.Parse(s)).ToArray();
public static double[] RSDouble =>
ReadLine().Split().Select(s => double.Parse(s)).ToArray();
#endregion
#region Output
public static void
OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes"
: "No");
public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES"
: "NO");
#endregion
}
public class Mod {
#region
private readonly static long M = 1000000007;
public static long Add(long a, long b) => (a * b) % M;
public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M
: (a - b) % M + M;
public static long Multi(long a, long b) => (a * b) % M;
#endregion
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;
using static Atcoder.IO;
namespace Atcoder {
class Program {
static StreamWriter sw =
new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
static void Main(string[] args) {
try {
SetOut(sw);
Solve.Answer();
Out.Flush();
} catch (Exception ex) {
WriteLine(ex.ToString());
Out.Flush();
}
}
}
public class Solve {
static long n;
static long k;
static long[] a;
public static void Answer() {
var nk = IO.RSLong;
n = nk[0];
k = nk[1];
a = IO.RSLong;
if (k == 0) {
WriteLine(a.Max());
return;
}
long ng = 0;
long ok = long.MaxValue - 1;
while (ok - ng > 1) {
long mid = (ok + ng) / 2;
if (IsOK(mid))
ok = mid;
else
ng = mid;
}
WriteLine(ok);
// WriteLine(ng);
}
public static bool IsOK(long mid) {
long totalCnt = 0;
for (int i = 0; i < n; i++) {
long cnt = (long)(a[i] / mid);
if (a[i] % mid == 0)
cnt--;
totalCnt += cnt;
}
return totalCnt <= k;
}
}
public class IO {
#region Input
public static int RInt => int.Parse(ReadLine());
public static long RLong => long.Parse(ReadLine());
public static double RDouble => double.Parse(ReadLine());
public static string[] RSString => ReadLine().Split();
public static int[] RSInt =>
ReadLine().Split().Select(s => int.Parse(s)).ToArray();
public static long[] RSLong =>
ReadLine().Split().Select(s => long.Parse(s)).ToArray();
public static double[] RSDouble =>
ReadLine().Split().Select(s => double.Parse(s)).ToArray();
#endregion
#region Output
public static void
OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes"
: "No");
public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES"
: "NO");
#endregion
}
public class Mod {
#region
private readonly static long M = 1000000007;
public static long Add(long a, long b) => (a * b) % M;
public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M
: (a - b) % M + M;
public static long Multi(long a, long b) => (a * b) % M;
#endregion
}
}
|
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 662
| 4
|
using System;
using static System.Console;
namespace abc174 {
class Program {
static int[] ReadNumList() {
var line = ReadLine().Split(' ');
if (line.Length == 1 && string.IsNullOrEmpty(line[0])) {
return new int[0];
}
var numList = new int[line.Length];
for (var i = 0; i < line.Length; ++i) {
numList[i] = int.Parse(line[i]);
}
return numList;
}
static void Main() {
var nk = ReadLine().Split(' ');
var n = int.Parse(nk[0]);
var k = int.Parse(nk[1]);
var aList = ReadNumList();
var startLen = 0;
var startCut = 0L;
var endLen = 1;
var endCut = 0L;
foreach (var a in aList) {
startLen = Math.Max(startLen, a);
endCut += a - 1;
}
WriteLine(DivSearch(k, startLen, startCut, endLen, endCut, aList));
}
static long CalcCutCount(int length, int[] aList) {
var total = 0L;
foreach (var a in aList) {
total += (long)Math.Ceiling((double)a / length) - 1;
}
return total;
}
static long DivSearch(int targetCut, int startLen, long startCut, int endLen,
long endCut, int[] aList) {
if (startLen - endLen <= 1) {
if (targetCut >= endCut) {
return endLen;
} else {
return startLen;
}
}
var centerLen = (startLen + endLen) / 2;
var centerCut = CalcCutCount(centerLen, aList);
if (centerCut < targetCut) {
return DivSearch(targetCut, centerLen, centerCut, endLen, endCut, aList);
} else {
return DivSearch(targetCut, startLen, startCut, centerLen, centerCut,
aList);
}
}
}
}
|
using System;
using static System.Console;
namespace abc174 {
class Program {
static int[] ReadNumList() {
var line = ReadLine().Split(' ');
if (line.Length == 1 && string.IsNullOrEmpty(line[0])) {
return new int[0];
}
var numList = new int[line.Length];
for (var i = 0; i < line.Length; ++i) {
numList[i] = int.Parse(line[i]);
}
return numList;
}
static void Main() {
var nk = ReadLine().Split(' ');
var n = int.Parse(nk[0]);
var k = int.Parse(nk[1]);
var aList = ReadNumList();
var startLen = 0;
var startCut = 0L;
var endLen = 1;
var endCut = 0L;
foreach (var a in aList) {
startLen = Math.Max(startLen, a);
endCut += a - 1;
}
WriteLine(DivSearch(k, startLen, startCut, endLen, endCut, aList));
}
static long CalcCutCount(int length, int[] aList) {
var total = 0L;
foreach (var a in aList) {
total += (long)Math.Ceiling((double)a / length) - 1;
}
return total;
}
static long DivSearch(int targetCut, int startLen, long startCut, int endLen,
long endCut, int[] aList) {
if (startLen - endLen <= 1) {
if (targetCut >= endCut) {
return endLen;
} else {
return startLen;
}
}
var centerLen = (startLen + endLen) / 2;
var centerCut = CalcCutCount(centerLen, aList);
if (centerCut <= targetCut) {
return DivSearch(targetCut, centerLen, centerCut, endLen, endCut, aList);
} else {
return DivSearch(targetCut, startLen, startCut, centerLen, centerCut,
aList);
}
}
}
}
|
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 19]]
| 8
| 399
| 2
|
using System;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split();
int N = int.Parse(str[0]);
int K = int.Parse(str[1]);
int[] a = new int[N];
string[] str2 = Console.ReadLine().Split();
for (var i = 0; i < N; i++) {
a[i] = int.Parse(str2[i]);
}
int min = 0;
int max = 1000000007;
while (min < max) {
int m = (min + max) / 2;
long ans = 0;
for (var k = 0; k < N; k++) {
ans += (a[k] + m - 1) / m - 1;
}
if (ans > K) {
min = m + 1;
} else {
max = m;
}
}
Console.WriteLine(min);
}
}
|
using System;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split();
int N = int.Parse(str[0]);
int K = int.Parse(str[1]);
int[] a = new int[N];
string[] str2 = Console.ReadLine().Split();
for (var i = 0; i < N; i++) {
a[i] = int.Parse(str2[i]);
}
int min = 1;
int max = 1000000007;
while (min < max) {
int m = (min + max) / 2;
long ans = 0;
for (var k = 0; k < N; k++) {
ans += (a[k] + m - 1) / m - 1;
}
if (ans > K) {
min = m + 1;
} else {
max = m;
}
}
Console.WriteLine(min);
}
}
|
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203]]
| 8
| 218
| 2
|
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 ProblemE {
static bool SAIKI = false;
static public int numberOfRandomCases = 0;
static public void MakeTestCase(List<string> _input, List<string> _output,
ref Func<string[], bool> _outputChecker) {}
static public void Solve() {
var N = NN;
var K = NN;
var AList = NNList(N);
var left = 1L;
var right = 100000000000L;
while (right - left > 1) {
var mid = (right + left) / 2;
var cnt = 0L;
foreach (var item in AList) {
cnt += (long)((item - 1) / mid);
}
if (cnt <= K)
right = mid;
else
left = mid;
}
Console.WriteLine(left + 1);
}
class Printer : StreamWriter {
public override IFormatProvider FormatProvider {
get { return CultureInfo.InvariantCulture; }
}
public Printer(Stream stream)
: base(stream, new UTF8Encoding(false, true)) {
base.AutoFlush = false;
}
public Printer(Stream stream, Encoding encoding) : base(stream, encoding) {
base.AutoFlush = false;
}
}
static LIB_FastIO fastio = new LIB_FastIODebug();
static public void Main(string[] args) {
if (args.Length == 0) {
fastio = new LIB_FastIO();
Console.SetOut(new Printer(Console.OpenStandardOutput()));
}
if (SAIKI) {
var t = new Thread(Solve, 134217728);
t.Start();
t.Join();
} else
Solve();
Console.Out.Flush();
}
static long NN => fastio.Long();
static double ND => fastio.Double();
static string NS => fastio.Scan();
static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
static long Count<T>(this IEnumerable<T> x,
Func<T, bool> pred) => Enumerable.Count(x, pred);
static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v,
(int)n);
static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s,
(int)c);
static IOrderedEnumerable<T>
OrderByRand<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x, _ => xorshift);
static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x) =>
Enumerable.OrderBy(x.OrderByRand(), e => e);
static IOrderedEnumerable<T1> OrderBy<T1, T2>(this IEnumerable<T1> x,
Func<T1, T2> selector) =>
Enumerable.OrderBy(x.OrderByRand(), selector);
static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x) =>
Enumerable.OrderByDescending(x.OrderByRand(), e => e);
static IOrderedEnumerable<T1>
OrderByDescending<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) =>
Enumerable.OrderByDescending(x.OrderByRand(), selector);
static IOrderedEnumerable<string> OrderBy(this IEnumerable<string> x) =>
x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);
static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x,
Func<T, string> selector) =>
x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);
static IOrderedEnumerable<string>
OrderByDescending(this IEnumerable<string> x) =>
x.OrderByRand().OrderByDescending(e => e,
StringComparer.OrdinalIgnoreCase);
static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x,
Func<T, string> selector) =>
x.OrderByRand().OrderByDescending(selector,
StringComparer.OrdinalIgnoreCase);
static string Join<T>(this IEnumerable<T> x,
string separator = "") => string.Join(separator, x);
static uint xorshift {
get {
_xsi.MoveNext();
return _xsi.Current;
}
}
static IEnumerator<uint> _xsi = _xsc();
static IEnumerator<uint> _xsc() {
uint x = 123456789, y = 362436069, z = 521288629,
w = (uint)(DateTime.Now.Ticks & 0xffffffff);
while (true) {
var t = x ^ (x << 11);
x = y;
y = z;
z = w;
w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
yield return w;
}
}
}
}
namespace Library {
class LIB_FastIO {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public LIB_FastIO() { str = Console.OpenStandardInput(); }
readonly Stream str;
readonly byte[] buf = new byte[1024];
int len, ptr;
public bool isEof = false;
public bool IsEndOfStream {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get { return isEof; }
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
byte read() {
if (isEof)
throw new EndOfStreamException();
if (ptr >= len) {
ptr = 0;
if ((len = str.Read(buf, 0, 1024)) <= 0) {
isEof = true;
return 0;
}
}
return buf[ptr++];
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
char Char() {
byte b = 0;
do
b = read();
while (b < 33 || 126 < b);
return (char)b;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
virtual public string Scan() {
var sb = new StringBuilder();
for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
sb.Append(b);
return sb.ToString();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
virtual public long Long() {
long ret = 0;
byte b = 0;
var ng = false;
do
b = read();
while (b != '-' && (b < '0' || '9' < b));
if (b == '-') {
ng = true;
b = read();
}
for (; true; b = read()) {
if (b < '0' || '9' < b)
return ng ? -ret : ret;
else
ret = ret * 10 + b - '0';
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
virtual public double Double() {
return double.Parse(Scan(), CultureInfo.InvariantCulture);
}
}
class LIB_FastIODebug : LIB_FastIO {
Queue<string> param = new Queue<string>();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
string NextString() {
if (param.Count == 0)
foreach (var item in Console.ReadLine().Split(' '))
param.Enqueue(item);
return param.Dequeue();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public LIB_FastIODebug() {}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override string Scan() => NextString();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override long Long() => long.Parse(NextString());
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override double Double() => double.Parse(NextString());
}
}
|
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 ProblemE {
static bool SAIKI = false;
static public int numberOfRandomCases = 0;
static public void MakeTestCase(List<string> _input, List<string> _output,
ref Func<string[], bool> _outputChecker) {}
static public void Solve() {
var N = NN;
var K = NN;
var AList = NNList(N);
var left = 0L;
var right = 100000000000L;
while (right - left > 1) {
var mid = (right + left) / 2;
var cnt = 0L;
foreach (var item in AList) {
cnt += (long)((item - 1) / mid);
}
if (cnt <= K)
right = mid;
else
left = mid;
}
Console.WriteLine(left + 1);
}
class Printer : StreamWriter {
public override IFormatProvider FormatProvider {
get { return CultureInfo.InvariantCulture; }
}
public Printer(Stream stream)
: base(stream, new UTF8Encoding(false, true)) {
base.AutoFlush = false;
}
public Printer(Stream stream, Encoding encoding) : base(stream, encoding) {
base.AutoFlush = false;
}
}
static LIB_FastIO fastio = new LIB_FastIODebug();
static public void Main(string[] args) {
if (args.Length == 0) {
fastio = new LIB_FastIO();
Console.SetOut(new Printer(Console.OpenStandardOutput()));
}
if (SAIKI) {
var t = new Thread(Solve, 134217728);
t.Start();
t.Join();
} else
Solve();
Console.Out.Flush();
}
static long NN => fastio.Long();
static double ND => fastio.Double();
static string NS => fastio.Scan();
static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
static long Count<T>(this IEnumerable<T> x,
Func<T, bool> pred) => Enumerable.Count(x, pred);
static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v,
(int)n);
static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s,
(int)c);
static IOrderedEnumerable<T>
OrderByRand<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x, _ => xorshift);
static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x) =>
Enumerable.OrderBy(x.OrderByRand(), e => e);
static IOrderedEnumerable<T1> OrderBy<T1, T2>(this IEnumerable<T1> x,
Func<T1, T2> selector) =>
Enumerable.OrderBy(x.OrderByRand(), selector);
static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x) =>
Enumerable.OrderByDescending(x.OrderByRand(), e => e);
static IOrderedEnumerable<T1>
OrderByDescending<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) =>
Enumerable.OrderByDescending(x.OrderByRand(), selector);
static IOrderedEnumerable<string> OrderBy(this IEnumerable<string> x) =>
x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);
static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x,
Func<T, string> selector) =>
x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);
static IOrderedEnumerable<string>
OrderByDescending(this IEnumerable<string> x) =>
x.OrderByRand().OrderByDescending(e => e,
StringComparer.OrdinalIgnoreCase);
static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x,
Func<T, string> selector) =>
x.OrderByRand().OrderByDescending(selector,
StringComparer.OrdinalIgnoreCase);
static string Join<T>(this IEnumerable<T> x,
string separator = "") => string.Join(separator, x);
static uint xorshift {
get {
_xsi.MoveNext();
return _xsi.Current;
}
}
static IEnumerator<uint> _xsi = _xsc();
static IEnumerator<uint> _xsc() {
uint x = 123456789, y = 362436069, z = 521288629,
w = (uint)(DateTime.Now.Ticks & 0xffffffff);
while (true) {
var t = x ^ (x << 11);
x = y;
y = z;
z = w;
w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
yield return w;
}
}
}
}
namespace Library {
class LIB_FastIO {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public LIB_FastIO() { str = Console.OpenStandardInput(); }
readonly Stream str;
readonly byte[] buf = new byte[1024];
int len, ptr;
public bool isEof = false;
public bool IsEndOfStream {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get { return isEof; }
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
byte read() {
if (isEof)
throw new EndOfStreamException();
if (ptr >= len) {
ptr = 0;
if ((len = str.Read(buf, 0, 1024)) <= 0) {
isEof = true;
return 0;
}
}
return buf[ptr++];
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
char Char() {
byte b = 0;
do
b = read();
while (b < 33 || 126 < b);
return (char)b;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
virtual public string Scan() {
var sb = new StringBuilder();
for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
sb.Append(b);
return sb.ToString();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
virtual public long Long() {
long ret = 0;
byte b = 0;
var ng = false;
do
b = read();
while (b != '-' && (b < '0' || '9' < b));
if (b == '-') {
ng = true;
b = read();
}
for (; true; b = read()) {
if (b < '0' || '9' < b)
return ng ? -ret : ret;
else
ret = ret * 10 + b - '0';
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
virtual public double Double() {
return double.Parse(Scan(), CultureInfo.InvariantCulture);
}
}
class LIB_FastIODebug : LIB_FastIO {
Queue<string> param = new Queue<string>();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
string NextString() {
if (param.Count == 0)
foreach (var item in Console.ReadLine().Split(' '))
param.Enqueue(item);
return param.Dequeue();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public LIB_FastIODebug() {}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override string Scan() => NextString();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override long Long() => long.Parse(NextString());
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override double Double() => double.Parse(NextString());
}
}
|
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203]]
| 8
| 1,631
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Threading;
using System.Runtime.CompilerServices;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Template;
class Solver {
public Scanner sc;
public void Solve() {
int N;
long K;
sc.Make(out N, out K);
var A = sc.ArrInt;
int l = -1, r = 1000000007;
while (r - l > 1) {
var m = (r + l) / 2;
var ct = 0L;
for (int i = 0; i < N; i++) {
ct += (A[i] - 1) / m;
}
if (ct > K)
l = m;
else
r = m;
}
Console.WriteLine(r);
}
}
#region Template
public static class Template {
static void Main(string[] args) {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
var sol = new Solver() { sc = new Scanner() };
// var th = new Thread(sol.Solve, 1 << 26);th.Start();th.Join();
sol.Solve();
Console.Out.Flush();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmin<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) > 0) {
a = b;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmax<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) < 0) {
a = b;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void swap<T>(ref T a, ref T b) {
var t = b;
b = a;
a = t;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void swap<T>(this IList<T> A, int i, int j) {
var t = A[i];
A[i] = A[j];
A[j] = t;
}
public static T[] Create<T>(int n, Func<T> f) {
var rt = new T[n];
for (var i = 0; i < rt.Length; ++i)
rt[i] = f();
return rt;
}
public static T[] Create<T>(int n, Func<int, T> f) {
var rt = new T[n];
for (var i = 0; i < rt.Length; ++i)
rt[i] = f(i);
return rt;
}
public static void Out<T>(this IList<T> A, out T a) => a = A[0];
public static void Out<T>(this IList<T> A, out T a, out T b) {
a = A[0];
b = A[1];
}
public static void Out<T>(this IList<T> A, out T a, out T b, out T c) {
A.Out(out a, out b);
c = A[2];
}
public static void Out<T>(this IList<T> A, out T a, out T b, out T c,
out T d) {
A.Out(out a, out b, out c);
d = A[3];
}
public static string Concat<T>(this IEnumerable<T> A,
string sp) => string.Join(sp, A);
public static char ToChar(this int s, char begin = '0') => (char)(s + begin);
public static IEnumerable<T>
Shuffle<T>(this IEnumerable<T> A) => A.OrderBy(v => Guid.NewGuid());
public static int CompareTo<T>(this T[] A, T[] B, Comparison<T> cmp = null) {
cmp = cmp ?? Comparer<T>.Default.Compare;
for (var i = 0; i < Min(A.Length, B.Length); i++) {
int c = cmp(A[i], B[i]);
if (c > 0)
return 1;
else if (c < 0)
return -1;
}
if (A.Length == B.Length)
return 0;
if (A.Length > B.Length)
return 1;
else
return -1;
}
public static int ArgMax<T>(this IList<T> A, Comparison<T> cmp = null) {
cmp = cmp ?? Comparer<T>.Default.Compare;
T max = A[0];
int rt = 0;
for (int i = 1; i < A.Count; i++)
if (cmp(max, A[i]) < 0) {
max = A[i];
rt = i;
}
return rt;
}
public static T PopBack<T>(this List<T> A) {
var v = A[A.Count - 1];
A.RemoveAt(A.Count - 1);
return v;
}
public static void Fail<T>(T s) {
Console.WriteLine(s);
Console.Out.Close();
Environment.Exit(0);
}
}
public class Scanner {
public string Str => Console.ReadLine().Trim();
public int Int => int.Parse(Str);
public long Long => long.Parse(Str);
public double Double => double.Parse(Str);
public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
public int[] ArrInt1D(int n) => Create(n, () => Int);
public long[] ArrLong1D(int n) => Create(n, () => Long);
public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
private Queue<string> q = new Queue<string>();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public T Next<T>() {
if (q.Count == 0)
foreach (var item in Str.Split(' '))
q.Enqueue(item);
return (T)Convert.ChangeType(q.Dequeue(), typeof(T));
}
public void Make<T1>(out T1 v1) => v1 = Next<T1>();
public void Make<T1, T2>(out T1 v1, out T2 v2) {
v1 = Next<T1>();
v2 = Next<T2>();
}
public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) {
Make(out v1, out v2);
v3 = Next<T3>();
}
public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) {
Make(out v1, out v2, out v3);
v4 = Next<T4>();
}
public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5) {
Make(out v1, out v2, out v3, out v4);
v5 = Next<T5>();
}
public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5, out T6 v6) {
Make(out v1, out v2, out v3, out v4, out v5);
v6 = Next<T6>();
}
public void Make<T1, T2, T3, T4, T5, T6, T7>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5, out T6 v6,
out T7 v7) {
Make(out v1, out v2, out v3, out v4, out v5, out v6);
v7 = Next<T7>();
}
public (T1, T2) Make<T1, T2>() {
Make(out T1 v1, out T2 v2);
return (v1, v2);
}
public (T1, T2, T3) Make<T1, T2, T3>() {
Make(out T1 v1, out T2 v2, out T3 v3);
return (v1, v2, v3);
}
public (T1, T2, T3, T4) Make<T1, T2, T3, T4>() {
Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4);
return (v1, v2, v3, v4);
}
}
#endregion
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Threading;
using System.Runtime.CompilerServices;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Template;
class Solver {
public Scanner sc;
public void Solve() {
int N;
long K;
sc.Make(out N, out K);
var A = sc.ArrInt;
int l = 0, r = 1000000007;
while (r - l > 1) {
var m = (r + l) / 2;
var ct = 0L;
for (int i = 0; i < N; i++) {
ct += (A[i] - 1) / m;
}
if (ct > K)
l = m;
else
r = m;
}
Console.WriteLine(r);
}
}
#region Template
public static class Template {
static void Main(string[] args) {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
var sol = new Solver() { sc = new Scanner() };
// var th = new Thread(sol.Solve, 1 << 26);th.Start();th.Join();
sol.Solve();
Console.Out.Flush();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmin<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) > 0) {
a = b;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmax<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) < 0) {
a = b;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void swap<T>(ref T a, ref T b) {
var t = b;
b = a;
a = t;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void swap<T>(this IList<T> A, int i, int j) {
var t = A[i];
A[i] = A[j];
A[j] = t;
}
public static T[] Create<T>(int n, Func<T> f) {
var rt = new T[n];
for (var i = 0; i < rt.Length; ++i)
rt[i] = f();
return rt;
}
public static T[] Create<T>(int n, Func<int, T> f) {
var rt = new T[n];
for (var i = 0; i < rt.Length; ++i)
rt[i] = f(i);
return rt;
}
public static void Out<T>(this IList<T> A, out T a) => a = A[0];
public static void Out<T>(this IList<T> A, out T a, out T b) {
a = A[0];
b = A[1];
}
public static void Out<T>(this IList<T> A, out T a, out T b, out T c) {
A.Out(out a, out b);
c = A[2];
}
public static void Out<T>(this IList<T> A, out T a, out T b, out T c,
out T d) {
A.Out(out a, out b, out c);
d = A[3];
}
public static string Concat<T>(this IEnumerable<T> A,
string sp) => string.Join(sp, A);
public static char ToChar(this int s, char begin = '0') => (char)(s + begin);
public static IEnumerable<T>
Shuffle<T>(this IEnumerable<T> A) => A.OrderBy(v => Guid.NewGuid());
public static int CompareTo<T>(this T[] A, T[] B, Comparison<T> cmp = null) {
cmp = cmp ?? Comparer<T>.Default.Compare;
for (var i = 0; i < Min(A.Length, B.Length); i++) {
int c = cmp(A[i], B[i]);
if (c > 0)
return 1;
else if (c < 0)
return -1;
}
if (A.Length == B.Length)
return 0;
if (A.Length > B.Length)
return 1;
else
return -1;
}
public static int ArgMax<T>(this IList<T> A, Comparison<T> cmp = null) {
cmp = cmp ?? Comparer<T>.Default.Compare;
T max = A[0];
int rt = 0;
for (int i = 1; i < A.Count; i++)
if (cmp(max, A[i]) < 0) {
max = A[i];
rt = i;
}
return rt;
}
public static T PopBack<T>(this List<T> A) {
var v = A[A.Count - 1];
A.RemoveAt(A.Count - 1);
return v;
}
public static void Fail<T>(T s) {
Console.WriteLine(s);
Console.Out.Close();
Environment.Exit(0);
}
}
public class Scanner {
public string Str => Console.ReadLine().Trim();
public int Int => int.Parse(Str);
public long Long => long.Parse(Str);
public double Double => double.Parse(Str);
public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
public int[] ArrInt1D(int n) => Create(n, () => Int);
public long[] ArrLong1D(int n) => Create(n, () => Long);
public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
private Queue<string> q = new Queue<string>();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public T Next<T>() {
if (q.Count == 0)
foreach (var item in Str.Split(' '))
q.Enqueue(item);
return (T)Convert.ChangeType(q.Dequeue(), typeof(T));
}
public void Make<T1>(out T1 v1) => v1 = Next<T1>();
public void Make<T1, T2>(out T1 v1, out T2 v2) {
v1 = Next<T1>();
v2 = Next<T2>();
}
public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) {
Make(out v1, out v2);
v3 = Next<T3>();
}
public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) {
Make(out v1, out v2, out v3);
v4 = Next<T4>();
}
public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5) {
Make(out v1, out v2, out v3, out v4);
v5 = Next<T5>();
}
public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5, out T6 v6) {
Make(out v1, out v2, out v3, out v4, out v5);
v6 = Next<T6>();
}
public void Make<T1, T2, T3, T4, T5, T6, T7>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5, out T6 v6,
out T7 v7) {
Make(out v1, out v2, out v3, out v4, out v5, out v6);
v7 = Next<T7>();
}
public (T1, T2) Make<T1, T2>() {
Make(out T1 v1, out T2 v2);
return (v1, v2);
}
public (T1, T2, T3) Make<T1, T2, T3>() {
Make(out T1 v1, out T2 v2, out T3 v3);
return (v1, v2, v3);
}
public (T1, T2, T3, T4) Make<T1, T2, T3, T4>() {
Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4);
return (v1, v2, v3, v4);
}
}
#endregion
|
[["-", 0, 198, 0, 200, 0, 212, 0, 241, 0, 33], ["-", 0, 198, 0, 200, 0, 212, 0, 241, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203]]
| 8
| 1,945
| 3
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;
namespace Program {
public static class ProblemB {
static bool SAIKI = false;
static public int numberOfRandomCases = 0;
static public void MakeTestCase(List<string> _input, List<string> _output,
ref Func<string[], bool> _outputChecker) {}
static public void Solve() {
var N = NN;
var Q = NN;
var cList = NNList(N);
var lrList = Repeat(0, Q).Select(_ => new { l = NN, r = NN }).ToArray();
var sorted =
lrList.Select((e, i) => new { e, i }).OrderBy(e => e.e.r).ToArray();
var seg = new LIB_SegTree<long>(N, 0, (x, y) => x + y);
var last = new long[N];
for (var i = 0; i < N; i++)
last[i] = -1;
var idx = 0;
var ans = new long[Q];
foreach (var item in sorted) {
while (idx < item.e.r) {
if (last[cList[idx]] > -1)
seg[last[cList[idx]]] = 0;
seg[idx] = 1;
last[cList[idx]] = idx;
++idx;
}
ans[item.i] = seg.Query(item.e.l - 1, item.e.r);
}
for (var i = 0; i < Q; i++) {
Console.WriteLine(ans[i]);
}
}
class Printer : StreamWriter {
public override IFormatProvider FormatProvider {
get { return CultureInfo.InvariantCulture; }
}
public Printer(Stream stream)
: base(stream, new UTF8Encoding(false, true)) {
base.AutoFlush = false;
}
public Printer(Stream stream, Encoding encoding) : base(stream, encoding) {
base.AutoFlush = false;
}
}
static LIB_FastIO fastio = new LIB_FastIODebug();
static public void Main(string[] args) {
if (args.Length == 0) {
fastio = new LIB_FastIO();
Console.SetOut(new Printer(Console.OpenStandardOutput()));
}
if (SAIKI) {
var t = new Thread(Solve, 134217728);
t.Start();
t.Join();
} else
Solve();
Console.Out.Flush();
}
static long NN => fastio.Long();
static double ND => fastio.Double();
static string NS => fastio.Scan();
static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
static long Count<T>(this IEnumerable<T> x,
Func<T, bool> pred) => Enumerable.Count(x, pred);
static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v,
(int)n);
static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s,
(int)c);
static IOrderedEnumerable<T>
OrderByRand<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x, _ => xorshift);
static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x) =>
Enumerable.OrderBy(x.OrderByRand(), e => e);
static IOrderedEnumerable<T1> OrderBy<T1, T2>(this IEnumerable<T1> x,
Func<T1, T2> selector) =>
Enumerable.OrderBy(x.OrderByRand(), selector);
static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x) =>
Enumerable.OrderByDescending(x.OrderByRand(), e => e);
static IOrderedEnumerable<T1>
OrderByDescending<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) =>
Enumerable.OrderByDescending(x.OrderByRand(), selector);
static IOrderedEnumerable<string> OrderBy(this IEnumerable<string> x) =>
x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);
static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x,
Func<T, string> selector) =>
x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);
static IOrderedEnumerable<string>
OrderByDescending(this IEnumerable<string> x) =>
x.OrderByRand().OrderByDescending(e => e,
StringComparer.OrdinalIgnoreCase);
static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x,
Func<T, string> selector) =>
x.OrderByRand().OrderByDescending(selector,
StringComparer.OrdinalIgnoreCase);
static string Join<T>(this IEnumerable<T> x,
string separator = "") => string.Join(separator, x);
static uint xorshift {
get {
_xsi.MoveNext();
return _xsi.Current;
}
}
static IEnumerator<uint> _xsi = _xsc();
static IEnumerator<uint> _xsc() {
uint x = 123456789, y = 362436069, z = 521288629,
w = (uint)(DateTime.Now.Ticks & 0xffffffff);
while (true) {
var t = x ^ (x << 11);
x = y;
y = z;
z = w;
w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
yield return w;
}
}
}
}
namespace Library {
class LIB_SegTree<T> {
int n, sz;
T ti;
Func<T, T, T> f;
T[] dat;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public LIB_SegTree(long _n, T _ti, Func<T, T, T> _f) {
n = 1;
sz = (int)_n;
while (n < _n)
n <<= 1;
ti = _ti;
f = _f;
dat = Enumerable.Repeat(ti, n << 1).ToArray();
for (var i = n - 1; i > 0; i--)
dat[i] = f(dat[(i << 1) | 0], dat[(i << 1) | 1]);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public LIB_SegTree(IEnumerable<T> l, T _ti, Func<T, T, T> _f)
: this(l.Count(), _ti, _f) {
var idx = 0;
foreach (var item in l)
dat[n + idx++] = item;
for (var i = n - 1; i > 0; i--)
dat[i] = f(dat[(i << 1) | 0], dat[(i << 1) | 1]);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Update(long i, T v) {
dat[i += n] = v;
while ((i >>= 1) > 0)
dat[i] = f(dat[(i << 1) | 0], dat[(i << 1) | 1]);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public T Query(long l, long r) {
if (l == r)
return ti;
if (r < l)
throw new Exception();
var vl = ti;
var vr = ti;
for (long li = n + l, ri = n + r; li < ri; li >>= 1, ri >>= 1) {
if ((li & 1) == 1)
vl = f(vl, dat[li++]);
if ((ri & 1) == 1)
vr = f(dat[--ri], vr);
}
return f(vl, vr);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
int FindToRight(int st, Func<T, bool> check, ref T acc, int k, int l, int r) {
if (l + 1 == r) {
acc = f(acc, dat[k]);
return check(acc) ? k - n : sz;
}
int m = (l + r) >> 1;
if (m <= st)
return FindToRight(st, check, ref acc, (k << 1) | 1, m, r);
if (st <= l && !check(f(acc, dat[k]))) {
acc = f(acc, dat[k]);
return sz;
}
int vl = FindToRight(st, check, ref acc, (k << 1) | 0, l, m);
if (vl != sz)
return vl;
return FindToRight(st, check, ref acc, (k << 1) | 1, m, r);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int FindToRight(int st, Func<T, bool> check) {
T acc = ti;
return FindToRight(st, check, ref acc, 1, 0, n);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
int FindToLeft(int st, Func<T, bool> check, ref T acc, int k, int l, int r) {
if (l + 1 == r) {
acc = f(dat[k], acc);
return check(acc) ? k - n : -1;
}
int m = (l + r) >> 1;
if (m > st)
return FindToLeft(st, check, ref acc, (k << 1) | 0, l, m);
if (st >= r - 1 && !check(f(dat[k], acc))) {
acc = f(dat[k], acc);
return -1;
}
int vr = FindToLeft(st, check, ref acc, (k << 1) | 1, m, r);
if (vr != -1)
return vr;
return FindToLeft(st, check, ref acc, (k << 1) | 0, l, m);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int FindToLeft(int st, Func<T, bool> check) {
T acc = ti;
return FindToLeft(st, check, ref acc, 1, 0, n);
}
public T this[long idx] {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get { return dat[idx + n]; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
set { Update(idx, value); }
}
}
class LIB_FastIO {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public LIB_FastIO() { str = Console.OpenStandardInput(); }
readonly Stream str;
readonly byte[] buf = new byte[1024];
int len, ptr;
public bool isEof = false;
public bool IsEndOfStream {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get { return isEof; }
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
byte read() {
if (isEof)
throw new EndOfStreamException();
if (ptr >= len) {
ptr = 0;
if ((len = str.Read(buf, 0, 1024)) <= 0) {
isEof = true;
return 0;
}
}
return buf[ptr++];
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
char Char() {
byte b = 0;
do
b = read();
while (b < 33 || 126 < b);
return (char)b;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
virtual public string Scan() {
var sb = new StringBuilder();
for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
sb.Append(b);
return sb.ToString();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
virtual public long Long() {
long ret = 0;
byte b = 0;
var ng = false;
do
b = read();
while (b != '-' && (b < '0' || '9' < b));
if (b == '-') {
ng = true;
b = read();
}
for (; true; b = read()) {
if (b < '0' || '9' < b)
return ng ? -ret : ret;
else
ret = ret * 10 + b - '0';
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
virtual public double Double() {
return double.Parse(Scan(), CultureInfo.InvariantCulture);
}
}
class LIB_FastIODebug : LIB_FastIO {
Queue<string> param = new Queue<string>();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
string NextString() {
if (param.Count == 0)
foreach (var item in Console.ReadLine().Split(' '))
param.Enqueue(item);
return param.Dequeue();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public LIB_FastIODebug() {}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override string Scan() => NextString();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override long Long() => long.Parse(NextString());
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override double Double() => double.Parse(NextString());
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;
namespace Program {
public static class ProblemB {
static bool SAIKI = false;
static public int numberOfRandomCases = 0;
static public void MakeTestCase(List<string> _input, List<string> _output,
ref Func<string[], bool> _outputChecker) {}
static public void Solve() {
var N = NN;
var Q = NN;
var cList = NNList(N);
var lrList = Repeat(0, Q).Select(_ => new { l = NN, r = NN }).ToArray();
var sorted =
lrList.Select((e, i) => new { e, i }).OrderBy(e => e.e.r).ToArray();
var seg = new LIB_SegTree<long>(N, 0, (x, y) => x + y);
var last = new long[N];
for (var i = 0; i < N; i++)
last[i] = -1;
var idx = 0;
var ans = new long[Q];
foreach (var item in sorted) {
while (idx < item.e.r) {
if (last[cList[idx] - 1] > -1)
seg[last[cList[idx] - 1]] = 0;
seg[idx] = 1;
last[cList[idx] - 1] = idx;
++idx;
}
ans[item.i] = seg.Query(item.e.l - 1, item.e.r);
}
for (var i = 0; i < Q; i++) {
Console.WriteLine(ans[i]);
}
}
class Printer : StreamWriter {
public override IFormatProvider FormatProvider {
get { return CultureInfo.InvariantCulture; }
}
public Printer(Stream stream)
: base(stream, new UTF8Encoding(false, true)) {
base.AutoFlush = false;
}
public Printer(Stream stream, Encoding encoding) : base(stream, encoding) {
base.AutoFlush = false;
}
}
static LIB_FastIO fastio = new LIB_FastIODebug();
static public void Main(string[] args) {
if (args.Length == 0) {
fastio = new LIB_FastIO();
Console.SetOut(new Printer(Console.OpenStandardOutput()));
}
if (SAIKI) {
var t = new Thread(Solve, 134217728);
t.Start();
t.Join();
} else
Solve();
Console.Out.Flush();
}
static long NN => fastio.Long();
static double ND => fastio.Double();
static string NS => fastio.Scan();
static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
static long Count<T>(this IEnumerable<T> x,
Func<T, bool> pred) => Enumerable.Count(x, pred);
static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v,
(int)n);
static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s,
(int)c);
static IOrderedEnumerable<T>
OrderByRand<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x, _ => xorshift);
static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x) =>
Enumerable.OrderBy(x.OrderByRand(), e => e);
static IOrderedEnumerable<T1> OrderBy<T1, T2>(this IEnumerable<T1> x,
Func<T1, T2> selector) =>
Enumerable.OrderBy(x.OrderByRand(), selector);
static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x) =>
Enumerable.OrderByDescending(x.OrderByRand(), e => e);
static IOrderedEnumerable<T1>
OrderByDescending<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) =>
Enumerable.OrderByDescending(x.OrderByRand(), selector);
static IOrderedEnumerable<string> OrderBy(this IEnumerable<string> x) =>
x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);
static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x,
Func<T, string> selector) =>
x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);
static IOrderedEnumerable<string>
OrderByDescending(this IEnumerable<string> x) =>
x.OrderByRand().OrderByDescending(e => e,
StringComparer.OrdinalIgnoreCase);
static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x,
Func<T, string> selector) =>
x.OrderByRand().OrderByDescending(selector,
StringComparer.OrdinalIgnoreCase);
static string Join<T>(this IEnumerable<T> x,
string separator = "") => string.Join(separator, x);
static uint xorshift {
get {
_xsi.MoveNext();
return _xsi.Current;
}
}
static IEnumerator<uint> _xsi = _xsc();
static IEnumerator<uint> _xsc() {
uint x = 123456789, y = 362436069, z = 521288629,
w = (uint)(DateTime.Now.Ticks & 0xffffffff);
while (true) {
var t = x ^ (x << 11);
x = y;
y = z;
z = w;
w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
yield return w;
}
}
}
}
namespace Library {
class LIB_SegTree<T> {
int n, sz;
T ti;
Func<T, T, T> f;
T[] dat;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public LIB_SegTree(long _n, T _ti, Func<T, T, T> _f) {
n = 1;
sz = (int)_n;
while (n < _n)
n <<= 1;
ti = _ti;
f = _f;
dat = Enumerable.Repeat(ti, n << 1).ToArray();
for (var i = n - 1; i > 0; i--)
dat[i] = f(dat[(i << 1) | 0], dat[(i << 1) | 1]);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public LIB_SegTree(IEnumerable<T> l, T _ti, Func<T, T, T> _f)
: this(l.Count(), _ti, _f) {
var idx = 0;
foreach (var item in l)
dat[n + idx++] = item;
for (var i = n - 1; i > 0; i--)
dat[i] = f(dat[(i << 1) | 0], dat[(i << 1) | 1]);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Update(long i, T v) {
dat[i += n] = v;
while ((i >>= 1) > 0)
dat[i] = f(dat[(i << 1) | 0], dat[(i << 1) | 1]);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public T Query(long l, long r) {
if (l == r)
return ti;
if (r < l)
throw new Exception();
var vl = ti;
var vr = ti;
for (long li = n + l, ri = n + r; li < ri; li >>= 1, ri >>= 1) {
if ((li & 1) == 1)
vl = f(vl, dat[li++]);
if ((ri & 1) == 1)
vr = f(dat[--ri], vr);
}
return f(vl, vr);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
int FindToRight(int st, Func<T, bool> check, ref T acc, int k, int l, int r) {
if (l + 1 == r) {
acc = f(acc, dat[k]);
return check(acc) ? k - n : sz;
}
int m = (l + r) >> 1;
if (m <= st)
return FindToRight(st, check, ref acc, (k << 1) | 1, m, r);
if (st <= l && !check(f(acc, dat[k]))) {
acc = f(acc, dat[k]);
return sz;
}
int vl = FindToRight(st, check, ref acc, (k << 1) | 0, l, m);
if (vl != sz)
return vl;
return FindToRight(st, check, ref acc, (k << 1) | 1, m, r);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int FindToRight(int st, Func<T, bool> check) {
T acc = ti;
return FindToRight(st, check, ref acc, 1, 0, n);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
int FindToLeft(int st, Func<T, bool> check, ref T acc, int k, int l, int r) {
if (l + 1 == r) {
acc = f(dat[k], acc);
return check(acc) ? k - n : -1;
}
int m = (l + r) >> 1;
if (m > st)
return FindToLeft(st, check, ref acc, (k << 1) | 0, l, m);
if (st >= r - 1 && !check(f(dat[k], acc))) {
acc = f(dat[k], acc);
return -1;
}
int vr = FindToLeft(st, check, ref acc, (k << 1) | 1, m, r);
if (vr != -1)
return vr;
return FindToLeft(st, check, ref acc, (k << 1) | 0, l, m);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int FindToLeft(int st, Func<T, bool> check) {
T acc = ti;
return FindToLeft(st, check, ref acc, 1, 0, n);
}
public T this[long idx] {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get { return dat[idx + n]; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
set { Update(idx, value); }
}
}
class LIB_FastIO {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public LIB_FastIO() { str = Console.OpenStandardInput(); }
readonly Stream str;
readonly byte[] buf = new byte[1024];
int len, ptr;
public bool isEof = false;
public bool IsEndOfStream {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get { return isEof; }
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
byte read() {
if (isEof)
throw new EndOfStreamException();
if (ptr >= len) {
ptr = 0;
if ((len = str.Read(buf, 0, 1024)) <= 0) {
isEof = true;
return 0;
}
}
return buf[ptr++];
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
char Char() {
byte b = 0;
do
b = read();
while (b < 33 || 126 < b);
return (char)b;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
virtual public string Scan() {
var sb = new StringBuilder();
for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
sb.Append(b);
return sb.ToString();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
virtual public long Long() {
long ret = 0;
byte b = 0;
var ng = false;
do
b = read();
while (b != '-' && (b < '0' || '9' < b));
if (b == '-') {
ng = true;
b = read();
}
for (; true; b = read()) {
if (b < '0' || '9' < b)
return ng ? -ret : ret;
else
ret = ret * 10 + b - '0';
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
virtual public double Double() {
return double.Parse(Scan(), CultureInfo.InvariantCulture);
}
}
class LIB_FastIODebug : LIB_FastIO {
Queue<string> param = new Queue<string>();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
string NextString() {
if (param.Count == 0)
foreach (var item in Console.ReadLine().Split(' '))
param.Enqueue(item);
return param.Dequeue();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public LIB_FastIODebug() {}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override string Scan() => NextString();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override long Long() => long.Parse(NextString());
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override double Double() => double.Parse(NextString());
}
}
|
[["+", 31, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 0, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 0, 204, 206, 207, 0, 28, 0, 16, 12, 203]]
| 8
| 2,823
| 6
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;
public class Solve {
static public int mod = 1000000007;
static public string al = "abcdefghijklmnopqrstuvwxyz";
public static void Main() {
// •ûj
//
var tn = inta();
var n = tn[0];
var q = tn[1];
var a = inta();
var l = new int[q];
var r = new int[q];
var tl = new int[q];
var tr = new int[q];
for (int i = 0; i < q; i++) {
var tmp = inta();
l[i] = tmp[0];
r[i] = tmp[1];
tl[i] = l[i];
tr[i] = r[i];
}
Array.Sort(tr, tl);
// WriteLine(string.Join(" ",tl));
// WriteLine(string.Join(" ",tr));
var bit = new BIT(n);
var nowr = 1;
var dic = new Dictionary<string, long>();
var last = new int[500001];
for (int i = 0; i <= 500000; i++) {
last[i] = -1;
}
for (int i = 1; i <= q; i++) {
while (tr[i - 1] >= nowr) {
// WriteLine($"{tr[i-1]} {nowr}");
if (last[a[nowr - 1]] == -1) {
last[a[nowr - 1]] = nowr;
bit.Change(nowr, 1);
} else {
bit.Change(last[a[nowr - 1]], -1);
last[a[nowr - 1]] = nowr;
bit.Change(nowr, 1);
}
nowr++;
// WriteLine(tr[i-1]);
// WriteLine(nowr);
}
// WriteLine(bit.Query(tl[i-1],tr[i-1]));
var key = tl[i - 1].ToString() + "-" + tr[i - 1].ToString();
if (!dic.ContainsKey(key)) {
dic.Add(key, bit.Query(tl[i - 1], tr[i - 1]));
}
}
var ans = new List<long>();
for (int i = 0; i < q; i++) {
var key = l[i].ToString() + "-" + r[i].ToString();
ans.Add(dic[key]);
}
WriteLine(string.Join("\n", ans));
}
public static void swap(ref int a, ref int b) {
int temp = a;
a = b;
b = temp;
}
static void charswap(ref char a, ref char b) {
char temp = a;
a = b;
b = temp;
}
static int ncr(int n, int r) {
if (n < r)
return 0;
r = Min(r, n - r);
long nn = 1;
for (int i = n - r + 1; i <= n; i++) {
nn = nn * i % mod;
}
long rr = 1;
for (int i = 1; i <= r; i++) {
rr = rr * i % mod;
}
rr = square((int)rr, mod - 2);
nn = nn * rr % mod;
return (int)nn;
}
// a^b mod
static int square(int a, int b) {
string binary = Convert.ToString(b, 2);
int bileng = binary.Length;
long a_power = a;
long value = 1;
for (int i = bileng - 1; i >= 0; i--) {
if (binary[i] == '1') {
value = value * a_power % mod;
}
a_power = a_power * a_power % mod;
}
return (int)value;
}
static int square2(int a, int b) {
long output = 1;
var list = new List<long>();
int sh = 1;
long n = a;
list.Add(a);
while (sh < b) {
sh *= 2;
n = n * n % mod;
list.Add(n);
}
for (int i = list.Count - 1; i >= 0; i--) {
if (b > sh) {
b -= sh;
sh /= 2;
output = output * list[i] % mod;
}
}
return (int)output;
}
//Šeí“Çæ
static string rstr() { return ReadLine(); }
static int rint() { return int.Parse(ReadLine()); }
static long rlong() { return long.Parse(ReadLine()); }
static string[] stra() { return ReadLine().Split(' '); }
static char[] chara() {
string[] a = stra();
string b = "";
for (int i = 0; i < a.Length; i++) {
b += a[i];
}
return b.ToCharArray();
}
static int[] inta() {
string[] read_str_array = ReadLine().Split(' ');
int[] return_int_array = new int[read_str_array.Length];
for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
}
return return_int_array;
}
static int[,] inta2(int num_array, int in_array) {
int[,] int_array2 = new int[num_array, in_array];
for (int i = 0; i < num_array; i++) {
int[] temp_array = inta();
for (int j = 0; j < in_array; j++) {
int_array2[i, j] = temp_array[j];
}
}
return int_array2;
}
static long[] longa() {
string[] read_str_array = ReadLine().Split(' ');
long[] return_long_array = new long[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_long_array[countup_i] = long.Parse(read_str_array[countup_i]);
}
return return_long_array;
}
static double[] doublea() {
string[] read_str_array = ReadLine().Split(' ');
double[] return_double_array = new double[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_double_array[countup_i] = double.Parse(read_str_array[countup_i]);
}
return return_double_array;
}
// -----------------------------
static long GCD(long a, long b) {
if (a < b) {
long temp = a;
a = b;
b = temp;
}
if (a % b == 0) {
return b;
} else {
long temp = b;
b = a % b;
a = temp;
return GCD(a, b);
}
}
static long LCM(long a, long b) { return a * b / GCD(a, b); }
static void WriteArray(int[,] a, int b, int c) {
for (int i = 0; i < b; i++) {
for (int j = 0; j < c; j++) {
if (j != 0)
Write(" ");
Write(a[i, j]);
}
WriteLine();
}
}
}
class BIT {
private long[] _bit;
private int leng;
public BIT(int a) {
_bit = new long[a + 1];
leng = _bit.Length;
}
public void Change(int a, long b) {
while (a <= leng) {
_bit[a] += b;
a += -a & a;
}
}
public long Query(int a, int b) {
a--;
long ret = 0;
while (b > 0) {
ret += _bit[b];
b -= -b & b;
}
while (a > 0) {
ret -= _bit[a];
a -= -a & a;
}
return ret;
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;
public class Solve {
static public int mod = 1000000007;
static public string al = "abcdefghijklmnopqrstuvwxyz";
public static void Main() {
// •ûj
//
var tn = inta();
var n = tn[0];
var q = tn[1];
var a = inta();
var l = new int[q];
var r = new int[q];
var tl = new int[q];
var tr = new int[q];
for (int i = 0; i < q; i++) {
var tmp = inta();
l[i] = tmp[0];
r[i] = tmp[1];
tl[i] = l[i];
tr[i] = r[i];
}
Array.Sort(tr, tl);
// WriteLine(string.Join(" ",tl));
// WriteLine(string.Join(" ",tr));
var bit = new BIT(n);
var nowr = 1;
var dic = new Dictionary<string, long>();
var last = new int[500001];
for (int i = 0; i <= 500000; i++) {
last[i] = -1;
}
for (int i = 1; i <= q; i++) {
while (tr[i - 1] >= nowr) {
// WriteLine($"{tr[i-1]} {nowr}");
if (last[a[nowr - 1]] == -1) {
last[a[nowr - 1]] = nowr;
bit.Change(nowr, 1);
} else {
bit.Change(last[a[nowr - 1]], -1);
last[a[nowr - 1]] = nowr;
bit.Change(nowr, 1);
}
nowr++;
// WriteLine(tr[i-1]);
// WriteLine(nowr);
}
// WriteLine(bit.Query(tl[i-1],tr[i-1]));
var key = tl[i - 1].ToString() + "-" + tr[i - 1].ToString();
if (!dic.ContainsKey(key)) {
dic.Add(key, bit.Query(tl[i - 1], tr[i - 1]));
}
}
var ans = new List<long>();
for (int i = 0; i < q; i++) {
var key = l[i].ToString() + "-" + r[i].ToString();
ans.Add(dic[key]);
}
WriteLine(string.Join("\n", ans));
}
public static void swap(ref int a, ref int b) {
int temp = a;
a = b;
b = temp;
}
static void charswap(ref char a, ref char b) {
char temp = a;
a = b;
b = temp;
}
static int ncr(int n, int r) {
if (n < r)
return 0;
r = Min(r, n - r);
long nn = 1;
for (int i = n - r + 1; i <= n; i++) {
nn = nn * i % mod;
}
long rr = 1;
for (int i = 1; i <= r; i++) {
rr = rr * i % mod;
}
rr = square((int)rr, mod - 2);
nn = nn * rr % mod;
return (int)nn;
}
// a^b mod
static int square(int a, int b) {
string binary = Convert.ToString(b, 2);
int bileng = binary.Length;
long a_power = a;
long value = 1;
for (int i = bileng - 1; i >= 0; i--) {
if (binary[i] == '1') {
value = value * a_power % mod;
}
a_power = a_power * a_power % mod;
}
return (int)value;
}
static int square2(int a, int b) {
long output = 1;
var list = new List<long>();
int sh = 1;
long n = a;
list.Add(a);
while (sh < b) {
sh *= 2;
n = n * n % mod;
list.Add(n);
}
for (int i = list.Count - 1; i >= 0; i--) {
if (b > sh) {
b -= sh;
sh /= 2;
output = output * list[i] % mod;
}
}
return (int)output;
}
//Šeí“Çæ
static string rstr() { return ReadLine(); }
static int rint() { return int.Parse(ReadLine()); }
static long rlong() { return long.Parse(ReadLine()); }
static string[] stra() { return ReadLine().Split(' '); }
static char[] chara() {
string[] a = stra();
string b = "";
for (int i = 0; i < a.Length; i++) {
b += a[i];
}
return b.ToCharArray();
}
static int[] inta() {
string[] read_str_array = ReadLine().Split(' ');
int[] return_int_array = new int[read_str_array.Length];
for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
}
return return_int_array;
}
static int[,] inta2(int num_array, int in_array) {
int[,] int_array2 = new int[num_array, in_array];
for (int i = 0; i < num_array; i++) {
int[] temp_array = inta();
for (int j = 0; j < in_array; j++) {
int_array2[i, j] = temp_array[j];
}
}
return int_array2;
}
static long[] longa() {
string[] read_str_array = ReadLine().Split(' ');
long[] return_long_array = new long[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_long_array[countup_i] = long.Parse(read_str_array[countup_i]);
}
return return_long_array;
}
static double[] doublea() {
string[] read_str_array = ReadLine().Split(' ');
double[] return_double_array = new double[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_double_array[countup_i] = double.Parse(read_str_array[countup_i]);
}
return return_double_array;
}
// -----------------------------
static long GCD(long a, long b) {
if (a < b) {
long temp = a;
a = b;
b = temp;
}
if (a % b == 0) {
return b;
} else {
long temp = b;
b = a % b;
a = temp;
return GCD(a, b);
}
}
static long LCM(long a, long b) { return a * b / GCD(a, b); }
static void WriteArray(int[,] a, int b, int c) {
for (int i = 0; i < b; i++) {
for (int j = 0; j < c; j++) {
if (j != 0)
Write(" ");
Write(a[i, j]);
}
WriteLine();
}
}
}
class BIT {
private long[] _bit;
private int leng;
public BIT(int a) {
_bit = new long[a + 1];
leng = _bit.Length;
}
public void Change(int a, long b) {
while (a < leng) {
_bit[a] += b;
a += -a & a;
}
}
public long Query(int a, int b) {
a--;
long ret = 0;
while (b > 0) {
ret += _bit[b];
b -= -b & b;
}
while (a > 0) {
ret -= _bit[a];
a -= -a & a;
}
return ret;
}
}
|
[["-", 0, 195, 8, 196, 0, 52, 15, 16, 17, 19], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 18]]
| 8
| 1,668
| 2
|
using System;
namespace A {
class Program {
static void Main(string[] args) {
int x = int.Parse(Console.ReadLine());
if (x < 600)
Console.WriteLine(8);
else if (x < 800)
Console.WriteLine(7);
else if (x < 1000)
Console.WriteLine(6);
else if (x < 1200)
Console.WriteLine(5);
else if (x < 1200)
Console.WriteLine(4);
else if (x < 1600)
Console.WriteLine(3);
else if (x < 1800)
Console.WriteLine(2);
else
Console.WriteLine(1);
}
}
}
|
using System;
namespace A {
class Program {
static void Main(string[] args) {
int x = int.Parse(Console.ReadLine());
if (x < 600)
Console.WriteLine(8);
else if (x < 800)
Console.WriteLine(7);
else if (x < 1000)
Console.WriteLine(6);
else if (x < 1200)
Console.WriteLine(5);
else if (x < 1400)
Console.WriteLine(4);
else if (x < 1600)
Console.WriteLine(3);
else if (x < 1800)
Console.WriteLine(2);
else
Console.WriteLine(1);
}
}
}
|
[["-", 75, 57, 75, 57, 75, 57, 15, 16, 12, 203], ["+", 75, 57, 75, 57, 75, 57, 15, 16, 12, 203]]
| 8
| 141
| 2
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace MSPC2020 {
class A {
static void Main(string[] args) {
// var CA = Enumerable.Repeat(0, (int)N).Select(_ =>
// Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray(); var
// LRd = Console.ReadLine().Split().Select(int.Parse).ToArray();
var X = int.Parse(Console.ReadLine());
// var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
if (400 <= X && X <= 599)
Console.WriteLine("8");
if (600 <= X && X <= 799)
Console.WriteLine("7");
if (800 <= X && X <= 999)
Console.WriteLine("6");
if (1000 <= X && X <= 1199)
Console.WriteLine("5");
if (1200 <= X && X <= 1399)
Console.WriteLine("4");
if (1400 <= X && X <= 1599)
Console.WriteLine("3");
if (1600 <= X && X <= 1799)
Console.WriteLine("2");
if (1800 <= X && X <= 1999)
Console.WriteLine("");
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace MSPC2020 {
class A {
static void Main(string[] args) {
// var CA = Enumerable.Repeat(0, (int)N).Select(_ =>
// Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray(); var
// LRd = Console.ReadLine().Split().Select(int.Parse).ToArray();
var X = int.Parse(Console.ReadLine());
// var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
if (400 <= X && X <= 599)
Console.WriteLine("8");
if (600 <= X && X <= 799)
Console.WriteLine("7");
if (800 <= X && X <= 999)
Console.WriteLine("6");
if (1000 <= X && X <= 1199)
Console.WriteLine("5");
if (1200 <= X && X <= 1399)
Console.WriteLine("4");
if (1400 <= X && X <= 1599)
Console.WriteLine("3");
if (1600 <= X && X <= 1799)
Console.WriteLine("2");
if (1800 <= X && X <= 1999)
Console.WriteLine("1");
}
}
}
|
[["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 203
| 1
|
using System.Linq;
using System.Text;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Security.Cryptography.X509Certificates;
using System.Diagnostics;
using System.Reflection.Metadata;
using System.Threading;
namespace AtCoder {
class Program {
struct Point {
public int x;
public int y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
}
const int BiggestMod = 1000000007;
public static void Main() {
var num = int.Parse(Console.ReadLine());
Console.WriteLine(10 - (num % 200));
}
}
}
|
using System.Linq;
using System.Text;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Security.Cryptography.X509Certificates;
using System.Diagnostics;
using System.Reflection.Metadata;
using System.Threading;
namespace AtCoder {
class Program {
struct Point {
public int x;
public int y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
}
const int BiggestMod = 1000000007;
public static void Main() {
var num = int.Parse(Console.ReadLine());
Console.WriteLine(10 - (num / 200));
}
}
}
|
[["-", 0, 28, 0, 16, 12, 23, 0, 16, 17, 109], ["+", 0, 28, 0, 16, 12, 23, 0, 16, 17, 85]]
| 8
| 145
| 2
|
using System;
class Program {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int A = int.Parse(input[0]);
int B = int.Parse(input[1]);
int C = int.Parse(input[2]);
int K = int.Parse(Console.ReadLine());
while (B <= A && K > 0) {
B *= 2;
K--;
}
while (C <= B && K > 0) {
C *= 2;
K--;
}
if (A < B && B < C)
Console.WriteLine("yes");
else
Console.WriteLine("No");
}
}
|
using System;
class Program {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int A = int.Parse(input[0]);
int B = int.Parse(input[1]);
int C = int.Parse(input[2]);
int K = int.Parse(Console.ReadLine());
while (B <= A && K > 0) {
B *= 2;
K--;
}
while (C <= B && K > 0) {
C *= 2;
K--;
}
if (A < B && B < C)
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
| 156
| 2
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
var x = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
long n = long.Parse(Console.ReadLine());
for (int p = 0; p < n; p++) {
if (x[0] > x[1]) {
x[1] *= 2;
} else {
x[2] *= 2;
}
}
if (x[0] < x[1] && x[1] < x[2]) {
Console.Write("Yes");
} else {
Console.Write("No");
}
}
}
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
var x = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
long n = long.Parse(Console.ReadLine());
for (int p = 0; p < n; p++) {
if (x[0] >= x[1]) {
x[1] *= 2;
} else {
x[2] *= 2;
}
}
if (x[0] < x[1] && x[1] < x[2]) {
Console.Write("Yes");
} else {
Console.Write("No");
}
}
}
|
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 20]]
| 8
| 161
| 2
|
using System;
using System.Collections.Generic;
class Program {
static void Main() {
string[] ABC = Console.ReadLine().Split(' ');
int A = int.Parse(ABC[0]);
int B = int.Parse(ABC[1]);
int C = int.Parse(ABC[2]);
int K = int.Parse(Console.ReadLine());
for (int i = 0; i < K; i++) {
if (A < B && B < C) {
if (C <= B || C <= A) {
C = C * 2;
} else if (C > B && B <= A) {
B = B * 2;
} else if (C > A && B > A) {
A = A * 2;
}
}
}
if (A < B && B < C) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
|
using System;
using System.Collections.Generic;
class Program {
static void Main() {
string[] ABC = Console.ReadLine().Split(' ');
int A = int.Parse(ABC[0]);
int B = int.Parse(ABC[1]);
int C = int.Parse(ABC[2]);
int K = int.Parse(Console.ReadLine());
for (int i = 0; i < K; i++) {
if (A < B && B < C) {
} else {
if (C <= B || C <= A) {
C = C * 2;
} else if (C > B && B <= A) {
B = B * 2;
} else if (C > A && B > A) {
A = A * 2;
}
}
}
// Console.WriteLine(A);
// Console.WriteLine(B);
// Console.WriteLine(C);
if (A < B && B < C) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
|
[["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 45]]
| 8
| 209
| 3
|
using System;
using System.Runtime.CompilerServices;
namespace ChokudaiScanner {
class MainClass {
static void Main() {
Scanner cin = new Scanner();
int A = cin.NextInt();
int B = cin.NextInt();
int C = cin.NextInt();
int K = cin.NextInt();
string ans = "No";
while (0 < K) {
if (A >= B) {
B = B * B;
K--;
}
if (B >= C) {
C = C * C;
K--;
}
if (A < B && B < C) {
ans = "Yes";
break;
}
}
if (A < B && B < C) {
ans = "Yes";
}
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);
if (s.Length == 0)
return Next();
i = 0;
return s[i++];
}
public string[] ArrayNext(int N) {
string[] Array = new string[N];
for (int i = 0; i < N; i++) {
Array[i] = Next();
}
return Array;
}
public int NextInt() { return int.Parse(Next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = NextInt() + add;
}
return Array;
}
public long NextLong() { return long.Parse(Next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = NextLong() + add;
}
return Array;
}
public double NextDouble() { return double.Parse(Next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = NextDouble() + add;
}
return Array;
}
}
}
|
using System;
using System.Runtime.CompilerServices;
namespace ChokudaiScanner {
class MainClass {
static void Main() {
Scanner cin = new Scanner();
int A = cin.NextInt();
int B = cin.NextInt();
int C = cin.NextInt();
int K = cin.NextInt();
string ans = "No";
while (0 < K) {
if (A >= B) {
B = B * 2;
K--;
} else if (B >= C) {
C = C * 2;
K--;
}
if (A < B && B < C) {
ans = "Yes";
break;
}
}
if (A < B && B < C) {
ans = "Yes";
}
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);
if (s.Length == 0)
return Next();
i = 0;
return s[i++];
}
public string[] ArrayNext(int N) {
string[] Array = new string[N];
for (int i = 0; i < N; i++) {
Array[i] = Next();
}
return Array;
}
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;
}
}
}
|
[["-", 64, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 95]]
| 8
| 563
| 5
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace MSPC2020 {
class A {
static void Main(string[] args) {
// var CA = Enumerable.Repeat(0, (int)N).Select(_ =>
// Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray(); var
// LRd = Console.ReadLine().Split().Select(int.Parse).ToArray(); var X =
// int.Parse(Console.ReadLine()); var a =
// Console.ReadLine().Split().Select(int.Parse).ToArray();
var ABC = Console.ReadLine().Split().Select(int.Parse).ToArray();
var K = int.Parse(Console.ReadLine());
var A = ABC[0];
var B = ABC[1];
var C = ABC[2];
for (int i = 0; i < K; i++) {
if (B < A) {
B *= 2;
} else if (C < B) {
C *= 2;
}
}
if (A < B && B < C)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace MSPC2020 {
class A {
static void Main(string[] args) {
// var CA = Enumerable.Repeat(0, (int)N).Select(_ =>
// Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray(); var
// LRd = Console.ReadLine().Split().Select(int.Parse).ToArray(); var X =
// int.Parse(Console.ReadLine()); var a =
// Console.ReadLine().Split().Select(int.Parse).ToArray();
var ABC = Console.ReadLine().Split().Select(int.Parse).ToArray();
var K = int.Parse(Console.ReadLine());
var A = ABC[0];
var B = ABC[1];
var C = ABC[2];
for (int i = 0; i < K; i++) {
if (B <= A) {
B *= 2;
} else if (C <= B) {
C *= 2;
}
// Console.WriteLine("{0} {1} {2}", A, B, C);
// if (A < B && B < C) Console.WriteLine("Yes");
}
if (A < B && B < C)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
}
|
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 19], ["-", 8, 196, 0, 57, 75, 57, 15, 16, 17, 18], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 19]]
| 8
| 171
| 4
|
using System;
using static System.Console;
using static System.Math;
using System.Numerics;
using System.Collections.Generic;
using System.Linq;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
var x = myRead.readIntArray();
var k = myRead.readInt();
int count = 0;
while (x[0] > x[1]) {
x[1] *= 2;
count++;
}
while (x[1] > x[2]) {
x[2] *= 2;
count++;
}
string str = "No";
if (count <= k)
str = "Yes";
WriteLine(str);
Out.Flush();
}
}
public static class myRead {
public static int readInt() { return int.Parse(ReadLine()); }
public static long readLong() { return long.Parse(ReadLine()); }
public static string reatStr() { return ReadLine(); }
public static int[] readIntArray() {
return ReadLine().Split(' ').Select(int.Parse).ToArray();
}
public static long[] readLongArray() {
return ReadLine().Split(' ').Select(long.Parse).ToArray();
}
public static string[] readStrArray() { return ReadLine().Split(' '); }
}
public static class MyMath {
public static long Factorical(long n) {
return n <= 1 ? 1L : n * Factorical(n - 1);
}
public static long Permutation(long n, long m) {
return m == 0 ? 1L
: (m == n) ? Permutation(n, m - 1)
: n * Permutation(n - 1, m - 1);
}
public static long Combination(long n, long m) {
return n - m > m ? Permutation(n, m) / Factorical(m)
: Permutation(n, n - m) / Factorical(n - m);
}
public static long Gcd(long n, long m) {
return n % m == 0 ? m : Gcd(m, n % m);
}
public static long Lcm(long n, long m) { return n * m / Gcd(n, m); }
public static long Pow(long n, long m) {
return (m == 1 || m == 0) ? 1L : n * Pow(n, m - 1);
}
}
}
|
using System;
using static System.Console;
using static System.Math;
using System.Numerics;
using System.Collections.Generic;
using System.Linq;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
var x = myRead.readIntArray();
var k = myRead.readInt();
int count = 0;
while (x[0] >= x[1]) {
x[1] *= 2;
count++;
}
while (x[1] >= x[2]) {
x[2] *= 2;
count++;
}
string str = "No";
if (count <= k)
str = "Yes";
WriteLine(str);
Out.Flush();
}
}
public static class myRead {
public static int readInt() { return int.Parse(ReadLine()); }
public static long readLong() { return long.Parse(ReadLine()); }
public static string reatStr() { return ReadLine(); }
public static int[] readIntArray() {
return ReadLine().Split(' ').Select(int.Parse).ToArray();
}
public static long[] readLongArray() {
return ReadLine().Split(' ').Select(long.Parse).ToArray();
}
public static string[] readStrArray() { return ReadLine().Split(' '); }
}
public static class MyMath {
public static long Factorical(long n) {
return n <= 1 ? 1L : n * Factorical(n - 1);
}
public static long Permutation(long n, long m) {
return m == 0 ? 1L
: (m == n) ? Permutation(n, m - 1)
: n * Permutation(n - 1, m - 1);
}
public static long Combination(long n, long m) {
return n - m > m ? Permutation(n, m) / Factorical(m)
: Permutation(n, n - m) / Factorical(n - m);
}
public static long Gcd(long n, long m) {
return n % m == 0 ? m : Gcd(m, n % m);
}
public static long Lcm(long n, long m) { return n * m / Gcd(n, m); }
public static long Pow(long n, long m) {
return (m == 1 || m == 0) ? 1L : n * Pow(n, m - 1);
}
}
}
|
[["-", 0, 195, 8, 196, 0, 52, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 20]]
| 8
| 518
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace ABC {
class MPCO2020B {
const string FILE = "/tmp/data.txt";
static void Main(string[] args) {
#if DEBUG
Console.SetIn(new StreamReader(FILE));
#endif
var Ia = RIa(3);
var K = RI();
int n = 0;
while (Ia[0] > Ia[1]) {
Ia[1] *= 2;
++n;
}
while (Ia[1] > Ia[2]) {
Ia[2] *= 2;
++n;
}
string result = (n <= K) ? "Yes" : "No";
Console.WriteLine(result);
#if DEBUG
Console.WriteLine("*** end ***");
Console.SetIn(Console.In);
Console.ReadKey();
Console.WriteLine();
#endif
}
static int RI() { return int.Parse(Console.ReadLine()); }
static int[] RIa(int n) {
string[] sa = Console.ReadLine().Split(' ');
int[] la = new int[n];
for (int i = 0; i < n; ++i) {
la[i] = int.Parse(sa[i]);
}
return la;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace ABC {
class MPCO2020B {
const string FILE = "/tmp/data.txt";
static void Main(string[] args) {
#if DEBUG
Console.SetIn(new StreamReader(FILE));
#endif
var Ia = RIa(3);
var K = RI();
int n = 0;
while (Ia[0] >= Ia[1]) {
Ia[1] *= 2;
++n;
}
while (Ia[1] >= Ia[2]) {
Ia[2] *= 2;
++n;
}
string result = (n <= K) ? "Yes" : "No";
Console.WriteLine(result);
#if DEBUG
Console.WriteLine("*** end ***");
Console.SetIn(Console.In);
Console.ReadKey();
Console.WriteLine();
#endif
}
static int RI() { return int.Parse(Console.ReadLine()); }
static int[] RIa(int n) {
string[] sa = Console.ReadLine().Split(' ');
int[] la = new int[n];
for (int i = 0; i < n; ++i) {
la[i] = int.Parse(sa[i]);
}
return la;
}
}
}
|
[["-", 0, 195, 8, 196, 0, 52, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 20]]
| 8
| 295
| 4
|
using System;
using System.Linq;
namespace M_solutions2020 {
class Program {
static void Main(string[] args) { b(); }
public static void b() {
int[] abc = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
int k = int.Parse(Console.ReadLine());
for (int i = 0; i < k; i++) {
if (abc[0] > abc[1])
abc[1] *= 2;
else if (abc[1] > abc[2])
abc[2] *= 2;
}
if (abc[0] < abc[1] && abc[1] < abc[2]) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
using System;
using System.Linq;
namespace M_solutions2020 {
class Program {
static void Main(string[] args) { b(); }
public static void b() {
int[] abc = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
int k = int.Parse(Console.ReadLine());
for (int i = 0; i < k; i++) {
if (abc[0] >= abc[1])
abc[1] *= 2;
else if (abc[1] >= abc[2])
abc[2] *= 2;
}
if (abc[0] < abc[1] && abc[1] < abc[2]) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 20], ["-", 8, 196, 0, 57, 75, 57, 15, 16, 17, 47], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 20]]
| 8
| 182
| 4
|
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();
int[] abc = Console.ReadLine().Split().Select(int.Parse).ToArray();
var a = abc[0];
var b = abc[1];
var c = abc[2];
var k = int.Parse(Console.ReadLine());
var ans = "";
for (int i = 0; i < k; i++) {
if (a > b)
b *= 2;
else if (b > c)
c *= 2;
else
break;
}
if (a < b && b < c)
ans = "Yes";
else
ans = "No";
// 出力
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();
int[] abc = Console.ReadLine().Split().Select(int.Parse).ToArray();
var a = abc[0];
var b = abc[1];
var c = abc[2];
var k = int.Parse(Console.ReadLine());
var ans = "";
for (int i = 0; i < k; i++) {
if (a >= b)
b *= 2;
else if (b >= c)
c *= 2;
else
break;
}
if (a < b && b < c)
ans = "Yes";
else
ans = "No";
// 出力
Console.WriteLine(ans);
}
}
|
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 20], ["-", 8, 196, 0, 57, 75, 57, 15, 16, 17, 47], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 20]]
| 8
| 183
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello {
public static void Main() {
hoge();
System.Console.ReadLine();
}
public static void hoge() {
var vars = System.Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var a = vars[0];
var b = vars[1];
var c = vars[2];
vars = System.Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var k = vars[0];
for (int i = 0; i < k + 1; i++) {
if (a < b && b < c) {
Console.WriteLine("Yes");
return;
}
if (a > b) {
b *= 2;
} else if (b > c) {
c *= 2;
}
}
Console.WriteLine("No");
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello {
public static void Main() {
hoge();
System.Console.ReadLine();
}
public static void hoge() {
var vars = System.Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var a = vars[0];
var b = vars[1];
var c = vars[2];
vars = System.Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var k = vars[0];
for (int i = 0; i < k + 1; i++) {
if (a < b && b < c) {
Console.WriteLine("Yes");
return;
}
if (a >= b) {
b *= 2;
} else if (b >= c) {
c *= 2;
}
}
Console.WriteLine("No");
}
}
|
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 20], ["-", 8, 196, 0, 57, 75, 57, 15, 16, 17, 47], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 20]]
| 8
| 212
| 4
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace Tasks {
public class B {
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
public static void Solve() {
var ABC = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
var (A, B, C) = (ABC[0], ABC[1], ABC[2]);
var K = int.Parse(Console.ReadLine());
for (var i = 0; i < K; i++) {
if (B < A)
B *= 2;
else if (C < B)
C *= 2;
}
var answer = A < B && B < C;
Console.WriteLine(answer ? "Yes" : "No");
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace Tasks {
public class B {
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
public static void Solve() {
var ABC = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
var (A, B, C) = (ABC[0], ABC[1], ABC[2]);
var K = int.Parse(Console.ReadLine());
for (var i = 0; i < K; i++) {
if (B <= A)
B *= 2;
else if (C <= B)
C *= 2;
}
var answer = A < B && B < C;
Console.WriteLine(answer ? "Yes" : "No");
}
}
}
|
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 19], ["-", 8, 196, 0, 57, 75, 57, 15, 16, 17, 18], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 19]]
| 8
| 224
| 4
|
using System;
using System.Linq;
class name {
static void Main() {
int[] gakki = Console.ReadLine().Split().Select(int.Parse).ToArray();
int[] score = Console.ReadLine().Split().Select(int.Parse).ToArray();
int k = gakki[1];
int n = gakki[0];
for (int m = 0; m < n - k; m++) {
if (score[k + 1] > score[m]) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
using System;
using System.Linq;
class name {
static void Main() {
int[] gakki = Console.ReadLine().Split().Select(int.Parse).ToArray();
int[] score = Console.ReadLine().Split().Select(int.Parse).ToArray();
int k = gakki[1];
int n = gakki[0];
for (int m = 0; m < n - k; m++) {
if (score[k + m] > score[m]) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
[["-", 31, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 12, 22]]
| 8
| 142
| 2
|
using System;
using System.Linq;
class C {
static void Main() {
var x = (Console.ReadLine()).Split(' ');
int N = int.Parse(x[0]);
int K = int.Parse(x[1]);
// string[] y = (Console.ReadLine()).Split(' ');
var A = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
// int[] A = new int[N];
/*for (int i = 0; i < N; i++)
{
A[i] = int.Parse(y[i]);
}*/
for (int i = K; i < N; i++) {
if ((int)A[i - K] < (int)A[K + 1]) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
using System;
using System.Linq;
class C {
static void Main() {
var x = (Console.ReadLine()).Split(' ');
int N = int.Parse(x[0]);
int K = int.Parse(x[1]);
var A = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
for (int i = K; i < N; i++) {
if ((int)A[i - K] < (int)A[i]) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
[["-", 51, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["-", 51, 204, 206, 207, 0, 28, 0, 16, 17, 72], ["-", 51, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 12, 74, 51, 204, 206, 207, 0, 28, 0, 22]]
| 8
| 159
| 4
|
using System;
using static System.Console;
using static System.Math;
using System.Numerics;
using System.Collections.Generic;
using System.Linq;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
var s = myRead.readIntArray();
var a = myRead.readLongArray();
for (int i = s[1]; i < s[0]; i++) {
var ans = "No";
if (a[i - s[1]] < a[i - 1])
ans = "Yes";
WriteLine(ans);
Out.Flush();
}
}
}
public static class myRead {
public static int readInt() { return int.Parse(ReadLine()); }
public static long readLong() { return long.Parse(ReadLine()); }
public static string reatStr() { return ReadLine(); }
public static int[] readIntArray() {
return ReadLine().Split(' ').Select(int.Parse).ToArray();
}
public static long[] readLongArray() {
return ReadLine().Split(' ').Select(long.Parse).ToArray();
}
public static string[] readStrArray() { return ReadLine().Split(' '); }
}
public static class MyMath {
public static long Factorical(long n) {
return n <= 1 ? 1L : n * Factorical(n - 1);
}
public static long Permutation(long n, long m) {
return m == 0 ? 1L
: (m == n) ? Permutation(n, m - 1)
: n * Permutation(n - 1, m - 1);
}
public static long Combination(long n, long m) {
return n - m > m ? Permutation(n, m) / Factorical(m)
: Permutation(n, n - m) / Factorical(n - m);
}
public static long Gcd(long n, long m) {
return n % m == 0 ? m : Gcd(m, n % m);
}
public static long Lcm(long n, long m) { return n * m / Gcd(n, m); }
public static long Pow(long n, long m) {
return (m == 1 || m == 0) ? 1L : n * Pow(n, m - 1);
}
}
}
|
using System;
using static System.Console;
using static System.Math;
using System.Numerics;
using System.Collections.Generic;
using System.Linq;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
var s = myRead.readIntArray();
var a = myRead.readLongArray();
for (int i = s[1]; i < s[0]; i++) {
var ans = "No";
if (a[i - s[1]] < a[i])
ans = "Yes";
WriteLine(ans);
Out.Flush();
}
}
}
public static class myRead {
public static int readInt() { return int.Parse(ReadLine()); }
public static long readLong() { return long.Parse(ReadLine()); }
public static string reatStr() { return ReadLine(); }
public static int[] readIntArray() {
return ReadLine().Split(' ').Select(int.Parse).ToArray();
}
public static long[] readLongArray() {
return ReadLine().Split(' ').Select(long.Parse).ToArray();
}
public static string[] readStrArray() { return ReadLine().Split(' '); }
}
public static class MyMath {
public static long Factorical(long n) {
return n <= 1 ? 1L : n * Factorical(n - 1);
}
public static long Permutation(long n, long m) {
return m == 0 ? 1L
: (m == n) ? Permutation(n, m - 1)
: n * Permutation(n - 1, m - 1);
}
public static long Combination(long n, long m) {
return n - m > m ? Permutation(n, m) / Factorical(m)
: Permutation(n, n - m) / Factorical(n - m);
}
public static long Gcd(long n, long m) {
return n % m == 0 ? m : Gcd(m, n % m);
}
public static long Lcm(long n, long m) { return n * m / Gcd(n, m); }
public static long Pow(long n, long m) {
return (m == 1 || m == 0) ? 1L : n * Pow(n, m - 1);
}
}
}
|
[["-", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203]]
| 8
| 500
| 2
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics.Contracts;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Xml.Schema;
using System.Threading;
using System.Diagnostics.CodeAnalysis;
using System.Security.Cryptography;
using System.IO.Pipes;
using Microsoft.Win32;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.CodeDom;
using System.Diagnostics.SymbolStore;
namespace AtCoder {
public static class Ex {
public static List<string> FastSort(this List<string> s) {
s.Sort(StringComparer.OrdinalIgnoreCase);
return s.ToList();
}
public static void yesno(this bool b) { Console.WriteLine(b ? "yes" : "no"); }
public static void YesNo(this bool b) { Console.WriteLine(b ? "Yes" : "No"); }
public static void YESNO(this bool b) { Console.WriteLine(b ? "YES" : "NO"); }
public static int PopCount(this int bits) {
bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff);
}
}
partial class AtCoder {
public string GetStr() { return Console.ReadLine().Trim(); }
public char GetChar() { return Console.ReadLine().Trim()[0]; }
public int GetInt() { return int.Parse(Console.ReadLine().Trim()); }
public long GetLong() { return long.Parse(Console.ReadLine().Trim()); }
public double GetDouble() { return double.Parse(Console.ReadLine().Trim()); }
public string[] GetStrArray() { return Console.ReadLine().Trim().Split(' '); }
public int[] GetIntArray() {
return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
}
public long[] GetLongArray() {
return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
}
public char[] GetCharArray() {
return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray();
}
public double[] GetDoubleArray() {
return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();
}
public T[][] CreateJaggedArray<T>(int H, int W, T value) {
return Enumerable.Repeat(0, H)
.Select(s => Enumerable.Repeat(value, W).ToArray())
.ToArray();
}
public int[][] GetIntJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetIntArray().ToArray())
.ToArray();
}
public long[][] GetLongJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetLongArray().ToArray())
.ToArray();
}
public char[][] GetCharJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetStr().ToCharArray())
.ToArray();
}
public double[][] GetDoubleJaggedArray(int N) {
return Enumerable.Repeat(0, N).Select(s => GetDoubleArray()).ToArray();
}
Dictionary<int, List<int>> GetUnweightedAdjacencyList(int N, int M,
bool isDirected,
bool isNode_0indexed) {
var dic = new Dictionary<int, List<int>>();
foreach (var e in Enumerable.Range(0, N)) {
dic.Add(e, new List<int>());
}
for (int i = 0; i < M; i++) {
var input = GetIntArray();
var a = isNode_0indexed ? input[0] : input[0] - 1;
var b = isNode_0indexed ? input[1] : input[1] - 1;
dic[a].Add(b);
if (isDirected == false)
dic[b].Add(a);
}
return dic;
}
Dictionary<int, List<Edge>> GetWeightedAdjacencyList(int N, int M,
bool isDirected,
bool isNode_0indexed) {
var dic = new Dictionary<int, List<Edge>>();
foreach (var e in Enumerable.Range(0, N)) {
dic.Add(e, new List<Edge>());
}
for (int i = 0; i < M; i++) {
var input = GetIntArray();
var a = isNode_0indexed ? input[0] : input[0] - 1;
var b = isNode_0indexed ? input[1] : input[1] - 1;
var c = input[2];
dic[a].Add(new Edge(b, c));
if (isDirected == false)
dic[b].Add(new Edge(a, c));
}
return dic;
}
bool eq<T, U>() => typeof(T).Equals(typeof(U));
T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
: eq<T, long>() ? ct<T, long>(long.Parse(s))
: eq<T, double>() ? ct<T, double>(double.Parse(s))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
void Multi<T>(out T a) => a = cv<T>(GetStr());
void Multi<T, U>(out T a, out U b) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
}
void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
}
void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e,
out Y f) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
f = cv<Y>(ar[5]);
}
}
class Edge {
public Edge(int to, long length) {
To = to;
Length = length;
}
public int To { get; set; }
public long Length { get; set; }
}
class Comparable : IComparable<Comparable> {
public Comparable(int value) { this.value = value; }
public int value;
public int CompareTo(Comparable c) {
return this.value < c.value ? 1 : this.value == c.value ? 0 : -1;
}
}
partial class Program {
static void Main() {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
new AtCoder().Solve();
Console.Out.Flush();
Console.Read();
}
}
public partial class AtCoder {
public void Solve() {
int N = GetInt();
var map = GetLongJaggedArray(N)
.Select(s => new { x = s[0], y = s[1], p = s[2] })
.ToArray();
var xmin = new long [1 << N][];
var ymin = new long [1 << N][];
for (int i = 0; i < 1 << N; i++) {
xmin[i] = new long[N];
ymin[i] = new long[N];
}
var min = Enumerable.Repeat(long.MaxValue, N + 1).ToArray();
List<long> xls;
List<long> yls;
for (int bit = 0; bit < 1 << N; bit++) {
xls = new List<long>(16);
xls.Add(0);
yls = new List<long>(16);
yls.Add(0);
for (int i = 0; i < N; i++) {
if (((bit >> i) & 1) == 1) {
xls.Add(map[i].x);
yls.Add(map[i].y);
}
}
for (int i = 0; i < N; i++) {
xmin[bit][i] = xls.Min(m => Math.Abs(m - map[i].x));
ymin[bit][i] = yls.Min(m => Math.Abs(m - map[i].x));
}
}
int tmp, xbit, ybit, cnt, t;
long sum;
for (int trit = 0; trit < (int)Math.Pow(3, N); trit++) {
tmp = trit;
xbit = 0;
ybit = 0;
cnt = N;
for (int i = 0; i < N; i++) {
t = tmp % 3;
tmp /= 3;
if (t == 1)
xbit += 1 << i;
else if (t == 2)
ybit += 1 << i;
else
cnt--;
}
sum = 0;
for (int i = 0; i < N; i++)
sum += Math.Min(xmin[xbit][i], ymin[ybit][i]) * map[i].p;
min[cnt] = Math.Min(min[cnt], sum);
}
foreach (var m in min)
Console.WriteLine(m);
}
}
}
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics.Contracts;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Xml.Schema;
using System.Threading;
using System.Diagnostics.CodeAnalysis;
using System.Security.Cryptography;
using System.IO.Pipes;
using Microsoft.Win32;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.CodeDom;
using System.Diagnostics.SymbolStore;
namespace AtCoder {
public static class Ex {
public static List<string> FastSort(this List<string> s) {
s.Sort(StringComparer.OrdinalIgnoreCase);
return s.ToList();
}
public static void yesno(this bool b) { Console.WriteLine(b ? "yes" : "no"); }
public static void YesNo(this bool b) { Console.WriteLine(b ? "Yes" : "No"); }
public static void YESNO(this bool b) { Console.WriteLine(b ? "YES" : "NO"); }
public static int PopCount(this int bits) {
bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff);
}
}
partial class AtCoder {
public string GetStr() { return Console.ReadLine().Trim(); }
public char GetChar() { return Console.ReadLine().Trim()[0]; }
public int GetInt() { return int.Parse(Console.ReadLine().Trim()); }
public long GetLong() { return long.Parse(Console.ReadLine().Trim()); }
public double GetDouble() { return double.Parse(Console.ReadLine().Trim()); }
public string[] GetStrArray() { return Console.ReadLine().Trim().Split(' '); }
public int[] GetIntArray() {
return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
}
public long[] GetLongArray() {
return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
}
public char[] GetCharArray() {
return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray();
}
public double[] GetDoubleArray() {
return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();
}
public T[][] CreateJaggedArray<T>(int H, int W, T value) {
return Enumerable.Repeat(0, H)
.Select(s => Enumerable.Repeat(value, W).ToArray())
.ToArray();
}
public int[][] GetIntJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetIntArray().ToArray())
.ToArray();
}
public long[][] GetLongJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetLongArray().ToArray())
.ToArray();
}
public char[][] GetCharJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetStr().ToCharArray())
.ToArray();
}
public double[][] GetDoubleJaggedArray(int N) {
return Enumerable.Repeat(0, N).Select(s => GetDoubleArray()).ToArray();
}
Dictionary<int, List<int>> GetUnweightedAdjacencyList(int N, int M,
bool isDirected,
bool isNode_0indexed) {
var dic = new Dictionary<int, List<int>>();
foreach (var e in Enumerable.Range(0, N)) {
dic.Add(e, new List<int>());
}
for (int i = 0; i < M; i++) {
var input = GetIntArray();
var a = isNode_0indexed ? input[0] : input[0] - 1;
var b = isNode_0indexed ? input[1] : input[1] - 1;
dic[a].Add(b);
if (isDirected == false)
dic[b].Add(a);
}
return dic;
}
Dictionary<int, List<Edge>> GetWeightedAdjacencyList(int N, int M,
bool isDirected,
bool isNode_0indexed) {
var dic = new Dictionary<int, List<Edge>>();
foreach (var e in Enumerable.Range(0, N)) {
dic.Add(e, new List<Edge>());
}
for (int i = 0; i < M; i++) {
var input = GetIntArray();
var a = isNode_0indexed ? input[0] : input[0] - 1;
var b = isNode_0indexed ? input[1] : input[1] - 1;
var c = input[2];
dic[a].Add(new Edge(b, c));
if (isDirected == false)
dic[b].Add(new Edge(a, c));
}
return dic;
}
bool eq<T, U>() => typeof(T).Equals(typeof(U));
T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
: eq<T, long>() ? ct<T, long>(long.Parse(s))
: eq<T, double>() ? ct<T, double>(double.Parse(s))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
void Multi<T>(out T a) => a = cv<T>(GetStr());
void Multi<T, U>(out T a, out U b) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
}
void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
}
void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e,
out Y f) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
f = cv<Y>(ar[5]);
}
}
class Edge {
public Edge(int to, long length) {
To = to;
Length = length;
}
public int To { get; set; }
public long Length { get; set; }
}
class Comparable : IComparable<Comparable> {
public Comparable(int value) { this.value = value; }
public int value;
public int CompareTo(Comparable c) {
return this.value < c.value ? 1 : this.value == c.value ? 0 : -1;
}
}
partial class Program {
static void Main() {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
new AtCoder().Solve();
Console.Out.Flush();
Console.Read();
}
}
public partial class AtCoder {
public void Solve() {
int N = GetInt();
var map = GetLongJaggedArray(N)
.Select(s => new { x = s[0], y = s[1], p = s[2] })
.ToArray();
var xmin = new long [1 << N][];
var ymin = new long [1 << N][];
for (int i = 0; i < 1 << N; i++) {
xmin[i] = new long[N];
ymin[i] = new long[N];
}
var min = Enumerable.Repeat(long.MaxValue, N + 1).ToArray();
List<long> xls;
List<long> yls;
for (int bit = 0; bit < 1 << N; bit++) {
xls = new List<long>(16);
xls.Add(0);
yls = new List<long>(16);
yls.Add(0);
for (int i = 0; i < N; i++) {
if (((bit >> i) & 1) == 1) {
xls.Add(map[i].x);
yls.Add(map[i].y);
}
}
for (int i = 0; i < N; i++) {
xmin[bit][i] = xls.Min(m => Math.Abs(m - map[i].x));
ymin[bit][i] = yls.Min(m => Math.Abs(m - map[i].y));
}
}
int tmp, xbit, ybit, cnt, t;
long sum;
for (int trit = 0; trit < (int)Math.Pow(3, N); trit++) {
tmp = trit;
xbit = 0;
ybit = 0;
cnt = N;
for (int i = 0; i < N; i++) {
t = tmp % 3;
tmp /= 3;
if (t == 1)
xbit += 1 << i;
else if (t == 2)
ybit += 1 << i;
else
cnt--;
}
sum = 0;
for (int i = 0; i < N; i++)
sum += Math.Min(xmin[xbit][i], ymin[ybit][i]) * map[i].p;
min[cnt] = Math.Min(min[cnt], sum);
}
foreach (var m in min)
Console.WriteLine(m);
}
}
}
|
[["-", 3, 4, 0, 28, 0, 16, 12, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 16, 12, 214, 141, 22]]
| 8
| 2,471
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Threading;
using System.Runtime.CompilerServices;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Template;
using SC = Scanner;
public partial class Solver {
public void Solve() {
var N = sc.Int;
var P = new(int X, int Y, char U)[N];
for (int i = 0; i < N; i++) {
sc.Make(out P[i].X, out P[i].Y, out P[i].U);
}
var res = int.MaxValue;
Array.Sort(P, (a, b) => {
if (a.X == b.X)
return a.Y - b.Y;
return a.X - b.X;
});
const int g = 200200;
var umin = Create(400400, () => int.MaxValue / 2);
var dmin = Create(400400, () => int.MaxValue / 2);
for (int i = 0; i < N;) {
int idx = i;
var U = new Set<int>((a, b) => b - a);
var D = new Set<int>();
while (idx < N && P[idx].X == P[i].X) {
if (P[idx].U == 'U') {
var lw = D.LowerBound(P[idx].Y);
if (lw != D.Count)
chmin(ref res, (D[lw] - P[idx].Y) * 5);
U.Add(P[idx].Y);
umin[P[idx].Y - P[idx].X + g] = P[idx].X;
} else if (P[idx].U == 'D') {
var lw = U.LowerBound(P[idx].Y);
if (lw != U.Count)
chmin(ref res, (P[idx].Y - U[lw]) * 5);
D.Add(P[idx].Y);
dmin[P[idx].Y + P[idx].X] = P[idx].X;
} else if (P[idx].U == 'L') {
if (umin[P[idx].Y - P[idx].X + g] != int.MaxValue / 2)
chmin(ref res, -(umin[P[idx].Y - P[idx].X + g] - P[idx].X) * 10);
if (dmin[P[idx].Y + P[idx].X] != int.MaxValue / 2)
chmin(ref res, -(dmin[P[idx].Y + P[idx].X] - P[idx].X) * 10);
}
idx++;
}
i = idx;
}
for (int i = 0; i < dmin.Length; i++)
umin[i] = dmin[i] = int.MaxValue / 2;
for (int i = N - 1; i >= 0; i--) {
if (P[i].U == 'U')
umin[P[i].Y + P[i].X] = P[i].X;
else if (P[i].U == 'D')
dmin[P[i].Y - P[i].X + g] = P[i].X;
else if (P[i].U == 'R') {
if (umin[P[i].Y + P[i].X] != int.MaxValue / 2)
chmin(ref res, -(P[i].X - umin[P[i].Y + P[i].X]) * 10);
if (dmin[P[i].Y - P[i].X + g] != int.MaxValue / 2)
chmin(ref res, -(P[i].X - dmin[P[i].Y - P[i].X + g]) * 10);
}
}
Array.Sort(P, (a, b) => {
if (a.Y == b.Y)
return a.X - b.X;
return a.Y - b.Y;
});
for (int i = 0; i < N;) {
int idx = i;
var R = new Set<int>((a, b) => b - a);
var L = new Set<int>();
while (idx < N && P[idx].Y == P[i].Y) {
if (P[idx].U == 'R') {
var lw = L.LowerBound(P[idx].X);
if (lw != L.Count)
chmin(ref res, (L[lw] - P[idx].X) * 5);
R.Add(P[idx].Y);
} else if (P[idx].U == 'L') {
var lw = R.LowerBound(P[idx].X);
if (lw != R.Count)
chmin(ref res, (P[idx].X - R[lw]) * 5);
L.Add(P[idx].Y);
}
idx++;
}
i = idx;
}
if (res == int.MaxValue)
Console.WriteLine("SAFE");
else
Console.WriteLine(res);
}
}
public class Set<T> {
Node root;
readonly IComparer<T> comparer;
readonly Node nil;
public bool IsMultiSet { get; set; }
public Set(IComparer<T> comparer) {
nil = new Node(default(T));
root = nil;
this.comparer = comparer;
}
public Set(Comparison<T> comaprison) : this(Comparer<T>.Create(comaprison)) {}
public Set() : this(Comparer<T>.Default) {}
public bool Add(T v) { return insert(ref root, v); }
public bool Remove(T v) { return remove(ref root, v); }
public T this[int index] {
get { return find(root, index); }
}
public int Count {
get { return root.Count; }
}
public void RemoveAt(int k) {
if (k < 0 || k >= root.Count)
throw new ArgumentOutOfRangeException();
removeAt(ref root, k);
}
public T[] Items {
get {
var ret = new T[root.Count];
var k = 0;
walk(root, ret, ref k);
return ret;
}
}
void walk(Node t, T[] a, ref int k) {
if (t.Count == 0)
return;
walk(t.lst, a, ref k);
a[k++] = t.Key;
walk(t.rst, a, ref k);
}
bool insert(ref Node t, T key) {
if (t.Count == 0) {
t = new Node(key);
t.lst = t.rst = nil;
t.Update();
return true;
}
var cmp = comparer.Compare(t.Key, key);
bool res;
if (cmp > 0)
res = insert(ref t.lst, key);
else if (cmp == 0) {
if (IsMultiSet)
res = insert(ref t.lst, key);
else
return false;
} else
res = insert(ref t.rst, key);
balance(ref t);
return res;
}
bool remove(ref Node t, T key) {
if (t.Count == 0)
return false;
var cmp = comparer.Compare(key, t.Key);
bool ret;
if (cmp < 0)
ret = remove(ref t.lst, key);
else if (cmp > 0)
ret = remove(ref t.rst, key);
else {
ret = true;
var k = t.lst.Count;
if (k == 0) {
t = t.rst;
return true;
}
if (t.rst.Count == 0) {
t = t.lst;
return true;
}
t.Key = find(t.lst, k - 1);
removeAt(ref t.lst, k - 1);
}
balance(ref t);
return ret;
}
void removeAt(ref Node t, int k) {
var cnt = t.lst.Count;
if (cnt < k)
removeAt(ref t.rst, k - cnt - 1);
else if (cnt > k)
removeAt(ref t.lst, k);
else {
if (cnt == 0) {
t = t.rst;
return;
}
if (t.rst.Count == 0) {
t = t.lst;
return;
}
t.Key = find(t.lst, k - 1);
removeAt(ref t.lst, k - 1);
}
balance(ref t);
}
void balance(ref Node t) {
var balance = t.lst.Height - t.rst.Height;
if (balance == -2) {
if (t.rst.lst.Height - t.rst.rst.Height > 0) {
rotR(ref t.rst);
}
rotL(ref t);
} else if (balance == 2) {
if (t.lst.lst.Height - t.lst.rst.Height < 0)
rotL(ref t.lst);
rotR(ref t);
} else
t.Update();
}
T find(Node t, int k) {
if (k < 0 || k > root.Count)
throw new ArgumentOutOfRangeException();
for (;;) {
if (k == t.lst.Count)
return t.Key;
else if (k < t.lst.Count)
t = t.lst;
else {
k -= t.lst.Count + 1;
t = t.rst;
}
}
}
public int LowerBound(T v) {
var k = 0;
var t = root;
for (;;) {
if (t.Count == 0)
return k;
if (comparer.Compare(v, t.Key) <= 0)
t = t.lst;
else {
k += t.lst.Count + 1;
t = t.rst;
}
}
}
public int UpperBound(T v) {
var k = 0;
var t = root;
for (;;) {
if (t.Count == 0)
return k;
if (comparer.Compare(t.Key, v) <= 0) {
k += t.lst.Count + 1;
t = t.rst;
} else
t = t.lst;
}
}
public bool Contains(T v) {
var k = 0;
var t = root;
for (;;) {
if (t.Count == 0)
return false;
if (comparer.Compare(t.Key, v) == 0)
return true;
if (comparer.Compare(t.Key, v) < 0) {
k += t.lst.Count + 1;
t = t.rst;
} else
t = t.lst;
}
}
void rotR(ref Node t) {
var l = t.lst;
t.lst = l.rst;
l.rst = t;
t.Update();
l.Update();
t = l;
}
void rotL(ref Node t) {
var r = t.rst;
t.rst = r.lst;
r.lst = t;
t.Update();
r.Update();
t = r;
}
public T[] ToArray() {
var rt = new T[Count];
var idx = 0;
Action<Node> dfs = null;
dfs = a => {
if (a.lst != nil)
dfs(a.lst);
rt[idx++] = a.Key;
if (a.rst != nil)
dfs(a.rst);
};
dfs(root);
return rt;
}
class Node {
public Node(T key) { Key = key; }
public int Count { get; private set; }
public sbyte Height { get; private set; }
public T Key { get; set; }
public Node lst, rst;
public void Update() {
Count = 1 + lst.Count + rst.Count;
Height = (sbyte)(1 + Math.Max(lst.Height, rst.Height));
}
public override string ToString() {
return string.Format("Count = {0}, Key = {1}", Count, Key);
}
}
}
#region Template
public partial class Solver {
public SC sc = new SC();
static void Main(string[] args) {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
var sol = new Solver();
int testcase = 1;
// testcase = sol.sc.Int;
// var th = new Thread(sol.Solve, 1 << 26);th.Start();th.Join();
while (testcase-- > 0)
sol.Solve();
Console.Out.Flush();
}
}
public static class Template {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmin<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) > 0) {
a = b;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmax<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) < 0) {
a = b;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void swap<T>(ref T a, ref T b) {
var t = b;
b = a;
a = t;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void swap<T>(this IList<T> A, int i, int j) {
var t = A[i];
A[i] = A[j];
A[j] = t;
}
public static T[] Create<T>(int n, Func<T> f) {
var rt = new T[n];
for (var i = 0; i < rt.Length; ++i)
rt[i] = f();
return rt;
}
public static T[] Create<T>(int n, Func<int, T> f) {
var rt = new T[n];
for (var i = 0; i < rt.Length; ++i)
rt[i] = f(i);
return rt;
}
public static void Out<T>(this IList<T> A, out T a) => a = A[0];
public static void Out<T>(this IList<T> A, out T a, out T b) {
a = A[0];
b = A[1];
}
public static void Out<T>(this IList<T> A, out T a, out T b, out T c) {
A.Out(out a, out b);
c = A[2];
}
public static void Out<T>(this IList<T> A, out T a, out T b, out T c,
out T d) {
A.Out(out a, out b, out c);
d = A[3];
}
public static string Concat<T>(this IEnumerable<T> A,
string sp) => string.Join(sp, A);
public static char ToChar(this int s, char begin = '0') => (char)(s + begin);
public static IEnumerable<T>
Shuffle<T>(this IEnumerable<T> A) => A.OrderBy(v => Guid.NewGuid());
public static int CompareTo<T>(this T[] A, T[] B, Comparison<T> cmp = null) {
cmp = cmp ?? Comparer<T>.Default.Compare;
for (var i = 0; i < Min(A.Length, B.Length); i++) {
int c = cmp(A[i], B[i]);
if (c > 0)
return 1;
else if (c < 0)
return -1;
}
if (A.Length == B.Length)
return 0;
if (A.Length > B.Length)
return 1;
else
return -1;
}
public static string
ToStr<T>(this T[][] A) => A.Select(a => a.Concat(" ")).Concat("\n");
public static int ArgMax<T>(this IList<T> A, Comparison<T> cmp = null) {
cmp = cmp ?? Comparer<T>.Default.Compare;
T max = A[0];
int rt = 0;
for (int i = 1; i < A.Count; i++)
if (cmp(max, A[i]) < 0) {
max = A[i];
rt = i;
}
return rt;
}
public static T PopBack<T>(this List<T> A) {
var v = A[A.Count - 1];
A.RemoveAt(A.Count - 1);
return v;
}
public static void Fail<T>(T s) {
Console.WriteLine(s);
Console.Out.Close();
Environment.Exit(0);
}
}
public class Scanner {
public string Str => Console.ReadLine().Trim();
public int Int => int.Parse(Str);
public long Long => long.Parse(Str);
public double Double => double.Parse(Str);
public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
public int[] ArrInt1D(int n) => Create(n, () => Int);
public long[] ArrLong1D(int n) => Create(n, () => Long);
public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
private Queue<string> q = new Queue<string>();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public T Next<T>() {
if (q.Count == 0)
foreach (var item in Str.Split(' '))
q.Enqueue(item);
return (T)Convert.ChangeType(q.Dequeue(), typeof(T));
}
public void Make<T1>(out T1 v1) => v1 = Next<T1>();
public void Make<T1, T2>(out T1 v1, out T2 v2) {
v1 = Next<T1>();
v2 = Next<T2>();
}
public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) {
Make(out v1, out v2);
v3 = Next<T3>();
}
public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) {
Make(out v1, out v2, out v3);
v4 = Next<T4>();
}
public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5) {
Make(out v1, out v2, out v3, out v4);
v5 = Next<T5>();
}
public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5, out T6 v6) {
Make(out v1, out v2, out v3, out v4, out v5);
v6 = Next<T6>();
}
public void Make<T1, T2, T3, T4, T5, T6, T7>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5, out T6 v6,
out T7 v7) {
Make(out v1, out v2, out v3, out v4, out v5, out v6);
v7 = Next<T7>();
}
public (T1, T2) Make<T1, T2>() {
Make(out T1 v1, out T2 v2);
return (v1, v2);
}
public (T1, T2, T3) Make<T1, T2, T3>() {
Make(out T1 v1, out T2 v2, out T3 v3);
return (v1, v2, v3);
}
public (T1, T2, T3, T4) Make<T1, T2, T3, T4>() {
Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4);
return (v1, v2, v3, v4);
}
}
#endregion
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Threading;
using System.Runtime.CompilerServices;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Template;
using SC = Scanner;
public partial class Solver {
public void Solve() {
var N = sc.Int;
var P = new(int X, int Y, char U)[N];
for (int i = 0; i < N; i++) {
sc.Make(out P[i].X, out P[i].Y, out P[i].U);
}
var res = int.MaxValue;
Array.Sort(P, (a, b) => {
if (a.X == b.X)
return a.Y - b.Y;
return a.X - b.X;
});
const int g = 200200;
var umin = Create(400400, () => int.MaxValue / 2);
var dmin = Create(400400, () => int.MaxValue / 2);
for (int i = 0; i < N;) {
int idx = i;
var U = new Set<int>((a, b) => b - a);
var D = new Set<int>();
while (idx < N && P[idx].X == P[i].X) {
if (P[idx].U == 'U') {
var lw = D.LowerBound(P[idx].Y);
if (lw != D.Count)
chmin(ref res, (D[lw] - P[idx].Y) * 5);
U.Add(P[idx].Y);
umin[P[idx].Y - P[idx].X + g] = P[idx].X;
} else if (P[idx].U == 'D') {
var lw = U.LowerBound(P[idx].Y);
if (lw != U.Count)
chmin(ref res, (P[idx].Y - U[lw]) * 5);
D.Add(P[idx].Y);
dmin[P[idx].Y + P[idx].X] = P[idx].X;
} else if (P[idx].U == 'L') {
if (umin[P[idx].Y - P[idx].X + g] != int.MaxValue / 2)
chmin(ref res, -(umin[P[idx].Y - P[idx].X + g] - P[idx].X) * 10);
if (dmin[P[idx].Y + P[idx].X] != int.MaxValue / 2)
chmin(ref res, -(dmin[P[idx].Y + P[idx].X] - P[idx].X) * 10);
}
idx++;
}
i = idx;
}
for (int i = 0; i < dmin.Length; i++)
umin[i] = dmin[i] = int.MaxValue / 2;
for (int i = N - 1; i >= 0; i--) {
if (P[i].U == 'U')
umin[P[i].Y + P[i].X] = P[i].X;
else if (P[i].U == 'D')
dmin[P[i].Y - P[i].X + g] = P[i].X;
else if (P[i].U == 'R') {
if (umin[P[i].Y + P[i].X] != int.MaxValue / 2)
chmin(ref res, -(P[i].X - umin[P[i].Y + P[i].X]) * 10);
if (dmin[P[i].Y - P[i].X + g] != int.MaxValue / 2)
chmin(ref res, -(P[i].X - dmin[P[i].Y - P[i].X + g]) * 10);
}
}
Array.Sort(P, (a, b) => {
if (a.Y == b.Y)
return a.X - b.X;
return a.Y - b.Y;
});
for (int i = 0; i < N;) {
int idx = i;
var R = new Set<int>((a, b) => b - a);
var L = new Set<int>();
while (idx < N && P[idx].Y == P[i].Y) {
if (P[idx].U == 'R') {
var lw = L.LowerBound(P[idx].X);
if (lw != L.Count)
chmin(ref res, (L[lw] - P[idx].X) * 5);
R.Add(P[idx].X);
} else if (P[idx].U == 'L') {
var lw = R.LowerBound(P[idx].X);
if (lw != R.Count)
chmin(ref res, (P[idx].X - R[lw]) * 5);
L.Add(P[idx].X);
}
idx++;
}
i = idx;
}
if (res == int.MaxValue)
Console.WriteLine("SAFE");
else
Console.WriteLine(res);
}
}
public class Set<T> {
Node root;
readonly IComparer<T> comparer;
readonly Node nil;
public bool IsMultiSet { get; set; }
public Set(IComparer<T> comparer) {
nil = new Node(default(T));
root = nil;
this.comparer = comparer;
}
public Set(Comparison<T> comaprison) : this(Comparer<T>.Create(comaprison)) {}
public Set() : this(Comparer<T>.Default) {}
public bool Add(T v) { return insert(ref root, v); }
public bool Remove(T v) { return remove(ref root, v); }
public T this[int index] {
get { return find(root, index); }
}
public int Count {
get { return root.Count; }
}
public void RemoveAt(int k) {
if (k < 0 || k >= root.Count)
throw new ArgumentOutOfRangeException();
removeAt(ref root, k);
}
public T[] Items {
get {
var ret = new T[root.Count];
var k = 0;
walk(root, ret, ref k);
return ret;
}
}
void walk(Node t, T[] a, ref int k) {
if (t.Count == 0)
return;
walk(t.lst, a, ref k);
a[k++] = t.Key;
walk(t.rst, a, ref k);
}
bool insert(ref Node t, T key) {
if (t.Count == 0) {
t = new Node(key);
t.lst = t.rst = nil;
t.Update();
return true;
}
var cmp = comparer.Compare(t.Key, key);
bool res;
if (cmp > 0)
res = insert(ref t.lst, key);
else if (cmp == 0) {
if (IsMultiSet)
res = insert(ref t.lst, key);
else
return false;
} else
res = insert(ref t.rst, key);
balance(ref t);
return res;
}
bool remove(ref Node t, T key) {
if (t.Count == 0)
return false;
var cmp = comparer.Compare(key, t.Key);
bool ret;
if (cmp < 0)
ret = remove(ref t.lst, key);
else if (cmp > 0)
ret = remove(ref t.rst, key);
else {
ret = true;
var k = t.lst.Count;
if (k == 0) {
t = t.rst;
return true;
}
if (t.rst.Count == 0) {
t = t.lst;
return true;
}
t.Key = find(t.lst, k - 1);
removeAt(ref t.lst, k - 1);
}
balance(ref t);
return ret;
}
void removeAt(ref Node t, int k) {
var cnt = t.lst.Count;
if (cnt < k)
removeAt(ref t.rst, k - cnt - 1);
else if (cnt > k)
removeAt(ref t.lst, k);
else {
if (cnt == 0) {
t = t.rst;
return;
}
if (t.rst.Count == 0) {
t = t.lst;
return;
}
t.Key = find(t.lst, k - 1);
removeAt(ref t.lst, k - 1);
}
balance(ref t);
}
void balance(ref Node t) {
var balance = t.lst.Height - t.rst.Height;
if (balance == -2) {
if (t.rst.lst.Height - t.rst.rst.Height > 0) {
rotR(ref t.rst);
}
rotL(ref t);
} else if (balance == 2) {
if (t.lst.lst.Height - t.lst.rst.Height < 0)
rotL(ref t.lst);
rotR(ref t);
} else
t.Update();
}
T find(Node t, int k) {
if (k < 0 || k > root.Count)
throw new ArgumentOutOfRangeException();
for (;;) {
if (k == t.lst.Count)
return t.Key;
else if (k < t.lst.Count)
t = t.lst;
else {
k -= t.lst.Count + 1;
t = t.rst;
}
}
}
public int LowerBound(T v) {
var k = 0;
var t = root;
for (;;) {
if (t.Count == 0)
return k;
if (comparer.Compare(v, t.Key) <= 0)
t = t.lst;
else {
k += t.lst.Count + 1;
t = t.rst;
}
}
}
public int UpperBound(T v) {
var k = 0;
var t = root;
for (;;) {
if (t.Count == 0)
return k;
if (comparer.Compare(t.Key, v) <= 0) {
k += t.lst.Count + 1;
t = t.rst;
} else
t = t.lst;
}
}
public bool Contains(T v) {
var k = 0;
var t = root;
for (;;) {
if (t.Count == 0)
return false;
if (comparer.Compare(t.Key, v) == 0)
return true;
if (comparer.Compare(t.Key, v) < 0) {
k += t.lst.Count + 1;
t = t.rst;
} else
t = t.lst;
}
}
void rotR(ref Node t) {
var l = t.lst;
t.lst = l.rst;
l.rst = t;
t.Update();
l.Update();
t = l;
}
void rotL(ref Node t) {
var r = t.rst;
t.rst = r.lst;
r.lst = t;
t.Update();
r.Update();
t = r;
}
public T[] ToArray() {
var rt = new T[Count];
var idx = 0;
Action<Node> dfs = null;
dfs = a => {
if (a.lst != nil)
dfs(a.lst);
rt[idx++] = a.Key;
if (a.rst != nil)
dfs(a.rst);
};
dfs(root);
return rt;
}
class Node {
public Node(T key) { Key = key; }
public int Count { get; private set; }
public sbyte Height { get; private set; }
public T Key { get; set; }
public Node lst, rst;
public void Update() {
Count = 1 + lst.Count + rst.Count;
Height = (sbyte)(1 + Math.Max(lst.Height, rst.Height));
}
public override string ToString() {
return string.Format("Count = {0}, Key = {1}", Count, Key);
}
}
}
#region Template
public partial class Solver {
public SC sc = new SC();
static void Main(string[] args) {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
var sol = new Solver();
int testcase = 1;
// testcase = sol.sc.Int;
// var th = new Thread(sol.Solve, 1 << 26);th.Start();th.Join();
while (testcase-- > 0)
sol.Solve();
Console.Out.Flush();
}
}
public static class Template {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmin<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) > 0) {
a = b;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmax<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) < 0) {
a = b;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void swap<T>(ref T a, ref T b) {
var t = b;
b = a;
a = t;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void swap<T>(this IList<T> A, int i, int j) {
var t = A[i];
A[i] = A[j];
A[j] = t;
}
public static T[] Create<T>(int n, Func<T> f) {
var rt = new T[n];
for (var i = 0; i < rt.Length; ++i)
rt[i] = f();
return rt;
}
public static T[] Create<T>(int n, Func<int, T> f) {
var rt = new T[n];
for (var i = 0; i < rt.Length; ++i)
rt[i] = f(i);
return rt;
}
public static void Out<T>(this IList<T> A, out T a) => a = A[0];
public static void Out<T>(this IList<T> A, out T a, out T b) {
a = A[0];
b = A[1];
}
public static void Out<T>(this IList<T> A, out T a, out T b, out T c) {
A.Out(out a, out b);
c = A[2];
}
public static void Out<T>(this IList<T> A, out T a, out T b, out T c,
out T d) {
A.Out(out a, out b, out c);
d = A[3];
}
public static string Concat<T>(this IEnumerable<T> A,
string sp) => string.Join(sp, A);
public static char ToChar(this int s, char begin = '0') => (char)(s + begin);
public static IEnumerable<T>
Shuffle<T>(this IEnumerable<T> A) => A.OrderBy(v => Guid.NewGuid());
public static int CompareTo<T>(this T[] A, T[] B, Comparison<T> cmp = null) {
cmp = cmp ?? Comparer<T>.Default.Compare;
for (var i = 0; i < Min(A.Length, B.Length); i++) {
int c = cmp(A[i], B[i]);
if (c > 0)
return 1;
else if (c < 0)
return -1;
}
if (A.Length == B.Length)
return 0;
if (A.Length > B.Length)
return 1;
else
return -1;
}
public static string
ToStr<T>(this T[][] A) => A.Select(a => a.Concat(" ")).Concat("\n");
public static int ArgMax<T>(this IList<T> A, Comparison<T> cmp = null) {
cmp = cmp ?? Comparer<T>.Default.Compare;
T max = A[0];
int rt = 0;
for (int i = 1; i < A.Count; i++)
if (cmp(max, A[i]) < 0) {
max = A[i];
rt = i;
}
return rt;
}
public static T PopBack<T>(this List<T> A) {
var v = A[A.Count - 1];
A.RemoveAt(A.Count - 1);
return v;
}
public static void Fail<T>(T s) {
Console.WriteLine(s);
Console.Out.Close();
Environment.Exit(0);
}
}
public class Scanner {
public string Str => Console.ReadLine().Trim();
public int Int => int.Parse(Str);
public long Long => long.Parse(Str);
public double Double => double.Parse(Str);
public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
public int[] ArrInt1D(int n) => Create(n, () => Int);
public long[] ArrLong1D(int n) => Create(n, () => Long);
public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
private Queue<string> q = new Queue<string>();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public T Next<T>() {
if (q.Count == 0)
foreach (var item in Str.Split(' '))
q.Enqueue(item);
return (T)Convert.ChangeType(q.Dequeue(), typeof(T));
}
public void Make<T1>(out T1 v1) => v1 = Next<T1>();
public void Make<T1, T2>(out T1 v1, out T2 v2) {
v1 = Next<T1>();
v2 = Next<T2>();
}
public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) {
Make(out v1, out v2);
v3 = Next<T3>();
}
public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) {
Make(out v1, out v2, out v3);
v4 = Next<T4>();
}
public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5) {
Make(out v1, out v2, out v3, out v4);
v5 = Next<T5>();
}
public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5, out T6 v6) {
Make(out v1, out v2, out v3, out v4, out v5);
v6 = Next<T6>();
}
public void Make<T1, T2, T3, T4, T5, T6, T7>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5, out T6 v6,
out T7 v7) {
Make(out v1, out v2, out v3, out v4, out v5, out v6);
v7 = Next<T7>();
}
public (T1, T2) Make<T1, T2>() {
Make(out T1 v1, out T2 v2);
return (v1, v2);
}
public (T1, T2, T3) Make<T1, T2, T3>() {
Make(out T1 v1, out T2 v2, out T3 v3);
return (v1, v2, v3);
}
public (T1, T2, T3, T4) Make<T1, T2, T3, T4>() {
Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4);
return (v1, v2, v3, v4);
}
}
#endregion
|
[["-", 0, 213, 3, 4, 0, 28, 0, 214, 141, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 214, 141, 22]]
| 8
| 4,518
| 4
|
using System;
namespace _20200711_A {
class Program {
static void Main(string[] args) {
int L, R, n;
string input;
input = System.Console.ReadLine();
L = int.Parse(input.Split(' ')[0]);
R = int.Parse(input.Split(' ')[1]);
n = int.Parse(input.Split(' ')[2]);
Console.WriteLine(((R / n) + (L / n)).ToString());
}
}
}
|
using System;
namespace _20200711_A {
class Program {
static void Main(string[] args) {
int L, R, n;
string input;
input = System.Console.ReadLine();
L = int.Parse(input.Split(' ')[0]);
R = int.Parse(input.Split(' ')[1]);
n = int.Parse(input.Split(' ')[2]);
Console.WriteLine(((R / n) - ((L - 1) / n)).ToString());
}
}
}
|
[["-", 0, 213, 63, 214, 205, 23, 0, 16, 17, 72], ["+", 0, 213, 63, 214, 205, 23, 0, 16, 17, 33], ["+", 63, 214, 205, 23, 0, 16, 12, 23, 0, 24], ["+", 12, 23, 0, 16, 31, 23, 0, 16, 17, 33], ["+", 12, 23, 0, 16, 31, 23, 0, 16, 12, 203], ["+", 0, 16, 12, 23, 0, 16, 31, 23, 0, 25]]
| 8
| 122
| 6
|
using System;
using System.Linq;
class name {
static void Main() {
int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
int sum = 0;
for (int i = a[0]; i < a[1] + 1; i++) {
if (i % a[3] == 0) {
sum++;
}
}
Console.WriteLine(sum);
}
}
|
using System;
using System.Linq;
class name {
static void Main() {
int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
int sum = 0;
for (int i = a[0]; i < a[1] + 1; i++) {
if (i % a[2] == 0) {
sum++;
}
}
Console.WriteLine(sum);
}
}
|
[["-", 31, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 31, 16, 12, 204, 206, 207, 0, 28, 0, 203]]
| 8
| 97
| 2
|
public class Program {
public static void Main() {
long n = long.Parse(System.Console.ReadLine());
System.Console.WriteLine(-n % 1000);
}
}
|
public class Program {
public static void Main() {
long n = long.Parse(System.Console.ReadLine());
System.Console.WriteLine((10000 - n) % 1000);
}
}
|
[["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 24], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 31, 203], ["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 25]]
| 8
| 41
| 3
|
using System;
public class p {
static void Main() {
int A = int.Parse(Console.ReadLine());
Console.WriteLine(A % 1000 % 1000);
}
}
|
using System;
public class p {
static void Main() {
int A = int.Parse(Console.ReadLine());
Console.WriteLine((1000 - A % 1000) % 1000);
}
}
|
[["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 24], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 31, 203], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 17, 33], ["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 25]]
| 8
| 40
| 4
|
using System;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
namespace ForAtcoder {
class Program {
static void Main(string[] args) {
long n = long.Parse(Console.ReadLine());
long mod = n % 1000;
Console.WriteLine(mod != 0 ? mod : 0);
}
}
}
|
using System;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
namespace ForAtcoder {
class Program {
static void Main(string[] args) {
long n = long.Parse(Console.ReadLine());
long mod = n % 1000;
Console.WriteLine(mod != 0 ? (1000 - mod) : 0);
}
}
}
|
[["+", 3, 4, 0, 28, 0, 41, 64, 23, 0, 24], ["+", 0, 28, 0, 41, 64, 23, 0, 16, 31, 203], ["+", 0, 28, 0, 41, 64, 23, 0, 16, 17, 33], ["+", 3, 4, 0, 28, 0, 41, 64, 23, 0, 25]]
| 8
| 73
| 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 AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
// 解答はココに書く
int yen = cin.ReadInt;
int left = yen % 1000;
int ans = 0;
if (left == 0) {
ans = 0;
} else {
ans = 1000 - yen;
}
WriteLine(ans);
}
}
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) {
// 解答はココに書く
int yen = cin.ReadInt;
int left = yen % 1000;
int ans;
if (left == 0) {
ans = 0;
} else {
ans = 1000 - left;
}
WriteLine(ans);
}
}
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, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 75, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 12, 22]]
| 8
| 470
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace CSharpSample01 {
class Program {
static void Main(string[] args) {
var N = int.Parse(Console.ReadLine());
int answer = N;
while (answer >= 0) {
answer -= 1000;
}
answer = answer * -1;
Console.WriteLine(answer);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace CSharpSample01 {
class Program {
static void Main(string[] args) {
var N = int.Parse(Console.ReadLine());
int answer = N % 1000;
if (answer != 0) {
answer -= 1000;
answer = answer * -1;
}
Console.WriteLine(answer);
}
}
}
|
[["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 109], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 52, 0, 89], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["-", 0, 195, 8, 196, 0, 52, 15, 16, 17, 20], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 79], ["-", 0, 195, 8, 196, 0, 52, 8, 196, 0, 46], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 79
| 8
|
using System;
namespace ConsoleApp3 {
internal class Program {
private static void Main(string[] args) {
var input = int.Parse(Console.ReadLine());
var result = input;
while (result >= 0) {
result -= 1000;
}
Console.WriteLine(-result);
}
}
}
|
using System;
namespace ConsoleApp3 {
internal class Program {
private static void Main(string[] args) {
var input = int.Parse(Console.ReadLine());
var result = input;
while (result > 0) {
result -= 1000;
}
Console.WriteLine(-result);
}
}
}
|
[["-", 0, 195, 8, 196, 0, 52, 15, 16, 17, 20], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 47]]
| 8
| 63
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder.Abc {
// https://atcoder.jp/contests/abc141/tasks/abc141_a
public class QuestionA {
public static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
// 整数の入力
long n = long.Parse(Console.ReadLine());
var a = 1000 - (n % 1000);
Console.WriteLine(a);
Console.Out.Flush();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder.Abc {
// https://atcoder.jp/contests/abc141/tasks/abc141_a
public class QuestionA {
public static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
// 整数の入力
long n = long.Parse(Console.ReadLine());
var a = 1000 - (n % 1000);
Console.WriteLine(a == 1000 ? 0 : a);
Console.Out.Flush();
}
}
}
|
[["+", 3, 4, 0, 28, 0, 41, 15, 16, 17, 60], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 12, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 101], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 64, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 102], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 75, 22]]
| 8
| 121
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Numerics;
using System.Threading;
using System.Runtime.CompilerServices;
using static System.Math;
using static System.Array;
using static AtCoder.Sc_out;
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);
var th = new Thread(Run, 1 << 26);
th.Start();
th.Join();
// Run();
Console.Out.Flush();
}
static void Run() {
int Testcase = 1;
for (var _ = 0; _ < Testcase; _++)
Solve();
}
static void Solve() {
int N = Cin.Int;
N %= 1000;
OutL(1000 - N);
}
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 Cin {
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]);
}
}
static class Sc_out {
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 System.Threading;
using System.Runtime.CompilerServices;
using static System.Math;
using static System.Array;
using static AtCoder.Sc_out;
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);
var th = new Thread(Run, 1 << 26);
th.Start();
th.Join();
// Run();
Console.Out.Flush();
}
static void Run() {
int Testcase = 1;
for (var _ = 0; _ < Testcase; _++)
Solve();
}
static void Solve() {
int N = Cin.Int;
N %= 1000;
OutL((1000 - N) % 1000);
}
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 Cin {
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]);
}
}
static class Sc_out {
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));
}
}
|
[["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 25], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 109], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
| 8
| 1,787
| 4
|
using System;
using System.Collections.Generic;
class IDONTKNOWCSHARP {
public static void Main() {
int num = int.Parse(Console.ReadLine());
int[] array = new int[4];
array[0] = 0;
array[1] = 0;
array[2] = 0;
array[3] = 0;
for (int i = 0; i < num; i++) {
switch (Console.ReadLine()) {
case "AC":
array[0]++;
break;
case "WA":
array[1]++;
break;
case "TLE":
array[2]++;
break;
case "RE":
array[3]++;
break;
}
}
Console.WriteLine($"AC x {array[0]}\r\n" + $"WA x {array[1]}\r\n" +
$"TLE x {array[2]}\r\n" + $"RE x {array[3]}");
}
}
|
using System;
using System.Collections.Generic;
class IDONTKNOWCSHARP {
public static void Main() {
int num = int.Parse(Console.ReadLine());
int[] array = new int[4];
array[0] = 0;
array[1] = 0;
array[2] = 0;
array[3] = 0;
for (int i = 0; i < num; i++) {
switch (Console.ReadLine()) {
case "AC":
array[0]++;
break;
case "WA":
array[1]++;
break;
case "TLE":
array[2]++;
break;
case "RE":
array[3]++;
break;
}
}
Console.WriteLine($"AC x {array[0]}\r\n" + $"WA x {array[1]}\r\n" +
$"TLE x {array[2]}\r\n" + $"RE x {array[3]}");
// Console.ReadKey();
}
}
|
[["-", 3, 4, 0, 28, 0, 16, 12, 283, 0, 296], ["+", 3, 4, 0, 28, 0, 16, 12, 283, 0, 296]]
| 8
| 204
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ProgramingStudying2 {
class Program {
static void Main(string[] args) {
var n = int.Parse(Console.ReadLine());
var ac = 0;
var wa = 0;
var tle = 0;
var re = 0;
for (int i = 0; i < n; i++) {
var s = Console.ReadLine();
if (s == "AC") {
ac++;
}
if (s == "WA") {
wa++;
}
if (s == "TLE") {
tle++;
}
if (s == "RE") {
re++;
}
}
Console.WriteLine("AC x " + ac);
Console.WriteLine("WA " + wa);
Console.WriteLine("TLE x " + tle);
Console.WriteLine("RE x " + re);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ProgramingStudying2 {
class Program {
static void Main(string[] args) {
var n = int.Parse(Console.ReadLine());
var ac = 0;
var wa = 0;
var tle = 0;
var re = 0;
for (int i = 0; i < n; i++) {
var s = Console.ReadLine();
if (s == "AC") {
ac++;
}
if (s == "WA") {
wa++;
}
if (s == "TLE") {
tle++;
}
if (s == "RE") {
re++;
}
}
Console.WriteLine("AC x " + ac);
Console.WriteLine("WA x " + wa);
Console.WriteLine("TLE x " + tle);
Console.WriteLine("RE x " + re);
}
}
}
|
[["-", 3, 4, 0, 28, 0, 16, 31, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 16, 31, 5, 0, 222]]
| 8
| 189
| 2
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;
class program {
static public int mod = 1000000007;
static void Main() {
var n = rint();
var ans = new Dictionary<string, int>() {
{ "AC", 0 }, { "WA", 0 }, { "TLE", 0 }, { "RE", 0 }
};
for (int i = 0; i < n; i++) {
string s = rstr();
ans[s]++;
}
WriteLine("AC" + " × " + ans["AC"]);
WriteLine("WA" + " × " + ans["WA"]);
WriteLine("TLE" + " × " + ans["TLE"]);
WriteLine("RE" + " × " + ans["RE"]);
}
static int pow(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 string rstr() { return ReadLine(); }
static int rint() { return int.Parse(ReadLine()); }
static long rlong() { return long.Parse(ReadLine()); }
static string[] stra() { return ReadLine().Split(' '); }
static char[] chara() {
string[] a = stra();
string b = "";
for (int i = 0; i < a.Length; i++) {
b += a[i];
}
return b.ToCharArray();
}
static int[] inta() {
string[] read_str_array = ReadLine().Split(' ');
int[] return_int_array = new int[read_str_array.Length];
for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
}
return return_int_array;
}
static long[] longa() {
string[] read_str_array = ReadLine().Split(' ');
long[] return_long_array = new long[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_long_array[countup_i] = long.Parse(read_str_array[countup_i]);
}
return return_long_array;
}
static double[] doublea() {
string[] read_str_array = ReadLine().Split(' ');
double[] return_double_array = new double[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_double_array[countup_i] = double.Parse(read_str_array[countup_i]);
}
return return_double_array;
}
static long GCD(long a, long b) {
if (a < b) {
long temp = a;
a = b;
b = temp;
}
if (a % b == 0) {
return b;
} else {
long temp = b;
b = a % b;
a = temp;
return GCD(a, b);
}
}
static long LCM(long a, long b) { return a * b / GCD(a, b); }
static void WriteArray2(int[,] a, int b, int c) {
for (int i = 0; i < b; i++) {
for (int j = 0; j < c; j++) {
if (j != 0)
Write(" ");
Write(a[i, j]);
}
WriteLine();
}
}
static void WriteArray(int[] a, int b) {
for (int i = 0; i < b; i++) {
Write(" ");
Write(a[i]);
}
WriteLine();
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;
class program {
static public int mod = 1000000007;
static void Main() {
var n = rint();
var ans = new Dictionary<string, int>() {
{ "AC", 0 }, { "WA", 0 }, { "TLE", 0 }, { "RE", 0 }
};
for (int i = 0; i < n; i++) {
string s = rstr();
ans[s]++;
}
WriteLine("AC" + " x " + ans["AC"]);
WriteLine("WA" + " x " + ans["WA"]);
WriteLine("TLE" + " x " + ans["TLE"]);
WriteLine("RE" + " x " + ans["RE"]);
}
static int pow(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 string rstr() { return ReadLine(); }
static int rint() { return int.Parse(ReadLine()); }
static long rlong() { return long.Parse(ReadLine()); }
static string[] stra() { return ReadLine().Split(' '); }
static char[] chara() {
string[] a = stra();
string b = "";
for (int i = 0; i < a.Length; i++) {
b += a[i];
}
return b.ToCharArray();
}
static int[] inta() {
string[] read_str_array = ReadLine().Split(' ');
int[] return_int_array = new int[read_str_array.Length];
for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
}
return return_int_array;
}
static long[] longa() {
string[] read_str_array = ReadLine().Split(' ');
long[] return_long_array = new long[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_long_array[countup_i] = long.Parse(read_str_array[countup_i]);
}
return return_long_array;
}
static double[] doublea() {
string[] read_str_array = ReadLine().Split(' ');
double[] return_double_array = new double[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_double_array[countup_i] = double.Parse(read_str_array[countup_i]);
}
return return_double_array;
}
static long GCD(long a, long b) {
if (a < b) {
long temp = a;
a = b;
b = temp;
}
if (a % b == 0) {
return b;
} else {
long temp = b;
b = a % b;
a = temp;
return GCD(a, b);
}
}
static long LCM(long a, long b) { return a * b / GCD(a, b); }
static void WriteArray2(int[,] a, int b, int c) {
for (int i = 0; i < b; i++) {
for (int j = 0; j < c; j++) {
if (j != 0)
Write(" ");
Write(a[i, j]);
}
WriteLine();
}
}
static void WriteArray(int[] a, int b) {
for (int i = 0; i < b; i++) {
Write(" ");
Write(a[i]);
}
WriteLine();
}
}
|
[["-", 0, 28, 0, 16, 31, 16, 12, 5, 0, 222], ["+", 0, 28, 0, 16, 31, 16, 12, 5, 0, 222]]
| 8
| 870
| 8
|
using System;
using System.Linq;
class Test {
static void Main(string[] args) {
var inputs = System.Console.ReadLine()
.Split(' ')
.Select(s => int.Parse(s))
.ToArray();
int N = inputs[0];
int cntAC = 0;
int cntWA = 0;
int cntTLE = 0;
int cntRE = 0;
for (int i = 0; i < N; i++) {
string A = System.Console.ReadLine();
if (A == "AC") {
cntAC++;
} else if (A == "WA") {
cntWA++;
} else if (A == "TLE") {
cntTLE++;
} else if (A == "RE") {
cntWA++;
}
}
Console.WriteLine("AC x " + cntAC);
Console.WriteLine("WA x " + cntWA);
Console.WriteLine("TLE x " + cntTLE);
Console.WriteLine("RE x " + cntRE);
}
}
|
using System;
using System.Linq;
class Test {
static void Main(string[] args) {
var inputs = System.Console.ReadLine()
.Split(' ')
.Select(s => int.Parse(s))
.ToArray();
int N = inputs[0];
int cntAC = 0;
int cntWA = 0;
int cntTLE = 0;
int cntRE = 0;
for (int i = 0; i < N; i++) {
string A = System.Console.ReadLine();
if (A == "AC") {
cntAC++;
} else if (A == "WA") {
cntWA++;
} else if (A == "TLE") {
cntTLE++;
} else if (A == "RE") {
cntRE++;
}
}
Console.WriteLine("AC x " + cntAC);
Console.WriteLine("WA x " + cntWA);
Console.WriteLine("TLE x " + cntTLE);
Console.WriteLine("RE x " + cntRE);
}
}
|
[["-", 75, 57, 64, 196, 0, 1, 0, 223, 0, 22], ["+", 75, 57, 64, 196, 0, 1, 0, 223, 0, 22]]
| 8
| 211
| 2
|
using System;
namespace atcoder {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
int[] ans = new int[4];
string AC = "AC x";
string WA = "WA x";
string TEL = "TEL x";
string RE = "RE x";
for (int i = 0; i < N; i++) {
string Input = Console.ReadLine().Replace("\r\n", "");
switch (Input) {
case ("AC"): {
ans[0]++;
break;
}
case ("WA"): {
ans[1]++;
break;
}
case ("TEL"): {
ans[2]++;
break;
}
case ("RE"): {
ans[3]++;
break;
}
}
}
Console.WriteLine(AC + " " + ans[0]);
Console.WriteLine(WA + " " + ans[1]);
Console.WriteLine(TEL + " " + ans[2]);
Console.WriteLine(RE + " " + ans[3]);
}
}
}
|
using System;
namespace atcoder {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
int[] ans = new int[4];
string AC = "AC x";
string WA = "WA x";
string TEL = "TLE x";
string RE = "RE x";
for (int i = 0; i < N; i++) {
string Input = Console.ReadLine().Replace("\r\n", "");
switch (Input) {
case ("AC"): {
ans[0]++;
break;
}
case ("WA"): {
ans[1]++;
break;
}
case ("TLE"): {
ans[2]++;
break;
}
case ("RE"): {
ans[3]++;
break;
}
}
}
Console.WriteLine(AC + " " + ans[0]);
Console.WriteLine(WA + " " + ans[1]);
Console.WriteLine(TEL + " " + ans[2]);
Console.WriteLine(RE + " " + ans[3]);
}
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 5, 0, 222], ["+", 0, 198, 0, 200, 0, 212, 0, 5, 0, 222], ["-", 0, 239, 0, 264, 0, 23, 0, 5, 0, 222], ["+", 0, 239, 0, 264, 0, 23, 0, 5, 0, 222]]
| 8
| 249
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
int[] ans = new int[4];
int n = crI();
for (int i = 0; i < n; i++) {
string s = crS();
if (s.Equals("AC"))
ans[0]++;
else if (s.Equals("WA"))
ans[1]++;
else if (s.Equals("TLE"))
ans[2]++;
else if (s.Equals("RE"))
ans[3]++;
}
Console.WriteLine("AC × " + ans[0]);
Console.WriteLine("WA × " + ans[1]);
Console.WriteLine("TLE × " + ans[2]);
Console.WriteLine("RE × " + ans[3]);
}
//入力受け取り用
static string crS() { return Console.ReadLine(); }
static int crI() { return int.Parse(Console.ReadLine()); }
static int[] arrInt() {
return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
}
static long[] arrLong() {
return Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray();
}
static string[] arrStr() { return Console.ReadLine().Split(' ').ToArray(); }
static List<int[]> mapInt(int h) {
List<int[]> mapInt = new List<int[]>();
for (int i = 0; i < h; i++) {
mapInt.Add(arrInt());
}
return mapInt;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
int[] ans = new int[4];
int n = crI();
for (int i = 0; i < n; i++) {
string s = crS();
if (s.Equals("AC"))
ans[0]++;
else if (s.Equals("WA"))
ans[1]++;
else if (s.Equals("TLE"))
ans[2]++;
else if (s.Equals("RE"))
ans[3]++;
}
Console.WriteLine("AC x " + ans[0]);
Console.WriteLine("WA x " + ans[1]);
Console.WriteLine("TLE x " + ans[2]);
Console.WriteLine("RE x " + ans[3]);
}
//入力受け取り用
static string crS() { return Console.ReadLine(); }
static int crI() { return int.Parse(Console.ReadLine()); }
static int[] arrInt() {
return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
}
static long[] arrLong() {
return Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray();
}
static string[] arrStr() { return Console.ReadLine().Split(' ').ToArray(); }
static List<int[]> mapInt(int h) {
List<int[]> mapInt = new List<int[]>();
for (int i = 0; i < h; i++) {
mapInt.Add(arrInt());
}
return mapInt;
}
}
|
[["-", 3, 4, 0, 28, 0, 16, 31, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 16, 31, 5, 0, 222]]
| 8
| 397
| 8
|
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
namespace AtCoder {
class Program {
static void Main(string[] args) {
var num = Scanner.Integer();
var strings = new List<string>();
for (int i = 0; i < num; i++) {
strings.Add(Scanner.Scan());
}
var sb = new StringBuilder();
sb.AppendLine("AC " + strings.Count(x => x == "AC"));
sb.AppendLine("WA x " + strings.Count(x => x == "WA"));
sb.AppendLine("TLE x " + strings.Count(x => x == "TLE"));
sb.AppendLine("RE x " + strings.Count(x => x == "RE"));
Console.WriteLine(sb);
}
// 以下ユーティリティー
static readonly StreamScanner Scanner =
new StreamScanner(Console.OpenStandardInput());
/// <summary> 数値読み込み </summary>
private static List<long> ScanLong(int count = 0) {
var scan = new List<long>();
for (int i = 0; i < count; i++) {
scan.Add(Scanner.Long());
}
return scan;
}
/// <summary> 一括出力 </summary>
private static void OutAllLine(IEnumerable<dynamic> items) {
var sb = new StringBuilder();
foreach (var result in items) {
sb.Append(result + "\n");
}
sb = sb.Remove(sb.Length - 1, 1);
Console.WriteLine(sb);
}
/// <summary> 素数判定 </summary>
public static bool IsPrime(int num) {
if (num < 2) {
return false;
}
if (num == 2) {
return true;
}
if (num % 2 == 0) {
return false;
}
double sqrtNum = Math.Sqrt(num);
for (int i = 3; i <= sqrtNum; i += 2) {
if (num % i == 0) {
return false;
}
}
return true;
}
public static IEnumerable<int> PrimeFactors(int n) {
int i = 2;
int tmp = n;
while (i * i <= n) //※1
{
if (tmp % i == 0) {
tmp /= i;
yield return i;
} else {
i++;
}
}
if (tmp != 1)
yield return tmp;
}
}
public class StreamScanner {
public StreamScanner(Stream stream) { str = stream; }
private readonly Stream str;
private readonly byte[] buf = new byte[1024];
private int len, ptr;
public bool isEof = false;
public bool IsEndOfStream {
get { return isEof; }
}
private 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++];
}
public char Char() {
byte b = 0;
do
b = read();
while (b < 33 || 126 < b);
return (char)b;
}
public string Scan() {
var sb = new StringBuilder();
for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
sb.Append(b);
return sb.ToString();
}
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';
}
}
public int Integer() { return (int)Long(); }
public double Double() {
return double.Parse(Scan(), CultureInfo.InvariantCulture);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
namespace AtCoder {
class Program {
static void Main(string[] args) {
var num = Scanner.Integer();
var strings = new List<string>();
for (int i = 0; i < num; i++) {
strings.Add(Scanner.Scan());
}
var sb = new StringBuilder();
sb.AppendLine("AC x " + strings.Count(x => x == "AC"));
sb.AppendLine("WA x " + strings.Count(x => x == "WA"));
sb.AppendLine("TLE x " + strings.Count(x => x == "TLE"));
sb.AppendLine("RE x " + strings.Count(x => x == "RE"));
Console.WriteLine(sb);
}
// 以下ユーティリティー
static readonly StreamScanner Scanner =
new StreamScanner(Console.OpenStandardInput());
/// <summary> 数値読み込み </summary>
private static List<long> ScanLong(int count = 0) {
var scan = new List<long>();
for (int i = 0; i < count; i++) {
scan.Add(Scanner.Long());
}
return scan;
}
/// <summary> 一括出力 </summary>
private static void OutAllLine(IEnumerable<dynamic> items) {
var sb = new StringBuilder();
foreach (var result in items) {
sb.Append(result + "\n");
}
sb = sb.Remove(sb.Length - 1, 1);
Console.WriteLine(sb);
}
/// <summary> 素数判定 </summary>
public static bool IsPrime(int num) {
if (num < 2) {
return false;
}
if (num == 2) {
return true;
}
if (num % 2 == 0) {
return false;
}
double sqrtNum = Math.Sqrt(num);
for (int i = 3; i <= sqrtNum; i += 2) {
if (num % i == 0) {
return false;
}
}
return true;
}
public static IEnumerable<int> PrimeFactors(int n) {
int i = 2;
int tmp = n;
while (i * i <= n) //※1
{
if (tmp % i == 0) {
tmp /= i;
yield return i;
} else {
i++;
}
}
if (tmp != 1)
yield return tmp;
}
}
public class StreamScanner {
public StreamScanner(Stream stream) { str = stream; }
private readonly Stream str;
private readonly byte[] buf = new byte[1024];
private int len, ptr;
public bool isEof = false;
public bool IsEndOfStream {
get { return isEof; }
}
private 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++];
}
public char Char() {
byte b = 0;
do
b = read();
while (b < 33 || 126 < b);
return (char)b;
}
public string Scan() {
var sb = new StringBuilder();
for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
sb.Append(b);
return sb.ToString();
}
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';
}
}
public int Integer() { return (int)Long(); }
public double Double() {
return double.Parse(Scan(), CultureInfo.InvariantCulture);
}
}
}
|
[["-", 3, 4, 0, 28, 0, 16, 31, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 16, 31, 5, 0, 222]]
| 8
| 862
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace test1 {
class Program {
static void Main(string[] args) {
var N = int.Parse(Console.ReadLine());
var list = new List<string>();
for (int i = 0; i < N; i++) {
list.Add(Console.ReadLine());
}
Console.WriteLine("AC x {0}",
list.Where(x => string.Compare(x, "AC") == 0).Count());
Console.WriteLine("WA x {0}",
list.Where(x => string.Compare(x, "WA") == 0).Count());
Console.WriteLine("TLE x {0}",
list.Where(x => string.Compare(x, "TLE") == 0).Count());
Console.WriteLine("REx {0}",
list.Where(x => string.Compare(x, "RE") == 0).Count());
return;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace test1 {
class Program {
static void Main(string[] args) {
var N = int.Parse(Console.ReadLine());
var list = new List<string>();
for (int i = 0; i < N; i++) {
list.Add(Console.ReadLine());
}
Console.WriteLine("AC x {0}",
list.Where(x => string.Compare(x, "AC") == 0).Count());
Console.WriteLine("WA x {0}",
list.Where(x => string.Compare(x, "WA") == 0).Count());
Console.WriteLine("TLE x {0}",
list.Where(x => string.Compare(x, "TLE") == 0).Count());
Console.WriteLine("RE x {0}",
list.Where(x => string.Compare(x, "RE") == 0).Count());
return;
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 220
| 2
|
using System;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
namespace ForAtcoder {
class Program {
static void Main(string[] args) {
long n = long.Parse(Console.ReadLine());
long ac = 0;
long wa = 0;
long tle = 0;
long re = 0;
for (var i = 1; i <= n; i++) {
string tmp = Console.ReadLine();
switch (tmp) {
case "AC":
ac++;
break;
case "WA":
wa++;
break;
case "TLE":
tle++;
break;
case "RE":
re++;
break;
}
Console.WriteLine($"AC x {ac}");
Console.WriteLine($"WA x {wa}");
Console.WriteLine($"TLE x {tle}");
Console.WriteLine($"RE x {re}");
}
}
}
}
|
using System;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
namespace ForAtcoder {
class Program {
static void Main(string[] args) {
long n = long.Parse(Console.ReadLine());
long ac = 0;
long wa = 0;
long tle = 0;
long re = 0;
for (var i = 1; i <= n; i++) {
string tmp = Console.ReadLine();
switch (tmp) {
case "AC":
ac++;
break;
case "WA":
wa++;
break;
case "TLE":
tle++;
break;
case "RE":
re++;
break;
}
}
Console.WriteLine($"AC x {ac}");
Console.WriteLine($"WA x {wa}");
Console.WriteLine($"TLE x {tle}");
Console.WriteLine($"RE x {re}");
}
}
}
|
[["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46], ["-", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46]]
| 8
| 192
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
var n = int.Parse(Console.ReadLine());
var ansl = new int[4] { 0, 0, 0, 0 };
for (var i = 0; n > i; i++) {
var l = Console.ReadLine();
if (l == "AC")
ansl[0]++;
if (l == "WA")
ansl[1]++;
if (l == "TLR")
ansl[2]++;
if (l == "RE")
ansl[3]++;
}
for (var i = 0; 4 > i; i++) {
if (i == 0)
Console.Write("AC");
if (i == 1)
Console.Write("WA");
if (i == 2)
Console.Write("TLE");
if (i == 3)
Console.Write("RE");
Console.WriteLine($" x {ansl[i]}");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
var n = int.Parse(Console.ReadLine());
var ansl = new int[4] { 0, 0, 0, 0 };
for (var i = 0; n > i; i++) {
var l = Console.ReadLine();
if (l == "AC")
ansl[0]++;
if (l == "WA")
ansl[1]++;
if (l == "TLE")
ansl[2]++;
if (l == "RE")
ansl[3]++;
}
for (var i = 0; 4 > i; i++) {
if (i == 0)
Console.Write("AC");
if (i == 1)
Console.Write("WA");
if (i == 2)
Console.Write("TLE");
if (i == 3)
Console.Write("RE");
Console.WriteLine($" x {ansl[i]}");
}
}
}
|
[["-", 8, 196, 0, 57, 15, 16, 12, 5, 0, 222], ["+", 8, 196, 0, 57, 15, 16, 12, 5, 0, 222]]
| 8
| 234
| 2
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Program {
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
static void Solve() {
var N = sc.ReadInt();
var result = new string[] { "AC", "WA", "TLE", "RE " };
var count = new int[4];
for (int i = 0; i < N; i++) {
var S = sc.ReadStr();
count[Array.IndexOf(result, S)]++;
}
for (int i = 0; i < 4; i++) {
Console.WriteLine($"{result[i]} x {count[i]}");
}
}
public struct ModInt {
public const long Mod = (int)1e9 + 7;
public long num;
public ModInt(long n) {
num = n;
while (num < 0)
num += Mod;
}
public override string ToString() { return num.ToString(); }
public static ModInt operator +(ModInt l, ModInt r) {
l.num += r.num;
if (l.num >= Mod)
l.num -= Mod;
return l;
}
public static ModInt operator -(ModInt l, ModInt r) {
l.num -= r.num;
if (l.num < 0)
l.num += Mod;
return l;
}
public static ModInt operator *(ModInt l, ModInt r) {
return new ModInt(l.num * r.num % Mod);
}
public static ModInt operator /(ModInt l, ModInt r) {
return l * Inverse(r);
}
public static implicit operator ModInt(long n) {
n %= Mod;
if (n < 0)
n += Mod;
return new ModInt(n);
}
public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); }
public static ModInt Pow(long v, long k) {
v = new ModInt(v).num;
long res = 1;
while (k > 0) {
if ((k & 1) == 1)
res = res * v % Mod;
v = v * v % Mod;
k >>= 1;
}
return new ModInt(res);
}
public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }
private static List<ModInt> Facs = new List<ModInt> { 1 };
private static List<ModInt> iFacs = new List<ModInt> { 1 };
public static ModInt Fac(int n) {
for (int i = Facs.Count; i <= n; i++) {
Facs.Add(i * Facs[i - 1]);
iFacs.Add(Inverse(Facs[i]));
}
return Facs[n];
}
public static ModInt iFac(int n) {
Fac(n);
return iFacs[n];
}
public static ModInt nCr(int n, int r, bool loop = false) {
if (n < r || n < 0 || r < 0)
return 0;
if (n == r)
return 1;
if (loop && n > (int)1e6)
return nCrLoop(n, r);
return Fac(n) * iFac(r) * iFac(n - r);
}
public static ModInt nCrLoop(long n, long r) {
ModInt num = 1;
for (long i = 1; i <= r; i++) {
num = num * (n - i + 1) / i;
}
return num;
}
public static ModInt nHr(int n, int r) { return nCr(n + r - 1, r); }
}
static Scanner sc = new Scanner();
}
class Scanner {
string[] S = new string[0];
int Index = 0;
char[] Separators = new char[] { ' ' };
public string Next() {
if (this.Index < this.S.Length)
return this.S[this.Index++];
var line = "";
while (line == "")
line = Console.ReadLine();
this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
if (this.S.Length == 0)
return this.Next();
this.Index = 0;
return this.S[this.Index++];
}
public string ReadStr() { return this.Next(); }
public char ReadChar() { return this.Next()[0]; }
public int ReadInt() { return int.Parse(this.Next()); }
public uint ReadUInt() { return uint.Parse(this.Next()); }
public long ReadLong() { return long.Parse(this.Next()); }
public double ReadDouble() { return double.Parse(this.Next()); }
public Tuple<int, int> ReadTup(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add);
}
public Tuple<long, long> ReadTupLong(int add = 0) {
return Tuple.Create(this.ReadLong() + add, this.ReadLong() + add);
}
public Tuple<int, int, int> ReadTup3(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add);
}
public Tuple<int, int, int, int> ReadTup4(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add, this.ReadInt() + add);
}
public int[] ReadIntArray(int n) {
var array = new int[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadInt();
}
return array;
}
public long[] ReadLongArray(int n) {
var array = new long[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadLong();
}
return array;
}
public double[] ReadDoubleArray(int n) {
var array = new double[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadDouble();
}
return array;
}
public char[] ReadCharArray(int n) {
var array = new char[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadChar();
}
return array;
}
public string[] ReadStrArray(int n) {
var array = new string[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadStr();
}
return array;
}
public Tuple<long, long>[] ReadTupLongArray(int n, int add = 0) {
var array = new Tuple<long, long>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTupLong(add);
}
return array;
}
public Tuple<int, int>[] ReadTupArray(int n, int add = 0) {
var array = new Tuple<int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup(add);
}
return array;
}
public Tuple<int, int, int>[] ReadTup3Array(int n, int add = 0) {
var array = new Tuple<int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup3(add);
}
return array;
}
public Tuple<int, int, int, int>[] ReadTup4Array(int n, int add = 0) {
var array = new Tuple<int, int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup4(add);
}
return array;
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Program {
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
static void Solve() {
var N = sc.ReadInt();
var result = new string[] { "AC", "WA", "TLE", "RE" };
var count = new int[4];
for (int i = 0; i < N; i++) {
var S = sc.ReadStr();
count[Array.IndexOf(result, S)]++;
}
for (int i = 0; i < 4; i++) {
Console.WriteLine($"{result[i]} x {count[i]}");
}
}
public struct ModInt {
public const long Mod = (int)1e9 + 7;
public long num;
public ModInt(long n) {
num = n;
while (num < 0)
num += Mod;
}
public override string ToString() { return num.ToString(); }
public static ModInt operator +(ModInt l, ModInt r) {
l.num += r.num;
if (l.num >= Mod)
l.num -= Mod;
return l;
}
public static ModInt operator -(ModInt l, ModInt r) {
l.num -= r.num;
if (l.num < 0)
l.num += Mod;
return l;
}
public static ModInt operator *(ModInt l, ModInt r) {
return new ModInt(l.num * r.num % Mod);
}
public static ModInt operator /(ModInt l, ModInt r) {
return l * Inverse(r);
}
public static implicit operator ModInt(long n) {
n %= Mod;
if (n < 0)
n += Mod;
return new ModInt(n);
}
public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); }
public static ModInt Pow(long v, long k) {
v = new ModInt(v).num;
long res = 1;
while (k > 0) {
if ((k & 1) == 1)
res = res * v % Mod;
v = v * v % Mod;
k >>= 1;
}
return new ModInt(res);
}
public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }
private static List<ModInt> Facs = new List<ModInt> { 1 };
private static List<ModInt> iFacs = new List<ModInt> { 1 };
public static ModInt Fac(int n) {
for (int i = Facs.Count; i <= n; i++) {
Facs.Add(i * Facs[i - 1]);
iFacs.Add(Inverse(Facs[i]));
}
return Facs[n];
}
public static ModInt iFac(int n) {
Fac(n);
return iFacs[n];
}
public static ModInt nCr(int n, int r, bool loop = false) {
if (n < r || n < 0 || r < 0)
return 0;
if (n == r)
return 1;
if (loop && n > (int)1e6)
return nCrLoop(n, r);
return Fac(n) * iFac(r) * iFac(n - r);
}
public static ModInt nCrLoop(long n, long r) {
ModInt num = 1;
for (long i = 1; i <= r; i++) {
num = num * (n - i + 1) / i;
}
return num;
}
public static ModInt nHr(int n, int r) { return nCr(n + r - 1, r); }
}
static Scanner sc = new Scanner();
}
class Scanner {
string[] S = new string[0];
int Index = 0;
char[] Separators = new char[] { ' ' };
public string Next() {
if (this.Index < this.S.Length)
return this.S[this.Index++];
var line = "";
while (line == "")
line = Console.ReadLine();
this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
if (this.S.Length == 0)
return this.Next();
this.Index = 0;
return this.S[this.Index++];
}
public string ReadStr() { return this.Next(); }
public char ReadChar() { return this.Next()[0]; }
public int ReadInt() { return int.Parse(this.Next()); }
public uint ReadUInt() { return uint.Parse(this.Next()); }
public long ReadLong() { return long.Parse(this.Next()); }
public double ReadDouble() { return double.Parse(this.Next()); }
public Tuple<int, int> ReadTup(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add);
}
public Tuple<long, long> ReadTupLong(int add = 0) {
return Tuple.Create(this.ReadLong() + add, this.ReadLong() + add);
}
public Tuple<int, int, int> ReadTup3(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add);
}
public Tuple<int, int, int, int> ReadTup4(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add, this.ReadInt() + add);
}
public int[] ReadIntArray(int n) {
var array = new int[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadInt();
}
return array;
}
public long[] ReadLongArray(int n) {
var array = new long[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadLong();
}
return array;
}
public double[] ReadDoubleArray(int n) {
var array = new double[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadDouble();
}
return array;
}
public char[] ReadCharArray(int n) {
var array = new char[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadChar();
}
return array;
}
public string[] ReadStrArray(int n) {
var array = new string[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadStr();
}
return array;
}
public Tuple<long, long>[] ReadTupLongArray(int n, int add = 0) {
var array = new Tuple<long, long>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTupLong(add);
}
return array;
}
public Tuple<int, int>[] ReadTupArray(int n, int add = 0) {
var array = new Tuple<int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup(add);
}
return array;
}
public Tuple<int, int, int>[] ReadTup3Array(int n, int add = 0) {
var array = new Tuple<int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup3(add);
}
return array;
}
public Tuple<int, int, int, int>[] ReadTup4Array(int n, int add = 0) {
var array = new Tuple<int, int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup4(add);
}
return array;
}
}
|
[["-", 0, 212, 0, 227, 0, 229, 0, 5, 0, 222], ["+", 0, 212, 0, 227, 0, 229, 0, 5, 0, 222]]
| 8
| 1,781
| 2
|
using System;
using System.Linq;
class name {
static void Main() {
int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
string m = string.Empty;
int[] h = new int[10];
string AC = "AC";
string WA = "WA";
string TLE = "TLE";
string RE = "RE";
for (int k = 0; k < n[0]; k++) {
m = Console.ReadLine();
if (m.Equals(AC)) {
h[0] += 1;
} else if (m.Equals(WA)) {
h[1] += 1;
} else if (m.Equals(TLE)) {
h[2] += 1;
} else if (m.Equals(RE)) {
h[3] += 1;
}
}
Console.WriteLine("AC × " + h[0] + "");
Console.WriteLine("WA × " + h[1] + "");
Console.WriteLine("TLE × " + h[2] + "");
Console.WriteLine("RE × " + h[3] + "");
}
}
|
using System;
using System.Linq;
class name {
static void Main() {
int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
string m = string.Empty;
int[] h = new int[10];
string AC = "AC";
string WA = "WA";
string TLE = "TLE";
string RE = "RE";
for (int k = 0; k < n[0]; k++) {
m = Console.ReadLine();
if (m.Equals(AC)) {
h[0] += 1;
} else if (m.Equals(WA)) {
h[1] += 1;
} else if (m.Equals(TLE)) {
h[2] += 1;
} else if (m.Equals(RE)) {
h[3] += 1;
}
}
Console.WriteLine("AC x " + h[0] + "");
Console.WriteLine("WA x " + h[1] + "");
Console.WriteLine("TLE x " + h[2] + "");
Console.WriteLine("RE x " + h[3] + "");
}
}
|
[["-", 0, 28, 0, 16, 31, 16, 31, 5, 0, 222], ["+", 0, 28, 0, 16, 31, 16, 31, 5, 0, 222]]
| 8
| 261
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace atcoder172 {
class Program {
static void Main(string[] args) {
var n = long.Parse(Console.ReadLine());
var acCnt = 0;
var waCnt = 0;
var tleCnt = 0;
var reCnt = 0;
for (var i = 0; i < n; i++) {
var resultStr = Console.ReadLine();
switch (resultStr) {
case "AC":
acCnt++;
break;
case "WA":
waCnt++;
break;
case "TLE":
tleCnt++;
break;
case "RE ":
reCnt++;
break;
}
}
Console.WriteLine($"AC x {acCnt}");
Console.WriteLine($"WA x {waCnt}");
Console.WriteLine($"TLE x {tleCnt}");
Console.WriteLine($"RE x {reCnt}");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace atcoder172 {
class Program {
static void Main(string[] args) {
var n = long.Parse(Console.ReadLine());
var acCnt = 0;
var waCnt = 0;
var tleCnt = 0;
var reCnt = 0;
for (var i = 0; i < n; i++) {
var resultStr = Console.ReadLine();
switch (resultStr) {
case "AC":
acCnt++;
break;
case "WA":
waCnt++;
break;
case "TLE":
tleCnt++;
break;
case "RE":
reCnt++;
break;
}
}
Console.WriteLine($"AC x {acCnt}");
Console.WriteLine($"WA x {waCnt}");
Console.WriteLine($"TLE x {tleCnt}");
Console.WriteLine($"RE x {reCnt}");
}
}
}
|
[["-", 8, 254, 0, 239, 0, 264, 0, 5, 0, 222], ["+", 8, 254, 0, 239, 0, 264, 0, 5, 0, 222]]
| 8
| 199
| 2
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.