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 static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;
namespace ABC123C {
class Program {
static void Main(string[] args) {
long N = ReadLong;
long[] limit = new long[5];
for (int i = 0; i < 5; i++) {
limit[i] = ReadLong;
}
long min = limit.Min();
if (min >= N) {
Console.WriteLine(5);
return;
} else {
long ans = N / min + 5;
Console.WriteLine(ans);
}
}
}
}
namespace Assistant {
static class Input {
static List<string> line = new List<string>();
static int index = 0;
static String ReadNext() {
if (line.Count <= index)
line.AddRange(Console.ReadLine().Split());
return line[index++];
}
public static int ReadInt => int.Parse(ReadNext());
public static long ReadLong => long.Parse(ReadNext());
public static int[] ReadInts =>
Console.ReadLine().Split().Select(int.Parse).ToArray();
public static long[] NextLongs =>
Console.ReadLine().Split().Select(long.Parse).ToArray();
}
static class Debug {
static public void Draw2D(int[,] map, int mode = 1) {
#if DEBUG
int W = map.GetLength(0);
int H = map.GetLength(1);
int[,] map2 = new int[W + 1, H + 1];
for (int i = 0; i < W + 1; i++) {
for (int j = 0; j < H + 1; j++) {
if (i == 0 && j == 0)
map2[i, j] = 0;
else if (i == 0)
map2[i, j] = j - 1;
else if (j == 0)
map2[i, j] = i - 1;
else
map2[i, j] = map[i - 1, j - 1];
}
}
for (int i = 0; i < W + 1; i++) {
for (int j = 0; j < H + 1; j++) {
if (mode == 0)
Console.Write(map2[i, j] % 10);
if (mode == 1)
Console.Write(map2[i, j] + " ");
}
Console.WriteLine();
}
Console.WriteLine();
#endif
}
static void Draw1D(int[] array, int mode = 0) {
#if DEBUG
Console.WriteLine(string.Join(" ", array));
#endif
}
}
}
|
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;
namespace ABC123C {
class Program {
static void Main(string[] args) {
long N = ReadLong;
long[] limit = new long[5];
for (int i = 0; i < 5; i++) {
limit[i] = ReadLong;
}
long min = limit.Min();
if (min >= N) {
Console.WriteLine(5);
return;
} else {
long ans = (long)Math.Ceiling((double)N / min) + 4;
Console.WriteLine(ans);
}
}
}
}
namespace Assistant {
static class Input {
static List<string> line = new List<string>();
static int index = 0;
static String ReadNext() {
if (line.Count <= index)
line.AddRange(Console.ReadLine().Split());
return line[index++];
}
public static int ReadInt => int.Parse(ReadNext());
public static long ReadLong => long.Parse(ReadNext());
public static int[] ReadInts =>
Console.ReadLine().Split().Select(int.Parse).ToArray();
public static long[] NextLongs =>
Console.ReadLine().Split().Select(long.Parse).ToArray();
}
static class Debug {
static public void Draw2D(int[,] map, int mode = 1) {
#if DEBUG
int W = map.GetLength(0);
int H = map.GetLength(1);
int[,] map2 = new int[W + 1, H + 1];
for (int i = 0; i < W + 1; i++) {
for (int j = 0; j < H + 1; j++) {
if (i == 0 && j == 0)
map2[i, j] = 0;
else if (i == 0)
map2[i, j] = j - 1;
else if (j == 0)
map2[i, j] = i - 1;
else
map2[i, j] = map[i - 1, j - 1];
}
}
for (int i = 0; i < W + 1; i++) {
for (int j = 0; j < H + 1; j++) {
if (mode == 0)
Console.Write(map2[i, j] % 10);
if (mode == 1)
Console.Write(map2[i, j] + " ");
}
Console.WriteLine();
}
Console.WriteLine();
#endif
}
static void Draw1D(int[] array, int mode = 0) {
#if DEBUG
Console.WriteLine(string.Join(" ", array));
#endif
}
}
}
|
[["+", 0, 200, 0, 212, 0, 16, 31, 74, 0, 24], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 39, 199], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 0, 25], ["+", 0, 16, 31, 74, 51, 213, 63, 214, 205, 22], ["+", 0, 16, 31, 74, 51, 213, 63, 214, 0, 131], ["+", 0, 16, 31, 74, 51, 213, 63, 214, 141, 22], ["+", 0, 16, 31, 74, 51, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 31, 74, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 31, 74, 39, 199], ["+", 3, 4, 0, 28, 0, 16, 31, 74, 0, 25], ["+", 0, 16, 31, 74, 51, 213, 3, 4, 0, 25], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203]]
| 8
| 587
| 13
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApp2 {
class Program {
static void Main(string[] args) {
var N = long.Parse(Console.ReadLine());
var A = long.Parse(Console.ReadLine());
var B = long.Parse(Console.ReadLine());
var C = long.Parse(Console.ReadLine());
var D = long.Parse(Console.ReadLine());
var E = long.Parse(Console.ReadLine());
var min = Math.Min(Math.Min(Math.Min(Math.Min(A, B), C), D), E);
Console.WriteLine(Math.Ceiling((decimal)(N / min) + 1) + 4);
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApp2 {
class Program {
static void Main(string[] args) {
var N = long.Parse(Console.ReadLine());
var A = long.Parse(Console.ReadLine());
var B = long.Parse(Console.ReadLine());
var C = long.Parse(Console.ReadLine());
var D = long.Parse(Console.ReadLine());
var E = long.Parse(Console.ReadLine());
var min = Math.Min(Math.Min(Math.Min(Math.Min(A, B), C), D), E);
Console.WriteLine(4 + ((N % min == 0) ? N / min : N / min + 1));
}
}
}
|
[["-", 0, 28, 0, 16, 31, 213, 63, 214, 205, 22], ["-", 0, 28, 0, 16, 31, 213, 63, 214, 0, 131], ["-", 0, 28, 0, 16, 31, 213, 63, 214, 141, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 31, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["-", 3, 4, 0, 28, 0, 16, 31, 74, 39, 199], ["+", 0, 41, 15, 23, 0, 16, 31, 16, 31, 22], ["+", 0, 41, 15, 23, 0, 16, 31, 16, 17, 109], ["+", 0, 41, 15, 23, 0, 16, 31, 16, 12, 22], ["+", 12, 23, 0, 41, 15, 23, 0, 16, 17, 60], ["+", 12, 23, 0, 41, 15, 23, 0, 16, 12, 203], ["-", 0, 28, 0, 16, 31, 74, 51, 23, 0, 24], ["+", 0, 28, 0, 16, 12, 23, 0, 41, 0, 101], ["-", 0, 28, 0, 16, 31, 74, 51, 23, 0, 25], ["+", 0, 28, 0, 16, 12, 23, 0, 41, 0, 102], ["+", 12, 23, 0, 41, 75, 16, 31, 16, 31, 22], ["+", 12, 23, 0, 41, 75, 16, 31, 16, 17, 85], ["+", 12, 23, 0, 41, 75, 16, 31, 16, 12, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
| 8
| 201
| 20
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;
public class C {
public static void Main() => (new Solver()).Solve();
}
public class Solver {
public void Solve() {
long N = GetLong();
var num = GetLongs(5);
var min = num.Min();
var neck = Array.FindIndex(num, x => x == min);
WriteLine(5 + N / num[neck]);
}
}
public static class MyIO {
private static string[] args = new string[0];
private static int cnt = 0;
private static IEnumerable<string>
getArgs(long N) => Range(0, N).Select(_ => getArg());
private static string getArg() {
if (cnt == args.Length) {
args = Console.ReadLine().Split();
cnt = 0;
}
return args[cnt++];
}
public static int GetInt() => int.Parse(getArg());
public static long GetLong() => long.Parse(getArg());
public static double GetDouble() => double.Parse(getArg());
public static decimal GetDecimal() => decimal.Parse(getArg());
public static string GetString() => getArg();
public static char GetChar() => getArg()[0];
public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
public static long[] GetLongs(long N) =>
getArgs(N).Select(long.Parse).ToArray();
public static double[] GetDoubles(long N) =>
getArgs(N).Select(double.Parse).ToArray();
public static decimal[] GetDecimals(long N) =>
getArgs(N).Select(decimal.Parse).ToArray();
public static string[] GetStrings(long N) => getArgs(N).ToArray();
}
public static class MyUtil {
public static void chmax<T>(ref T x, T y)
where T : IComparable<T> {
if (x.CompareTo(y) < 0)
x = y;
}
public static void chmin<T>(ref T x, T y)
where T : IComparable<T> {
if (x.CompareTo(y) > 0)
x = y;
}
public static void swap<T>(ref T x, ref T y) {
T tmp = x;
x = y;
y = tmp;
}
public static long rightShift(long x, long y) => (x >> (int)y);
public static long leftShift(long x, long y) => (x << (int)y);
public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
public static long lcm(long x, long y) => (x / gcd(x, y)) * y;
public static IEnumerable<int>
Range(long start, long count) => Enumerable.Range((int)start, (int)count);
public static void
Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;
public class C {
public static void Main() => (new Solver()).Solve();
}
public class Solver {
public void Solve() {
long N = GetLong();
var num = GetLongs(5);
var min = num.Min();
var neck = Array.FindIndex(num, x => x == min);
WriteLine(4 + (N + num[neck] - 1) / num[neck]);
}
}
public static class MyIO {
private static string[] args = new string[0];
private static int cnt = 0;
private static IEnumerable<string>
getArgs(long N) => Range(0, N).Select(_ => getArg());
private static string getArg() {
if (cnt == args.Length) {
args = Console.ReadLine().Split();
cnt = 0;
}
return args[cnt++];
}
public static int GetInt() => int.Parse(getArg());
public static long GetLong() => long.Parse(getArg());
public static double GetDouble() => double.Parse(getArg());
public static decimal GetDecimal() => decimal.Parse(getArg());
public static string GetString() => getArg();
public static char GetChar() => getArg()[0];
public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
public static long[] GetLongs(long N) =>
getArgs(N).Select(long.Parse).ToArray();
public static double[] GetDoubles(long N) =>
getArgs(N).Select(double.Parse).ToArray();
public static decimal[] GetDecimals(long N) =>
getArgs(N).Select(decimal.Parse).ToArray();
public static string[] GetStrings(long N) => getArgs(N).ToArray();
}
public static class MyUtil {
public static void chmax<T>(ref T x, T y)
where T : IComparable<T> {
if (x.CompareTo(y) < 0)
x = y;
}
public static void chmin<T>(ref T x, T y)
where T : IComparable<T> {
if (x.CompareTo(y) > 0)
x = y;
}
public static void swap<T>(ref T x, ref T y) {
T tmp = x;
x = y;
y = tmp;
}
public static long rightShift(long x, long y) => (x >> (int)y);
public static long leftShift(long x, long y) => (x << (int)y);
public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
public static long lcm(long x, long y) => (x / gcd(x, y)) * y;
public static IEnumerable<int>
Range(long start, long count) => Enumerable.Range((int)start, (int)count);
public static void
Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 16, 31, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 31, 203], ["+", 0, 28, 0, 16, 12, 16, 31, 23, 0, 24], ["+", 12, 16, 31, 23, 0, 16, 31, 16, 17, 72], ["+", 31, 23, 0, 16, 31, 16, 12, 204, 205, 22], ["+", 0, 16, 31, 16, 12, 204, 206, 207, 0, 70], ["+", 31, 16, 12, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 16, 31, 16, 12, 204, 206, 207, 0, 73], ["+", 0, 16, 12, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 16, 12, 16, 31, 23, 0, 16, 12, 203], ["+", 0, 28, 0, 16, 12, 16, 31, 23, 0, 25]]
| 8
| 734
| 11
|
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
#if DEBUG
MyDebugger.Test(process, "../TextFile1.txt");
// MyDebugger.Test(process, "../TextFile2.txt");
// MyDebugger.MakeTestCase("../TextFile2.txt");
#else
object ret = process(new StreamReader(Console.OpenStandardInput()));
Console.WriteLine(ret);
#endif
}
static object process(TextReader input) {
var n = long.Parse(input.ReadLine());
var ary = new long[5];
ary[0] = long.Parse(input.ReadLine());
ary[1] = long.Parse(input.ReadLine());
ary[2] = long.Parse(input.ReadLine());
ary[3] = long.Parse(input.ReadLine());
ary[4] = long.Parse(input.ReadLine());
var min = long.MaxValue;
var minp = 0;
for (int i = 0; i < ary.Length; i++) {
if (ary[i] < min) {
min = ary[i];
minp = i;
}
}
return 5 + n / min;
}
}
|
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
#if DEBUG
MyDebugger.Test(process, "../TextFile1.txt");
// MyDebugger.Test(process, "../TextFile2.txt");
// MyDebugger.MakeTestCase("../TextFile2.txt");
#else
object ret = process(new StreamReader(Console.OpenStandardInput()));
Console.WriteLine(ret);
#endif
}
static object process(TextReader input) {
var n = long.Parse(input.ReadLine());
var ary = new long[5];
ary[0] = long.Parse(input.ReadLine());
ary[1] = long.Parse(input.ReadLine());
ary[2] = long.Parse(input.ReadLine());
ary[3] = long.Parse(input.ReadLine());
ary[4] = long.Parse(input.ReadLine());
var min = long.MaxValue;
var minp = 0;
for (int i = 0; i < ary.Length; i++) {
if (ary[i] < min) {
min = ary[i];
minp = i;
}
}
if (n % min == 0) {
return 4 + n / min;
} else {
return 4 + n / min + 1;
}
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 0, 195, 8, 196, 0, 37, 0, 16, 31, 203], ["+", 0, 57, 64, 196, 0, 37, 0, 16, 31, 203], ["+", 0, 57, 64, 196, 0, 37, 0, 16, 17, 72], ["+", 64, 196, 0, 37, 0, 16, 12, 16, 31, 22], ["+", 64, 196, 0, 37, 0, 16, 12, 16, 17, 85], ["+", 64, 196, 0, 37, 0, 16, 12, 16, 12, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 8, 196, 0, 57, 75, 196, 0, 37, 0, 38], ["+", 75, 196, 0, 37, 0, 16, 31, 16, 31, 203], ["+", 0, 57, 75, 196, 0, 37, 0, 16, 17, 72], ["+", 0, 57, 75, 196, 0, 37, 0, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 259
| 24
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp15 {
class Class26 {
static void Main() {
long N = long.Parse(Console.ReadLine());
var M = new long[5];
M[0] = long.Parse(Console.ReadLine()); // A
M[1] = long.Parse(Console.ReadLine()); // B
M[2] = long.Parse(Console.ReadLine()); // C
M[3] = long.Parse(Console.ReadLine()); // D
M[4] = long.Parse(Console.ReadLine()); // E
long min = M.Min();
Console.WriteLine(5 + N / min);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp15 {
class Class26 {
static void Main() {
long N = long.Parse(Console.ReadLine());
var M = new long[5];
M[0] = long.Parse(Console.ReadLine()); // A
M[1] = long.Parse(Console.ReadLine()); // B
M[2] = long.Parse(Console.ReadLine()); // C
M[3] = long.Parse(Console.ReadLine()); // D
M[4] = long.Parse(Console.ReadLine()); // E
long min = M.Min();
Console.WriteLine(4 + N / min + (N % min >= 1 ? 1 : 0));
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 16, 31, 203], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 31, 203], ["+", 0, 28, 0, 16, 31, 16, 12, 16, 12, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 3, 4, 0, 28, 0, 16, 12, 23, 0, 24], ["+", 12, 23, 0, 41, 15, 16, 31, 16, 31, 22], ["+", 12, 23, 0, 41, 15, 16, 31, 16, 17, 109], ["+", 0, 16, 12, 23, 0, 41, 15, 16, 17, 20], ["+", 0, 16, 12, 23, 0, 41, 15, 16, 12, 203], ["+", 0, 28, 0, 16, 12, 23, 0, 41, 0, 101], ["+", 0, 28, 0, 16, 12, 23, 0, 41, 64, 203], ["+", 0, 28, 0, 16, 12, 23, 0, 41, 0, 102], ["+", 0, 28, 0, 16, 12, 23, 0, 41, 75, 203], ["+", 3, 4, 0, 28, 0, 16, 12, 23, 0, 25]]
| 8
| 170
| 14
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace AtCoder {
class Program {
static void Main() {
//ここから
long N = IO.ReadLineToLong();
long[] str = new long[5];
for (int i = 0; i < 5; i++) {
str[i] = IO.ReadLineToLong();
}
long min = str.Min();
long ans;
if (min >= N) {
ans = 5;
} else {
ans = N / min + 5;
}
//ここまで
Console.WriteLine(ans);
Console.ReadKey();
}
}
class Func {
long mod = 1000000007;
static public void Swap<T>(ref T a, ref T b) {
T temp = a;
a = b;
b = temp;
}
static public long GCD(int a, int b) { return b != 0 ? GCD(b, a % b) : a; }
static public long LCM(int a, int b) { return (long)a * b / GCD(a, b); }
static public int Factorial(int a) {
return a == 1 ? a : a * Factorial(a - 1);
}
static public int Conbin(int n, int m) {
return Factorial(n) / (Factorial(n - m) * Factorial(m));
}
static public void Factoring(long num, ref long[] vs) {
if (num == 1) {
vs[1]++;
}
for (long i = 2; i < (long)Math.Sqrt(num); i++) {
if (num % i == 0) {
vs[i]++;
Factoring(num / i, ref vs);
}
}
vs[1]++;
}
}
class IO {
static public string ReadLineToString() { return Console.ReadLine(); }
static public int ReadLineToInt() { return int.Parse(Console.ReadLine()); }
static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
static public string[] ReadLineToStringArray() {
return Console.ReadLine().Split(' ').ToArray();
}
static public int[] ReadLineToIntArray() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
static public long[] ReadLineToLongArray() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
}
static public List<string> ReadLineToStringList() {
return Console.ReadLine().Split(' ').ToList();
}
static public List<int> ReadLineToIntList() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToList();
}
static public List<long> ReadLineToLongList() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToList();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace AtCoder {
class Program {
static void Main() {
//ここから
long N = IO.ReadLineToLong();
long[] str = new long[5];
for (int i = 0; i < 5; i++) {
str[i] = IO.ReadLineToLong();
}
long min = str.Min();
long ans;
if (min >= N) {
ans = 5;
} else if (N % min == 0) {
ans = N / min + 4;
} else {
ans = N / min + 5;
}
//ここまで
Console.WriteLine(ans);
Console.ReadKey();
}
}
class Func {
long mod = 1000000007;
static public void Swap<T>(ref T a, ref T b) {
T temp = a;
a = b;
b = temp;
}
static public long GCD(int a, int b) { return b != 0 ? GCD(b, a % b) : a; }
static public long LCM(int a, int b) { return (long)a * b / GCD(a, b); }
static public int Factorial(int a) {
return a == 1 ? a : a * Factorial(a - 1);
}
static public int Conbin(int n, int m) {
return Factorial(n) / (Factorial(n - m) * Factorial(m));
}
static public void Factoring(long num, ref long[] vs) {
if (num == 1) {
vs[1]++;
}
for (long i = 2; i < (long)Math.Sqrt(num); i++) {
if (num % i == 0) {
vs[i]++;
Factoring(num / i, ref vs);
}
}
vs[1]++;
}
}
class IO {
static public string ReadLineToString() { return Console.ReadLine(); }
static public int ReadLineToInt() { return int.Parse(Console.ReadLine()); }
static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
static public string[] ReadLineToStringArray() {
return Console.ReadLine().Split(' ').ToArray();
}
static public int[] ReadLineToIntArray() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
static public long[] ReadLineToLongArray() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
}
static public List<string> ReadLineToStringList() {
return Console.ReadLine().Split(' ').ToList();
}
static public List<int> ReadLineToIntList() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToList();
}
static public List<long> ReadLineToLongList() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToList();
}
}
}
|
[["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 24], ["+", 0, 57, 75, 57, 15, 16, 31, 16, 31, 22], ["+", 0, 57, 75, 57, 15, 16, 31, 16, 17, 109], ["+", 0, 57, 75, 57, 15, 16, 31, 16, 12, 22], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 60], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 25], ["+", 75, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 31, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 17, 85], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 12, 22], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["+", 0, 57, 75, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 75, 57, 64, 196, 0, 46], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 95], ["+", 8, 196, 0, 57, 75, 57, 75, 196, 0, 45]]
| 8
| 644
| 19
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
var N = cin.ReadLong;
var M = cin.ReadLongArray(5).Min();
Console.WriteLine(N / M + 5);
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
var N = cin.ReadLong;
var M = cin.ReadLongArray(5).Min();
var ans = (long)Ceiling((double)N / (double)M) + 4;
Console.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;
}
}
}
|
[["-", 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, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 0, 24], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 39, 199], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 0, 25], ["+", 0, 212, 0, 16, 31, 74, 51, 213, 63, 22], ["+", 3, 4, 0, 28, 0, 16, 31, 74, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 31, 74, 39, 199], ["+", 3, 4, 0, 28, 0, 16, 31, 74, 0, 25], ["+", 3, 4, 0, 28, 0, 16, 12, 74, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 12, 74, 39, 199], ["+", 3, 4, 0, 28, 0, 16, 12, 74, 0, 25], ["+", 0, 16, 31, 74, 51, 213, 3, 4, 0, 25], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 456
| 25
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
var N = sc.ReadLong();
var X = sc.ReadLongArray(5);
var min = X.Min();
var x = (N + 1) / min;
if (x == 0)
x = 1;
var ans = 5 + x - 1;
Console.WriteLine(ans);
}
static int INF = int.MaxValue;
static long LINF = long.MaxValue;
static Scanner sc = new Scanner();
static long Gcd(long a, long b) {
var v = new[] { a, b };
while (v[1] != 0) {
v = new[] { v[1], v[0] % v[1] };
}
return v[0];
}
static long Lcm(long a, long b) { return a / Gcd(a, b) * b; }
}
class Modulo {
public readonly int MOD;
private readonly List<int> Facs = new List<int>() { 1 };
public Modulo(int mod = 1000000007) { this.MOD = mod; }
public int Mul(int a, int b) { return (int)(Math.BigMul(a, b) % MOD); }
public int Div(int a, int b) { return Mul(a, Pow(b, MOD - 2)); }
public int Pow(int a, int n) {
switch (n) {
case 0:
return 1;
case 1:
return a;
default:
int p1 = Pow(a, n / 2);
int p2 = Mul(p1, p1);
return ((n % 2) == 0) ? p2 : Mul(p2, a);
}
}
public int Fac(int n) {
for (int i = this.Facs.Count; i <= n; i++) {
this.Facs.Add(Mul(i, Facs[i - 1]));
}
return this.Facs[n];
}
public int nPr(int n, int r) => Div(Fac(n), Fac(n - r));
public int nCr(int n, int r) {
if (n < r)
return 0;
if (n == r)
return 1;
int res = Fac(n);
res = Div(res, Fac(r));
res = Div(res, Fac(n - r));
return res;
}
}
class Debug {
public static void Dump<T>(T[,] array) {
Console.WriteLine();
var h = array.GetLength(0);
var w = array.GetLength(1);
for (int r = 0; r < h; r++) {
for (int c = 0; c < w; c++) {
Console.Write(array[r, c]);
Console.Write(" ");
}
Console.WriteLine();
}
Console.WriteLine();
}
public static void Dump<T>(T[] array) {
Console.WriteLine();
Console.WriteLine(string.Join(" ", array));
Console.WriteLine();
}
}
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 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 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;
}
}
class HashMap<K, V> : Dictionary<K, V>
where V : new() {
private V DefaltValue = new V();
public HashMap() {}
public HashMap(V defaultValue) { this.DefaltValue = new V(); }
new public V this[K i] { get { V v;
return TryGetValue(i, out v) ? v : base[i] = this.DefaltValue;
}
set { base[i] = value; }
}
}
class Vector<T> : List<T>
where T : new() {
public Vector() {}
public Vector(int count, T defaultValue) {
for (int i = 0; i < count; i++) {
this.Add(defaultValue);
}
}
}
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];
}
public T Peek() { return this.Array[0]; }
private void UpHeap() {
var n = this.Count - 1;
while (n != 0) {
var parent = (n - 1) / 2;
if (this.Array[n].CompareTo(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;
}
}
}
private int Compare(T a, T b) {
var c = a.CompareTo(b);
if (!this.Greater) {
c = -c;
}
return c;
}
private void Swap(int a, int b) {
var tmp = this.Array[a];
this.Array[a] = this.Array[b];
this.Array[b] = tmp;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
var N = sc.ReadLong();
var X = sc.ReadLongArray(5);
var min = X.Min();
var x = N / min + (N % min > 0 ? 1 : 0);
if (x == 0)
x = 1;
var ans = 5 + x - 1;
Console.WriteLine(ans);
}
static int INF = int.MaxValue;
static long LINF = long.MaxValue;
static Scanner sc = new Scanner();
static long Gcd(long a, long b) {
var v = new[] { a, b };
while (v[1] != 0) {
v = new[] { v[1], v[0] % v[1] };
}
return v[0];
}
static long Lcm(long a, long b) { return a / Gcd(a, b) * b; }
}
class Modulo {
public readonly int MOD;
private readonly List<int> Facs = new List<int>() { 1 };
public Modulo(int mod = 1000000007) { this.MOD = mod; }
public int Mul(int a, int b) { return (int)(Math.BigMul(a, b) % MOD); }
public int Div(int a, int b) { return Mul(a, Pow(b, MOD - 2)); }
public int Pow(int a, int n) {
switch (n) {
case 0:
return 1;
case 1:
return a;
default:
int p1 = Pow(a, n / 2);
int p2 = Mul(p1, p1);
return ((n % 2) == 0) ? p2 : Mul(p2, a);
}
}
public int Fac(int n) {
for (int i = this.Facs.Count; i <= n; i++) {
this.Facs.Add(Mul(i, Facs[i - 1]));
}
return this.Facs[n];
}
public int nPr(int n, int r) => Div(Fac(n), Fac(n - r));
public int nCr(int n, int r) {
if (n < r)
return 0;
if (n == r)
return 1;
int res = Fac(n);
res = Div(res, Fac(r));
res = Div(res, Fac(n - r));
return res;
}
}
class Debug {
public static void Dump<T>(T[,] array) {
Console.WriteLine();
var h = array.GetLength(0);
var w = array.GetLength(1);
for (int r = 0; r < h; r++) {
for (int c = 0; c < w; c++) {
Console.Write(array[r, c]);
Console.Write(" ");
}
Console.WriteLine();
}
Console.WriteLine();
}
public static void Dump<T>(T[] array) {
Console.WriteLine();
Console.WriteLine(string.Join(" ", array));
Console.WriteLine();
}
}
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 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 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;
}
}
class HashMap<K, V> : Dictionary<K, V>
where V : new() {
private V DefaltValue = new V();
public HashMap() {}
public HashMap(V defaultValue) { this.DefaltValue = new V(); }
new public V this[K i] { get { V v;
return TryGetValue(i, out v) ? v : base[i] = this.DefaltValue;
}
set { base[i] = value; }
}
}
class Vector<T> : List<T>
where T : new() {
public Vector() {}
public Vector(int count, T defaultValue) {
for (int i = 0; i < count; i++) {
this.Add(defaultValue);
}
}
}
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];
}
public T Peek() { return this.Array[0]; }
private void UpHeap() {
var n = this.Count - 1;
while (n != 0) {
var parent = (n - 1) / 2;
if (this.Array[n].CompareTo(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;
}
}
}
private int Compare(T a, T b) {
var c = a.CompareTo(b);
if (!this.Greater) {
c = -c;
}
return c;
}
private void Swap(int a, int b) {
var tmp = this.Array[a];
this.Array[a] = this.Array[b];
this.Array[b] = tmp;
}
}
|
[["-", 0, 200, 0, 212, 0, 16, 31, 23, 0, 24], ["+", 0, 200, 0, 212, 0, 16, 31, 16, 17, 85], ["+", 0, 200, 0, 212, 0, 16, 31, 16, 12, 22], ["+", 0, 200, 0, 212, 0, 16, 12, 23, 0, 24], ["+", 12, 23, 0, 41, 15, 16, 31, 16, 31, 22], ["+", 12, 23, 0, 41, 15, 16, 31, 16, 17, 109], ["+", 12, 23, 0, 41, 15, 16, 31, 16, 12, 22], ["+", 0, 16, 12, 23, 0, 41, 15, 16, 17, 47], ["+", 0, 16, 12, 23, 0, 41, 15, 16, 12, 203], ["+", 0, 212, 0, 16, 12, 23, 0, 41, 0, 101], ["+", 0, 212, 0, 16, 12, 23, 0, 41, 0, 102], ["+", 0, 212, 0, 16, 12, 23, 0, 41, 75, 203], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 85], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22]]
| 8
| 1,713
| 14
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
return;
}
public void Solve(ConsoleInput cin) {
var N = cin.ReadLong;
var trans = cin.ReadLongArray(5);
Console.WriteLine(N / trans.Min() + 1 + 4);
}
}
public static class Extensions {
public static string Reverse(this string sourse) {
char[] chrAry = sourse.ToCharArray();
Array.Reverse(chrAry);
return new string(chrAry);
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
return;
}
public void Solve(ConsoleInput cin) {
var N = cin.ReadLong;
var trans = cin.ReadLongArray(5);
if (N % trans.Min() != 0) {
Console.WriteLine(N / trans.Min() + 1 + 4);
} else {
Console.WriteLine(N / trans.Min() + 4);
}
}
}
public static class Extensions {
public static string Reverse(this string sourse) {
char[] chrAry = sourse.ToCharArray();
Array.Reverse(chrAry);
return new string(chrAry);
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["+", 15, 16, 31, 16, 12, 213, 63, 214, 205, 22], ["+", 15, 16, 31, 16, 12, 213, 63, 214, 0, 131], ["+", 15, 16, 31, 16, 12, 213, 63, 214, 141, 22], ["+", 15, 16, 31, 16, 12, 213, 3, 4, 0, 24], ["+", 15, 16, 31, 16, 12, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 79], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 75, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 75, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 75, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 75, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 31, 22], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 17, 85], ["+", 0, 16, 31, 16, 12, 213, 63, 214, 205, 22], ["+", 0, 16, 31, 16, 12, 213, 63, 214, 0, 131], ["+", 0, 16, 31, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 16, 31, 16, 12, 213, 3, 4, 0, 24], ["+", 0, 16, 31, 16, 12, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 502
| 32
|
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main(string[] args) {
long n = long.Parse(Console.ReadLine());
long[] t = new long[5];
for (var i = 0; i < 5; i++) {
t[i] = long.Parse(Console.ReadLine());
}
Array.Sort(t);
long ans = 5 + (n / t[0]);
Console.WriteLine(ans);
}
}
|
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main(string[] args) {
long n = long.Parse(Console.ReadLine());
long[] t = new long[5];
for (var i = 0; i < 5; i++) {
t[i] = long.Parse(Console.ReadLine());
}
Array.Sort(t);
long ans = 4 + (n + t[0] - 1) / t[0];
Console.WriteLine(ans);
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 16, 31, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 31, 203], ["-", 0, 212, 0, 16, 12, 23, 0, 16, 17, 85], ["+", 12, 16, 31, 23, 0, 16, 31, 16, 17, 72], ["+", 0, 16, 12, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 16, 12, 16, 31, 23, 0, 16, 12, 203], ["+", 0, 200, 0, 212, 0, 16, 12, 16, 17, 85], ["+", 0, 212, 0, 16, 12, 16, 12, 204, 205, 22], ["+", 0, 16, 12, 16, 12, 204, 206, 207, 0, 70], ["+", 12, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 16, 12, 16, 12, 204, 206, 207, 0, 73]]
| 8
| 137
| 11
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
namespace Program {
public class ABC123C {
static public void Main(string[] args) {
var N = NextLong;
var param = NextLongArray(5);
var mini = param.Min();
Console.WriteLine(N / mini + 5);
}
static class Console_ {
private static Queue<string> param = new Queue<string>();
public static string NextString() {
if (param.Count == 0)
foreach (var item in Console.ReadLine().Split(' '))
param.Enqueue(item);
return param.Dequeue();
}
}
static int NextInt => int.Parse(Console_.NextString());
static int[] NextIntArray(int N) {
var ret = new int[N];
for (int i = 0; i < N; ++i)
ret[i] = NextInt;
return ret;
}
static long NextLong => long.Parse(Console_.NextString());
static long[] NextLongArray(int N) {
var ret = new long[N];
for (int i = 0; i < N; ++i)
ret[i] = NextLong;
return ret;
}
static string NextString => Console_.NextString();
static void Rep(int count, Action<int> func) {
for (int i = 0; i < count; ++i)
func(i);
}
static void Rep(int count, Action func) {
for (int i = 0; i < count; ++i)
func();
}
static void Foreach<T>(IEnumerable<T> list, Action<T> func) {
foreach (var item in list)
func(item);
}
static void Foreach<T>(IEnumerable<T> list, Action<T, int> func) {
int idx = -1;
foreach (var item in list)
func(item, ++idx);
}
static IEnumerable<long> Prime(long x) {
if (x < 2)
yield break;
yield return 2;
var halfx = x / 2;
var table = new bool[halfx + 1];
var max = (long)(Math.Sqrt(x) / 2);
for (long i = 1; i <= max; ++i) {
if (table[i])
continue;
var add = 2 * i + 1;
yield return add;
for (long j = 2 * i * (i + 1); j <= halfx; j += add)
table[j] = true;
}
for (long i = max + 1; i <= halfx; ++i)
if (!table[i])
yield return 2 * i + 1;
}
static IEnumerable<long> Divisor(long x) {
if (x < 1)
yield break;
var max = (long)Math.Sqrt(x);
for (long i = 1; i < max; ++i) {
if (x % i != 0)
continue;
yield return i;
if (i != x / i)
yield return x / i;
}
}
static long GCD(long a, long b) {
long tmpa = a, tmpb = b;
while (tmpb > 0) {
var tmp = tmpb;
tmpb = tmpa % tmpb;
tmpa = tmp;
}
return tmpa;
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
namespace Program {
public class ABC123C {
static public void Main(string[] args) {
var N = NextLong;
var param = NextLongArray(5);
var mini = param.Min();
Console.WriteLine(N / mini - (N % mini == 0 ? 1 : 0) + 5);
}
static class Console_ {
private static Queue<string> param = new Queue<string>();
public static string NextString() {
if (param.Count == 0)
foreach (var item in Console.ReadLine().Split(' '))
param.Enqueue(item);
return param.Dequeue();
}
}
static int NextInt => int.Parse(Console_.NextString());
static int[] NextIntArray(int N) {
var ret = new int[N];
for (int i = 0; i < N; ++i)
ret[i] = NextInt;
return ret;
}
static long NextLong => long.Parse(Console_.NextString());
static long[] NextLongArray(int N) {
var ret = new long[N];
for (int i = 0; i < N; ++i)
ret[i] = NextLong;
return ret;
}
static string NextString => Console_.NextString();
static void Rep(int count, Action<int> func) {
for (int i = 0; i < count; ++i)
func(i);
}
static void Rep(int count, Action func) {
for (int i = 0; i < count; ++i)
func();
}
static void Foreach<T>(IEnumerable<T> list, Action<T> func) {
foreach (var item in list)
func(item);
}
static void Foreach<T>(IEnumerable<T> list, Action<T, int> func) {
int idx = -1;
foreach (var item in list)
func(item, ++idx);
}
static IEnumerable<long> Prime(long x) {
if (x < 2)
yield break;
yield return 2;
var halfx = x / 2;
var table = new bool[halfx + 1];
var max = (long)(Math.Sqrt(x) / 2);
for (long i = 1; i <= max; ++i) {
if (table[i])
continue;
var add = 2 * i + 1;
yield return add;
for (long j = 2 * i * (i + 1); j <= halfx; j += add)
table[j] = true;
}
for (long i = max + 1; i <= halfx; ++i)
if (!table[i])
yield return 2 * i + 1;
}
static IEnumerable<long> Divisor(long x) {
if (x < 1)
yield break;
var max = (long)Math.Sqrt(x);
for (long i = 1; i < max; ++i) {
if (x % i != 0)
continue;
yield return i;
if (i != x / i)
yield return x / i;
}
}
static long GCD(long a, long b) {
long tmpa = a, tmpb = b;
while (tmpb > 0) {
var tmp = tmpb;
tmpb = tmpa % tmpb;
tmpa = tmp;
}
return tmpa;
}
}
}
|
[["+", 3, 4, 0, 28, 0, 16, 31, 16, 17, 33], ["+", 0, 28, 0, 16, 31, 16, 12, 23, 0, 24], ["+", 12, 23, 0, 41, 15, 16, 31, 16, 31, 22], ["+", 12, 23, 0, 41, 15, 16, 31, 16, 17, 109], ["+", 12, 23, 0, 41, 15, 16, 31, 16, 12, 22], ["+", 31, 16, 12, 23, 0, 41, 15, 16, 17, 60], ["+", 31, 16, 12, 23, 0, 41, 15, 16, 12, 203], ["+", 0, 16, 31, 16, 12, 23, 0, 41, 0, 101], ["+", 0, 16, 31, 16, 12, 23, 0, 41, 64, 203], ["+", 0, 16, 31, 16, 12, 23, 0, 41, 0, 102], ["+", 0, 16, 31, 16, 12, 23, 0, 41, 75, 203], ["+", 0, 28, 0, 16, 31, 16, 12, 23, 0, 25]]
| 8
| 697
| 12
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace ConsoleApp2 {
public class Program {
public static void Main(string[] args) {
long N = long.Parse(Console.ReadLine());
long A = long.Parse(Console.ReadLine());
long B = long.Parse(Console.ReadLine());
long C = long.Parse(Console.ReadLine());
long D = long.Parse(Console.ReadLine());
long E = long.Parse(Console.ReadLine());
long[] carryNum = new long[5] { A, B, C, D, E };
long slow = carryNum.Min();
Console.WriteLine(N / slow + 5);
}
private static long[] Read(string input) {
string[] inputs = input.Split(' ');
long num = inputs.Length;
long[] longs = new long[num];
for (long i = 0; i < num; i++) {
longs[i] = long.Parse(inputs[i]);
}
return longs;
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace ConsoleApp2 {
public class Program {
public static void Main(string[] args) {
long N = long.Parse(Console.ReadLine());
long A = long.Parse(Console.ReadLine());
long B = long.Parse(Console.ReadLine());
long C = long.Parse(Console.ReadLine());
long D = long.Parse(Console.ReadLine());
long E = long.Parse(Console.ReadLine());
long[] carryNum = new long[5] { A, B, C, D, E };
long slow = carryNum.Min();
if (N % slow == 0)
Console.WriteLine(N / slow + 4);
else
Console.WriteLine(N / slow + 5);
}
private static long[] Read(string input) {
string[] inputs = input.Split(' ');
long num = inputs.Length;
long[] longs = new long[num];
for (long i = 0; i < num; i++) {
longs[i] = long.Parse(inputs[i]);
}
return longs;
}
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 205, 22], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 0, 131], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 141, 22], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 31, 22], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 17, 85], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 12, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95]]
| 8
| 240
| 20
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
class Solver {
Scanner sc = new Scanner();
public void Solve() {
var N = sc.nextLong();
var A = sc.nextLong();
var B = sc.nextLong();
var C = sc.nextLong();
var D = sc.nextLong();
var E = sc.nextLong();
var arr = new long[] { A, B, C, D, E };
WriteLine(5 + (N / arr.Min()));
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
class Program {
static void Main(string[] args) {
Solver s = new Solver();
s.Solve();
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
class Solver {
Scanner sc = new Scanner();
public void Solve() {
var N = sc.nextLong();
var A = sc.nextLong();
var B = sc.nextLong();
var C = sc.nextLong();
var D = sc.nextLong();
var E = sc.nextLong();
var arr = new long[] { A, B, C, D, E };
WriteLine(4 + Math.Ceiling((decimal)N / (decimal)arr.Min()));
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
class Program {
static void Main(string[] args) {
Solver s = new Solver();
s.Solve();
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 16, 31, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 31, 203], ["+", 0, 28, 0, 16, 12, 213, 63, 214, 205, 22], ["+", 0, 28, 0, 16, 12, 213, 63, 214, 0, 131], ["+", 0, 28, 0, 16, 12, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 16, 31, 74, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 31, 74, 39, 199], ["+", 3, 4, 0, 28, 0, 16, 31, 74, 0, 25], ["+", 3, 4, 0, 28, 0, 16, 12, 74, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 12, 74, 39, 199], ["+", 3, 4, 0, 28, 0, 16, 12, 74, 0, 25]]
| 8
| 507
| 11
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
var N = long.Parse(Console.ReadLine());
var cities = new int[5];
var X = long.MaxValue;
for (int i = 0; i < cities.Length; i++) {
cities[i] = int.Parse(Console.ReadLine());
X = Math.Min(cities[i], X);
}
decimal t = Math.Ceiling((decimal)N / X) + 4;
Console.WriteLine(t);
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
var N = long.Parse(Console.ReadLine());
var cities = new long[5];
var X = long.MaxValue;
for (int i = 0; i < cities.Length; i++) {
cities[i] = long.Parse(Console.ReadLine());
X = Math.Min(cities[i], X);
}
// 切り上げ
long t = (N + X - 1) / X + 4;
Console.WriteLine(t);
}
}
|
[["-", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["+", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["-", 0, 1, 0, 11, 12, 213, 63, 214, 205, 199], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 205, 199], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 212, 0, 16, 31, 213, 63, 214, 205, 22], ["-", 0, 212, 0, 16, 31, 213, 63, 214, 0, 131], ["-", 0, 212, 0, 16, 31, 213, 63, 214, 141, 22], ["-", 0, 212, 0, 16, 31, 213, 3, 4, 0, 24], ["-", 3, 4, 0, 28, 0, 16, 31, 74, 39, 199], ["-", 3, 4, 0, 28, 0, 16, 31, 74, 0, 25], ["-", 31, 213, 3, 4, 0, 28, 0, 16, 17, 85], ["+", 31, 16, 31, 23, 0, 16, 31, 16, 17, 72], ["+", 0, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 16, 31, 16, 31, 23, 0, 16, 12, 203], ["+", 0, 200, 0, 212, 0, 16, 31, 16, 17, 85], ["+", 0, 200, 0, 212, 0, 16, 31, 16, 12, 22]]
| 8
| 132
| 18
|
using System;
using System.Collections.Generic;
namespace abc123_c {
class Program {
static void Main(string[] args) {
var n = CIn.ReadLong();
var l = CIn.ReadLongArray(5);
Array.Sort(l);
Console.WriteLine(Math.Ceiling((double)n / l[0]) + 4);
}
}
class CIn {
private static readonly Queue<string> fieldBuffer = new Queue<string>();
public static string Read() {
if (fieldBuffer.Count == 0) {
foreach (var field in Console.ReadLine().Split()) {
fieldBuffer.Enqueue(field);
}
}
return fieldBuffer.Dequeue();
}
public static int ReadInt() => int.Parse(Read());
public static long ReadLong() => long.Parse(Read());
public static double ReadDouble() => double.Parse(Read());
public static string[] ReadStringArray(long n) {
var array = new string[n];
for (var i = 0; i < n; i++) {
array[i] = Read();
}
return array;
}
public static int[] ReadIntArray(long n) {
var array = new int[n];
for (var i = 0; i < n; i++) {
array[i] = ReadInt();
}
return array;
}
public static long[] ReadLongArray(long n) {
var array = new long[n];
for (var i = 0; i < n; i++) {
array[i] = ReadLong();
}
return array;
}
public static double[] ReadDoubleArray(long n) {
var array = new double[n];
for (var i = 0; i < n; i++) {
array[i] = ReadDouble();
}
return array;
}
}
}
|
using System;
using System.Collections.Generic;
namespace abc123_c {
class Program {
static void Main(string[] args) {
var n = CIn.ReadLong();
var l = CIn.ReadLongArray(5);
Array.Sort(l);
Console.WriteLine((n - 1) / l[0] + 5);
}
}
class CIn {
private static readonly Queue<string> fieldBuffer = new Queue<string>();
public static string Read() {
if (fieldBuffer.Count == 0) {
foreach (var field in Console.ReadLine().Split()) {
fieldBuffer.Enqueue(field);
}
}
return fieldBuffer.Dequeue();
}
public static int ReadInt() => int.Parse(Read());
public static long ReadLong() => long.Parse(Read());
public static double ReadDouble() => double.Parse(Read());
public static string[] ReadStringArray(long n) {
var array = new string[n];
for (var i = 0; i < n; i++) {
array[i] = Read();
}
return array;
}
public static int[] ReadIntArray(long n) {
var array = new int[n];
for (var i = 0; i < n; i++) {
array[i] = ReadInt();
}
return array;
}
public static long[] ReadLongArray(long n) {
var array = new long[n];
for (var i = 0; i < n; i++) {
array[i] = ReadLong();
}
return array;
}
public static double[] ReadDoubleArray(long n) {
var array = new double[n];
for (var i = 0; i < n; i++) {
array[i] = ReadDouble();
}
return array;
}
}
}
|
[["-", 0, 28, 0, 16, 31, 213, 63, 214, 205, 22], ["-", 0, 28, 0, 16, 31, 213, 63, 214, 0, 131], ["-", 0, 28, 0, 16, 31, 213, 63, 214, 141, 22], ["-", 0, 28, 0, 16, 31, 213, 3, 4, 0, 24], ["-", 3, 4, 0, 28, 0, 16, 31, 74, 39, 199], ["-", 3, 4, 0, 28, 0, 16, 31, 74, 0, 25], ["+", 0, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 16, 31, 16, 31, 23, 0, 16, 12, 203], ["+", 0, 28, 0, 16, 31, 16, 31, 23, 0, 25], ["-", 0, 28, 0, 16, 31, 213, 3, 4, 0, 25], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
| 8
| 391
| 12
|
using System;
namespace algorithm {
class Program {
static void Main(string[] args) {
double n = long.Parse(Console.ReadLine());
long a = long.Parse(Console.ReadLine());
long b = long.Parse(Console.ReadLine());
long c = long.Parse(Console.ReadLine());
long d = long.Parse(Console.ReadLine());
long e = long.Parse(Console.ReadLine());
//最小を取得
double min = Math.Min(a, Math.Min(b, Math.Min(c, Math.Min(d, e))));
n = n / min;
double ans = Math.Ceiling(n) + 4;
Console.WriteLine(ans.ToString());
}
}
}
|
using System;
namespace algorithm {
class Program {
static void Main(string[] args) {
double n = long.Parse(Console.ReadLine());
long a = long.Parse(Console.ReadLine());
long b = long.Parse(Console.ReadLine());
long c = long.Parse(Console.ReadLine());
long d = long.Parse(Console.ReadLine());
long e = long.Parse(Console.ReadLine());
//最小を取得
double min = Math.Min(a, Math.Min(b, Math.Min(c, Math.Min(d, e))));
Console.WriteLine(Convert.ToInt64(Math.Ceiling((double)n / min)) + 4);
}
}
}
|
[["-", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 17, 85], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 28, 0, 16, 31, 213, 63, 214, 205, 22], ["+", 0, 28, 0, 16, 31, 213, 63, 214, 0, 131], ["+", 0, 28, 0, 16, 31, 213, 63, 214, 141, 22], ["+", 0, 28, 0, 16, 31, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 31, 74, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 31, 74, 39, 199], ["+", 3, 4, 0, 28, 0, 16, 31, 74, 0, 25], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 85], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["+", 0, 28, 0, 16, 31, 213, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["-", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["-", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25]]
| 8
| 169
| 33
|
namespace ABC123_C {
using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
public class Program {
static void Main(string[] args) {
var n = ReadInput();
var vehicles = ReadLinesAslong(5).ToList();
WriteLine(Solve(n, vehicles));
}
public static long Solve(long n, List<long> vehicles) {
var bottleNeck =
vehicles.Select((x, i) => new { x, i })
.Aggregate((min, working) => min.x > working.x ? working : min);
var bottleNeckIndex = bottleNeck.i;
var bottleNeckThroughput = bottleNeck.x;
var beforeBottleNeck = bottleNeckIndex;
long throughBottleNeck = 1 + n / bottleNeckThroughput;
var afterBottleNeck = vehicles.Count - bottleNeckIndex - 1;
return beforeBottleNeck + afterBottleNeck + throughBottleNeck;
}
static IEnumerable<long>
ReadLinesAslong(long n) => ReadLines(n).Select(x => long.Parse(x));
static IEnumerable<string> ReadLines(long n) {
for (long i = 0; i < n; i++)
yield return ReadLine();
}
static long ReadInput() => long.Parse(ReadLine());
}
}
|
namespace ABC123_C {
using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
public class Program {
static void Main(string[] args) {
var n = ReadInput();
var vehicles = ReadLinesAslong(5).ToList();
WriteLine(Solve(n, vehicles));
}
public static long Solve(long n, List<long> vehicles) {
var bottleNeck =
vehicles.Select((x, i) => new { x, i })
.Aggregate((min, working) => min.x > working.x ? working : min);
var bottleNeckIndex = bottleNeck.i;
var bottleNeckThroughput = bottleNeck.x;
var beforeBottleNeck = bottleNeckIndex;
long throughBottleNeck =
(long)Math.Ceiling((double)n / (double)bottleNeckThroughput);
var afterBottleNeck = vehicles.Count - bottleNeckIndex - 1;
return beforeBottleNeck + afterBottleNeck + throughBottleNeck;
}
static IEnumerable<long>
ReadLinesAslong(long n) => ReadLines(n).Select(x => long.Parse(x));
static IEnumerable<string> ReadLines(long n) {
for (long i = 0; i < n; i++)
yield return ReadLine();
}
static long ReadInput() => long.Parse(ReadLine());
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 16, 31, 203], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["+", 0, 198, 0, 200, 0, 212, 0, 74, 0, 24], ["+", 0, 198, 0, 200, 0, 212, 0, 74, 39, 199], ["+", 0, 198, 0, 200, 0, 212, 0, 74, 0, 25], ["+", 0, 212, 0, 74, 51, 213, 63, 214, 205, 22], ["+", 0, 212, 0, 74, 51, 213, 63, 214, 0, 131], ["+", 0, 212, 0, 74, 51, 213, 63, 214, 141, 22], ["+", 0, 212, 0, 74, 51, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 31, 74, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 31, 74, 39, 199], ["+", 3, 4, 0, 28, 0, 16, 31, 74, 0, 25], ["+", 3, 4, 0, 28, 0, 16, 12, 74, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 12, 74, 39, 199], ["+", 3, 4, 0, 28, 0, 16, 12, 74, 0, 25], ["+", 0, 212, 0, 74, 51, 213, 3, 4, 0, 25]]
| 8
| 249
| 16
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1 {
class Program {
//
static void Main(string[] args) {
List<long> Ninzu = new List<long>();
long N = long.Parse(Console.ReadLine());
long A = long.Parse(Console.ReadLine());
Ninzu.Add(A);
long B = long.Parse(Console.ReadLine());
Ninzu.Add(B);
long C = long.Parse(Console.ReadLine());
Ninzu.Add(C);
long D = long.Parse(Console.ReadLine());
Ninzu.Add(D);
long E = long.Parse(Console.ReadLine());
Ninzu.Add(E);
long minNinzu = Math.Min(Ninzu.Min(x => x), N);
Console.WriteLine(Math.Ceiling((1.0 * N) / minNinzu) + 4);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1 {
class Program {
//
static void Main(string[] args) {
List<long> Ninzu = new List<long>();
long N = long.Parse(Console.ReadLine());
long A = long.Parse(Console.ReadLine());
Ninzu.Add(A);
long B = long.Parse(Console.ReadLine());
Ninzu.Add(B);
long C = long.Parse(Console.ReadLine());
Ninzu.Add(C);
long D = long.Parse(Console.ReadLine());
Ninzu.Add(D);
long E = long.Parse(Console.ReadLine());
Ninzu.Add(E);
long minNinzu = Math.Min(Ninzu.Min(x => x), N);
Console.WriteLine(
((long)(Math.Ceiling((1.0 * N) / minNinzu) + 4)).ToString());
}
}
}
|
[["+", 0, 28, 0, 213, 63, 214, 205, 23, 0, 24], ["+", 0, 213, 63, 214, 205, 23, 0, 74, 0, 24], ["+", 0, 213, 63, 214, 205, 23, 0, 74, 39, 199], ["+", 0, 213, 63, 214, 205, 23, 0, 74, 0, 25], ["+", 63, 214, 205, 23, 0, 74, 51, 23, 0, 24], ["+", 63, 214, 205, 23, 0, 74, 51, 23, 0, 25], ["+", 0, 28, 0, 213, 63, 214, 205, 23, 0, 25], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25]]
| 8
| 219
| 11
|
using System;
using System.Linq;
namespace C___Five_Transportations {
class Program {
static void Main(string[] args) {
var N = int.Parse(Console.ReadLine());
var moveTimes = new int[5];
moveTimes[0] = int.Parse(Console.ReadLine());
moveTimes[1] = int.Parse(Console.ReadLine());
moveTimes[2] = int.Parse(Console.ReadLine());
moveTimes[3] = int.Parse(Console.ReadLine());
moveTimes[4] = int.Parse(Console.ReadLine());
Console.WriteLine(Math.Ceiling((decimal)N / moveTimes.Min()) + 4);
}
}
}
|
using System;
using System.Linq;
namespace C___Five_Transportations {
class Program {
static void Main(string[] args) {
var N = long.Parse(Console.ReadLine());
var moveTimes = new long[5];
moveTimes[0] = long.Parse(Console.ReadLine());
moveTimes[1] = long.Parse(Console.ReadLine());
moveTimes[2] = long.Parse(Console.ReadLine());
moveTimes[3] = long.Parse(Console.ReadLine());
moveTimes[4] = long.Parse(Console.ReadLine());
Console.WriteLine(Math.Ceiling((decimal)N / moveTimes.Min()) + 4);
}
}
}
|
[["-", 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, 227, 39, 224, 39, 199], ["+", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["-", 0, 1, 0, 11, 12, 213, 63, 214, 205, 199], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 205, 199]]
| 8
| 153
| 14
|
using System;
namespace AtCoder {
class Program {
static void Main(string[] args) {
long N = long.Parse(Console.ReadLine());
long[] T = new long[5];
long Min = long.MaxValue;
for (int i = 0; i < 5; i++) {
T[i] = long.Parse(Console.ReadLine());
if (T[i] < Min) {
Min = T[i];
}
}
long Total = 5 + N / Min;
Console.WriteLine(Total.ToString());
}
}
}
|
using System;
namespace AtCoder {
class Program {
static void Main(string[] args) {
long N = long.Parse(Console.ReadLine());
long[] T = new long[5];
long Min = long.MaxValue;
for (int i = 0; i < 5; i++) {
T[i] = long.Parse(Console.ReadLine());
if (T[i] < Min) {
Min = T[i];
}
}
long Total = (N - 1) / Min + 5;
Console.WriteLine(Total.ToString());
}
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 16, 31, 203], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["+", 0, 212, 0, 16, 31, 16, 31, 23, 0, 24], ["+", 0, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 16, 31, 16, 31, 23, 0, 16, 12, 203], ["+", 0, 212, 0, 16, 31, 16, 31, 23, 0, 25], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203]]
| 8
| 124
| 8
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
var N = long.Parse(Console.ReadLine());
List<long> list = new List<long>();
for (var i = 0; i < 5; i++) {
list.Add(long.Parse(Console.ReadLine()));
}
if (N <= list.Min()) {
Console.WriteLine(5);
} else {
Console.WriteLine(5 + N / list.Min());
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
var N = decimal.Parse(Console.ReadLine());
List<decimal> list = new List<decimal>();
for (var i = 0; i < 5; i++) {
list.Add(decimal.Parse(Console.ReadLine()));
}
if (N <= list.Min()) {
Console.WriteLine(5);
} else {
Console.WriteLine(4 + Math.Ceiling(N / list.Min()));
}
}
}
|
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["-", 0, 197, 0, 198, 39, 236, 237, 238, 0, 199], ["+", 0, 197, 0, 198, 39, 236, 237, 238, 0, 199], ["-", 0, 212, 0, 230, 39, 236, 237, 238, 0, 199], ["+", 0, 212, 0, 230, 39, 236, 237, 238, 0, 199], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 205, 199], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 205, 199], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 31, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 31, 203], ["+", 0, 28, 0, 16, 12, 213, 63, 214, 205, 22], ["+", 0, 28, 0, 16, 12, 213, 63, 214, 0, 131], ["+", 0, 28, 0, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 28, 0, 16, 12, 213, 3, 4, 0, 24], ["+", 0, 28, 0, 16, 12, 213, 3, 4, 0, 25]]
| 8
| 127
| 15
|
using System;
namespace AtCoder123C {
class Program {
static void Main(string[] args) {
decimal N = decimal.Parse(Console.ReadLine());
decimal[] MaxAvailable = new decimal[5];
decimal sum = 0;
decimal min = 1000000000000000;
for (int i = 0; i < 5; i++) {
MaxAvailable[i] = decimal.Parse(Console.ReadLine());
if (min > MaxAvailable[i]) {
min = MaxAvailable[i];
}
}
sum = 5 + Math.Floor(N / min);
Console.WriteLine(sum);
}
}
}
|
using System;
namespace AtCoder123C {
class Program {
static void Main(string[] args) {
decimal N = decimal.Parse(Console.ReadLine());
decimal[] MaxAvailable = new decimal[5];
decimal sum = 0;
decimal min = 1000000000000000;
for (int i = 0; i < 5; i++) {
MaxAvailable[i] = decimal.Parse(Console.ReadLine());
if (min > MaxAvailable[i]) {
min = MaxAvailable[i];
}
}
if (N % min == 0) {
sum = 4 + Math.Floor(N / min);
} else
sum = 5 + Math.Floor(N / min);
Console.WriteLine(sum);
}
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 31, 203], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 0, 11, 12, 16, 12, 213, 63, 214, 205, 22], ["+", 0, 11, 12, 16, 12, 213, 63, 214, 0, 131], ["+", 0, 11, 12, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 11, 12, 16, 12, 213, 3, 4, 0, 24], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 17, 85], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["+", 0, 11, 12, 16, 12, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95]]
| 8
| 127
| 24
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
class Myon {
static void Main(string[] args) { var myon = new Myon(); }
public Myon() {
long N = long.Parse(Console.ReadLine());
long[] size = new long[5];
for (int i = 0; i < 5; i++) {
size[i] = long.Parse(Console.ReadLine());
}
long A = 0;
if (N % size[0] != 0)
A = N / size[0] + 1;
else
A = N / size[0];
// Console.WriteLine(A);
long B = 0;
if (size[1] >= size[0])
B += A + 1;
else if (N % size[1] != 0)
B += N / size[1] + 1 + 1;
else
B += N / size[1] + 1;
if (B <= A)
B++;
// Console.WriteLine(B);
long C = 0;
if (size[2] >= size[1])
C += B + 1;
else if (N % size[2] != 0)
C += N / size[2] + 1 + 2;
else
C += N / size[2] + 2;
if (C <= B)
C++;
// Console.WriteLine(C);
long D = 0;
if (size[3] >= size[2])
D += C + 1;
else if (N % size[3] != 0)
D += N / size[3] + 1 + 3;
else
D += N / size[3] + 3;
if (D <= C)
D++;
// Console.WriteLine(D);
long E = 0;
if (size[4] >= size[3])
E += D + 1;
else if (N % size[4] != 0)
E += N / size[4] + 1 + 4;
else
E += N / size[4] + 4;
if (E <= D)
E++;
Console.WriteLine(E);
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
class Myon {
static void Main(string[] args) { var myon = new Myon(); }
public Myon() {
long N = long.Parse(Console.ReadLine());
long[] size = new long[5];
for (int i = 0; i < 5; i++) {
size[i] = long.Parse(Console.ReadLine());
}
long A = 0;
if (N % size[0] != 0)
A = N / size[0] + 1;
else
A = N / size[0];
// Console.WriteLine(A);
long B = 0;
if (size[1] >= size[0])
B += A + 1;
else if (N % size[1] != 0)
B += N / size[1] + 1 + 1;
else
B += N / size[1] + 1;
if (B <= A)
B = A + 1;
// Console.WriteLine(B);
long C = 0;
if (size[2] >= size[1])
C += B + 1;
else if (N % size[2] != 0)
C += N / size[2] + 1 + 2;
else
C += N / size[2] + 2;
if (C <= B)
C = B + 1;
// Console.WriteLine(C);
long D = 0;
if (size[3] >= size[2])
D += C + 1;
else if (N % size[3] != 0)
D += N / size[3] + 1 + 3;
else
D += N / size[3] + 3;
if (D <= C)
D = C + 1;
// Console.WriteLine(D);
long E = 0;
if (size[4] >= size[3])
E += D + 1;
else if (N % size[4] != 0)
E += N / size[4] + 1 + 4;
else
E += N / size[4] + 4;
if (E <= D)
E = D + 1;
Console.WriteLine(E);
}
}
|
[["-", 8, 196, 0, 57, 64, 1, 0, 223, 0, 29], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 1, 0, 11, 12, 16, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 12, 16, 17, 72], ["+", 0, 57, 64, 1, 0, 11, 12, 16, 12, 203]]
| 8
| 430
| 20
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;
using static AtCoderTemplate.MyExtensions;
using static AtCoderTemplate.MyInputOutputs;
using static AtCoderTemplate.MyNumericFunctions;
namespace AtCoderTemplate {
class Program {
static void Main(string[] args) {
var N = ReadLong();
var AToE = ReadLongColumns(5)[0];
Console.WriteLine(N / AToE.Min() + 5);
}
}
static class MyInputOutputs {
/* Input & Output*/
public static int ReadInt() { return int.Parse(Console.ReadLine()); }
public static long ReadLong() { return long.Parse(Console.ReadLine()); }
public static List<int> ReadInts() {
return Console.ReadLine().Split(' ').Select(c => int.Parse(c)).ToList();
}
public static List<long> ReadLongs() {
return Console.ReadLine().Split(' ').Select(c => long.Parse(c)).ToList();
}
public static List<List<int>> ReadIntColumns(int n) {
/*
入力例
A1 B1
A2 B2
...
An Bn
出力例
[[A1,A2,...,An], [B1,B2,...,Bn]]
*/
var rows = Enumerable.Range(0, n).Select(i => ReadInts()).ToList();
var m = rows.FirstOrDefault()?.Count() ?? 0;
return Enumerable.Range(0, m)
.Select(i => rows.Select(items => items[i]).ToList())
.ToList();
}
public static List<List<long>> ReadLongColumns(int n) {
/*
入力例
A1 B1
A2 B2
...
An Bn
出力例
[[A1,A2,...,An], [B1,B2,...,Bn]]
*/
var rows = Enumerable.Range(0, n).Select(i => ReadLongs()).ToList();
var m = rows.FirstOrDefault()?.Count() ?? 0;
return Enumerable.Range(0, m)
.Select(i => rows.Select(items => items[i]).ToList())
.ToList();
}
public static void PrintRow<T>(IEnumerable<T> list) {
/* 横ベクトルで表示
A B C D ...
*/
if (!list.IsEmpty()) {
Console.Write(list.First());
foreach (var item in list.Skip(1)) {
Console.Write($" {item}");
}
}
Console.Write("\n");
}
public static void PrintColomn<T>(IEnumerable<T> list) {
/* 縦ベクトルで表示
A
B
C
D
...
*/
foreach (var item in list) {
Console.WriteLine(item);
}
}
public static void Print2DArray<T>(IEnumerable<IEnumerable<T>> sources) {
foreach (var row in sources) {
PrintRow(row);
}
}
public static void PrintIf<T1, T2>(bool condition, T1 trueResult,
T2 falseResult) {
if (condition) {
Console.WriteLine(trueResult);
} else {
Console.WriteLine(falseResult);
}
}
}
static class MyNumericFunctions {
public static int Fact(int n) {
return Enumerable.Range(1, n).Aggregate(1, ((i, k) => i * k));
}
public static int PermNum(int n, int m) {
if (m > n) {
return 0;
}
return Enumerable.Range(n - m, m + 1).Aggregate(1, ((i, k) => i * k));
}
public static int CombNum(int n, int m) { return PermNum(n, m) / Fact(m); }
// 最大公約数 (m ≧ n)
public static int GCD(int m, int n) {
if (n == 0) {
return m;
} else {
return GCD(n, m % n);
}
}
// 最小公倍数 (m ≧ n)
public static int LCM(int m, int n) { return GCD(m, n) / (m * n); }
}
static class MyExtensions {
public static bool IsEmpty<T>(this IEnumerable<T> source) {
return source.Count() == 0;
}
/// <summary>
/// 一つ前の値との差を得る
/// O(N * log(N))
/// </summary>
public static IEnumerable<int> Diff(this IEnumerable<int> source) {
var list = source.ToList();
return Enumerable.Range(1, list.Count - 1)
.Select(i => list[i] - list[i - 1]);
}
/// <summary>
/// 累積和を得る
/// O(N * log(N))
/// </summary>
public static IEnumerable<int> CumSum(this IEnumerable<int> source) {
var list = source.ToList();
var result = new List<int> { list[0] };
foreach (var i in Enumerable.Range(1, source.Count() - 1)) {
result.Add(result[i - 1] + list[i]);
}
return result;
}
/// <summary>
/// 昇順にソートしたインデックスを得る
/// </summary>
public static IEnumerable<int> SortIndex<T>(this IEnumerable<T> source) {
return source.Select((item, i) => new { Item = item, Index = i })
.OrderBy(x => x.Item)
.Select(x => x.Index);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;
using static AtCoderTemplate.MyExtensions;
using static AtCoderTemplate.MyInputOutputs;
using static AtCoderTemplate.MyNumericFunctions;
namespace AtCoderTemplate {
class Program {
static void Main(string[] args) {
var N = ReadLong();
var AToE = ReadLongColumns(5)[0];
var min = AToE.Min();
var isRest = N % min != 0;
PrintIf(isRest, N / min + 5, N / min + 4);
}
}
static class MyInputOutputs {
/* Input & Output*/
public static int ReadInt() { return int.Parse(Console.ReadLine()); }
public static long ReadLong() { return long.Parse(Console.ReadLine()); }
public static List<int> ReadInts() {
return Console.ReadLine().Split(' ').Select(c => int.Parse(c)).ToList();
}
public static List<long> ReadLongs() {
return Console.ReadLine().Split(' ').Select(c => long.Parse(c)).ToList();
}
public static List<List<int>> ReadIntColumns(int n) {
/*
入力例
A1 B1
A2 B2
...
An Bn
出力例
[[A1,A2,...,An], [B1,B2,...,Bn]]
*/
var rows = Enumerable.Range(0, n).Select(i => ReadInts()).ToList();
var m = rows.FirstOrDefault()?.Count() ?? 0;
return Enumerable.Range(0, m)
.Select(i => rows.Select(items => items[i]).ToList())
.ToList();
}
public static List<List<long>> ReadLongColumns(int n) {
/*
入力例
A1 B1
A2 B2
...
An Bn
出力例
[[A1,A2,...,An], [B1,B2,...,Bn]]
*/
var rows = Enumerable.Range(0, n).Select(i => ReadLongs()).ToList();
var m = rows.FirstOrDefault()?.Count() ?? 0;
return Enumerable.Range(0, m)
.Select(i => rows.Select(items => items[i]).ToList())
.ToList();
}
public static void PrintRow<T>(IEnumerable<T> list) {
/* 横ベクトルで表示
A B C D ...
*/
if (!list.IsEmpty()) {
Console.Write(list.First());
foreach (var item in list.Skip(1)) {
Console.Write($" {item}");
}
}
Console.Write("\n");
}
public static void PrintColomn<T>(IEnumerable<T> list) {
/* 縦ベクトルで表示
A
B
C
D
...
*/
foreach (var item in list) {
Console.WriteLine(item);
}
}
public static void Print2DArray<T>(IEnumerable<IEnumerable<T>> sources) {
foreach (var row in sources) {
PrintRow(row);
}
}
public static void PrintIf<T1, T2>(bool condition, T1 trueResult,
T2 falseResult) {
if (condition) {
Console.WriteLine(trueResult);
} else {
Console.WriteLine(falseResult);
}
}
}
static class MyNumericFunctions {
public static int Fact(int n) {
return Enumerable.Range(1, n).Aggregate(1, ((i, k) => i * k));
}
public static int PermNum(int n, int m) {
if (m > n) {
return 0;
}
return Enumerable.Range(n - m, m + 1).Aggregate(1, ((i, k) => i * k));
}
public static int CombNum(int n, int m) { return PermNum(n, m) / Fact(m); }
// 最大公約数 (m ≧ n)
public static int GCD(int m, int n) {
if (n == 0) {
return m;
} else {
return GCD(n, m % n);
}
}
// 最小公倍数 (m ≧ n)
public static int LCM(int m, int n) { return GCD(m, n) / (m * n); }
}
static class MyExtensions {
public static bool IsEmpty<T>(this IEnumerable<T> source) {
return source.Count() == 0;
}
/// <summary>
/// 一つ前の値との差を得る
/// O(N * log(N))
/// </summary>
public static IEnumerable<int> Diff(this IEnumerable<int> source) {
var list = source.ToList();
return Enumerable.Range(1, list.Count - 1)
.Select(i => list[i] - list[i - 1]);
}
/// <summary>
/// 累積和を得る
/// O(N * log(N))
/// </summary>
public static IEnumerable<int> CumSum(this IEnumerable<int> source) {
var list = source.ToList();
var result = new List<int> { list[0] };
foreach (var i in Enumerable.Range(1, source.Count() - 1)) {
result.Add(result[i - 1] + list[i]);
}
return result;
}
/// <summary>
/// 昇順にソートしたインデックスを得る
/// </summary>
public static IEnumerable<int> SortIndex<T>(this IEnumerable<T> source) {
return source.Select((item, i) => new { Item = item, Index = i })
.OrderBy(x => x.Item)
.Select(x => x.Index);
}
}
}
|
[["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 3, 4, 0, 28, 0, 16, 31, 16, 31, 22], ["-", 3, 4, 0, 28, 0, 16, 31, 16, 17, 85], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 200, 0, 212, 0, 16, 31, 16, 31, 22], ["+", 0, 200, 0, 212, 0, 16, 31, 16, 17, 109], ["+", 0, 200, 0, 212, 0, 16, 31, 16, 12, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 79], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 1, 0, 213, 63, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 21], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 31, 22], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 17, 85], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 12, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
| 8
| 1,021
| 32
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class MainClass {
public static void Main(string[] args) {
long n = long.Parse(Console.ReadLine());
long a = long.Parse(Console.ReadLine());
long b = long.Parse(Console.ReadLine());
long c = long.Parse(Console.ReadLine());
long d = long.Parse(Console.ReadLine());
long e = long.Parse(Console.ReadLine());
long[] m = new long[] { 0, a, b, c, d, e };
long[] map = new long[6];
map[0] = n;
long time = 0;
long mi = 99999999999999999;
for (int i = 0; i < m.Length - 1; i++) {
mi = Math.Min(mi, m[i + 1]);
time += p(n, m[i], m[i + 1], mi);
if (i != m.Length - 2)
time++;
}
Console.WriteLine(time);
}
public static long p(long n, long si, long oi, long mi) {
if (si != 0 && si <= oi)
return 0;
long r1 = (long)Math.Ceiling(n / (double)Math.Min(mi, si));
long r2 = (long)Math.Ceiling(n / (double)Math.Min(mi, oi));
if (si == 0) {
return r2;
}
return r2 - r1;
}
public static int Clamp(int val, int max, int min = 0) {
return Math.Min(max, Math.Max(min, val));
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class MainClass {
public static void Main(string[] args) {
long n = long.Parse(Console.ReadLine());
long a = long.Parse(Console.ReadLine());
long b = long.Parse(Console.ReadLine());
long c = long.Parse(Console.ReadLine());
long d = long.Parse(Console.ReadLine());
long e = long.Parse(Console.ReadLine());
long[] m = new long[] { 0, a, b, c, d, e };
long[] map = new long[6];
map[0] = n;
long time = 0;
long mi = 99999999999999999;
for (int i = 0; i < m.Length - 1; i++) {
time += p(n, m[i], m[i + 1], mi);
mi = Math.Min(mi, m[i + 1]);
if (i != m.Length - 2)
time++;
}
Console.WriteLine(time);
}
public static long p(long n, long si, long oi, long mi) {
if (si != 0 && si <= oi)
return 0;
long r1 = (long)Math.Ceiling(n / (double)Math.Min(mi, si));
long r2 = (long)Math.Ceiling(n / (double)Math.Min(mi, oi));
if (si == 0) {
return r2;
}
return r2 - r1;
}
public static int Clamp(int val, int max, int min = 0) {
return Math.Min(max, Math.Max(min, val));
}
}
|
[["-", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 0, 1, 0, 11, 12, 213, 63, 214, 205, 22], ["-", 0, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["-", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["-", 0, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["-", 0, 11, 12, 213, 3, 4, 0, 28, 0, 22], ["-", 0, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["-", 12, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["-", 3, 4, 0, 28, 0, 204, 206, 207, 0, 70], ["-", 0, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["-", 0, 204, 206, 207, 0, 28, 0, 16, 17, 72], ["-", 0, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["-", 3, 4, 0, 28, 0, 204, 206, 207, 0, 73], ["-", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["+", 0, 11, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 205, 22], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["+", 12, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["+", 3, 4, 0, 28, 0, 204, 206, 207, 0, 70], ["+", 0, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["+", 0, 204, 206, 207, 0, 28, 0, 16, 17, 72], ["+", 0, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 3, 4, 0, 28, 0, 204, 206, 207, 0, 73]]
| 8
| 382
| 32
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ABC123C {
class MainClass {
static int[] s;
static int[] n;
public static void Main(string[] args) {
var lst = new List<long>();
long n = long.Parse(Console.ReadLine());
for (int i = 0; i < 5; i++) {
long a = long.Parse(Console.ReadLine());
lst.Add(a);
}
lst.Sort((x, y) => x.CompareTo(y));
long ans = 0;
if (lst.First() < n) {
ans = n / lst.First() + 5;
} else {
ans = 5;
}
Console.WriteLine(ans);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ABC123C {
class MainClass {
static int[] s;
static int[] n;
public static void Main(string[] args) {
var lst = new List<long>();
long n = long.Parse(Console.ReadLine());
for (int i = 0; i < 5; i++) {
long a = long.Parse(Console.ReadLine());
lst.Add(a);
}
lst.Sort((x, y) => x.CompareTo(y));
long ans = 0;
if (lst.First() < n) {
if (n % lst.First() == 0) {
ans = n / lst.First() + 4;
} else {
ans = n / lst.First() + 5;
}
} else {
ans = 5;
}
Console.WriteLine(ans);
}
}
}
|
[["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 64, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 64, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["+", 15, 16, 31, 16, 12, 213, 63, 214, 205, 22], ["+", 15, 16, 31, 16, 12, 213, 63, 214, 0, 131], ["+", 15, 16, 31, 16, 12, 213, 63, 214, 141, 22], ["+", 15, 16, 31, 16, 12, 213, 3, 4, 0, 24], ["+", 15, 16, 31, 16, 12, 213, 3, 4, 0, 25], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["+", 64, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 95], ["+", 0, 57, 64, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 31, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 17, 85], ["+", 12, 16, 31, 16, 12, 213, 63, 214, 205, 22], ["+", 12, 16, 31, 16, 12, 213, 63, 214, 0, 131], ["+", 12, 16, 31, 16, 12, 213, 63, 214, 141, 22], ["+", 12, 16, 31, 16, 12, 213, 3, 4, 0, 24], ["+", 12, 16, 31, 16, 12, 213, 3, 4, 0, 25], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 0, 57, 64, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 170
| 29
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
string input = Console.ReadLine();
double n = double.Parse(input);
double[] capacity = new double[5];
input = Console.ReadLine();
capacity[0] = double.Parse(input);
input = Console.ReadLine();
capacity[1] = double.Parse(input);
input = Console.ReadLine();
capacity[2] = double.Parse(input);
input = Console.ReadLine();
capacity[3] = double.Parse(input);
input = Console.ReadLine();
capacity[4] = double.Parse(input);
Array.Sort(capacity);
if (n <= capacity[0]) {
Console.WriteLine("5");
} else {
if (n % capacity[0] != 0) {
Console.WriteLine(5 + Math.Floor(n / capacity[0]));
} else {
Console.WriteLine(4 + Math.Floor(n / capacity[0]));
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
string input = Console.ReadLine();
long n = long.Parse(input);
long[] capacity = new long[5];
input = Console.ReadLine();
capacity[0] = long.Parse(input);
input = Console.ReadLine();
capacity[1] = long.Parse(input);
input = Console.ReadLine();
capacity[2] = long.Parse(input);
input = Console.ReadLine();
capacity[3] = long.Parse(input);
input = Console.ReadLine();
capacity[4] = long.Parse(input);
Array.Sort(capacity);
if (n <= capacity[0]) {
Console.WriteLine("5");
} else {
if (n % capacity[0] != 0) {
Console.WriteLine(5 + ((n - n % capacity[0]) / capacity[0]));
} else {
Console.WriteLine(4 + (n / capacity[0]));
}
}
}
}
|
[["-", 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, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["+", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["-", 0, 1, 0, 11, 12, 213, 63, 214, 205, 199], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 205, 199], ["-", 0, 28, 0, 16, 12, 213, 63, 214, 205, 22], ["-", 0, 28, 0, 16, 12, 213, 63, 214, 0, 131], ["-", 0, 28, 0, 16, 12, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 16, 12, 23, 0, 24], ["+", 12, 23, 0, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 16, 31, 23, 0, 16, 12, 16, 31, 22], ["+", 0, 16, 31, 23, 0, 16, 12, 16, 17, 109], ["+", 31, 23, 0, 16, 12, 16, 12, 204, 205, 22], ["+", 0, 16, 12, 16, 12, 204, 206, 207, 0, 70], ["+", 12, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 16, 12, 16, 12, 204, 206, 207, 0, 73], ["+", 0, 16, 12, 23, 0, 16, 31, 23, 0, 25]]
| 8
| 244
| 33
|
// Undone
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
public class Program {
public static void Main() {
double N = ReadDouble();
double[] a = new double[5];
for (int i = 0; i < a.Length; i++) {
double d = ReadDouble();
a[i] = (d < N) ? Math.Ceiling(N / d) : 0;
}
double ans = 4;
if (a.Max() == 0) {
ans++;
} else {
ans += a.Max();
}
Console.WriteLine(ans);
}
private static List<int> _var;
public static int cin() {
if (_var == null || _var.Count() == 0) {
_var = Console.ReadLine().Split(' ').Select(int.Parse).ToList<int>();
}
int ans = _var[0];
_var.RemoveAt(0);
return ans;
}
public static void Swap<T>(ref T a, ref T b) {
T temp = a;
a = b;
b = temp;
}
public static string ReadStr() { return Console.ReadLine(); }
public static int ReadInt() { return int.Parse(Console.ReadLine()); }
public static double ReadDouble() { return double.Parse(Console.ReadLine()); }
public static long ReadLong() { return long.Parse(Console.ReadLine()); }
public static char ReadChar() { return Console.ReadLine()[0]; }
public static string[] ReadStringArray() {
return Console.ReadLine().Split(' ');
}
public static int[] ReadIntArray() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
public static double[] ReadDoubleArray() {
return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
}
public static long[] ReadLongArray() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
}
public static char[] ReadCharArray() { return Console.ReadLine().ToArray(); }
public static string[] ReadCharStringArray() {
return Console.ReadLine().ToCharArray().Select(c => c.ToString()).ToArray();
}
}
|
// Undone
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
public class Program {
public static void Main() {
double N = ReadDouble();
double[] a = new double[5];
for (int i = 0; i < a.Length; i++) {
double d = ReadDouble();
a[i] = (d < N) ? Math.Ceiling(N / d) : 0;
}
double ans = 0;
if (a.Max() == 0) {
ans = 5;
} else {
ans = a.Max() + 4;
}
Console.WriteLine((long)ans);
}
private static List<int> _var;
public static int cin() {
if (_var == null || _var.Count() == 0) {
_var = Console.ReadLine().Split(' ').Select(int.Parse).ToList<int>();
}
int ans = _var[0];
_var.RemoveAt(0);
return ans;
}
public static void Swap<T>(ref T a, ref T b) {
T temp = a;
a = b;
b = temp;
}
public static string ReadStr() { return Console.ReadLine(); }
public static int ReadInt() { return int.Parse(Console.ReadLine()); }
public static double ReadDouble() { return double.Parse(Console.ReadLine()); }
public static long ReadLong() { return long.Parse(Console.ReadLine()); }
public static char ReadChar() { return Console.ReadLine()[0]; }
public static string[] ReadStringArray() {
return Console.ReadLine().Split(' ');
}
public static int[] ReadIntArray() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
public static double[] ReadDoubleArray() {
return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
}
public static long[] ReadLongArray() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
}
public static char[] ReadCharArray() { return Console.ReadLine().ToArray(); }
public static string[] ReadCharStringArray() {
return Console.ReadLine().ToCharArray().Select(c => c.ToString()).ToArray();
}
}
|
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 57, 64, 196, 0, 1, 0, 223, 0, 29], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["-", 75, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 74, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 74, 39, 199], ["+", 0, 213, 3, 4, 0, 28, 0, 74, 0, 25]]
| 8
| 526
| 12
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace abc123c {
class Program {
static void Main(string[] args) {
long mina = 10000000000000000;
long N = long.Parse(Console.ReadLine());
for (int i = 0; i < 5; i++) {
long a = long.Parse(Console.ReadLine());
mina = Math.Min(mina, a);
}
long tim = N / mina + 5;
Console.WriteLine(tim);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace abc123c {
class Program {
static void Main(string[] args) {
long mina = 10000000000000000;
long N = long.Parse(Console.ReadLine());
for (int i = 0; i < 5; i++) {
long a = long.Parse(Console.ReadLine());
mina = Math.Min(mina, a);
}
long tim;
if (N % mina != 0) {
tim = N / mina + 5;
} else {
tim = N / mina + 4;
}
Console.WriteLine(tim);
}
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 79], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 31, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 17, 85], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 12, 22], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["+", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 122
| 23
|
using System;
using System.IO;
namespace ABC123C {
class Program {
static void Main(string[] args) {
if (args.Length > 0) {
Console.SetIn(new StreamReader(args[0]));
}
new Program().Solve();
}
void Solve() {
// 一番狭いところだけ考えればいいのかな
var N = long.Parse(Console.ReadLine());
var capacity = long.MaxValue;
for (int i = 0; i < 5; i++) {
var temp = long.Parse(Console.ReadLine());
if (temp < capacity) {
capacity = temp;
}
}
var ans = N / capacity + 5;
Console.WriteLine(ans);
}
}
}
|
using System;
using System.IO;
namespace ABC123C {
class Program {
static void Main(string[] args) {
if (args.Length > 0) {
Console.SetIn(new StreamReader(args[0]));
}
new Program().Solve();
}
void Solve() {
// 一番狭いところだけ考えればいいのかな
var N = long.Parse(Console.ReadLine());
var capacity = long.MaxValue;
for (int i = 0; i < 5; i++) {
var temp = long.Parse(Console.ReadLine());
if (temp < capacity) {
capacity = temp;
}
}
var ans = N / capacity + 5;
if (N % capacity == 0) {
ans--;
}
Console.WriteLine(ans);
}
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 68], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 146
| 13
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Beg123C {
class Program {
static void Main(string[] args) {
var N = long.Parse(Console.ReadLine());
var nums = new long[5];
nums[0] = long.Parse(Console.ReadLine());
nums[1] = long.Parse(Console.ReadLine());
nums[2] = long.Parse(Console.ReadLine());
nums[3] = long.Parse(Console.ReadLine());
nums[4] = long.Parse(Console.ReadLine());
var min = nums.Min();
var ans = min > N ? 5 : 4 + N / min + N % 1;
Console.WriteLine(ans);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Beg123C {
class Program {
static void Main(string[] args) {
var N = long.Parse(Console.ReadLine());
var nums = new long[5];
nums[0] = long.Parse(Console.ReadLine());
nums[1] = long.Parse(Console.ReadLine());
nums[2] = long.Parse(Console.ReadLine());
nums[3] = long.Parse(Console.ReadLine());
nums[4] = long.Parse(Console.ReadLine());
var min = nums.Min();
var ans = min > N ? 5 : N % min == 0 ? 4 + N / min : 4 + N / min + 1;
Console.WriteLine(ans);
}
}
}
|
[["+", 0, 41, 75, 41, 15, 16, 31, 16, 31, 22], ["+", 0, 41, 75, 41, 15, 16, 31, 16, 17, 109], ["+", 0, 41, 75, 41, 15, 16, 31, 16, 12, 22], ["+", 0, 212, 0, 41, 75, 41, 15, 16, 17, 60], ["+", 0, 212, 0, 41, 75, 41, 15, 16, 12, 203], ["+", 0, 200, 0, 212, 0, 41, 75, 41, 0, 101], ["+", 0, 200, 0, 212, 0, 41, 75, 41, 0, 102], ["+", 0, 41, 75, 41, 75, 16, 31, 16, 31, 203], ["-", 0, 212, 0, 41, 75, 16, 12, 16, 17, 109], ["+", 75, 41, 75, 16, 31, 16, 12, 16, 17, 85], ["+", 75, 41, 75, 16, 31, 16, 12, 16, 12, 22], ["+", 0, 212, 0, 41, 75, 41, 75, 16, 17, 72]]
| 8
| 184
| 12
|
using System;
namespace AtCoder.ABC._123 {
class c {
static void Main(string[] args) {
var line = Console.ReadLine().Trim();
var N = long.Parse(line);
long[] time = new long[5];
for (var i = 0; i < 5; i++) {
line = Console.ReadLine().Trim();
time[i] = long.Parse(line);
}
var min = time[0];
for (var i = 1; i < 5; ++i) {
if (min > time[i]) {
min = time[i];
}
}
Console.WriteLine(Math.Ceiling((double)N / min) + 4);
}
}
}
|
using System;
namespace AtCoder.ABC._123 {
class c {
static void Main(string[] args) {
var line = Console.ReadLine().Trim();
var N = long.Parse(line);
long[] time = new long[5];
for (var i = 0; i < 5; i++) {
line = Console.ReadLine().Trim();
time[i] = long.Parse(line);
}
var min = time[0];
for (var i = 1; i < 5; ++i) {
if (min > time[i]) {
min = time[i];
}
}
Console.WriteLine(
((long)(Math.Ceiling((double)N / min) + 4)).ToString("D"));
}
}
}
|
[["+", 0, 28, 0, 213, 63, 214, 205, 23, 0, 24], ["+", 0, 213, 63, 214, 205, 23, 0, 74, 0, 24], ["+", 0, 213, 63, 214, 205, 23, 0, 74, 39, 199], ["+", 0, 213, 63, 214, 205, 23, 0, 74, 0, 25], ["+", 63, 214, 205, 23, 0, 74, 51, 23, 0, 24], ["+", 63, 214, 205, 23, 0, 74, 51, 23, 0, 25], ["+", 0, 28, 0, 213, 63, 214, 205, 23, 0, 25], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25]]
| 8
| 161
| 14
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;
class MainClass : Scanner {
static int X, Y, Z, K;
static long[] A, B, C;
static void Main() {
(X, Y, Z, K) = ReadStream<int, int, int, int>();
A = RLongs();
B = RLongs();
C = RLongs();
Array.Sort(A);
Array.Sort(B);
Array.Sort(C);
var (lb, ub) = (-1L, 30000000001);
while (ub - lb > 1) {
var mid = (lb + ub) / 2;
if (comp(mid))
lb = mid;
else
ub = mid;
}
var ans = new List<long>();
long min = 30000000001;
for (int i = 0; i < X; i++) {
for (int j = 0; j < Y; j++) {
for (int k = Z - 1; k >= 0; k--) {
var v = A[i] + B[j] + C[k];
if (v < lb || (ans.Count >= K && v == min))
break;
min = Math.Min(min, v);
ans.Add(v);
}
}
}
ans.Sort();
ans.Reverse();
foreach (var i in ans) {
WriteLine(i);
}
}
static bool comp(long m) {
int cnt = 0;
for (int i = 0; i < X; i++) {
for (int j = 0; j < Y; j++) {
var (lb, ub) = (-1, C.Length);
while (ub - lb > 1) {
var mid = (lb + ub) / 2;
if (A[i] + B[j] + C[mid] < m)
lb = mid;
else
ub = mid;
}
cnt += C.Length - ub;
}
}
return cnt >= K;
}
}
public class PriorityQueue<T> {
public long Size { get; private set; } = 0;
public long MaxSize { get; private set; } = 0;
public T[] m_heap;
private Comparison<T> Comp = null;
public PriorityQueue(long maxSize, Comparison<T> comp) {
if (maxSize <= 0)
throw new Exception();
MaxSize = maxSize;
m_heap = new T[maxSize];
Comp = comp;
}
public void Push(T x) {
if (Size == MaxSize) {
T[] new_heap = new T[MaxSize << 1];
Array.Copy(m_heap, new_heap, MaxSize);
m_heap = new_heap;
MaxSize <<= 1;
}
long i = Size++;
while (i > 0) {
long p = (i - 1) / 2;
if (Comp(m_heap[p], x) <= 0)
break;
m_heap[i] = m_heap[p];
i = p;
}
m_heap[i] = x;
}
public T Pop() {
if (Size == 0)
throw new Exception("Queue is empty.");
T result = m_heap[0];
T x = m_heap[--Size];
long i = 0;
while (i * 2 + 1 < Size) {
long c1 = i * 2 + 1, c2 = i * 2 + 2;
if (c2 < Size && Comp(m_heap[c2], m_heap[c1]) < 0)
c1 = c2;
if (Comp(m_heap[c1], x) >= 0)
break;
m_heap[i] = m_heap[c1];
i = c1;
}
m_heap[i] = x;
return result;
}
}
class Scanner {
public static int RInt() => int.Parse(Console.ReadLine());
public static long RLong() => long.Parse(Console.ReadLine());
public static string RString() => Console.ReadLine();
public static double RDouble() => double.Parse(Console.ReadLine());
public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(),
int.Parse);
public static int[] RInts(Func<string, int> func) =>
Console.ReadLine().Split().Select(func).ToArray();
public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(),
long.Parse);
public static long[] RLongs(Func<string, long> func) =>
Console.ReadLine().Split().Select(func).ToArray();
public static double[] RDoubles() =>
Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
public static double[] RDoubles(Func<string, double> func) =>
Console.ReadLine().Split().Select(func).ToArray();
public static string[] RStrings() => Console.ReadLine().Split();
// public static string[] RStrings(Func<string, string> func) =>
// Console.ReadLine().Split().Select(func).ToArray();
public static T1 ReadStream<T1>() {
var r = RStrings();
var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
return r1;
}
public static (T1, T2) ReadStream<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) ReadStream<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) ReadStream<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 int X, Y, Z, K;
static long[] A, B, C;
static void Main() {
(X, Y, Z, K) = ReadStream<int, int, int, int>();
A = RLongs();
B = RLongs();
C = RLongs();
Array.Sort(A);
Array.Sort(B);
Array.Sort(C);
var (lb, ub) = (-1L, 30000000001);
while (ub - lb > 1) {
var mid = (lb + ub) / 2;
if (comp(mid))
lb = mid;
else
ub = mid;
}
var ans = new List<long>();
long min = 30000000001;
for (int i = 0; i < X; i++) {
for (int j = 0; j < Y; j++) {
for (int k = Z - 1; k >= 0; k--) {
var v = A[i] + B[j] + C[k];
if (v < lb || (ans.Count >= K && v == min))
break;
min = Math.Min(min, v);
ans.Add(v);
}
}
}
ans.Sort();
ans.Reverse();
for (int i = 0; i < K; i++) {
WriteLine(ans[i]);
}
}
static bool comp(long m) {
int cnt = 0;
for (int i = 0; i < X; i++) {
for (int j = 0; j < Y; j++) {
var (lb, ub) = (-1, C.Length);
while (ub - lb > 1) {
var mid = (lb + ub) / 2;
if (A[i] + B[j] + C[mid] < m)
lb = mid;
else
ub = mid;
}
cnt += C.Length - ub;
}
}
return cnt >= K;
}
}
public class PriorityQueue<T> {
public long Size { get; private set; } = 0;
public long MaxSize { get; private set; } = 0;
public T[] m_heap;
private Comparison<T> Comp = null;
public PriorityQueue(long maxSize, Comparison<T> comp) {
if (maxSize <= 0)
throw new Exception();
MaxSize = maxSize;
m_heap = new T[maxSize];
Comp = comp;
}
public void Push(T x) {
if (Size == MaxSize) {
T[] new_heap = new T[MaxSize << 1];
Array.Copy(m_heap, new_heap, MaxSize);
m_heap = new_heap;
MaxSize <<= 1;
}
long i = Size++;
while (i > 0) {
long p = (i - 1) / 2;
if (Comp(m_heap[p], x) <= 0)
break;
m_heap[i] = m_heap[p];
i = p;
}
m_heap[i] = x;
}
public T Pop() {
if (Size == 0)
throw new Exception("Queue is empty.");
T result = m_heap[0];
T x = m_heap[--Size];
long i = 0;
while (i * 2 + 1 < Size) {
long c1 = i * 2 + 1, c2 = i * 2 + 2;
if (c2 < Size && Comp(m_heap[c2], m_heap[c1]) < 0)
c1 = c2;
if (Comp(m_heap[c1], x) >= 0)
break;
m_heap[i] = m_heap[c1];
i = c1;
}
m_heap[i] = x;
return result;
}
}
class Scanner {
public static int RInt() => int.Parse(Console.ReadLine());
public static long RLong() => long.Parse(Console.ReadLine());
public static string RString() => Console.ReadLine();
public static double RDouble() => double.Parse(Console.ReadLine());
public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(),
int.Parse);
public static int[] RInts(Func<string, int> func) =>
Console.ReadLine().Split().Select(func).ToArray();
public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(),
long.Parse);
public static long[] RLongs(Func<string, long> func) =>
Console.ReadLine().Split().Select(func).ToArray();
public static double[] RDoubles() =>
Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
public static double[] RDoubles(Func<string, double> func) =>
Console.ReadLine().Split().Select(func).ToArray();
public static string[] RStrings() => Console.ReadLine().Split();
// public static string[] RStrings(Func<string, string> func) =>
// Console.ReadLine().Split().Select(func).ToArray();
public static T1 ReadStream<T1>() {
var r = RStrings();
var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
return r1;
}
public static (T1, T2) ReadStream<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) ReadStream<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) ReadStream<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);
}
}
|
[["-", 8, 201, 0, 195, 8, 196, 0, 210, 0, 266], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 88], ["-", 0, 195, 8, 196, 0, 210, 39, 216, 0, 217], ["+", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["-", 8, 201, 0, 195, 8, 196, 0, 210, 0, 267], ["-", 8, 201, 0, 195, 8, 196, 0, 210, 12, 22], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 35], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 22], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 29], ["+", 0, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["+", 3, 4, 0, 28, 0, 204, 206, 207, 0, 70], ["+", 3, 4, 0, 28, 0, 204, 206, 207, 0, 73]]
| 8
| 1,408
| 18
|
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 X = sc.ReadInt();
var Y = sc.ReadInt();
var Z = sc.ReadInt();
var K = sc.ReadInt();
var A = sc.ReadLongArray(X);
var B = sc.ReadLongArray(Y);
var C = sc.ReadLongArray(Z);
Array.Sort(A);
Array.Reverse(A);
Array.Sort(B);
Array.Reverse(B);
Array.Sort(C);
Array.Reverse(C);
var set = new HashSet<Tuple<long, int, int, int>>();
var q = new PriorityQueue<Tuple<long, int, int, int>>();
q.Enqueue(Tuple.Create(A[0] + B[0] + C[0], 0, 0, 0));
var rem = K;
while (q.Count > 0 && rem > 0) {
rem--;
var t = q.Dequeue();
var ans = t.Item1;
var x = t.Item2;
var y = t.Item3;
var z = t.Item4;
Console.WriteLine(ans);
for (int d = 0; d < 3; d++) {
var nx = x + (d == 0 ? 1 : 0);
var ny = y + (d == 1 ? 1 : 0);
var nz = z + (d == 2 ? 1 : 0);
if (nx == X || ny == Y || nz == Z)
continue;
var next = Tuple.Create(A[nx] + B[ny] + C[nz], nx, ny, nz);
if (set.Contains(next))
continue;
q.Enqueue(next);
}
}
}
class PriorityQueue<T> {
public int Count;
private int Capacity;
private bool IsMaxHeap;
private T[] Buffer;
private IComparer<T> Cmp;
public PriorityQueue(bool isMaxHeap = true, IComparer<T> cmp = null) {
Count = 0;
Capacity = 1 << 10;
IsMaxHeap = isMaxHeap;
Buffer = new T[Capacity];
if (cmp != null)
Cmp = cmp;
else
Cmp = Comparer<T>.Default;
}
public PriorityQueue(int capacity, bool isMaxHeap = true,
IComparer<T> cmp = null) {
Count = 0;
Capacity = Math.Max(16, capacity);
IsMaxHeap = isMaxHeap;
Buffer = new T[Capacity];
if (cmp != null)
Cmp = cmp;
else
Cmp = Comparer<T>.Default;
}
private void Resize() {
Capacity <<= 1;
Array.Resize(ref Buffer, Capacity);
}
public void Enqueue(T value) {
if (Count == Capacity)
Resize();
Buffer[Count] = value;
Count++;
UpHeap();
}
public T Dequeue() {
var res = Buffer[0];
Swap(0, Count - 1);
Count--;
DownHeap();
return res;
}
public T Peek() { return Buffer[0]; }
private void Swap(int i, int j) {
var tmp = Buffer[i];
Buffer[i] = Buffer[j];
Buffer[j] = tmp;
}
private void UpHeap() {
var n = this.Count - 1;
while (n != 0) {
var parent = (n - 1) / 2;
if (Compare(Buffer[n], Buffer[parent]) > 0) {
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 < Count - 1 &&
Compare(Buffer[child], Buffer[child + 1]) < 0) {
child += 1;
}
if (Compare(Buffer[parent], Buffer[child]) < 0) {
Swap(parent, child);
parent = child;
} else
break;
}
}
private int Compare(T x, T y) {
var res = Cmp.Compare(x, y);
if (!IsMaxHeap)
res *= -1;
return res;
}
}
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 X = sc.ReadInt();
var Y = sc.ReadInt();
var Z = sc.ReadInt();
var K = sc.ReadInt();
var A = sc.ReadLongArray(X);
var B = sc.ReadLongArray(Y);
var C = sc.ReadLongArray(Z);
Array.Sort(A);
Array.Reverse(A);
Array.Sort(B);
Array.Reverse(B);
Array.Sort(C);
Array.Reverse(C);
var set = new HashSet<Tuple<long, int, int, int>>();
var q = new PriorityQueue<Tuple<long, int, int, int>>();
q.Enqueue(Tuple.Create(A[0] + B[0] + C[0], 0, 0, 0));
var rem = K;
while (q.Count > 0 && rem > 0) {
rem--;
var t = q.Dequeue();
var ans = t.Item1;
var x = t.Item2;
var y = t.Item3;
var z = t.Item4;
Console.WriteLine(ans);
for (int d = 0; d < 3; d++) {
var nx = x + (d == 0 ? 1 : 0);
var ny = y + (d == 1 ? 1 : 0);
var nz = z + (d == 2 ? 1 : 0);
if (nx == X || ny == Y || nz == Z)
continue;
var next = Tuple.Create(A[nx] + B[ny] + C[nz], nx, ny, nz);
if (set.Contains(next))
continue;
set.Add(next);
q.Enqueue(next);
}
}
}
class PriorityQueue<T> {
public int Count;
private int Capacity;
private bool IsMaxHeap;
private T[] Buffer;
private IComparer<T> Cmp;
public PriorityQueue(bool isMaxHeap = true, IComparer<T> cmp = null) {
Count = 0;
Capacity = 1 << 10;
IsMaxHeap = isMaxHeap;
Buffer = new T[Capacity];
if (cmp != null)
Cmp = cmp;
else
Cmp = Comparer<T>.Default;
}
public PriorityQueue(int capacity, bool isMaxHeap = true,
IComparer<T> cmp = null) {
Count = 0;
Capacity = Math.Max(16, capacity);
IsMaxHeap = isMaxHeap;
Buffer = new T[Capacity];
if (cmp != null)
Cmp = cmp;
else
Cmp = Comparer<T>.Default;
}
private void Resize() {
Capacity <<= 1;
Array.Resize(ref Buffer, Capacity);
}
public void Enqueue(T value) {
if (Count == Capacity)
Resize();
Buffer[Count] = value;
Count++;
UpHeap();
}
public T Dequeue() {
var res = Buffer[0];
Swap(0, Count - 1);
Count--;
DownHeap();
return res;
}
public T Peek() { return Buffer[0]; }
private void Swap(int i, int j) {
var tmp = Buffer[i];
Buffer[i] = Buffer[j];
Buffer[j] = tmp;
}
private void UpHeap() {
var n = this.Count - 1;
while (n != 0) {
var parent = (n - 1) / 2;
if (Compare(Buffer[n], Buffer[parent]) > 0) {
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 < Count - 1 &&
Compare(Buffer[child], Buffer[child + 1]) < 0) {
child += 1;
}
if (Compare(Buffer[parent], Buffer[child]) < 0) {
Swap(parent, child);
parent = child;
} else
break;
}
}
private int Compare(T x, T y) {
var res = Cmp.Compare(x, y);
if (!IsMaxHeap)
res *= -1;
return res;
}
}
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;
}
}
|
[["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35]]
| 8
| 1,930
| 7
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
long[] b = Console.ReadLine().Split().Select(long.Parse).ToArray();
long[] c = Console.ReadLine().Split().Select(long.Parse).ToArray();
Array.Sort(a);
Array.Reverse(a);
Array.Sort(b);
Array.Reverse(b);
Array.Sort(c);
Array.Reverse(c);
foreach (long i in solve(a, b, c, Math.Min(s[0], 3000),
Math.Min(s[1], 3000), Math.Min(s[2], 3000),
s[3])) {
Console.WriteLine(i);
}
}
static long[] solve(long[] a, long[] b, long[] c, int x, int y, int z,
int k) {
List<long> l = new List<long>();
for (int i = 0; i < x; i++) {
for (int j = 0; j < y; j++) {
l.Add(a[i] + b[j]);
}
}
l.Sort();
l.Reverse();
for (int i = 0; i < x * y; i++) {
for (int j = 0; j < z; j++)
l.Add(l[i] + c[j]);
}
l.Sort();
l.Reverse();
return l.Where((s, t) => t < k).ToArray();
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
long[] b = Console.ReadLine().Split().Select(long.Parse).ToArray();
long[] c = Console.ReadLine().Split().Select(long.Parse).ToArray();
Array.Sort(a);
Array.Reverse(a);
Array.Sort(b);
Array.Reverse(b);
Array.Sort(c);
Array.Reverse(c);
foreach (long i in solve(a, b, c, Math.Min(s[0], 3000),
Math.Min(s[1], 3000), Math.Min(s[2], 3000),
s[3])) {
Console.WriteLine(i);
}
}
static long[] solve(long[] a, long[] b, long[] c, int x, int y, int z,
int k) {
List<long> l = new List<long>();
for (int i = 0; i < x; i++) {
for (int j = 0; j < y; j++) {
l.Add(a[i] + b[j]);
}
}
l.Sort();
l.Reverse();
List<long> ans = new List<long>();
for (int i = 0; i < Math.Min(k, x * y); i++) {
for (int j = 0; j < z; j++)
ans.Add(l[i] + c[j]);
}
ans.Sort();
ans.Reverse();
return ans.Where((s, t) => t < k).ToArray();
}
}
|
[["+", 8, 196, 0, 197, 0, 198, 39, 236, 141, 22], ["+", 0, 197, 0, 198, 39, 236, 237, 238, 0, 18], ["+", 0, 197, 0, 198, 39, 236, 237, 238, 0, 199], ["+", 0, 197, 0, 198, 39, 236, 237, 238, 0, 47], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 230, 0, 228], ["+", 0, 200, 0, 212, 0, 230, 39, 236, 141, 22], ["+", 0, 212, 0, 230, 39, 236, 237, 238, 0, 18], ["+", 0, 212, 0, 230, 39, 236, 237, 238, 0, 199], ["+", 0, 212, 0, 230, 39, 236, 237, 238, 0, 47], ["+", 0, 200, 0, 212, 0, 230, 3, 4, 0, 24], ["+", 0, 200, 0, 212, 0, 230, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 7, 15, 16, 12, 213, 63, 214, 205, 22], ["+", 0, 7, 15, 16, 12, 213, 63, 214, 0, 131], ["+", 0, 7, 15, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 7, 15, 16, 12, 213, 3, 4, 0, 24], ["+", 15, 16, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 7, 15, 16, 12, 213, 3, 4, 0, 21], ["+", 0, 7, 15, 16, 12, 213, 3, 4, 0, 25], ["-", 0, 7, 8, 1, 0, 213, 63, 214, 205, 22], ["+", 0, 7, 8, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 205, 22], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 205, 22]]
| 8
| 427
| 29
|
using System.Collections.Generic;
using System;
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;
}
}
public class P : IComparable {
public long s { get; set; }
public int i { get; set; }
public int j { get; set; }
public int k { get; set; }
public int CompareTo(object obj) {
var x = (P)obj;
if (this.s > x.s)
return 1;
else if (this.s == x.s)
return 0;
else
return -1;
}
}
public class Hello {
public static void Main() {
string[] line = Console.ReadLine().Trim().Split(' ');
var x = int.Parse(line[0]);
var y = int.Parse(line[1]);
var z = int.Parse(line[2]);
var K = int.Parse(line[3]);
line = Console.ReadLine().Trim().Split(' ');
var a = Array.ConvertAll(line, long.Parse);
line = Console.ReadLine().Trim().Split(' ');
var b = Array.ConvertAll(line, long.Parse);
line = Console.ReadLine().Trim().Split(' ');
var c = Array.ConvertAll(line, long.Parse);
Array.Sort(a);
Array.Sort(b);
Array.Sort(c);
Array.Reverse(a);
Array.Reverse(b);
Array.Reverse(c);
getAns(a, b, c, x, y, z, K);
}
static void getAns(long[] a, long[] b, long[] c, int x, int y, int z, int K) {
var pq = new PriorityQueue<P>(30000, 1);
var used = new bool[x, y, z];
pq.Push(new P { s = a[0] + b[0] + c[0], i = 0, j = 0, k = 0 });
used[0, 0, 0] = true;
var count = 0;
while (count < K) {
var w = pq.Pop();
Console.WriteLine(w.s);
count++;
if (!used[w.i + 1, w.j, w.k]) {
pq.Push(new P { s = a[w.i + 1] + b[w.j] + c[w.k], i = w.i + 1, j = w.j,
k = w.k });
used[w.i + 1, w.j, w.k] = true;
}
if (!used[w.i, w.j + 1, w.k]) {
pq.Push(new P { s = a[w.i] + b[w.j + 1] + c[w.k], i = w.i, j = w.j + 1,
k = w.k });
used[w.i, w.j + 1, w.k] = true;
}
if (!used[w.i, w.j, w.k + 1]) {
pq.Push(new P { s = a[w.i] + b[w.j] + c[w.k + 1], i = w.i, j = w.j,
k = w.k + 1 });
used[w.i, w.j, w.k + 1] = true;
}
}
}
}
|
using System.Collections.Generic;
using System;
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;
}
}
public class P : IComparable {
public long s { get; set; }
public int i { get; set; }
public int j { get; set; }
public int k { get; set; }
public int CompareTo(object obj) {
var x = (P)obj;
if (this.s > x.s)
return 1;
else if (this.s == x.s)
return 0;
else
return -1;
}
}
public class Hello {
public static void Main() {
string[] line = Console.ReadLine().Trim().Split(' ');
var x = int.Parse(line[0]);
var y = int.Parse(line[1]);
var z = int.Parse(line[2]);
var K = int.Parse(line[3]);
line = Console.ReadLine().Trim().Split(' ');
var a = Array.ConvertAll(line, long.Parse);
line = Console.ReadLine().Trim().Split(' ');
var b = Array.ConvertAll(line, long.Parse);
line = Console.ReadLine().Trim().Split(' ');
var c = Array.ConvertAll(line, long.Parse);
Array.Sort(a);
Array.Sort(b);
Array.Sort(c);
Array.Reverse(a);
Array.Reverse(b);
Array.Reverse(c);
getAns(a, b, c, x, y, z, K);
}
static void getAns(long[] a, long[] b, long[] c, int x, int y, int z, int K) {
var pq = new PriorityQueue<P>(30000, 1);
var used = new bool[x, y, z];
pq.Push(new P { s = a[0] + b[0] + c[0], i = 0, j = 0, k = 0 });
used[0, 0, 0] = true;
var count = 0;
while (count < K) {
var w = pq.Pop();
Console.WriteLine(w.s);
count++;
if (w.i + 1 < x && !used[w.i + 1, w.j, w.k]) {
pq.Push(new P { s = a[w.i + 1] + b[w.j] + c[w.k], i = w.i + 1, j = w.j,
k = w.k });
used[w.i + 1, w.j, w.k] = true;
}
if (w.j + 1 < y && !used[w.i, w.j + 1, w.k]) {
pq.Push(new P { s = a[w.i] + b[w.j + 1] + c[w.k], i = w.i, j = w.j + 1,
k = w.k });
used[w.i, w.j + 1, w.k] = true;
}
if (w.k + 1 < z && !used[w.i, w.j, w.k + 1]) {
pq.Push(new P { s = a[w.i] + b[w.j] + c[w.k + 1], i = w.i, j = w.j,
k = w.k + 1 });
used[w.i, w.j, w.k + 1] = true;
}
}
}
}
|
[["+", 15, 16, 31, 16, 31, 16, 31, 214, 205, 22], ["+", 15, 16, 31, 16, 31, 16, 31, 214, 0, 131], ["+", 15, 16, 31, 16, 31, 16, 31, 214, 141, 22], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 17, 72], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 12, 203], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 18], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 17, 98]]
| 8
| 1,326
| 24
|
//#define C
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
class Program {
static void Main() {
#if false
var N = int.Parse(ReadLine());
var a = new int[N];
var b = new int[N];
var c = new int[N];
for (int i = 0; i < N; i++)
{
var l = ReadLine().Split().Select(int.Parse).ToArray();
a[i] = l[0];
b[i] = l[1];
c[i] = l[2];
}
#endif
var XYZK = ReadLine().Split().Select(int.Parse).ToArray();
var X = XYZK[0];
var Y = XYZK[1];
var Z = XYZK[2];
var K = XYZK[3];
var A = ReadLine()
.Split()
.Select(long.Parse)
.OrderByDescending(x => x)
.ToArray();
var B = ReadLine()
.Split()
.Select(long.Parse)
.OrderByDescending(x => x)
.ToArray();
var C = ReadLine()
.Split()
.Select(long.Parse)
.OrderByDescending(x => x)
.ToArray();
var c = new long[X * Y];
for (int i = 0; i < X; i++) {
for (int j = 0; j < Y; j++) {
c[i * Y + j] = A[i] + B[j];
}
}
Array.Sort(c);
var l = Math.Min(c.Length, 3000);
var d = new long[l * Z];
for (int i = 0; i < l; i++) {
for (int j = 0; j < Z; j++) {
d[i * Z + j] = c[i] + C[j];
}
}
Array.Sort(d);
for (int i = K - 1; i >= 0; i--) {
WriteLine(d[i]);
}
}
}
|
//#define C
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
class Program {
static void Main() {
#if false
var N = int.Parse(ReadLine());
var a = new int[N];
var b = new int[N];
var c = new int[N];
for (int i = 0; i < N; i++)
{
var l = ReadLine().Split().Select(int.Parse).ToArray();
a[i] = l[0];
b[i] = l[1];
c[i] = l[2];
}
#endif
var XYZK = ReadLine().Split().Select(int.Parse).ToArray();
var X = XYZK[0];
var Y = XYZK[1];
var Z = XYZK[2];
var K = XYZK[3];
var A = ReadLine()
.Split()
.Select(long.Parse)
.OrderByDescending(x => x)
.ToArray();
var B = ReadLine()
.Split()
.Select(long.Parse)
.OrderByDescending(x => x)
.ToArray();
var C = ReadLine()
.Split()
.Select(long.Parse)
.OrderByDescending(x => x)
.ToArray();
var c = new long[X * Y];
for (int i = 0; i < X; i++) {
for (int j = 0; j < Y; j++) {
c[i * Y + j] = A[i] + B[j];
}
}
Array.Sort(c);
var l = Math.Min(c.Length, 3000);
var d = new long[l * Z];
for (int i = 0; i < l; i++) {
for (int j = 0; j < Z; j++) {
d[i * Z + j] = c[c.Length - 1 - i] + C[j];
}
}
Array.Sort(d);
var f = 0;
for (int i = d.Length - 1; i >= 0; i--) {
if (f >= K)
return;
WriteLine(d[i]);
f++;
}
}
}
|
[["+", 0, 28, 0, 16, 31, 16, 31, 214, 205, 22], ["+", 0, 28, 0, 16, 31, 16, 31, 214, 0, 131], ["+", 0, 28, 0, 16, 31, 16, 31, 214, 141, 22], ["+", 206, 207, 0, 28, 0, 16, 31, 16, 17, 33], ["+", 206, 207, 0, 28, 0, 16, 31, 16, 12, 203], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 10, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["+", 0, 200, 0, 212, 0, 16, 31, 214, 205, 22], ["+", 0, 200, 0, 212, 0, 16, 31, 214, 0, 131], ["+", 0, 200, 0, 212, 0, 16, 31, 214, 141, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 20], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 37, 0, 38], ["+", 0, 7, 8, 196, 0, 57, 64, 37, 0, 35], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["+", 0, 7, 8, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 223, 0, 29]]
| 8
| 464
| 26
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Beg123D {
class Program {
static void Main(string[] args) {
var read =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
var X = read[0];
var Y = read[1];
var Z = read[2];
var K = read[3];
var YZ = Y * Z;
var As = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
var Bs = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
var Cs = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
var delness = new List<long>();
var memo = new List<long>();
foreach (var b in Bs) {
foreach (var c in Cs) {
memo.Add(b + c);
}
}
As.Sort();
As.Reverse();
memo.Sort();
memo.Reverse();
foreach (var a in As) {
for (int i = 0; i < K; i++) {
delness.Add(a + memo[i]);
}
}
delness.Sort();
delness.Reverse();
for (int i = 0; i < K; i++) {
Console.WriteLine(delness[i]);
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Beg123D {
class Program {
static void Main(string[] args) {
var read =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
var X = read[0];
var Y = read[1];
var Z = read[2];
var K = read[3];
var YZ = Y * Z;
var As = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
var Bs = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
var Cs = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
var delness = new List<long>();
var memo = new List<long>();
foreach (var b in Bs) {
foreach (var c in Cs) {
memo.Add(b + c);
}
}
As.Sort();
As.Reverse();
memo.Sort();
memo.Reverse();
foreach (var a in As) {
for (int i = 0; i < Math.Min(K, YZ); i++) {
delness.Add(a + memo[i]);
}
}
delness.Sort();
delness.Reverse();
for (int i = 0; i < K; i++) {
Console.WriteLine(delness[i]);
}
}
}
}
|
[["+", 0, 7, 15, 16, 12, 213, 63, 214, 205, 22], ["+", 0, 7, 15, 16, 12, 213, 63, 214, 0, 131], ["+", 0, 7, 15, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 7, 15, 16, 12, 213, 3, 4, 0, 24], ["+", 0, 7, 15, 16, 12, 213, 3, 4, 0, 21], ["+", 15, 16, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 7, 15, 16, 12, 213, 3, 4, 0, 25]]
| 8
| 361
| 7
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace program {
class Program {
static void Main() {
int[] n = Input.ScanIntArray();
Array.Sort(n);
if ((n[0] * n[0] + n[1] * n[1]) == (n[2] * n[2]))
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
static class Input {
static public int ScanInt() { return int.Parse(Console.ReadLine()); }
static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
static public long ScanLong() { return long.Parse(Console.ReadLine()); }
static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
static public int[] ScanIntArray() {
return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
}
static public uint[] ScanUintArray() {
return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray();
}
static public double[] ScanDoubleArray() {
return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray();
}
static public long[] ScanLongArray() {
return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
}
static public ulong[] ScanUlongArray() {
return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray();
}
static public string ScanStr() { return Console.ReadLine(); }
static public string[] ScanStrArray() { return ScanStr().Split(' '); }
}
static class MyMath {
public static int GCD(int a, int b) {
Func<int, int, int> gcd = null;
gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
return a > b ? gcd(a, b) : gcd(b, a);
}
public static ulong GCD(ulong a, ulong b) {
Func<ulong, ulong, ulong> gcd = null;
gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
return a > b ? gcd(a, b) : gcd(b, a);
}
public static int LCM(int a, int b) { return a * b / GCD(a, b); }
public static ulong LCM(ulong a, ulong b) { return a * b / GCD(a, b); }
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace program {
class Program {
static void Main() {
int[] n = Input.ScanIntArray();
Array.Sort(n);
if (n[0] == n[1] && n[1] == n[2])
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
static class Input {
static public int ScanInt() { return int.Parse(Console.ReadLine()); }
static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
static public long ScanLong() { return long.Parse(Console.ReadLine()); }
static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
static public int[] ScanIntArray() {
return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
}
static public uint[] ScanUintArray() {
return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray();
}
static public double[] ScanDoubleArray() {
return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray();
}
static public long[] ScanLongArray() {
return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
}
static public ulong[] ScanUlongArray() {
return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray();
}
static public string ScanStr() { return Console.ReadLine(); }
static public string[] ScanStrArray() { return ScanStr().Split(' '); }
}
static class MyMath {
public static int GCD(int a, int b) {
Func<int, int, int> gcd = null;
gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
return a > b ? gcd(a, b) : gcd(b, a);
}
public static ulong GCD(ulong a, ulong b) {
Func<ulong, ulong, ulong> gcd = null;
gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
return a > b ? gcd(a, b) : gcd(b, a);
}
public static int LCM(int a, int b) { return a * b / GCD(a, b); }
public static ulong LCM(ulong a, ulong b) { return a * b / GCD(a, b); }
}
}
|
[["-", 8, 196, 0, 57, 15, 16, 31, 23, 0, 24], ["-", 15, 16, 31, 23, 0, 16, 31, 16, 17, 48], ["-", 31, 23, 0, 16, 31, 16, 12, 204, 205, 22], ["-", 0, 16, 31, 16, 12, 204, 206, 207, 0, 70], ["-", 31, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 16, 31, 16, 12, 204, 206, 207, 0, 73], ["-", 0, 57, 15, 16, 31, 23, 0, 16, 17, 72], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["-", 15, 16, 31, 23, 0, 16, 12, 16, 17, 48], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["-", 8, 196, 0, 57, 15, 16, 31, 23, 0, 25], ["-", 8, 196, 0, 57, 15, 16, 12, 23, 0, 24], ["-", 15, 16, 12, 23, 0, 16, 31, 204, 205, 22], ["-", 12, 23, 0, 16, 31, 204, 206, 207, 0, 70], ["-", 0, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 12, 23, 0, 16, 31, 204, 206, 207, 0, 73], ["-", 0, 57, 15, 16, 12, 23, 0, 16, 17, 48], ["-", 8, 196, 0, 57, 15, 16, 12, 23, 0, 25]]
| 8
| 634
| 18
|
using System;
namespace CSsample {
class Program {
static void Main(string[] args) {
Console.WriteLine("Hello World!");
string input = Console.ReadLine();
var x = input.Split(' ');
int A = int.Parse(x[0]);
int B = int.Parse(x[1]);
int C = int.Parse(x[2]);
if (A == B && B == C) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
using System;
namespace CSsample {
class Program {
static void Main(string[] args) {
string input = Console.ReadLine();
var x = input.Split(' ');
int A = int.Parse(x[0]);
int B = int.Parse(x[1]);
int C = int.Parse(x[2]);
if (A == B && B == C) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
[["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 124
| 9
|
using System;
using System.Linq;
class B {
static void Main() {
Console.ReadLine();
var s = Console.ReadLine();
Console.WriteLine(s.Count(x => x == 'R') > s.Length / 2);
}
}
|
using System;
using System.Linq;
class B {
static void Main() {
Console.ReadLine();
var s = Console.ReadLine();
Console.WriteLine(s.Count(x => x == 'R') > s.Length / 2 ? "Yes" : "No");
}
}
|
[["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 101], ["+", 3, 4, 0, 28, 0, 41, 64, 5, 0, 62], ["+", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 102], ["+", 3, 4, 0, 28, 0, 41, 75, 5, 0, 62], ["+", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222]]
| 8
| 58
| 8
|
using System;
namespace CSsample {
class Bmondai {
static void Main(string[] args) {
string input = Console.ReadLine();
int R = 0;
int B = 0;
for (int i = 0; i < input.Length; i++) {
if (input[i] == 'R') {
R++;
} else if (input[i] == 'B') {
B++;
}
}
if (R > B) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
using System;
namespace CSsample {
class Bmondai {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
string input = Console.ReadLine();
int R = 0;
int B = 0;
for (int i = 0; i < input.Length; i++) {
if (input[i] == 'R') {
R++;
} else if (input[i] == 'B') {
B++;
}
}
if (R > B) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
[["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35]]
| 8
| 121
| 14
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
namespace AtTest.AGC_031 {
class B {
static void Main(string[] args) {
Method(args);
ReadLine();
}
static void Method(string[] args) {
int n = ReadInt();
int[] cs = new int[n];
for (int i = 0; i < n; i++)
cs[i] = ReadInt();
var have = new Dictionary<int, int>();
have.Add(cs[n - 1], n - 1);
var sums = new long[n];
long mask = 1000000000 + 7;
long res = 1;
for (int i = n - 2; i >= 0; i--) {
sums[i] = sums[i + 1];
if (have.ContainsKey(cs[i])) {
if (i + 1 < have[cs[i]]) {
res += sums[have[cs[i]]] + 1;
res %= mask;
sums[i] = Max(sums[i], sums[have[cs[i]]] + 1);
}
have[cs[i]] = i;
} else {
have.Add(cs[i], i);
}
// WriteLine(sums[i] + 1);
}
WriteLine(res);
}
private static string Read() { return ReadLine(); }
private static int ReadInt() { return int.Parse(Read()); }
private static long ReadLong() { return long.Parse(Read()); }
private static double ReadDouble() { return double.Parse(Read()); }
private static int[] ReadInts() {
return Array.ConvertAll(Read().Split(), int.Parse);
}
private static long[] ReadLongs() {
return Array.ConvertAll(Read().Split(), long.Parse);
}
private static double[] ReadDoubles() {
return Array.ConvertAll(Read().Split(), double.Parse);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
namespace AtTest.AGC_031 {
class B {
static void Main(string[] args) {
Method(args);
ReadLine();
}
static void Method(string[] args) {
int n = ReadInt();
int[] cs = new int[n];
for (int i = 0; i < n; i++)
cs[i] = ReadInt();
var have = new Dictionary<int, int>();
have.Add(cs[n - 1], n - 1);
var sums = new long[n];
long mask = 1000000000 + 7;
long res = 1;
for (int i = n - 2; i >= 0; i--) {
sums[i] = sums[i + 1];
if (have.ContainsKey(cs[i])) {
if (i + 1 < have[cs[i]]) {
long next = sums[have[cs[i]]] + 1;
res += next;
res %= mask;
sums[i] += next;
sums[i] %= mask;
}
have[cs[i]] = i;
} else {
have.Add(cs[i], i);
}
// WriteLine(sums[i]);
}
WriteLine(res);
}
private static string Read() { return ReadLine(); }
private static int ReadInt() { return int.Parse(Read()); }
private static long ReadLong() { return long.Parse(Read()); }
private static double ReadDouble() { return double.Parse(Read()); }
private static int[] ReadInts() {
return Array.ConvertAll(Read().Split(), int.Parse);
}
private static long[] ReadLongs() {
return Array.ConvertAll(Read().Split(), long.Parse);
}
private static double[] ReadDoubles() {
return Array.ConvertAll(Read().Split(), double.Parse);
}
}
}
|
[["-", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 0, 57, 64, 196, 0, 197, 0, 198, 39, 199], ["+", 64, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["+", 64, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 64, 196, 0, 1, 0, 11, 12, 213, 63, 22], ["-", 0, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["-", 12, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["-", 3, 4, 0, 28, 0, 204, 206, 207, 0, 70], ["-", 0, 28, 0, 204, 206, 207, 0, 28, 0, 22], ["-", 3, 4, 0, 28, 0, 204, 206, 207, 0, 73], ["-", 0, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["-", 31, 204, 206, 207, 0, 28, 0, 204, 205, 22], ["-", 206, 207, 0, 28, 0, 204, 206, 207, 0, 70], ["-", 0, 204, 206, 207, 0, 28, 0, 204, 205, 22], ["-", 206, 207, 0, 28, 0, 204, 206, 207, 0, 73], ["-", 0, 28, 0, 16, 31, 204, 206, 207, 0, 73], ["-", 12, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["-", 12, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["-", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 132]]
| 8
| 451
| 31
|
using System;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
long N = long.Parse(Console.ReadLine());
long[] A = new long[N];
for (var i = 0; i < N; i++) {
A[i] = long.Parse(Console.ReadLine());
}
long[] B = new long[200001];
long[] D = new long[200001];
long[] C = new long[200001];
C[0] = 1;
long mod = 1000000007;
for (var i = 1; i <= N; i++) {
if (i == 1 || A[i - 1] != A[i - 2]) {
D[i] = B[A[i - 1]];
C[i] = (C[i - 1] + D[i]) % mod;
B[A[i - 1]] = C[i];
}
}
long ans = 1;
for (var i = 1; i <= N; i++) {
ans = (ans + D[i]) % mod;
}
// for(var i=0;i<=N;i++){
// Console.WriteLine(D[i]+" "+C[i]);
//}
Console.WriteLine(ans);
}
}
|
using System;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
long N = long.Parse(Console.ReadLine());
long[] A = new long[N];
for (var i = 0; i < N; i++) {
A[i] = long.Parse(Console.ReadLine());
}
long[] B = new long[200001];
long[] D = new long[200001];
long[] C = new long[200001];
C[0] = 1;
long mod = 1000000007;
for (var i = 1; i <= N; i++) {
if (i == 1 || A[i - 1] != A[i - 2]) {
D[i] = B[A[i - 1]];
C[i] = (C[i - 1] + D[i]) % mod;
B[A[i - 1]] = C[i];
} else {
C[i] = C[i - 1];
}
}
long ans = 1;
for (var i = 1; i <= N; i++) {
ans = (ans + D[i]) % mod;
}
// for(var i=0;i<=N;i++){
// Console.WriteLine(D[i]+" "+C[i]);
//}
Console.WriteLine(ans);
}
}
|
[["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 75, 196, 0, 1, 0, 11, 31, 204, 205, 22], ["+", 0, 1, 0, 11, 31, 204, 206, 207, 0, 70], ["+", 0, 11, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 1, 0, 11, 31, 204, 206, 207, 0, 73], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 75, 196, 0, 1, 0, 11, 12, 204, 205, 22], ["+", 0, 1, 0, 11, 12, 204, 206, 207, 0, 70], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 0, 1, 0, 11, 12, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46]]
| 8
| 260
| 15
|
using System.Collections.Generic;
using System.Linq;
using static System.Console;
class K {
static void Main() {
var I = ReadLine().Split().Select(int.Parse).ToArray();
int N = I[0], A = I[1], B = I[2];
if (C(A ^ B) % 2 < 1)
WriteLine("NO");
else
WriteLine("YES\n" + string.Join(" ", G(N, A, B)));
}
static IEnumerable<int> G(int N, int A, int B) {
if (N == 1)
return new[] { A, B };
var p = new int[N];
int o = N - 1, z = 0;
for (var i = 0; i < N; i++)
p[i] = (B & (1 << i)) > 0 ? o-- : z++;
B = ((1 << (N - z)) - 1) << z;
var l = new List<int>();
var M = 1 << (N - 1);
for (var i = 0; i < M; i++)
l.Add(i ^ (i >> 1));
foreach (var i in G(N - 1, 1 << (N - 2), B ^ M))
l.Add(i ^ M);
return l.Select(x => {
var s = A;
for (var j = 0; j < N; j++)
s ^= ((x >> p[j]) & 1) << j;
return s;
});
}
static int C(int n) {
n = (n & 0x55555555) + ((n >> 1) & 0x55555555);
n = (n & 858993459) + ((n >> 2) & 858993459);
n = (n & 252645135) + ((n >> 4) & 252645135);
n = (n & 16711935) + ((n >> 8) & 16711935);
return (n & 65535) + ((n >> 16) & 65535);
}
}
|
using System.Collections.Generic;
using System.Linq;
using static System.Console;
class K {
static void Main() {
var I = ReadLine().Split().Select(int.Parse).ToArray();
int N = I[0], A = I[1], B = I[2];
if (C(A ^ B) % 2 < 1)
WriteLine("NO");
else
WriteLine("YES\n" + string.Join(" ", G(N, A, B)));
}
static IEnumerable<int> G(int N, int A, int B) {
if (N < 2)
return new[] { A, B };
var p = new int[N];
int o = N - 1, z = 0;
for (var i = 0; i < N; i++)
p[i] = ((B ^ A) & 1 << i) > 0 ? o-- : z++;
B = ((1 << (N - z)) - 1) << z;
var l = new List<int>();
var M = 1 << (N - 1);
for (var i = 0; i < M; i++)
l.Add(i ^ i >> 1);
foreach (var i in G(N - 1, 1 << (N - 2), B ^ M))
l.Add(i ^ M);
return l.Select(x => {
var s = A;
for (var j = 0; j < N; j++)
s ^= (x >> p[j] & 1) << j;
return s;
});
}
static int C(int n) {
n = (n & 0x55555555) + (n >> 1 & 0x55555555);
n = (n & 858993459) + (n >> 2 & 858993459);
n = (n & 252645135) + (n >> 4 & 252645135);
n = (n & 16711935) + (n >> 8 & 16711935);
return (n & 65535) + (n >> 16 & 65535);
}
}
|
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 11, 12, 41, 15, 16, 31, 23, 0, 24], ["+", 31, 23, 0, 16, 31, 23, 0, 16, 17, 140], ["+", 31, 23, 0, 16, 31, 23, 0, 16, 12, 22], ["+", 15, 16, 31, 23, 0, 16, 31, 23, 0, 25], ["-", 15, 16, 31, 23, 0, 16, 12, 23, 0, 24], ["-", 0, 11, 12, 41, 15, 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, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["-", 12, 16, 31, 23, 0, 16, 31, 23, 0, 25], ["-", 0, 1, 0, 11, 12, 16, 12, 23, 0, 24], ["-", 12, 16, 12, 23, 0, 16, 31, 23, 0, 25], ["-", 12, 16, 12, 23, 0, 16, 31, 23, 0, 24], ["-", 0, 16, 12, 23, 0, 16, 31, 23, 0, 24], ["-", 0, 16, 12, 23, 0, 16, 31, 23, 0, 25]]
| 8
| 459
| 24
|
using System.Collections.Generic;
using System.Linq;
using static System.Console;
class K {
static void Main() {
var I = ReadLine().Split().Select(int.Parse).ToArray();
int N = I[0], A = I[1], B = I[2];
if (C(A ^ B) % 2 < 1) {
WriteLine("NO");
return;
}
WriteLine("YES");
WriteLine(string.Join(" ", G(N, A, B)));
}
static IEnumerable<int> G(int N, int A, int B) {
if (N == 1)
return new[] { A, B };
var p = new int[N];
int c = C(B ^= A), o = N - 1, z = 0;
for (var i = 0; i < N; i++)
p[i] = (B & (1 << i)) > 0 ? o-- : z++;
B = ((1 << c) - 1) << (N - c);
var l = new List<int>();
var M = 1 << --N;
for (var i = 0; i < M; i++)
l.Add(i ^ (i >> 1));
foreach (var i in G(N--, 1 << N, B ^ M))
l.Add(i ^ M);
return l.Select(x => {
var s = A;
for (var j = 0; j < N; j++)
s ^= ((x >> p[j]) & 1) << j;
return s;
});
}
static int C(int n) {
n = (n & 0x55555555) + ((n >> 1) & 0x55555555);
n = (n & 858993459) + ((n >> 2) & 858993459);
n = (n & 252645135) + ((n >> 4) & 252645135);
n = (n & 16711935) + ((n >> 8) & 16711935);
return (n & 65535) + ((n >> 16) & 65535);
}
}
|
using System.Collections.Generic;
using System.Linq;
using static System.Console;
class K {
static void Main() {
var I = ReadLine().Split().Select(int.Parse).ToArray();
int N = I[0], A = I[1], B = I[2];
if (C(A ^ B) % 2 < 1) {
WriteLine("NO");
return;
}
WriteLine("YES");
WriteLine(string.Join(" ", G(N, A, B)));
}
static IEnumerable<int> G(int N, int A, int B) {
if (N == 1)
return new[] { A, B };
var p = new int[N];
int c = C(B ^= A), o = N - 1, z = 0;
for (var i = 0; i < N; i++)
p[i] = (B & (1 << i)) > 0 ? o-- : z++;
B = ((1 << c) - 1) << (N - c);
var l = new List<int>();
var M = 1 << (N - 1);
for (var i = 0; i < M; i++)
l.Add(i ^ (i >> 1));
foreach (var i in G(N - 1, 1 << (N - 2), B ^ M))
l.Add(i ^ M);
return l.Select(x => {
var s = A;
for (var j = 0; j < N; j++)
s ^= ((x >> p[j]) & 1) << j;
return s;
});
}
static int C(int n) {
n = (n & 0x55555555) + ((n >> 1) & 0x55555555);
n = (n & 858993459) + ((n >> 2) & 858993459);
n = (n & 252645135) + ((n >> 4) & 252645135);
n = (n & 16711935) + ((n >> 8) & 16711935);
return (n & 65535) + ((n >> 16) & 65535);
}
}
|
[["-", 0, 200, 0, 212, 0, 16, 12, 241, 0, 68], ["+", 0, 200, 0, 212, 0, 16, 12, 23, 0, 24], ["+", 0, 212, 0, 16, 12, 23, 0, 16, 17, 33], ["+", 0, 212, 0, 16, 12, 23, 0, 16, 12, 203], ["+", 0, 200, 0, 212, 0, 16, 12, 23, 0, 25], ["-", 12, 213, 3, 4, 0, 28, 0, 223, 0, 68], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 3, 4, 0, 28, 0, 16, 12, 23, 0, 24], ["+", 0, 28, 0, 16, 12, 23, 0, 16, 17, 33], ["+", 0, 28, 0, 16, 12, 23, 0, 16, 12, 203], ["+", 3, 4, 0, 28, 0, 16, 12, 23, 0, 25]]
| 8
| 465
| 12
|
using System;
class c {
static void Main() {
var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
var b = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
Console.WriteLine(a[0] * a[1] - b[0] * b[1]);
}
}
|
using System;
class c {
static void Main() {
var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
var b = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
Console.WriteLine((a[0] - b[0]) * (a[1] - b[1]));
}
}
|
[["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 24], ["-", 3, 4, 0, 28, 0, 16, 31, 16, 17, 48], ["-", 0, 28, 0, 16, 31, 16, 12, 204, 205, 22], ["-", 0, 16, 31, 16, 12, 204, 206, 207, 0, 70], ["-", 31, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 16, 31, 16, 12, 204, 206, 207, 0, 73], ["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 25], ["+", 3, 4, 0, 28, 0, 16, 12, 23, 0, 24], ["+", 0, 16, 12, 23, 0, 16, 31, 204, 205, 22], ["+", 12, 23, 0, 16, 31, 204, 206, 207, 0, 70], ["+", 0, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 12, 23, 0, 16, 31, 204, 206, 207, 0, 73], ["+", 0, 28, 0, 16, 12, 23, 0, 16, 17, 33], ["+", 3, 4, 0, 28, 0, 16, 12, 23, 0, 25]]
| 8
| 83
| 14
|
using System;
class Plogram {
static void Main() {
string[] ARRAY = Console.ReadLine().Split(' ');
string[] array = Console.ReadLine().Split(' ');
int H = int.Parse(ARRAY[0]);
int W = int.Parse(ARRAY[1]);
int h = int.Parse(array[0]);
int w = int.Parse(array[1]);
Console.WriteLine(H * W - h * w);
}
}
|
using System;
class Plogram {
static void Main() {
string[] ARRAY = Console.ReadLine().Split(' ');
string[] array = Console.ReadLine().Split(' ');
int H = int.Parse(ARRAY[0]);
int W = int.Parse(ARRAY[1]);
int h = int.Parse(array[0]);
int w = int.Parse(array[1]);
Console.WriteLine((H - h) * (W - w));
}
}
|
[["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 24], ["-", 3, 4, 0, 28, 0, 16, 31, 16, 17, 48], ["-", 3, 4, 0, 28, 0, 16, 31, 16, 12, 22], ["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 25], ["+", 3, 4, 0, 28, 0, 16, 12, 23, 0, 24], ["+", 0, 28, 0, 16, 12, 23, 0, 16, 31, 22], ["+", 0, 28, 0, 16, 12, 23, 0, 16, 17, 33], ["+", 3, 4, 0, 28, 0, 16, 12, 23, 0, 25]]
| 8
| 115
| 10
|
using System;
class Plogram {
static void Main() {
string[] ARRAY = Console.ReadLine().Split(' ');
string[] array = Console.ReadLine().Split(' ');
int H = int.Parse(ARRAY[0]);
int W = int.Parse(ARRAY[1]);
int h = int.Parse(array[0]);
int w = int.Parse(array[1]);
Console.WriteLine(H * W - h * w);
}
}
|
using System;
class Plogram {
static void Main() {
string[] ARRAY = Console.ReadLine().Split(' ');
string[] array = Console.ReadLine().Split(' ');
int H = int.Parse(ARRAY[0]);
int W = int.Parse(ARRAY[1]);
int h = int.Parse(array[0]);
int w = int.Parse(array[1]);
Console.WriteLine(H * W - (h * W + H * w - h * w));
}
}
|
[["+", 3, 4, 0, 28, 0, 16, 12, 23, 0, 24], ["+", 12, 23, 0, 16, 31, 16, 31, 16, 31, 22], ["+", 12, 23, 0, 16, 31, 16, 31, 16, 17, 48], ["+", 12, 23, 0, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 16, 12, 23, 0, 16, 31, 16, 17, 72], ["+", 12, 23, 0, 16, 31, 16, 12, 16, 31, 22], ["+", 12, 23, 0, 16, 31, 16, 12, 16, 17, 48], ["+", 12, 23, 0, 16, 31, 16, 12, 16, 12, 22], ["+", 0, 28, 0, 16, 12, 23, 0, 16, 17, 33], ["+", 3, 4, 0, 28, 0, 16, 12, 23, 0, 25]]
| 8
| 115
| 10
|
using System;
class Program {
static void Main(string[] args) {
var value_1 = Console.ReadLine().Split(' ');
var value_2 = Console.ReadLine().Split(' ');
var H = int.Parse(value_1[0]);
var W = int.Parse(value_1[1]);
var h = int.Parse(value_2[0]);
var w = int.Parse(value_2[1]);
Console.WriteLine((H * W) - (h * w));
}
}
|
using System;
class Program {
static void Main(string[] args) {
var value_1 = Console.ReadLine().Split(' ');
var value_2 = Console.ReadLine().Split(' ');
var H = int.Parse(value_1[0]);
var W = int.Parse(value_1[1]);
var h = int.Parse(value_2[0]);
var w = int.Parse(value_2[1]);
Console.WriteLine(H * W - (h * W + (H - h) * w));
}
}
|
[["-", 3, 4, 0, 28, 0, 16, 31, 23, 0, 24], ["-", 3, 4, 0, 28, 0, 16, 31, 23, 0, 25], ["+", 3, 4, 0, 28, 0, 16, 12, 23, 0, 24], ["+", 0, 16, 12, 23, 0, 16, 31, 16, 31, 22], ["+", 0, 16, 12, 23, 0, 16, 31, 16, 17, 48], ["+", 0, 16, 12, 23, 0, 16, 31, 16, 12, 22], ["+", 0, 28, 0, 16, 12, 23, 0, 16, 17, 72], ["+", 0, 16, 12, 16, 31, 23, 0, 16, 31, 22], ["+", 0, 16, 12, 16, 31, 23, 0, 16, 17, 33], ["+", 12, 23, 0, 16, 12, 16, 31, 23, 0, 25]]
| 8
| 119
| 10
|
using System;
class Program {
static void Main(string[] args) {
//入力
string[] input1 = Console.ReadLine().Split(' ');
string[] input2 = Console.ReadLine().Split(' ');
int H = int.Parse(input1[0]);
int W = int.Parse(input1[1]);
int h = int.Parse(input2[0]);
int w = int.Parse(input2[1]);
//出力
Console.WriteLine(H * W - h * w);
}
}
|
using System;
class Program {
static void Main(string[] args) {
//入力
string[] input1 = Console.ReadLine().Split(' ');
string[] input2 = Console.ReadLine().Split(' ');
int H = int.Parse(input1[0]);
int W = int.Parse(input1[1]);
int h = int.Parse(input2[0]);
int w = int.Parse(input2[1]);
//出力
Console.WriteLine((H - h) * (W - w));
}
}
|
[["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 24], ["-", 3, 4, 0, 28, 0, 16, 31, 16, 17, 48], ["-", 3, 4, 0, 28, 0, 16, 31, 16, 12, 22], ["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 25], ["+", 3, 4, 0, 28, 0, 16, 12, 23, 0, 24], ["+", 0, 28, 0, 16, 12, 23, 0, 16, 31, 22], ["+", 0, 28, 0, 16, 12, 23, 0, 16, 17, 33], ["+", 3, 4, 0, 28, 0, 16, 12, 23, 0, 25]]
| 8
| 121
| 8
|
using System;
using System.IO;
class Program {
static void Main(string[] args) {
var arr = Console.ReadLine().Split();
var N = int.Parse(arr[0]);
var M = int.Parse(arr[1]);
var C = int.Parse(arr[2]);
var B = Console.ReadLine().Split();
var answer = 0;
for (int i = 1; i <= N; i++) {
var A = Console.ReadLine().Split();
var sum = 0;
for (int j = 1; j <= M; j++) {
sum += int.Parse(A[j]) * int.Parse(B[j]);
}
if (sum + C > 0)
answer++;
}
var writer =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(writer);
Console.WriteLine(answer);
Console.Out.Flush();
}
}
|
using System;
using System.IO;
using System.Linq;
class Program {
static void Main(string[] args) {
var arr = Console.ReadLine().Split();
var N = int.Parse(arr[0]);
var M = int.Parse(arr[1]);
var C = int.Parse(arr[2]);
var B = Console.ReadLine().Split().Select(int.Parse).ToArray();
var answer = 0;
for (int i = 1; i <= N; i++) {
var A = Console.ReadLine().Split().Select(int.Parse).ToArray();
var sum = 0;
for (int j = 0; j < M; j++) {
sum += A[j] * B[j];
}
if (sum + C > 0)
answer++;
}
var writer =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(writer);
Console.WriteLine(answer);
Console.Out.Flush();
}
}
|
[["+", 36, 36, 36, 36, 0, 208, 0, 231, 0, 233], ["+", 36, 36, 0, 208, 0, 231, 141, 232, 234, 22], ["+", 36, 36, 0, 208, 0, 231, 141, 232, 0, 131], ["+", 36, 36, 0, 208, 0, 231, 141, 232, 141, 22], ["+", 36, 36, 36, 36, 0, 208, 0, 231, 0, 35], ["+", 205, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["+", 205, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["+", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 205, 213, 3, 4, 0, 28, 0, 214, 0, 131], ["+", 205, 213, 3, 4, 0, 28, 0, 214, 141, 22], ["+", 0, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 17, 19], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 17, 18], ["-", 0, 11, 12, 16, 31, 213, 63, 214, 205, 199], ["-", 0, 11, 12, 16, 31, 213, 63, 214, 0, 131], ["-", 0, 11, 12, 16, 31, 213, 63, 214, 141, 22], ["-", 0, 11, 12, 16, 31, 213, 3, 4, 0, 24], ["-", 0, 11, 12, 16, 31, 213, 3, 4, 0, 25], ["-", 0, 11, 12, 16, 12, 213, 63, 214, 205, 199], ["-", 0, 11, 12, 16, 12, 213, 63, 214, 0, 131], ["-", 0, 11, 12, 16, 12, 213, 63, 214, 141, 22], ["-", 0, 11, 12, 16, 12, 213, 3, 4, 0, 24], ["-", 0, 11, 12, 16, 12, 213, 3, 4, 0, 25]]
| 8
| 216
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
var imp = Console.ReadLine().Split(' ');
int N = int.Parse(imp[0]); //コードの個数
int M = int.Parse(imp[1]); //コードの項数
int C = int.Parse(imp[2]);
int count = 0;
int Aisum = 0;
var impB = Console.ReadLine().Split(' ');
for (int i = 0; i < N; ++i) {
var Ai = Console.ReadLine().Split(' ');
for (int j = 0; j < M; ++j) {
Aisum += int.Parse(Ai[j]) * int.Parse(impB[j]);
}
if (Aisum + C > 0) {
count += 1;
Aisum = 0;
}
// Console.Write(Aisum);
}
Console.Write(count);
// System.Threading.Thread.Sleep(1000);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
var imp = Console.ReadLine().Split(' ');
int N = int.Parse(imp[0]); //コードの個数
int M = int.Parse(imp[1]); //コードの項数
int C = int.Parse(imp[2]);
int count = 0;
int Aisum = 0;
var impB = Console.ReadLine().Split(' ');
for (int i = 0; i < N; ++i) {
var Ai = Console.ReadLine().Split(' ');
for (int j = 0; j < M; ++j) {
Aisum += int.Parse(Ai[j]) * int.Parse(impB[j]);
}
if (Aisum + C > 0) {
count += 1;
Aisum = 0;
} else {
Aisum = 0;
}
// Console.Write(Aisum);
}
Console.Write(count);
// System.Threading.Thread.Sleep(1000);
}
}
}
|
[["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46]]
| 8
| 226
| 7
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace cswork {
class Program {
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
i = 0;
return next();
}
public int nextInt() { return int.Parse(next()); }
public long nextLong() { return long.Parse(next()); }
public double nextDouble() { return double.Parse(next()); }
}
public Program() {}
static void Main(string[] args) { new Program().Omame(); }
Scanner cin = new Scanner();
const int MAXIN = 1024;
bool[] used = new bool[MAXIN];
int[] perm = new int[MAXIN];
List<int[]> permList = new List<int[]>();
public void Permutation(int pos, int n, int length) {
if (pos == n) {
permList.Add((int[])perm.Clone());
}
for (int i = 0; i < n; i++) {
if (!used[i]) {
perm[pos] = i;
used[i] = true;
Permutation(pos + 1, n, length);
used[i] = false;
}
}
}
public static List<long> GeneratePrime(long max) {
long prime;
double sqrtMax = Math.Sqrt(max);
var primeList = new List<long>();
List<long> searchList = new List<long>();
for (long i = 2; i <= max - 1; i++) {
searchList.Add(i);
}
do {
prime = searchList.First();
primeList.Add(prime);
searchList.RemoveAll(n => n % prime == 0);
} while (prime < sqrtMax);
primeList.AddRange(searchList);
return primeList;
}
// 最小公倍数
public static long Lcm(long a, long b) { return a * b / Gcd(a, b); }
// ユークリッドの互除法
public static long Gcd(long a, long b) {
if (a < b)
return Gcd(b, a);
while (b != 0) {
var remainder = a % b;
a = b;
b = remainder;
}
return a;
}
public static readonly string Yes = "Yes";
public static readonly string YES = "YES";
public static readonly string No = "No";
public static readonly string NO = "NO";
public static readonly string OK = "OK";
public static readonly string NG = "NG";
void Omame() {
long N = cin.nextLong();
long M = cin.nextLong();
List<long> list = new List<long>();
Dictionary<long, long> dic = new Dictionary<long, long>();
for (int i = 0; i < N; i++) {
long A = cin.nextLong();
long B = cin.nextLong();
list.Add(A);
dic.Add(A, B);
}
list.Sort();
long ans = 0;
for (int i = 0; i < N; i++) {
ans += Math.Min(M, dic[list[i]]) * list[i];
M -= Math.Min(M, dic[list[i]]);
if (M == 0) {
break;
}
}
Console.WriteLine(ans);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace cswork {
class Program {
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
i = 0;
return next();
}
public int nextInt() { return int.Parse(next()); }
public long nextLong() { return long.Parse(next()); }
public double nextDouble() { return double.Parse(next()); }
}
public Program() {}
static void Main(string[] args) { new Program().Omame(); }
Scanner cin = new Scanner();
const int MAXIN = 1024;
bool[] used = new bool[MAXIN];
int[] perm = new int[MAXIN];
List<int[]> permList = new List<int[]>();
public void Permutation(int pos, int n, int length) {
if (pos == n) {
permList.Add((int[])perm.Clone());
}
for (int i = 0; i < n; i++) {
if (!used[i]) {
perm[pos] = i;
used[i] = true;
Permutation(pos + 1, n, length);
used[i] = false;
}
}
}
public static List<long> GeneratePrime(long max) {
long prime;
double sqrtMax = Math.Sqrt(max);
var primeList = new List<long>();
List<long> searchList = new List<long>();
for (long i = 2; i <= max - 1; i++) {
searchList.Add(i);
}
do {
prime = searchList.First();
primeList.Add(prime);
searchList.RemoveAll(n => n % prime == 0);
} while (prime < sqrtMax);
primeList.AddRange(searchList);
return primeList;
}
// 最小公倍数
public static long Lcm(long a, long b) { return a * b / Gcd(a, b); }
// ユークリッドの互除法
public static long Gcd(long a, long b) {
if (a < b)
return Gcd(b, a);
while (b != 0) {
var remainder = a % b;
a = b;
b = remainder;
}
return a;
}
public static readonly string Yes = "Yes";
public static readonly string YES = "YES";
public static readonly string No = "No";
public static readonly string NO = "NO";
public static readonly string OK = "OK";
public static readonly string NG = "NG";
void Omame() {
long N = cin.nextLong();
long M = cin.nextLong();
List<long> list = new List<long>();
Dictionary<long, long> dic = new Dictionary<long, long>();
for (int i = 0; i < N; i++) {
long A = cin.nextLong();
long B = cin.nextLong();
if (!dic.ContainsKey(A)) {
list.Add(A);
dic.Add(A, B);
} else {
dic[A] += B;
}
}
list.Sort();
long ans = 0;
for (int i = 0; i < N; i++) {
ans += Math.Min(M, dic[list[i]]) * list[i];
M -= Math.Min(M, dic[list[i]]);
if (M == 0) {
break;
}
}
Console.WriteLine(ans);
}
}
}
|
[["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 0, 7, 8, 196, 0, 57, 15, 241, 0, 111], ["+", 0, 57, 15, 241, 0, 213, 63, 214, 205, 22], ["+", 0, 57, 15, 241, 0, 213, 63, 214, 0, 131], ["+", 0, 57, 15, 241, 0, 213, 63, 214, 141, 22], ["+", 0, 57, 15, 241, 0, 213, 3, 4, 0, 24], ["+", 15, 241, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 57, 15, 241, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 75, 196, 0, 1, 0, 11, 31, 204, 205, 22], ["+", 0, 1, 0, 11, 31, 204, 206, 207, 0, 70], ["+", 0, 11, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 1, 0, 11, 31, 204, 206, 207, 0, 73], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 12, 22], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 822
| 22
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder_solve {
class Program {
public const ulong mod = 1000000007;
static void Main(string[] args) {
var nm = Input3();
var n = nm[0];
var m = nm[1];
var ab = new Dictionary<long, long>();
var a = new long[n];
for (int i = 0; i < n; i++) {
var data = Input3();
if (!ab.ContainsKey(data[0]))
ab.Add(data[0], data[1]);
else
ab[data[0]] += data[1];
a[i] = data[0];
}
Array.Sort(a);
long bought = 0;
long ans = 0;
for (long j = 0; j < n; j++) {
ans += a[j] * Math.Min(m - bought, ab[a[j]]);
bought += Math.Min(m - bought, ab[a[j]]);
if (m - bought == 0)
break;
}
Console.WriteLine(ans);
}
static public long Input() { return long.Parse(Console.ReadLine()); }
static public string[] Input2() { return Console.ReadLine().Split(); }
static public long[] Input3() {
string[] data = Console.ReadLine().Split();
long[] res = new long[data.LongLength];
for (long i = 0; i < data.LongLength; i++) {
res[i] = long.Parse(data[i]);
}
return res;
}
public static long Choose(long n, long a) {
long x = 1;
long y = 1;
for (long i = 0; i < a; i++) {
x *= n - i;
y *= i + 1;
}
return x / y;
}
public static long Gcd(long a, long b) {
long x = Math.Max(a, b);
long y = Math.Min(a, b);
if (x % y == 0)
return y;
else
return Gcd(y, x % y);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder_solve {
class Program {
public const ulong mod = 1000000007;
static void Main(string[] args) {
var nm = Input3();
var n = nm[0];
var m = nm[1];
var ab = new Dictionary<long, long>();
var a = new long[n];
for (int i = 0; i < n; i++) {
var data = Input3();
if (!ab.ContainsKey(data[0]))
ab.Add(data[0], data[1]);
else
ab[data[0]] += data[1];
a[i] = data[0];
}
a = a.Distinct().ToArray();
Array.Sort(a);
long bought = 0;
long ans = 0;
for (long j = 0; j < n; j++) {
ans += a[j] * Math.Min(m - bought, ab[a[j]]);
bought += Math.Min(m - bought, ab[a[j]]);
// Console.WriteLine(bought + " " + ans + " " + a[j]);
if (m - bought == 0)
break;
}
Console.WriteLine(ans);
}
static public long Input() { return long.Parse(Console.ReadLine()); }
static public string[] Input2() { return Console.ReadLine().Split(); }
static public long[] Input3() {
string[] data = Console.ReadLine().Split();
long[] res = new long[data.LongLength];
for (long i = 0; i < data.LongLength; i++) {
res[i] = long.Parse(data[i]);
}
return res;
}
public static long Choose(long n, long a) {
long x = 1;
long y = 1;
for (long i = 0; i < a; i++) {
x *= n - i;
y *= i + 1;
}
return x / y;
}
public static long Gcd(long a, long b) {
long x = Math.Max(a, b);
long y = Math.Min(a, b);
if (x % y == 0)
return y;
else
return Gcd(y, x % y);
}
}
}
|
[["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 12, 213, 63, 214, 205, 213, 63, 214, 205, 22], ["+", 12, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["+", 12, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 12, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["+", 12, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 496
| 12
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace _121c {
class Program {
static void Main(string[] args) {
int[] read = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
Dictionary<long, long> AB = new Dictionary<long, long>();
long[] readLong = new long[2];
for (int i = 0; i < read[0]; i++) {
readLong = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
AB.Add(readLong[0], readLong[1]);
}
var sortrdAB = AB.OrderBy(x => x.Key);
long count = 0;
long sum = 0;
foreach (var tekito in sortrdAB) {
if (count + tekito.Value <= read[1]) {
sum += tekito.Key * tekito.Value;
count += tekito.Value;
} else {
sum += tekito.Key * (read[1] - count);
break;
}
}
Console.WriteLine(sum);
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace _121c {
class Program {
static void Main(string[] args) {
long[] read = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
List<Tuple<long, long>> AB = new List<Tuple<long, long>>();
long[] readLong = new long[2];
for (long i = 0; i < read[0]; i++) {
readLong = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
AB.Add(new Tuple<long, long>(readLong[0], readLong[1]));
}
var sortrdAB = AB.OrderBy(x => x.Item1);
long count = 0;
long sum = 0;
foreach (var tekito in sortrdAB) {
if (count + tekito.Item2 <= read[1]) {
sum += tekito.Item1 * tekito.Item2;
count += tekito.Item2;
} else {
sum += tekito.Item1 * (read[1] - count);
break;
}
}
Console.WriteLine(sum);
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 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, 236, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 39, 236, 141, 22], ["+", 0, 197, 0, 198, 39, 236, 237, 238, 0, 18], ["+", 0, 198, 39, 236, 237, 238, 0, 236, 141, 22], ["+", 39, 236, 237, 238, 0, 236, 237, 238, 0, 47], ["-", 0, 200, 0, 212, 0, 230, 39, 236, 141, 22], ["+", 0, 200, 0, 212, 0, 230, 39, 236, 141, 22], ["+", 0, 212, 0, 230, 39, 236, 237, 238, 0, 18], ["+", 0, 230, 39, 236, 237, 238, 0, 236, 141, 22], ["-", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 0, 213, 3, 4, 0, 28, 0, 230, 0, 228], ["+", 3, 4, 0, 28, 0, 230, 39, 236, 141, 22], ["+", 0, 28, 0, 230, 39, 236, 237, 238, 0, 18], ["+", 0, 28, 0, 230, 39, 236, 237, 238, 0, 199], ["+", 0, 28, 0, 230, 39, 236, 237, 238, 0, 21], ["+", 0, 28, 0, 230, 39, 236, 237, 238, 0, 47], ["+", 3, 4, 0, 28, 0, 230, 3, 4, 0, 24], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 3, 4, 0, 28, 0, 218, 8, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 218, 8, 214, 141, 22], ["-", 0, 57, 15, 16, 31, 16, 12, 214, 141, 22], ["+", 0, 57, 15, 16, 31, 16, 12, 214, 141, 22], ["-", 0, 1, 0, 11, 12, 16, 31, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 214, 141, 22], ["-", 0, 1, 0, 11, 12, 16, 12, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 16, 12, 214, 141, 22], ["-", 64, 196, 0, 1, 0, 11, 12, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 11, 12, 214, 141, 22]]
| 8
| 233
| 37
|
using System;
using System.Collections.Generic;
namespace AtCoderBegginerContest121 {
class Program {
static void Main(string[] args) {
var inptNM = Console.ReadLine().Split(' ');
int N = int.Parse(inptNM[0]);
int M = int.Parse(inptNM[1]);
List<EneDri> EneDriList = new List<EneDri> {};
for (int i = 0; i < N; i++) {
var inpt = Console.ReadLine().Split(' ');
EneDriList.Add(new EneDri(int.Parse(inpt[0]), int.Parse(inpt[1])));
}
EneDriList.Sort(comparison: (a, b) => a.Price - b.Price);
int stockSum = 0;
int priceSum = 0;
foreach (EneDri enedri in EneDriList) {
if (stockSum + enedri.Stock < M) {
priceSum = priceSum + enedri.Price * enedri.Stock;
stockSum = stockSum + enedri.Stock;
} else {
priceSum = priceSum + enedri.Price * (M - stockSum);
break;
}
}
Console.Write(priceSum);
}
}
class EneDri {
public int Price { get; set; }
public int Stock { get; set; }
public EneDri(int price, int stock) {
this.Price = price;
this.Stock = stock;
}
}
}
|
using System;
using System.Collections.Generic;
namespace AtCoderBegginerContest121 {
class Program {
static void Main(string[] args) {
var inptNM = Console.ReadLine().Split(' ');
int N = int.Parse(inptNM[0]);
int M = int.Parse(inptNM[1]);
List<EneDri> EneDriList = new List<EneDri> {};
for (int i = 0; i < N; i++) {
var inpt = Console.ReadLine().Split(' ');
EneDriList.Add(new EneDri(Int64.Parse(inpt[0]), Int64.Parse(inpt[1])));
}
EneDriList.Sort((a, b) => (int)(a.Price - b.Price));
long stockSum = 0;
long priceSum = 0;
foreach (EneDri enedri in EneDriList) {
if (stockSum + enedri.Stock < M) {
priceSum = priceSum + enedri.Price * enedri.Stock;
stockSum = stockSum + enedri.Stock;
} else {
priceSum = priceSum + enedri.Price * (M - stockSum);
break;
}
}
Console.Write(priceSum);
}
}
class EneDri {
public long Price { get; set; }
public long Stock { get; set; }
public EneDri(long price, long stock) {
this.Price = price;
this.Stock = stock;
}
}
}
|
[["-", 3, 4, 0, 28, 0, 213, 63, 214, 205, 199], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["-", 0, 213, 3, 4, 0, 28, 141, 322, 141, 22], ["-", 0, 213, 3, 4, 0, 28, 141, 322, 0, 102], ["+", 3, 4, 0, 28, 0, 218, 8, 74, 0, 24], ["+", 3, 4, 0, 28, 0, 218, 8, 74, 39, 199], ["+", 3, 4, 0, 28, 0, 218, 8, 74, 0, 25], ["+", 0, 28, 0, 218, 8, 74, 51, 23, 0, 24], ["+", 0, 28, 0, 218, 8, 74, 51, 23, 0, 25], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 201, 0, 235, 8, 201, 0, 277, 39, 199], ["+", 8, 201, 0, 235, 8, 201, 0, 277, 39, 199], ["-", 8, 201, 0, 263, 54, 55, 0, 220, 39, 199], ["+", 8, 201, 0, 263, 54, 55, 0, 220, 39, 199]]
| 8
| 289
| 23
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace CompetitiveProgramming {
class Program {
static void Main(string[] args) {
var AB_Array = new List<TwoInt>();
string[] n_m = Console.ReadLine().Split(' ');
int n = int.Parse(n_m[0]);
int m = int.Parse(n_m[1]);
//入力を受け取る
for (var i = 0; i < n; i++) {
string[] A_B = Console.ReadLine().Split(' ');
int a = int.Parse(A_B[0]);
int b = int.Parse(A_B[1]);
var ab = new TwoInt(a, b);
AB_Array.Add(ab);
}
//ソートする
AB_Array = SortTwoIntList(AB_Array);
foreach (var rec in AB_Array) {
Console.WriteLine($"{rec.A},{rec.B}");
}
//計算する
long totalPrice = 0;
for (var i = 0; i < n; i++) {
if (m - AB_Array[i].B >= 0) {
m -= AB_Array[i].B;
totalPrice += (long)AB_Array[i].A * (long)AB_Array[i].B;
} else {
totalPrice += (long)AB_Array[i].A * (long)m;
break;
}
}
Console.WriteLine(totalPrice);
}
static List<TwoInt> SortTwoIntList(List<TwoInt> list) {
IOrderedEnumerable<TwoInt> sortList =
list.OrderBy(rec => rec.A).ThenBy(rec => rec.B);
List<TwoInt> returnValue = sortList.ToList();
return returnValue;
}
}
class TwoInt {
public int A;
public int B;
public TwoInt(int A, int B) {
this.A = A;
this.B = B;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace CompetitiveProgramming {
class Program {
static void Main(string[] args) {
var AB_Array = new List<TwoInt>();
string[] n_m = Console.ReadLine().Split(' ');
int n = int.Parse(n_m[0]);
int m = int.Parse(n_m[1]);
//入力を受け取る
for (var i = 0; i < n; i++) {
string[] A_B = Console.ReadLine().Split(' ');
int a = int.Parse(A_B[0]);
int b = int.Parse(A_B[1]);
var ab = new TwoInt(a, b);
AB_Array.Add(ab);
}
//ソートする
AB_Array = SortTwoIntList(AB_Array);
// foreach(var rec in AB_Array)
//{
// Console.WriteLine($"{rec.A},{rec.B}");
//}
//計算する
long totalPrice = 0;
for (var i = 0; i < n; i++) {
if (m - AB_Array[i].B >= 0) {
m -= AB_Array[i].B;
totalPrice += (long)AB_Array[i].A * (long)AB_Array[i].B;
} else {
totalPrice += (long)AB_Array[i].A * (long)m;
break;
}
}
Console.WriteLine(totalPrice);
}
static List<TwoInt> SortTwoIntList(List<TwoInt> list) {
IOrderedEnumerable<TwoInt> sortList =
list.OrderBy(rec => rec.A).ThenBy(rec => rec.B);
List<TwoInt> returnValue = sortList.ToList();
return returnValue;
}
}
class TwoInt {
public int A;
public int B;
public TwoInt(int A, int B) {
this.A = A;
this.B = B;
}
}
}
|
[["-", 8, 201, 0, 195, 8, 196, 0, 210, 0, 266], ["-", 8, 201, 0, 195, 8, 196, 0, 210, 0, 24], ["-", 0, 195, 8, 196, 0, 210, 39, 216, 0, 217], ["-", 8, 201, 0, 195, 8, 196, 0, 210, 31, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 210, 0, 267], ["-", 8, 201, 0, 195, 8, 196, 0, 210, 12, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 210, 0, 25], ["-", 0, 195, 8, 196, 0, 210, 8, 196, 0, 45], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 213, 3, 4, 0, 28, 0, 283, 0, 295], ["-", 3, 4, 0, 28, 0, 283, 0, 284, 0, 45], ["-", 0, 28, 0, 283, 0, 284, 0, 214, 205, 22], ["-", 0, 28, 0, 283, 0, 284, 0, 214, 0, 131], ["-", 0, 28, 0, 283, 0, 284, 0, 214, 141, 22], ["-", 3, 4, 0, 28, 0, 283, 0, 284, 0, 46], ["-", 0, 213, 3, 4, 0, 28, 0, 283, 0, 296], ["-", 0, 213, 3, 4, 0, 28, 0, 283, 0, 62], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 210, 8, 196, 0, 1, 0, 35], ["-", 0, 195, 8, 196, 0, 210, 8, 196, 0, 46]]
| 8
| 392
| 28
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
var one = cin.ReadLine.Split(' ');
var N = int.Parse(one[0]);
var M = int.Parse(one[1]);
int result = 0;
List<List<int>> set = new List<List<int>>();
for (int i = 0; i < N; i++) {
List<int> setIn = new List<int>();
var two = cin.ReadLine.Split(' ');
setIn.Add(int.Parse(two[0]));
setIn.Add(int.Parse(two[1]));
set.Add(setIn);
}
set = set.OrderBy(x => x[0]).ToList();
foreach (var item in set) {
if (M == 0) {
break;
}
if (M - item[1] > 0) {
result += item[0] * item[1];
M -= item[1];
} else {
result += item[0] * M;
M = 0;
}
}
Console.Write(result);
}
}
public class deci {
public bool IsFinish { get; set; } = false;
public int Len { get; set; }
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
var one = cin.ReadLine.Split(' ');
var N = int.Parse(one[0]);
var M = long.Parse(one[1]);
long result = 0;
List<List<long>> set = new List<List<long>>();
for (int i = 0; i < N; i++) {
List<long> setIn = new List<long>();
var two = cin.ReadLine.Split(' ');
setIn.Add(long.Parse(two[0]));
setIn.Add(long.Parse(two[1]));
set.Add(setIn);
}
set = set.OrderBy(x => x[0]).ToList();
foreach (var item in set) {
if (M == 0) {
break;
}
if (M - item[1] > 0) {
result += (item[0] * item[1]);
M -= item[1];
} else {
result += (item[0] * M);
M = 0;
}
}
Console.Write(result);
}
}
public class deci {
public bool IsFinish { get; set; } = false;
public int Len { get; set; }
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 39, 236, 237, 238, 0, 236, 237, 238, 0, 199], ["+", 39, 236, 237, 238, 0, 236, 237, 238, 0, 199], ["-", 0, 197, 0, 198, 39, 236, 237, 238, 0, 199], ["+", 0, 197, 0, 198, 39, 236, 237, 238, 0, 199], ["-", 0, 212, 0, 230, 39, 236, 237, 238, 0, 199], ["+", 0, 212, 0, 230, 39, 236, 237, 238, 0, 199], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 205, 199], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 205, 199], ["+", 64, 196, 0, 1, 0, 11, 12, 23, 0, 24], ["+", 64, 196, 0, 1, 0, 11, 12, 23, 0, 25], ["+", 75, 196, 0, 1, 0, 11, 12, 23, 0, 24], ["+", 75, 196, 0, 1, 0, 11, 12, 23, 0, 25]]
| 8
| 688
| 20
|
using System;
using System.Collections.Generic;
using System.Linq;
public class Program {
static void Main() {
var nm = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
var abArray = new List<int[]>();
for (int i = 0; i < nm[0]; i++) {
abArray.Add(
Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray());
}
abArray.Sort((a, b) => a[0] - b[0]);
long price = 0;
var need = nm[1];
for (int i = 0; i < nm[0]; i++) {
if (abArray[i][1] > need) {
price += need * abArray[i][0];
need = 0;
} else {
price += abArray[i][1] * (long)abArray[i][0];
need -= abArray[i][1];
}
if (need == 0) {
Console.WriteLine(price);
break;
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
public class Program {
static void Main() {
var nm = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
var abArray = new List<long[]>();
for (int i = 0; i < nm[0]; i++) {
abArray.Add(
Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray());
}
abArray.Sort((a, b) => (int)(a[0] - b[0]));
long price = 0;
var need = nm[1];
for (int i = 0; i < nm[0]; i++) {
if (abArray[i][1] > need) {
price += need * abArray[i][0];
need = 0;
} else {
price += abArray[i][1] * abArray[i][0];
need -= abArray[i][1];
}
if (need == 0) {
Console.WriteLine(price);
break;
}
}
}
}
|
[["-", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["+", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["-", 0, 230, 39, 236, 237, 238, 0, 224, 39, 199], ["+", 0, 230, 39, 236, 237, 238, 0, 224, 39, 199], ["+", 3, 4, 0, 28, 0, 218, 8, 74, 0, 24], ["+", 3, 4, 0, 28, 0, 218, 8, 74, 39, 199], ["+", 3, 4, 0, 28, 0, 218, 8, 74, 0, 25], ["+", 0, 28, 0, 218, 8, 74, 51, 23, 0, 24], ["+", 0, 28, 0, 218, 8, 74, 51, 23, 0, 25], ["-", 0, 1, 0, 11, 12, 16, 12, 74, 0, 24], ["-", 0, 1, 0, 11, 12, 16, 12, 74, 39, 199], ["-", 0, 1, 0, 11, 12, 16, 12, 74, 0, 25]]
| 8
| 253
| 14
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
struct Shop {
public int price;
public int num;
public Shop(int price, int num) {
this.price = price;
this.num = num;
}
}
static void Main(string[] args) {
string[] temp = Console.ReadLine().Split(' ');
int N = int.Parse(temp[0]);
int M = int.Parse(temp[1]);
var list = new List<Shop>();
for (int i = 0; i < N; i++) {
temp = Console.ReadLine().Split(' ');
int price = int.Parse(temp[0]);
int num = int.Parse(temp[1]);
list.Add(new Shop(price, num));
}
list.Sort((a, b) => a.price.CompareTo(b.price));
int ans = 0;
for (int i = 0; i < N; i++) {
if (M >= list[i].num) {
ans += list[i].price * list[i].num;
M -= list[i].num;
} else {
ans += M * list[i].price;
break;
}
}
Console.WriteLine(ans);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
struct Shop {
public double price;
public double num;
public Shop(double price, double num) {
this.price = price;
this.num = num;
}
}
static void Main(string[] args) {
string[] temp = Console.ReadLine().Split(' ');
double N = double.Parse(temp[0]);
double M = double.Parse(temp[1]);
var list = new List<Shop>();
for (int i = 0; i < N; i++) {
temp = Console.ReadLine().Split(' ');
double price = double.Parse(temp[0]);
double num = double.Parse(temp[1]);
list.Add(new Shop(price, num));
}
list.Sort((a, b) => a.price.CompareTo(b.price));
double ans = 0;
for (int i = 0; i < N; i++) {
if (M >= list[i].num) {
ans += list[i].price * list[i].num;
M -= list[i].num;
} else {
ans += M * list[i].price;
break;
}
}
Console.WriteLine(ans);
}
}
|
[["-", 0, 270, 8, 201, 0, 124, 0, 198, 39, 199], ["+", 0, 270, 8, 201, 0, 124, 0, 198, 39, 199], ["-", 8, 201, 0, 263, 54, 55, 0, 220, 39, 199], ["+", 8, 201, 0, 263, 54, 55, 0, 220, 39, 199], ["-", 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], ["-", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199]]
| 8
| 294
| 26
|
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 N = cin.ReadInt;
int M = cin.ReadInt;
var Money = 0;
int count = 0;
List<Info> list = new List<Info>();
for (int i = 0; i < N; i++) {
list.Add(new Info(cin.ReadInt, cin.ReadInt));
}
foreach (var info in list.OrderBy(info => info.Price)) {
if (count + info.Num > M) {
Money += info.Price * (M - count);
break;
}
Money += info.Price * info.Num;
count += info.Num;
}
WriteLine(Money);
}
}
class Info {
public int Price;
public int Num;
public Info(int price, int num) {
this.Price = price;
this.Num = num;
}
}
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) {
long N = cin.ReadLong;
long M = cin.ReadLong;
long Money = 0;
long count = 0;
List<Info> list = new List<Info>();
for (int i = 0; i < N; i++) {
list.Add(new Info(cin.ReadInt, cin.ReadInt));
}
foreach (var info in list.OrderBy(info => info.Price)) {
if (count + info.Num > M) {
Money += info.Price * (M - count);
break;
}
Money += info.Price * info.Num;
count += info.Num;
}
WriteLine(Money);
}
}
class Info {
public long Price;
public long Num;
public Info(long price, long num) {
this.Price = price;
this.Num = num;
}
}
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, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 198, 0, 200, 0, 212, 0, 214, 141, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 141, 22], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 0, 235, 8, 201, 0, 124, 0, 198, 39, 199], ["+", 0, 235, 8, 201, 0, 124, 0, 198, 39, 199], ["-", 8, 201, 0, 263, 54, 55, 0, 220, 39, 199], ["+", 8, 201, 0, 263, 54, 55, 0, 220, 39, 199]]
| 8
| 595
| 20
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
class V {
public int p;
public int m;
}
class Program {
public static void Main() {
int N, M;
string[] strs = Console.ReadLine().Split(' ');
N = int.Parse(strs[0]);
M = int.Parse(strs[1]);
List<V> L = new List<V>() { Capacity = N };
for (int i = 0; i < N; i++) {
strs = Console.ReadLine().Split(' ');
V tmp = new V();
tmp.p = int.Parse(strs[0]);
tmp.m = int.Parse(strs[1]);
L.Add(tmp);
}
L.Sort((x, y) => x.p - y.p);
int price = 0;
for (int i = 0; i < N; i++) {
int c = Math.Min(L[i].m, M);
price += c * L[i].p;
L[i].m -= c;
M -= c;
if (M <= 0)
break;
}
Console.WriteLine(price);
}
}
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
class Program {
class V {
public long p;
public long m;
}
public static void Main() {
long N, M;
string[] strs = Console.ReadLine().Split(' ');
N = long.Parse(strs[0]);
M = long.Parse(strs[1]);
List<V> L = new List<V>() { Capacity = (int)N };
for (int i = 0; i < N; i++) {
strs = Console.ReadLine().Split(' ');
V tmp = new V();
tmp.p = long.Parse(strs[0]);
tmp.m = long.Parse(strs[1]);
L.Add(tmp);
}
L.Sort((x, y) => (int)(x.p - y.p));
long price = 0;
for (int i = 0; i < N;) {
long c = Math.Min(L[i].m, M);
price += c * L[i].p;
L[i].m -= c;
M -= c;
if (M <= 0)
break;
if (L[i].m == 0)
i++;
}
Console.WriteLine(price);
}
}
|
[["+", 36, 36, 36, 36, 0, 208, 0, 235, 141, 22], ["+", 36, 36, 0, 208, 0, 235, 8, 201, 0, 45], ["+", 0, 208, 0, 235, 8, 201, 0, 235, 0, 269], ["-", 0, 235, 8, 201, 0, 124, 0, 198, 39, 199], ["+", 0, 235, 8, 201, 0, 124, 0, 198, 39, 199], ["-", 36, 36, 36, 36, 0, 208, 0, 235, 0, 269], ["-", 36, 36, 36, 36, 0, 208, 0, 235, 141, 22], ["-", 36, 36, 0, 208, 0, 235, 8, 201, 0, 45], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 1, 0, 11, 12, 213, 63, 214, 205, 199], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 205, 199], ["+", 0, 230, 10, 229, 0, 11, 12, 74, 0, 24], ["+", 0, 230, 10, 229, 0, 11, 12, 74, 39, 199], ["+", 0, 230, 10, 229, 0, 11, 12, 74, 0, 25], ["+", 3, 4, 0, 28, 0, 218, 8, 74, 0, 24], ["+", 3, 4, 0, 28, 0, 218, 8, 74, 39, 199], ["+", 3, 4, 0, 28, 0, 218, 8, 74, 0, 25], ["+", 0, 28, 0, 218, 8, 74, 51, 23, 0, 24], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 0, 195, 8, 196, 0, 7, 26, 223, 0, 22], ["-", 0, 195, 8, 196, 0, 7, 26, 223, 0, 29], ["-", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 7, 8, 196, 0, 57, 64, 93, 0, 35], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 0, 57, 15, 16, 31, 214, 205, 204, 205, 22], ["+", 15, 16, 31, 214, 205, 204, 206, 207, 0, 70], ["+", 31, 214, 205, 204, 206, 207, 0, 28, 0, 22], ["+", 15, 16, 31, 214, 205, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 0, 131], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 141, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 223, 0, 22], ["+", 8, 196, 0, 57, 64, 1, 0, 223, 0, 29]]
| 8
| 280
| 48
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
int n = s[0];
int m = s[1];
int[][] ab = new int [n][];
for (int i = 0; i < n; i++) {
ab[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
}
Array.Sort(ab, (a, b) => a[0] - b[0]);
long sum = 0;
for (int i = 0; i < n; i++) {
sum += long.Parse(ab[i][0].ToString()) * long.Parse(ab[i][1].ToString());
m -= ab[i][1];
if (m < 0) {
while (m <= 0) {
sum -= ab[i][0];
m++;
}
}
if (m == 0)
break;
}
Console.WriteLine(sum);
}
}
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
int n = s[0];
int m = s[1];
int[][] ab = new int [n][];
for (int i = 0; i < n; i++) {
ab[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
}
Array.Sort(ab, (a, b) => a[0] - b[0]);
long sum = 0;
for (int i = 0; i < n; i++) {
sum += (long)ab[i][0] * (long)ab[i][1];
m -= ab[i][1];
if (m < 0) {
while (m < 0) {
sum -= ab[i][0];
m++;
}
}
if (m == 0)
break;
}
Console.WriteLine(sum);
}
}
|
[["-", 0, 11, 12, 16, 31, 213, 63, 214, 205, 199], ["-", 0, 11, 12, 16, 31, 213, 63, 214, 0, 131], ["-", 0, 11, 12, 16, 31, 213, 63, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 74, 39, 199], ["+", 0, 1, 0, 11, 12, 16, 31, 74, 0, 25], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["-", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["-", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25], ["-", 0, 11, 12, 16, 31, 213, 3, 4, 0, 25], ["-", 0, 11, 12, 16, 12, 213, 63, 214, 205, 199], ["-", 0, 11, 12, 16, 12, 213, 63, 214, 0, 131], ["-", 0, 11, 12, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 16, 12, 74, 39, 199], ["+", 0, 1, 0, 11, 12, 16, 12, 74, 0, 25], ["-", 0, 11, 12, 16, 12, 213, 3, 4, 0, 25], ["-", 0, 57, 64, 196, 0, 52, 15, 16, 17, 19], ["+", 0, 57, 64, 196, 0, 52, 15, 16, 17, 18]]
| 8
| 256
| 22
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace CSharpSample01 {
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
int N = int.Parse(str[0]);
int M = int.Parse(str[1]);
long cost = 0;
long drinkcnt = 0;
var dic = new Dictionary<int, int>();
for (int i = 0; i < N; i++) {
str = Console.ReadLine().Split(' ');
int a = int.Parse(str[0]);
int b = int.Parse(str[1]);
dic[a] = b;
}
var dic_sort =
dic.OrderBy(s => s.Key).ToDictionary(s => s.Key, s => s.Value);
foreach (var s in dic_sort) {
long price = s.Key;
long limit = s.Value;
if (drinkcnt + limit >= M) {
if (drinkcnt + limit > M) {
cost += price * (M - drinkcnt);
} else {
cost += price * limit;
}
break;
} else {
cost += price * limit;
drinkcnt += limit;
}
}
Console.WriteLine(cost);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace CSharpSample01 {
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
int N = int.Parse(str[0]);
int M = int.Parse(str[1]);
long cost = 0;
long drinkcnt = 0;
var dic = new Dictionary<long, long>();
for (int i = 0; i < N; i++) {
str = Console.ReadLine().Split(' ');
long a = int.Parse(str[0]);
long b = int.Parse(str[1]);
if (dic.ContainsKey(a)) {
dic[a] += b;
} else {
dic[a] = b;
}
}
var dic_sort =
dic.OrderBy(s => s.Key).ToDictionary(s => s.Key, s => s.Value);
foreach (var s in dic_sort) {
long price = s.Key;
long limit = s.Value;
if (drinkcnt + limit >= M) {
if (drinkcnt + limit > M) {
cost += price * (M - drinkcnt);
} else {
cost += price * limit;
}
break;
} else {
cost += price * limit;
drinkcnt += limit;
}
}
Console.WriteLine(cost);
}
}
}
|
[["-", 0, 212, 0, 230, 39, 236, 237, 238, 0, 199], ["+", 0, 212, 0, 230, 39, 236, 237, 238, 0, 199], ["-", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 57, 15, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 57, 15, 213, 3, 4, 0, 24], ["+", 0, 57, 15, 213, 3, 4, 0, 28, 0, 22], ["+", 8, 196, 0, 57, 15, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 11, 31, 204, 205, 22], ["+", 0, 1, 0, 11, 31, 204, 206, 207, 0, 70], ["+", 0, 11, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 1, 0, 11, 31, 204, 206, 207, 0, 73], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 75, 196, 0, 1, 0, 11, 31, 204, 205, 22], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 278
| 29
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace CSTest {
class Program {
static void Main(string[] args) {
var strings = Console.ReadLine().Split(' ');
var N = int.Parse(strings[0]);
var M = int.Parse(strings[1]);
var list = new List<Set>();
for (int i = 0; i < N; i++) {
strings = Console.ReadLine().Split(' ');
list.Add(new Set { Yen = int.Parse(strings[0]),
Count = int.Parse(strings[1]) });
}
int money = 0;
int drinkCount = 0;
foreach (var val in list.OrderBy(val => val.Yen)) {
int count = Math.Min(M - drinkCount, val.Count);
money += val.Yen * count;
drinkCount += count;
if (drinkCount >= M)
break;
}
Console.WriteLine(money);
}
}
class Set {
public int Yen { get; set; }
public int Count { get; set; }
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace CSTest {
class Program {
static void Main(string[] args) {
var strings = Console.ReadLine().Split(' ');
var N = int.Parse(strings[0]);
var M = int.Parse(strings[1]);
var list = new List<Set>();
for (int i = 0; i < N; i++) {
strings = Console.ReadLine().Split(' ');
list.Add(new Set { Yen = long.Parse(strings[0]),
Count = long.Parse(strings[1]) });
}
long money = 0;
long drinkCount = 0;
foreach (var val in list.OrderBy(val => val.Yen)) {
long count = Math.Min(M - drinkCount, val.Count);
money += val.Yen * count;
drinkCount += count;
if (drinkCount >= M)
break;
}
Console.WriteLine(money);
}
}
class Set {
public long Yen { get; set; }
public long Count { get; set; }
}
}
|
[["-", 10, 229, 0, 11, 12, 213, 63, 214, 205, 199], ["+", 10, 229, 0, 11, 12, 213, 63, 214, 205, 199], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 210, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 210, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 201, 0, 235, 8, 201, 0, 277, 39, 199], ["+", 8, 201, 0, 235, 8, 201, 0, 277, 39, 199]]
| 8
| 244
| 14
|
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;
namespace ABC121D {
class Program {
static void Main(string[] args) {
var A = ReadLong - 1;
var B = ReadLong;
long aXor = xorSum(A);
long bXor = xorSum(B);
// Console.WriteLine(aXor);
// Console.WriteLine(bXor);
Console.WriteLine(bXor ^ aXor);
}
static public long xorSum(long a) {
if (a % 2 == 0) {
return a + (a / 2) % 2;
} else {
return (a / 2) % 2 == 0 ? 1 : 0;
}
}
}
}
namespace Assistant {
static class Input {
static List<string> line = new List<string>();
static int index = 0;
static String ReadNext() {
if (line.Count <= index)
line.AddRange(Console.ReadLine().Split());
return line[index++];
}
public static int ReadInt => int.Parse(ReadNext());
public static long ReadLong => long.Parse(ReadNext());
public static int[] ReadInts =>
Console.ReadLine().Split().Select(int.Parse).ToArray();
public static long[] NextLongs =>
Console.ReadLine().Split().Select(long.Parse).ToArray();
}
static class Debug {
static public void Draw2D(int[,] map, int mode = 1) {
#if DEBUG
int W = map.GetLength(0);
int H = map.GetLength(1);
int[,] map2 = new int[W + 1, H + 1];
for (int i = 0; i < W + 1; i++) {
for (int j = 0; j < H + 1; j++) {
if (i == 0 && j == 0)
map2[i, j] = 0;
else if (i == 0)
map2[i, j] = j - 1;
else if (j == 0)
map2[i, j] = i - 1;
else
map2[i, j] = map[i - 1, j - 1];
}
}
for (int i = 0; i < W + 1; i++) {
for (int j = 0; j < H + 1; j++) {
if (mode == 0)
Console.Write(map2[i, j] % 10);
if (mode == 1)
Console.Write(map2[i, j] + " ");
}
Console.WriteLine();
}
Console.WriteLine();
#endif
}
static void Draw1D(int[] array, int mode = 0) {
#if DEBUG
Console.WriteLine(string.Join(" ", array));
#endif
}
}
}
|
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;
namespace ABC121D {
class Program {
static void Main(string[] args) {
var A = ReadLong - 1;
if (A < 0)
A = 0;
var B = ReadLong;
long aXor = xorSum(A);
long bXor = xorSum(B);
// Console.WriteLine(aXor);
// Console.WriteLine(bXor);
Console.WriteLine(bXor ^ aXor);
}
static public long xorSum(long a) {
if (a % 2 == 0) {
return a + (a / 2) % 2;
} else {
return (a / 2) % 2 == 0 ? 1 : 0;
}
}
}
}
namespace Assistant {
static class Input {
static List<string> line = new List<string>();
static int index = 0;
static String ReadNext() {
if (line.Count <= index)
line.AddRange(Console.ReadLine().Split());
return line[index++];
}
public static int ReadInt => int.Parse(ReadNext());
public static long ReadLong => long.Parse(ReadNext());
public static int[] ReadInts =>
Console.ReadLine().Split().Select(int.Parse).ToArray();
public static long[] NextLongs =>
Console.ReadLine().Split().Select(long.Parse).ToArray();
}
static class Debug {
static public void Draw2D(int[,] map, int mode = 1) {
#if DEBUG
int W = map.GetLength(0);
int H = map.GetLength(1);
int[,] map2 = new int[W + 1, H + 1];
for (int i = 0; i < W + 1; i++) {
for (int j = 0; j < H + 1; j++) {
if (i == 0 && j == 0)
map2[i, j] = 0;
else if (i == 0)
map2[i, j] = j - 1;
else if (j == 0)
map2[i, j] = i - 1;
else
map2[i, j] = map[i - 1, j - 1];
}
}
for (int i = 0; i < W + 1; i++) {
for (int j = 0; j < H + 1; j++) {
if (mode == 0)
Console.Write(map2[i, j] % 10);
if (mode == 1)
Console.Write(map2[i, j] + " ");
}
Console.WriteLine();
}
Console.WriteLine();
#endif
}
static void Draw1D(int[] array, int mode = 0) {
#if DEBUG
Console.WriteLine(string.Join(" ", array));
#endif
}
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35]]
| 8
| 591
| 10
|
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) {
//問題クラスを展開
ProgramD a = new ProgramD();
a.main(); //実行する
}
}
class ProgramA {
public void main() {
//入力
string[] s = Console.ReadLine().Split(' ');
string[] t = Console.ReadLine().Split(' ');
Console.WriteLine(
int.Parse(s[0]) * int.Parse(s[1]) - int.Parse(s[0]) * int.Parse(t[1]) -
int.Parse(s[1]) * int.Parse(t[0]) + int.Parse(t[1]) * int.Parse(t[0]));
}
}
class ProgramB {
public void main() {
//入力
string[] s = Console.ReadLine().Split(' ');
int n = int.Parse(s[0]);
int m = int.Parse(s[1]);
int c = int.Parse(s[2]);
int count = 0;
string[] b = Console.ReadLine().Split(' ');
for (int i = 0; i < n; i++) {
string[] a = Console.ReadLine().Split(' ');
int sum = c;
for (int j = 0; j < m; j++)
sum += int.Parse(a[j]) * int.Parse(b[j]);
if (sum > 0)
count++;
}
//答え出力
Console.WriteLine(count);
}
}
class ProgramC {
public void main() {
//入力
string[] ss = Console.ReadLine().Split(' ');
int n = int.Parse(ss[0]);
long m = long.Parse(ss[1]);
// i文字目までにACが何個あるか記録する
int[] AC = new int[n + 1];
int count = 0;
List<Task> list = new List<Task>();
for (int i = 0; i < n; i++) {
string[] s = Console.ReadLine().Split(' ');
list.Add(new Task(long.Parse(s[0]), long.Parse(s[1])));
}
var sort = list.OrderBy(x => x.a);
long ans = 0;
foreach (var s in sort) {
if (m > s.b) {
ans += s.a * s.b;
m -= s.b;
} else {
ans += s.a * m;
break;
}
}
Console.WriteLine(ans);
}
}
class Task {
public long a;
public long b;
public Task(long a, long b) {
this.a = a;
this.b = b;
}
}
class ProgramD {
public void main() {
//入力
string[] s = Console.ReadLine().Split(' ');
long a = long.Parse(s[0]);
long b = long.Parse(s[1]);
// F(A,B) は F(0,A-1)とF(0,B)との排他的論理和(よってF(0,n)を考える)
//排他的論理和はどっからでも足してよい。また任意の偶数nにおいてnとn+1の排他的論理和は1である。
long ta = 0;
long tb = 0;
// a-1を出す
if ((a - 1) % 2 == 1) {
if ((a / 2) % 2 == 1)
ta = 1;
} else {
if (((a - 1) / 2) % 2 == 1)
ta = a;
else
ta = a - 1;
}
// bを出す
if (b % 2 == 1) {
if (((b + 1) / 2) % 2 == 1)
tb = 1;
} else {
if ((b / 2) % 2 == 1)
tb = b + 1;
else
tb = b;
}
// taとtbの排他的論理和を求める
long ans = (ta ^ tb);
//答え出力
Console.WriteLine(ans);
}
}
}
|
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) {
//問題クラスを展開
ProgramD a = new ProgramD();
a.main(); //実行する
}
}
class ProgramA {
public void main() {
//入力
string[] s = Console.ReadLine().Split(' ');
string[] t = Console.ReadLine().Split(' ');
Console.WriteLine(
int.Parse(s[0]) * int.Parse(s[1]) - int.Parse(s[0]) * int.Parse(t[1]) -
int.Parse(s[1]) * int.Parse(t[0]) + int.Parse(t[1]) * int.Parse(t[0]));
}
}
class ProgramB {
public void main() {
//入力
string[] s = Console.ReadLine().Split(' ');
int n = int.Parse(s[0]);
int m = int.Parse(s[1]);
int c = int.Parse(s[2]);
int count = 0;
string[] b = Console.ReadLine().Split(' ');
for (int i = 0; i < n; i++) {
string[] a = Console.ReadLine().Split(' ');
int sum = c;
for (int j = 0; j < m; j++)
sum += int.Parse(a[j]) * int.Parse(b[j]);
if (sum > 0)
count++;
}
//答え出力
Console.WriteLine(count);
}
}
class ProgramC {
public void main() {
//入力
string[] ss = Console.ReadLine().Split(' ');
int n = int.Parse(ss[0]);
long m = long.Parse(ss[1]);
// i文字目までにACが何個あるか記録する
int[] AC = new int[n + 1];
int count = 0;
List<Task> list = new List<Task>();
for (int i = 0; i < n; i++) {
string[] s = Console.ReadLine().Split(' ');
list.Add(new Task(long.Parse(s[0]), long.Parse(s[1])));
}
var sort = list.OrderBy(x => x.a);
long ans = 0;
foreach (var s in sort) {
if (m > s.b) {
ans += s.a * s.b;
m -= s.b;
} else {
ans += s.a * m;
break;
}
}
Console.WriteLine(ans);
}
}
class Task {
public long a;
public long b;
public Task(long a, long b) {
this.a = a;
this.b = b;
}
}
class ProgramD {
public void main() {
//入力
string[] s = Console.ReadLine().Split(' ');
long a = long.Parse(s[0]);
long b = long.Parse(s[1]);
// F(A,B) は F(0,A-1)とF(0,B)との排他的論理和(よってF(0,n)を考える)
//排他的論理和はどっからでも足してよい。また任意の偶数nにおいてnとn+1の排他的論理和は1である。
if (a == 0 && b == 0) {
Console.WriteLine("0");
return;
}
if (a == 0) {
}
long ta = 0;
long tb = 0;
// a-1を出す
if (a == 0) {
} else if ((a - 1) % 2 == 1) {
if ((a / 2) % 2 == 1)
ta = 1;
} else {
if (((a - 1) / 2) % 2 == 1)
ta = a;
else
ta = a - 1;
}
// bを出す
if (b % 2 == 1) {
if (((b + 1) / 2) % 2 == 1)
tb = 1;
} else {
if ((b / 2) % 2 == 1)
tb = b + 1;
else
tb = b;
}
// taとtbの排他的論理和を求める
long ans = (ta ^ tb);
//答え出力
Console.WriteLine(ans);
}
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 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, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95]]
| 8
| 847
| 40
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace D {
public class Program {
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
public static void Solve() {
var ab = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
Console.WriteLine(F(ab[0], ab[1]));
}
static long F(long l, long r) {
var diff = r - l + 1;
if (diff % 2 == 0)
return r ^ F(l, r - 1);
else
return r ^ ((diff / 2) % 2);
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace D {
public class Program {
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
public static void Solve() {
var ab = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
Console.WriteLine(F(ab[0], ab[1]));
}
static long F(long l, long r) {
if (l % 2 == 0) {
var diff = r - l + 1;
if (diff % 2 == 0)
return F(l, r - 1) ^ r;
else
return ((diff / 2) % 2) ^ r;
} else {
return l ^ F(l + 1, r - 1) ^ r;
}
}
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 8, 196, 0, 57, 64, 37, 0, 16, 31, 22], ["-", 8, 196, 0, 57, 64, 37, 0, 16, 17, 140], ["+", 64, 196, 0, 57, 64, 37, 0, 16, 17, 140], ["+", 64, 196, 0, 57, 64, 37, 0, 16, 12, 22], ["-", 8, 196, 0, 57, 75, 37, 0, 16, 31, 22], ["-", 8, 196, 0, 57, 75, 37, 0, 16, 17, 140], ["+", 64, 196, 0, 57, 75, 37, 0, 16, 17, 140], ["+", 64, 196, 0, 57, 75, 37, 0, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 8, 196, 0, 57, 75, 196, 0, 37, 0, 38], ["+", 75, 196, 0, 37, 0, 16, 31, 16, 31, 22], ["+", 75, 196, 0, 37, 0, 16, 31, 16, 17, 140], ["+", 0, 37, 0, 16, 31, 16, 12, 213, 63, 22], ["+", 0, 16, 31, 16, 12, 213, 3, 4, 0, 24], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 0, 16, 31, 16, 12, 213, 3, 4, 0, 21], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 0, 16, 31, 16, 12, 213, 3, 4, 0, 25], ["+", 0, 57, 75, 196, 0, 37, 0, 16, 17, 140], ["+", 0, 57, 75, 196, 0, 37, 0, 16, 12, 22], ["+", 8, 196, 0, 57, 75, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 194
| 37
|
using System.Collections;
using System.Text;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System;
using System.Numerics;
class Program {
#region Reader
// static Vector2Int ReadVec2Int
//{
// get
// {
// string[] s = Console.ReadLine().Split(' ');
// return new Vector2Int(int.Parse(s[0]), int.Parse(s[1]));
// }
//}
// static Vector2Int[] ReadVec2Ints(int n)
//{
// List<Vector2Int> list = new List<Vector2Int>();
// for (int i = 0; i < n; ++i)
// {
// var ab = ReadInts;
// list.Add(new Vector2Int(ab[0], ab[1]));
// }
// return list.ToArray();
//}
// static HashSet<Vector2Int> ReadVec2IntHash(int n)
//{
// HashSet<Vector2Int> hash = new HashSet<Vector2Int>();
// for (int i = 0; i < n; ++i)
// {
// var ab = ReadInts;
// hash.Add(new Vector2Int(ab[0], ab[1]));
// }
// return hash;
//}
static string ReadStr => Console.ReadLine();
static string[] ReadStrs => Console.ReadLine().Split(' ');
static int ReadInt => Convert.ToInt32(Console.ReadLine());
static int[] ReadInts =>
Console.ReadLine().Split(' ').Select(s => Convert.ToInt32(s)).ToArray();
static long ReadLong => Convert.ToInt64(Console.ReadLine());
static long[] ReadLongs =>
Console.ReadLine().Split(' ').Select(s => Convert.ToInt64(s)).ToArray();
static long[,] ReLongMatrix(int r, int c) {
var mat = new long[r, c];
for (int i = 0; i < r; ++i) {
var x = ReadLongs;
for (int j = 0; j < c; ++j) {
mat[i, j] = x[j];
}
}
return mat;
}
static Tuple<string, string>[] ReTupleStr(int n) {
List<Tuple<string, string>> list = new List<Tuple<string, string>>();
for (int i = 0; i < n; ++i) {
var ab = ReadStrs;
list.Add(new Tuple<string, string>(ab[0], ab[1]));
}
return list.ToArray();
}
static Tuple<long, long>[] ReTupleLong(int n) {
List<Tuple<long, long>> list = new List<Tuple<long, long>>();
for (int i = 0; i < n; ++i) {
var ab = ReadLongs;
list.Add(new Tuple<long, long>(ab[0], ab[1]));
}
return list.ToArray();
}
static Tuple<int, int>[] ReadTupleInt(int n) {
List<Tuple<int, int>> list = new List<Tuple<int, int>>();
for (int i = 0; i < n; ++i) {
var ab = ReadInts;
list.Add(new Tuple<int, int>(ab[0], ab[1]));
}
return list.ToArray();
}
static Tuple<double, double>[] ReTupleDouble(int n) {
List<Tuple<double, double>> list = new List<Tuple<double, double>>();
for (int i = 0; i < n; ++i) {
var ab = ReadLongs;
list.Add(new Tuple<double, double>(ab[0], ab[1]));
}
return list.ToArray();
}
static Dictionary<int, HashSet<int>> ReAdjacencyList(int N, int M) {
Dictionary<int, HashSet<int>> dict = new Dictionary<int, HashSet<int>>();
for (int i = 0; i <= N; ++i) {
dict.Add(i, new HashSet<int>());
}
for (int i = 0; i < M; ++i) {
var ab = ReadInts;
dict[ab[0]].Add(ab[1]);
dict[ab[1]].Add(ab[0]);
}
return dict;
}
#endregion
static void Swap<T>(ref T a, ref T b) {
T temp = a;
a = b;
b = temp;
}
static int mod = (int)Pow(10, 9) + 7;
public static long GetInv(long a, long mod = 1000000007) {
return PowerMod(a, mod - 2, mod);
}
public static long Combination(long a, long b, long mod = 1000000007) {
if (b < 0 || b > a)
return 0;
if (b > a / 2)
b = a - b;
long numerator = Factorial(a, mod);
long denominator = (Factorial(b, mod) * Factorial(a - b, mod)) % mod;
return (numerator * GetInv(denominator, mod)) % mod;
}
public static long Factorial(long n, long mod = 1000000007) {
if (n == 0)
return 1;
if (n == 1)
return 1;
long ans = n;
for (int i = 2; i < n; i++) {
ans = (ans * i) % mod;
}
return ans;
}
private static long PowerMod(long a, long n, long mod = 1000000007) {
if (n == 0)
return 1;
if (n == 1)
return a;
long p = PowerMod(a, n / 2, mod);
if (n % 2 == 1)
return ((p * p) % mod * a) % mod;
else
return (p * p) % mod;
}
static void Main() {
long[] AB = ReadLongs;
long A = AB[0] - 1;
long B = AB[1];
int digitA = (int)Log(A, 2) + 1;
int digitB = (int)Log(B, 2) + 1;
int digit = Max(digitA, digitB);
long[] num2A = new long[digit];
long[] num2B = new long[digit];
for (int i = 0; i < digitA; i++) {
num2A[i] = ((A + 1) / (long)Pow(2, i + 1)) * (long)Pow(2, i) +
Max(((A + 1) % (long)Pow(2, i + 1)) - (long)Pow(2, i), 0);
}
for (int i = 0; i < digitB; i++) {
long k21 = (long)Pow(2, i + 1);
long k2 = (long)Pow(2, i);
num2B[i] = ((B + 1) / k21) * k2 + Max(((B + 1) % k21) - k2, 0);
}
long ans = 0;
for (int i = 0; i < digit; i++) {
ans += ((num2B[i] - num2A[i]) % 2) * (long)Pow(2, i);
}
WriteLine(ans);
}
}
|
using System.Collections;
using System.Text;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System;
using System.Numerics;
class Program {
#region Reader
// static Vector2Int ReadVec2Int
//{
// get
// {
// string[] s = Console.ReadLine().Split(' ');
// return new Vector2Int(int.Parse(s[0]), int.Parse(s[1]));
// }
//}
// static Vector2Int[] ReadVec2Ints(int n)
//{
// List<Vector2Int> list = new List<Vector2Int>();
// for (int i = 0; i < n; ++i)
// {
// var ab = ReadInts;
// list.Add(new Vector2Int(ab[0], ab[1]));
// }
// return list.ToArray();
//}
// static HashSet<Vector2Int> ReadVec2IntHash(int n)
//{
// HashSet<Vector2Int> hash = new HashSet<Vector2Int>();
// for (int i = 0; i < n; ++i)
// {
// var ab = ReadInts;
// hash.Add(new Vector2Int(ab[0], ab[1]));
// }
// return hash;
//}
static string ReadStr => Console.ReadLine();
static string[] ReadStrs => Console.ReadLine().Split(' ');
static int ReadInt => Convert.ToInt32(Console.ReadLine());
static int[] ReadInts =>
Console.ReadLine().Split(' ').Select(s => Convert.ToInt32(s)).ToArray();
static long ReadLong => Convert.ToInt64(Console.ReadLine());
static long[] ReadLongs =>
Console.ReadLine().Split(' ').Select(s => Convert.ToInt64(s)).ToArray();
static long[,] ReLongMatrix(int r, int c) {
var mat = new long[r, c];
for (int i = 0; i < r; ++i) {
var x = ReadLongs;
for (int j = 0; j < c; ++j) {
mat[i, j] = x[j];
}
}
return mat;
}
static Tuple<string, string>[] ReTupleStr(int n) {
List<Tuple<string, string>> list = new List<Tuple<string, string>>();
for (int i = 0; i < n; ++i) {
var ab = ReadStrs;
list.Add(new Tuple<string, string>(ab[0], ab[1]));
}
return list.ToArray();
}
static Tuple<long, long>[] ReTupleLong(int n) {
List<Tuple<long, long>> list = new List<Tuple<long, long>>();
for (int i = 0; i < n; ++i) {
var ab = ReadLongs;
list.Add(new Tuple<long, long>(ab[0], ab[1]));
}
return list.ToArray();
}
static Tuple<int, int>[] ReadTupleInt(int n) {
List<Tuple<int, int>> list = new List<Tuple<int, int>>();
for (int i = 0; i < n; ++i) {
var ab = ReadInts;
list.Add(new Tuple<int, int>(ab[0], ab[1]));
}
return list.ToArray();
}
static Tuple<double, double>[] ReTupleDouble(int n) {
List<Tuple<double, double>> list = new List<Tuple<double, double>>();
for (int i = 0; i < n; ++i) {
var ab = ReadLongs;
list.Add(new Tuple<double, double>(ab[0], ab[1]));
}
return list.ToArray();
}
static Dictionary<int, HashSet<int>> ReAdjacencyList(int N, int M) {
Dictionary<int, HashSet<int>> dict = new Dictionary<int, HashSet<int>>();
for (int i = 0; i <= N; ++i) {
dict.Add(i, new HashSet<int>());
}
for (int i = 0; i < M; ++i) {
var ab = ReadInts;
dict[ab[0]].Add(ab[1]);
dict[ab[1]].Add(ab[0]);
}
return dict;
}
#endregion
static void Swap<T>(ref T a, ref T b) {
T temp = a;
a = b;
b = temp;
}
static int mod = (int)Pow(10, 9) + 7;
public static long GetInv(long a, long mod = 1000000007) {
return PowerMod(a, mod - 2, mod);
}
public static long Combination(long a, long b, long mod = 1000000007) {
if (b < 0 || b > a)
return 0;
if (b > a / 2)
b = a - b;
long numerator = Factorial(a, mod);
long denominator = (Factorial(b, mod) * Factorial(a - b, mod)) % mod;
return (numerator * GetInv(denominator, mod)) % mod;
}
public static long Factorial(long n, long mod = 1000000007) {
if (n == 0)
return 1;
if (n == 1)
return 1;
long ans = n;
for (int i = 2; i < n; i++) {
ans = (ans * i) % mod;
}
return ans;
}
private static long PowerMod(long a, long n, long mod = 1000000007) {
if (n == 0)
return 1;
if (n == 1)
return a;
long p = PowerMod(a, n / 2, mod);
if (n % 2 == 1)
return ((p * p) % mod * a) % mod;
else
return (p * p) % mod;
}
static void Main() {
long[] AB = ReadLongs;
long A = Max(0, AB[0] - 1);
long B = AB[1];
if (B == 0) {
WriteLine(0);
return;
}
int digitA = (int)Log(A, 2) + 1;
int digitB = (int)Log(B, 2) + 1;
int digit = Max(digitA, digitB);
long[] num2A = new long[digit];
long[] num2B = new long[digit];
for (int i = 0; i < digitA; i++) {
num2A[i] = ((A + 1) / (long)Pow(2, i + 1)) * (long)Pow(2, i) +
Max(((A + 1) % (long)Pow(2, i + 1)) - (long)Pow(2, i), 0);
}
for (int i = 0; i < digitB; i++) {
long k21 = (long)Pow(2, i + 1);
long k2 = (long)Pow(2, i);
num2B[i] = ((B + 1) / k21) * k2 + Max(((B + 1) % k21) - k2, 0);
}
long ans = 0;
for (int i = 0; i < digit; i++) {
ans += ((num2B[i] - num2A[i]) % 2) * (long)Pow(2, i);
}
WriteLine(ans);
}
}
|
[["+", 0, 198, 0, 200, 0, 212, 0, 213, 63, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["+", 0, 212, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 21], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 213, 63, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 1,419
| 20
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;
public class Hello {
static public int mod = 1000000007;
public static void Main() {
// 方針
//
long[] n = longa();
var xorlist = new List<long>();
if (n[0] != n[1] && n[0] % 2 == 1) {
xorlist.Add(n[0]);
n[0]++;
}
if (n[0] != n[1] && n[1] % 2 == 0) {
xorlist.Add(n[1]);
n[1]--;
}
long sa = (n[1] - n[0] + 1) / 2;
if (sa % 2 == 1)
xorlist.Add(1);
if (xorlist.Count == 0)
xorlist.Add(n[0]);
long ans = 0;
foreach (var k in xorlist) {
ans = ans ^ k;
}
WriteLine(ans);
}
static void unionfind(ref int[] uni, int a, int b) {
var memo = new List<int>();
memo.Add(a);
memo.Add(b);
int min = Min(a, b);
while (uni[a] != a) {
a = uni[a];
memo.Add(a);
}
while (uni[b] != b) {
b = uni[b];
memo.Add(b);
}
min = Min(min, a);
min = Min(min, b);
foreach (var k in memo) {
uni[k] = min;
}
}
static int unionfind2(ref int[] uni, int a) {
var memo = new List<int>();
memo.Add(a);
while (uni[a] != a) {
a = uni[a];
memo.Add(a);
}
foreach (var k in memo) {
uni[k] = a;
}
return a;
}
static int binarysearchd(int[] a, int b) {
int leng = a.Length;
int min = 0;
int max = leng - 1;
while (max - min > 1) {
int mid = (min + max) / 2;
if (a[mid] < b) {
min = mid;
} else {
max = mid;
}
}
if (a[0] >= b) {
return 0;
} else if (a[leng - 1] < b) {
return leng;
} else {
if (a[max] < b) {
return max + 1;
}
return min + 1;
}
}
static int binarysearchu(int[] a, int b) {
int leng = a.Length;
int min = 0;
int max = leng - 1;
while (max - min > 1) {
int mid = (min + max) / 2;
if (a[mid] < b) {
min = mid;
} else {
max = mid;
}
}
if (a[0] > b) {
return leng;
} else if (a[leng - 1] <= b) {
return 0;
} else {
if (a[max] <= b) {
return leng - (max + 1);
}
return leng - (min + 1);
}
}
// 1からaまでの数字並べ替え全通り返すやつ
static List<string> permutation(int a) {
var list = new List<string>();
if (a == 1) {
list.Add("1");
return list;
} else {
foreach (var k in permutation(a - 1)) {
var ch = k.ToCharArray();
for (int i = 0; i <= ch.Length; i++) {
string intemp = "";
if (i == 0) {
intemp += a.ToString();
}
for (int j = 0; j < ch.Length; j++) {
intemp += ch[j].ToString();
if (i == j + 1) {
intemp += a.ToString();
}
}
list.Add(intemp);
}
}
}
return list;
}
static void swap(ref int a, ref int b) {
int temp = a;
a = b;
b = temp;
}
static void charswap(ref char a, ref char b) {
char temp = a;
a = b;
b = temp;
}
static int ncr(int n, int r) {
r = Min(r, n - r);
long nn = 1;
for (int i = n - r + 1; i <= n; i++) {
nn = nn * i % mod;
}
long rr = 1;
for (int i = 1; i <= r; i++) {
rr = rr * i % mod;
}
rr = square((int)rr, mod - 2);
nn = nn * rr % mod;
return (int)nn;
}
// 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;
}
//各種読取
static string rstr() { return ReadLine(); }
static int rint() { return int.Parse(ReadLine()); }
static long rlong() { return long.Parse(ReadLine()); }
static string[] stra() { return ReadLine().Split(' '); }
static char[] chara() {
string[] a = stra();
string b = "";
for (int i = 0; i < a.Length; i++) {
b += a[i];
}
return b.ToCharArray();
}
static int[] inta() {
string[] read_str_array = ReadLine().Split(' ');
int[] return_int_array = new int[read_str_array.Length];
for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
}
return return_int_array;
}
static int[,] inta2(int num_array, int in_array) {
int[,] int_array2 = new int[num_array, in_array];
for (int i = 0; i < num_array; i++) {
int[] temp_array = inta();
for (int j = 0; j < in_array; j++) {
int_array2[i, j] = temp_array[j];
}
}
return int_array2;
}
static long[] longa() {
string[] read_str_array = ReadLine().Split(' ');
long[] return_long_array = new long[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_long_array[countup_i] = long.Parse(read_str_array[countup_i]);
}
return return_long_array;
}
static double[] doublea() {
string[] read_str_array = ReadLine().Split(' ');
double[] return_double_array = new double[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_double_array[countup_i] = long.Parse(read_str_array[countup_i]);
}
return return_double_array;
}
// -----------------------------
static long divideup(long divided, long divid) {
long temp_divide = divided / divid;
if (divided % divid > 0) {
temp_divide++;
}
return temp_divide;
}
static long GCD(long a, long b) {
if (a < b) {
long temp = a;
a = b;
b = temp;
}
if (a % b == 0) {
return b;
} else {
long temp = b;
b = a % b;
a = temp;
return GCD(a, b);
}
}
static long LCM(long a, long b) { return a * b / GCD(a, b); }
}
//知見
// (string) hogestr -> (char[]) hoge
// char hoge = hogestr.ToCharArray();
// (char[]) hoge -> (string) hogestr
// string hoge = new string(hoge);
// Hashtable × Dictionary ○
// Dictionary hoge<string,int>
// hoge.ContainsKey(string) -> return boolean
// hoge[string] -> return int
// hoge[int] -> CE
// Dictionary hoge<int1,int2>
// hoge<int1,int2>: hoge[int1] -> return int2
// KeyValuePair<int,int> k <-> k.Key == int1 / k.Value == int2
// SortedDictionary() > SortedList() ???
// キュー -> 幅優先 ???
// var queue = new Queue<int>(); queue.Enqueue() queue.Dequeue()
// スタック -> 深さ優先 ???
// var stack = new Stack<int>(); stack.Push(hoge) stack.Pop() stackPeek()
// stack.Count
// if (list?.Count > 0) リストが空でもnullでもない
// ソート
// list.Sort(StringComparer.Ordinal); listの(辞書順?)ソート
// StringComparer.Ordinal とは
// Array.Sort(list1,list2);
// 出力
// foreach(var a int list){ WriteLine(a); } より
// WriteLine(string.Join("\n", list)); が速い
// var sw = new StreamWriter(Console.OpenStandardOutput()){AutoFlush = false};
// Console.SetOut(sw);
// foreach(var k in list[num-1]){
// WriteLine(k);
// }
// Console.Out.Flush();
// 未知
// 最小費用流
// 二分探索の理解が浅い
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;
public class Hello {
static public int mod = 1000000007;
public static void Main() {
// 方針
//
long[] n = longa();
var xorlist = new List<long>();
if (n[0] != n[1] && n[0] % 2 == 1) {
xorlist.Add(n[0]);
n[0]++;
}
if (n[0] != n[1] && n[1] % 2 == 0) {
xorlist.Add(n[1]);
n[1]--;
}
long sa = (n[1] - n[0] + 1) / 2;
if (sa % 2 == 1)
xorlist.Add(1);
if (n[0] == n[1])
xorlist.Add(n[0]);
long ans = 0;
foreach (var k in xorlist) {
ans = ans ^ k;
}
WriteLine(ans);
}
static void unionfind(ref int[] uni, int a, int b) {
var memo = new List<int>();
memo.Add(a);
memo.Add(b);
int min = Min(a, b);
while (uni[a] != a) {
a = uni[a];
memo.Add(a);
}
while (uni[b] != b) {
b = uni[b];
memo.Add(b);
}
min = Min(min, a);
min = Min(min, b);
foreach (var k in memo) {
uni[k] = min;
}
}
static int unionfind2(ref int[] uni, int a) {
var memo = new List<int>();
memo.Add(a);
while (uni[a] != a) {
a = uni[a];
memo.Add(a);
}
foreach (var k in memo) {
uni[k] = a;
}
return a;
}
static int binarysearchd(int[] a, int b) {
int leng = a.Length;
int min = 0;
int max = leng - 1;
while (max - min > 1) {
int mid = (min + max) / 2;
if (a[mid] < b) {
min = mid;
} else {
max = mid;
}
}
if (a[0] >= b) {
return 0;
} else if (a[leng - 1] < b) {
return leng;
} else {
if (a[max] < b) {
return max + 1;
}
return min + 1;
}
}
static int binarysearchu(int[] a, int b) {
int leng = a.Length;
int min = 0;
int max = leng - 1;
while (max - min > 1) {
int mid = (min + max) / 2;
if (a[mid] < b) {
min = mid;
} else {
max = mid;
}
}
if (a[0] > b) {
return leng;
} else if (a[leng - 1] <= b) {
return 0;
} else {
if (a[max] <= b) {
return leng - (max + 1);
}
return leng - (min + 1);
}
}
// 1からaまでの数字並べ替え全通り返すやつ
static List<string> permutation(int a) {
var list = new List<string>();
if (a == 1) {
list.Add("1");
return list;
} else {
foreach (var k in permutation(a - 1)) {
var ch = k.ToCharArray();
for (int i = 0; i <= ch.Length; i++) {
string intemp = "";
if (i == 0) {
intemp += a.ToString();
}
for (int j = 0; j < ch.Length; j++) {
intemp += ch[j].ToString();
if (i == j + 1) {
intemp += a.ToString();
}
}
list.Add(intemp);
}
}
}
return list;
}
static void swap(ref int a, ref int b) {
int temp = a;
a = b;
b = temp;
}
static void charswap(ref char a, ref char b) {
char temp = a;
a = b;
b = temp;
}
static int ncr(int n, int r) {
r = Min(r, n - r);
long nn = 1;
for (int i = n - r + 1; i <= n; i++) {
nn = nn * i % mod;
}
long rr = 1;
for (int i = 1; i <= r; i++) {
rr = rr * i % mod;
}
rr = square((int)rr, mod - 2);
nn = nn * rr % mod;
return (int)nn;
}
// 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;
}
//各種読取
static string rstr() { return ReadLine(); }
static int rint() { return int.Parse(ReadLine()); }
static long rlong() { return long.Parse(ReadLine()); }
static string[] stra() { return ReadLine().Split(' '); }
static char[] chara() {
string[] a = stra();
string b = "";
for (int i = 0; i < a.Length; i++) {
b += a[i];
}
return b.ToCharArray();
}
static int[] inta() {
string[] read_str_array = ReadLine().Split(' ');
int[] return_int_array = new int[read_str_array.Length];
for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
}
return return_int_array;
}
static int[,] inta2(int num_array, int in_array) {
int[,] int_array2 = new int[num_array, in_array];
for (int i = 0; i < num_array; i++) {
int[] temp_array = inta();
for (int j = 0; j < in_array; j++) {
int_array2[i, j] = temp_array[j];
}
}
return int_array2;
}
static long[] longa() {
string[] read_str_array = ReadLine().Split(' ');
long[] return_long_array = new long[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_long_array[countup_i] = long.Parse(read_str_array[countup_i]);
}
return return_long_array;
}
static double[] doublea() {
string[] read_str_array = ReadLine().Split(' ');
double[] return_double_array = new double[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_double_array[countup_i] = long.Parse(read_str_array[countup_i]);
}
return return_double_array;
}
// -----------------------------
static long divideup(long divided, long divid) {
long temp_divide = divided / divid;
if (divided % divid > 0) {
temp_divide++;
}
return temp_divide;
}
static long GCD(long a, long b) {
if (a < b) {
long temp = a;
a = b;
b = temp;
}
if (a % b == 0) {
return b;
} else {
long temp = b;
b = a % b;
a = temp;
return GCD(a, b);
}
}
static long LCM(long a, long b) { return a * b / GCD(a, b); }
}
|
[["-", 8, 196, 0, 57, 15, 16, 31, 214, 205, 22], ["-", 8, 196, 0, 57, 15, 16, 31, 214, 0, 131], ["-", 8, 196, 0, 57, 15, 16, 31, 214, 141, 22], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 204, 205, 22], ["+", 0, 57, 15, 16, 31, 204, 206, 207, 0, 70], ["+", 0, 57, 15, 16, 31, 204, 206, 207, 0, 73], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 204, 205, 22], ["+", 0, 57, 15, 16, 12, 204, 206, 207, 0, 70], ["+", 15, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 57, 15, 16, 12, 204, 206, 207, 0, 73]]
| 8
| 1,871
| 12
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace Algorithm {
class Program {
static void Main(string[] args) {
var AB = Console.ReadLine().Split().Select(long.Parse).ToArray();
Console.WriteLine(Solve(AB[0] - 1) ^ Solve(AB[1]));
}
static long Solve(long n) {
switch (n % 4) {
case 0:
return n;
case 1:
return 1;
case 2:
return n + 1;
case 3:
return 0;
}
return -1;
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace Algorithm {
class Program {
static void Main(string[] args) {
var AB = Console.ReadLine().Split().Select(long.Parse).ToArray();
Console.WriteLine(Solve(AB[0] - 1) ^ Solve(AB[1]));
}
static long Solve(long n) {
if (n < 0)
return 0;
switch (n % 4) {
case 0:
return n;
case 1:
return 1;
case 2:
return n + 1;
case 3:
return 0;
}
return -1;
}
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 37, 0, 38], ["+", 0, 195, 8, 196, 0, 57, 64, 37, 0, 203], ["+", 0, 195, 8, 196, 0, 57, 64, 37, 0, 35]]
| 8
| 128
| 9
|
using System;
class Program {
static void Main(string[] args) {
var ab = Console.ReadLine().Split();
var a = long.Parse(ab[0]);
var b = long.Parse(ab[1]);
Console.WriteLine(f(a - 1) ^ f(b));
}
static long f(long n) {
var ans = n;
for (int i = 1; i <= n % 4; i++)
ans ^= n - i;
return ans;
}
}
|
using System;
class Program {
static void Main(string[] args) {
var ab = Console.ReadLine().Split();
var a = long.Parse(ab[0]);
var b = long.Parse(ab[1]);
Console.WriteLine(f(a - 1) ^ f(b));
}
static long f(long n) {
if (n <= 0)
return 0;
var ans = n;
for (int i = 1; i <= n % 4; i++)
ans ^= n - i;
return ans;
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 19], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 37, 0, 38], ["+", 0, 195, 8, 196, 0, 57, 64, 37, 0, 203], ["+", 0, 195, 8, 196, 0, 57, 64, 37, 0, 35]]
| 8
| 113
| 9
|
using System;
namespace ABC121_D___XOR_World {
class Program {
static void Main(string[] args) {
var AB = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
var digit = 1;
long result = 0;
while (AB[1] >= Math.Pow(2, digit + 2)) {
result +=
((countBinary1(AB[1], digit) - countBinary1(AB[0] - 1, digit)) % 2) *
(long)Math.Pow(2, digit - 1);
digit++;
}
Console.WriteLine(result);
}
static long countBinary1(long number, int digit) {
long a = (long)(number / Math.Pow(2, digit)) * (long)Math.Pow(2, digit - 1);
long b = Math.Max(number % (long)Math.Pow(2, digit) -
(long)Math.Pow(2, digit - 1) + 1,
0);
return a + b;
}
}
}
|
using System;
namespace ABC121_D___XOR_World {
class Program {
static void Main(string[] args) {
var AB = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
var digit = 1;
long result = 0;
while (digit < 1000) {
result +=
((countBinary1(AB[1], digit) - countBinary1(AB[0] - 1, digit)) % 2) *
(long)Math.Pow(2, digit - 1);
digit++;
}
Console.WriteLine(result);
}
static long countBinary1(long number, int digit) {
long a = (long)(number / Math.Pow(2, digit)) * (long)Math.Pow(2, digit - 1);
long b = Math.Max(number % (long)Math.Pow(2, digit) -
(long)Math.Pow(2, digit - 1) + 1,
0);
return a + b;
}
}
}
|
[["-", 8, 196, 0, 52, 15, 16, 31, 204, 205, 22], ["-", 0, 52, 15, 16, 31, 204, 206, 207, 0, 70], ["-", 15, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 52, 15, 16, 31, 204, 206, 207, 0, 73], ["-", 0, 195, 8, 196, 0, 52, 15, 16, 17, 20], ["-", 0, 52, 15, 16, 12, 213, 63, 214, 205, 22], ["-", 0, 52, 15, 16, 12, 213, 63, 214, 0, 131], ["-", 0, 52, 15, 16, 12, 213, 63, 214, 141, 22], ["-", 0, 52, 15, 16, 12, 213, 3, 4, 0, 24], ["-", 15, 16, 12, 213, 3, 4, 0, 28, 0, 203], ["-", 0, 52, 15, 16, 12, 213, 3, 4, 0, 21], ["-", 12, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["-", 12, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["-", 0, 52, 15, 16, 12, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 12, 203]]
| 8
| 221
| 16
|
using System;
using System.Linq;
using System.Collections.Generic;
class Damondai {
static void Main() {
var ab =
Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
var A = ab[0];
var B = ab[1];
Console.WriteLine(Solve(A - 1) ^ Solve(B));
}
static long Solve(long num) {
if (num % 2 == 1)
return Calc(num);
else {
if (num == 0)
return 0;
return num ^ Calc(num - 1);
}
}
static long Calc(long num) { return (num + 1) / 2 % 2; }
}
|
using System;
using System.Linq;
using System.Collections.Generic;
class Damondai {
static void Main() {
var ab =
Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
var A = ab[0];
var B = ab[1];
var ans = Solve(A - 1) ^ Solve(B);
Console.WriteLine(ans);
}
static long Solve(long num) {
if (num % 2 == 1)
return Calc(num);
else {
if (num <= 0)
return 0;
return num ^ Calc(num - 1);
}
}
static long Calc(long num) { return (num + 1) / 2 % 2; }
}
|
[["-", 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, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 0, 57, 75, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 17, 19]]
| 8
| 156
| 15
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
long[] s = Console.ReadLine().Split().Select(long.Parse).ToArray();
long a = s[0];
long b = s[1];
Console.WriteLine(f(b) ^ f(a - 1));
}
static long f(long x) {
switch (x % 4) {
case 0:
return x;
case 1:
return 1;
case 2:
return x + 1;
case 3:
return 0;
default:
throw new ArgumentOutOfRangeException();
}
}
}
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
long[] s = Console.ReadLine().Split().Select(long.Parse).ToArray();
long a = s[0];
long b = s[1];
Console.WriteLine(f(b) ^ f(a - 1));
}
static long f(long x) {
switch (x % 4) {
case 0:
return x;
case 1:
return 1;
case 2:
return x + 1;
default:
return 0;
}
}
}
|
[["-", 0, 99, 8, 254, 0, 239, 0, 264, 0, 173], ["-", 0, 99, 8, 254, 0, 239, 0, 264, 0, 203], ["+", 0, 99, 8, 254, 0, 239, 0, 265, 0, 162], ["-", 0, 99, 8, 254, 0, 239, 0, 37, 0, 35], ["-", 0, 99, 8, 254, 0, 239, 0, 265, 0, 162], ["-", 0, 99, 8, 254, 0, 239, 0, 265, 0, 102], ["-", 0, 99, 8, 254, 0, 239, 0, 293, 0, 294], ["-", 8, 254, 0, 239, 0, 293, 0, 230, 0, 228], ["-", 8, 254, 0, 239, 0, 293, 0, 230, 39, 22], ["-", 0, 239, 0, 293, 0, 230, 3, 4, 0, 24], ["-", 0, 239, 0, 293, 0, 230, 3, 4, 0, 25]]
| 8
| 133
| 11
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BC121D {
class Program {
static void Main(string[] args) {
// 整数の入力
// int a = int.Parse(Console.ReadLine());
// スペース区切りの整数の入力
string[] input = Console.ReadLine().Split(' ');
long A = long.Parse(input[0]);
long B = long.Parse(input[1]);
long ans = xor_fromZero(A - 1) ^ xor_fromZero(B);
Console.WriteLine(ans);
}
public static long xor_fromZero(long n) {
if (n % 2 == 1) // nが奇数の時
{
if (((n + 1) / 2) % 2 == 0) {
return 0;
} else {
return 1;
}
} else // nが偶数の時
{
if ((n / 2) % 2 == 0) {
return n;
} else {
return n + 1;
}
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BC121D {
class Program {
static void Main(string[] args) {
// 整数の入力
// int a = int.Parse(Console.ReadLine());
// スペース区切りの整数の入力
string[] input = Console.ReadLine().Split(' ');
long A = long.Parse(input[0]);
long B = long.Parse(input[1]);
long ans = xor_fromZero(A - 1) ^ xor_fromZero(B);
Console.WriteLine(ans);
}
public static long xor_fromZero(long n) {
if (n <= 0) {
return 0;
}
//
if (n % 2 == 1) // nが奇数の時
{
if (((n + 1) / 2) % 2 == 0) {
return 0;
} else {
return 1;
}
} else // nが偶数の時
{
if ((n / 2) % 2 == 0) {
return n;
} else {
return n + 1;
}
}
}
}
}
|
[["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 19], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22]]
| 8
| 192
| 11
|
using System;
public class Hello {
static void Main() {
string[] line = Console.ReadLine().Trim().Split(' ');
var a = long.Parse(line[0]);
var b = long.Parse(line[1]);
getAns(a, b);
}
static void getAns(long a, long b) {
long ans;
if (a % 2 == 0 && b % 2 == 1) {
var c0 = (b - 1 - a) / 2 + 1;
if (c0 % 2 == 0)
ans = a ^ (b - 1);
else
ans = a ^ (b - 1) ^ 1L;
} else if (a % 2 == 0 && b % 2 == 0) {
var c0 = (b - 2 - a) / 2 + 1;
if (c0 % 2 == 0)
ans = b;
else
ans = b ^ 1L;
} else if (a % 2 == 1 && b % 2 == 1) {
var c0 = (b - a - 2) / 2 + 1;
if (c0 % 2 == 0)
ans = a ^ (b - 1);
else
ans = a ^ (b - 1) ^ 1L;
} else {
var c0 = (b - 3 - a) / 2 + 1;
if (c0 % 2 == 0)
ans = a ^ b;
else
ans = a ^ b ^ 1L;
}
Console.WriteLine(ans);
}
}
|
using System;
public class Hello {
static void Main() {
string[] line = Console.ReadLine().Trim().Split(' ');
var a = long.Parse(line[0]);
var b = long.Parse(line[1]);
getAns(a, b);
}
static void getAns(long a, long b) {
long ans;
if (a % 2 == 0 && b % 2 == 1) {
var c0 = (b - 1 - a) / 2 + 1;
if (c0 % 2 == 0)
ans = 0;
else
ans = 1;
} else if (a % 2 == 0 && b % 2 == 0) {
var c0 = (b - 2 - a) / 2 + 1;
if (c0 % 2 == 0)
ans = b;
else
ans = b ^ 1L;
} else if (a % 2 == 1 && b % 2 == 1) {
var c0 = (b - a - 2) / 2 + 1;
if (c0 % 2 == 0)
ans = a;
else
ans = a ^ 1L;
} else {
var c0 = (b - 3 - a) / 2 + 1;
if (c0 % 2 == 0)
ans = a ^ b;
else
ans = a ^ b ^ 1L;
}
Console.WriteLine(ans);
}
}
|
[["-", 0, 57, 64, 1, 0, 11, 12, 16, 31, 22], ["-", 0, 57, 64, 1, 0, 11, 12, 16, 17, 140], ["-", 64, 1, 0, 11, 12, 16, 12, 23, 0, 24], ["-", 0, 11, 12, 16, 12, 23, 0, 16, 31, 22], ["-", 0, 11, 12, 16, 12, 23, 0, 16, 17, 33], ["-", 0, 11, 12, 16, 12, 23, 0, 16, 12, 203], ["-", 64, 1, 0, 11, 12, 16, 12, 23, 0, 25], ["+", 64, 196, 0, 57, 64, 1, 0, 11, 12, 203], ["-", 75, 1, 0, 11, 12, 16, 31, 16, 31, 22], ["-", 75, 1, 0, 11, 12, 16, 31, 16, 17, 140], ["-", 0, 11, 12, 16, 31, 16, 12, 23, 0, 24], ["-", 12, 16, 31, 16, 12, 23, 0, 16, 31, 22], ["-", 12, 16, 31, 16, 12, 23, 0, 16, 17, 33], ["-", 0, 11, 12, 16, 31, 16, 12, 23, 0, 25], ["-", 0, 57, 75, 1, 0, 11, 12, 16, 17, 140], ["-", 0, 57, 75, 1, 0, 11, 12, 16, 12, 203], ["-", 12, 16, 31, 16, 12, 23, 0, 16, 12, 203]]
| 8
| 309
| 28
|
using System;
class Program {
static void Main(string[] args) {
var value_1 = Console.ReadLine().Split(' ');
var A = double.Parse(value_1[0]);
var B = double.Parse(value_1[1]);
var C = double.Parse(value_1[2]);
Console.WriteLine(B / A > C ? C : B / A);
}
}
|
using System;
class Program {
static void Main(string[] args) {
var value_1 = Console.ReadLine().Split(' ');
var A = double.Parse(value_1[0]);
var B = double.Parse(value_1[1]);
var C = double.Parse(value_1[2]);
Console.WriteLine(Math.Floor(B / A) > C ? C : Math.Floor(B / A));
}
}
|
[["+", 0, 41, 15, 16, 31, 213, 63, 214, 205, 22], ["+", 0, 41, 15, 16, 31, 213, 63, 214, 0, 131], ["+", 0, 41, 15, 16, 31, 213, 63, 214, 141, 22], ["+", 0, 41, 15, 16, 31, 213, 3, 4, 0, 24], ["+", 0, 41, 15, 16, 31, 213, 3, 4, 0, 25], ["+", 0, 28, 0, 41, 75, 213, 63, 214, 205, 22], ["+", 0, 28, 0, 41, 75, 213, 63, 214, 0, 131], ["+", 0, 28, 0, 41, 75, 213, 63, 214, 141, 22], ["+", 0, 28, 0, 41, 75, 213, 3, 4, 0, 24], ["+", 0, 28, 0, 41, 75, 213, 3, 4, 0, 25]]
| 8
| 90
| 10
|
using System;
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
int a = int.Parse(str[0]);
int b = int.Parse(str[1]);
int c = int.Parse(str[2]);
if (a * c <= b) {
Console.WriteLine(c);
} else {
for (int cnt = 1; cnt <= c; cnt++) {
if (a * cnt > b) {
Console.WriteLine(cnt);
break;
}
}
}
}
}
|
using System;
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
int a = int.Parse(str[0]);
int b = int.Parse(str[1]);
int c = int.Parse(str[2]);
if (a * c <= b) {
Console.WriteLine(c);
} else {
for (int cnt = 1; cnt <= c; cnt++) {
if (a * cnt > b) {
int ans = cnt - 1;
Console.WriteLine(cnt - 1);
break;
}
}
}
}
}
|
[["+", 0, 57, 64, 196, 0, 197, 0, 198, 39, 199], ["+", 64, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 33], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 197, 0, 35], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
| 8
| 130
| 9
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoderIO {
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
int A = int.Parse(str[0]);
int B = int.Parse(str[1]);
int C = int.Parse(str[2]);
int num = B / A;
if (num > C) {
num = C;
}
Console.WriteLine(C);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoderIO {
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
int A = int.Parse(str[0]);
int B = int.Parse(str[1]);
int C = int.Parse(str[2]);
int num = B / A;
if (num > C) {
num = C;
}
Console.WriteLine(num);
Console.ReadKey();
}
}
}
|
[["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["+", 8, 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
| 129
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
string b = System.Console.ReadLine();
char[] c = b.ToCharArray();
int cou = 0;
int coumax = 0;
for (int i = 0; i < b.Length; i++) {
if (c[i] == 'A' || c[i] == 'T' || c[i] == 'G' || c[i] == 'C') {
if (cou > coumax) {
cou = cou + 1;
coumax = cou;
} else
cou++;
} else
cou = 0;
}
Console.WriteLine(coumax);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
string b = System.Console.ReadLine();
char[] c = b.ToCharArray();
int cou = 0;
int coumax = 0;
for (int i = 0; i < b.Length; i++) {
if (c[i] == 'A' || c[i] == 'T' || c[i] == 'G' || c[i] == 'C') {
cou++;
if (cou > coumax) {
coumax = cou;
}
} else
cou = 0;
}
Console.WriteLine(coumax);
}
}
}
|
[["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 29], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 64, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["-", 64, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["-", 64, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["-", 64, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 8, 196, 0, 57, 64, 196, 0, 57, 0, 95], ["-", 64, 196, 0, 57, 75, 1, 0, 223, 0, 22], ["-", 64, 196, 0, 57, 75, 1, 0, 223, 0, 29], ["-", 0, 57, 64, 196, 0, 57, 75, 1, 0, 35]]
| 8
| 170
| 13
|
using System;
using System.Linq;
namespace B {
class Program {
static void Main(string[] args) {
var S = Console.ReadLine();
int maxLength = 0;
int length = 0;
var acgt = new[] { 'A', 'C', 'G', 'T' };
foreach (var c in S) {
if (acgt.Contains(c)) {
length++;
} else {
maxLength = Math.Max(maxLength, length);
length = 0;
}
}
Console.Write(maxLength);
}
}
}
|
using System;
using System.Linq;
namespace B {
class Program {
static void Main(string[] args) {
var S = Console.ReadLine();
int maxLength = 0;
int length = 0;
var acgt = new[] { 'A', 'C', 'G', 'T' };
foreach (var c in S) {
if (acgt.Contains(c)) {
length++;
} else {
maxLength = Math.Max(maxLength, length);
length = 0;
}
}
maxLength = Math.Max(maxLength, length);
Console.Write(maxLength);
}
}
}
|
[["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 205, 22], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["+", 0, 11, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 118
| 11
|
using System;
class Program {
static void Main(string[] args) {
string S = string.Empty;
int cnt = 0;
int ans = 0;
S = Console.ReadLine();
foreach (char c in S) {
if (c.ToString() == "A" || c.ToString() == "C" || c.ToString() == "G" ||
c.ToString() == "T") {
cnt++;
} else {
if (ans < cnt)
ans = cnt;
cnt = 0;
}
}
Console.WriteLine(ans);
}
}
|
using System;
class Program {
static void Main(string[] args) {
string S = string.Empty;
int cnt = 0;
int ans = 0;
S = Console.ReadLine();
foreach (char c in S) {
if (c.ToString() == "A" || c.ToString() == "C" || c.ToString() == "G" ||
c.ToString() == "T") {
cnt++;
} else {
if (ans < cnt)
ans = cnt;
cnt = 0;
}
}
if (ans > cnt) {
Console.WriteLine(ans);
} else {
Console.WriteLine(cnt);
}
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 75, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 75, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 75, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 75, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 123
| 18
|
using System;
using System.Linq;
using static System.Console;
namespace b {
static class Extensions {
public static int ToInt(this string str) { return int.Parse(str); }
}
class Program {
static bool isATCG(char c) {
return c == 'A' || c == 'T' || c == 'C' || c == 'G';
}
public static void Main(string[] args) {
var s = ReadLine();
var count = 0;
var prevcount = 0;
var flag1 = false;
var flag2 = false;
var flag3 = false;
for (int i = 0; i < s.Length; i++) {
flag1 = isATCG(s[i]);
if (flag1 == true && flag2 == false) {
// 立ち上がり
flag3 = true;
} else if (flag1 == false && flag2 == true) {
// 立ち下がり
flag3 = false;
if (prevcount < count)
prevcount = count;
count = 0;
}
if (flag3)
count++;
flag2 = flag1;
}
WriteLine(prevcount);
}
}
}
|
using System;
using System.Linq;
using static System.Console;
namespace b {
static class Extensions {
public static int ToInt(this string str) { return int.Parse(str); }
}
class Program {
static bool isATCG(char c) {
return c == 'A' || c == 'T' || c == 'C' || c == 'G';
}
public static void Main(string[] args) {
var s = ReadLine();
var count = 0;
var prevcount = 0;
var flag1 = false;
var flag2 = false;
var flag3 = false;
for (int i = 0; i < s.Length; i++) {
flag1 = isATCG(s[i]);
if (flag1 == true && flag2 == false) {
// 立ち上がり
flag3 = true;
} else if (flag1 == false && flag2 == true) {
// 立ち下がり
flag3 = false;
if (prevcount < count)
prevcount = count;
count = 0;
}
if (flag3)
count++;
if (flag3 == true && i == s.Length - 1) {
if (prevcount < count)
prevcount = count;
}
flag2 = flag1;
}
WriteLine(prevcount);
}
}
}
|
[["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 0, 57, 15, 16, 31, 16, 12, 211, 0, 146], ["+", 0, 7, 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, 60], ["+", 15, 16, 12, 16, 12, 16, 31, 214, 205, 22], ["+", 15, 16, 12, 16, 12, 16, 31, 214, 0, 131], ["+", 15, 16, 12, 16, 12, 16, 31, 214, 141, 22], ["+", 0, 57, 15, 16, 12, 16, 12, 16, 17, 33], ["+", 0, 57, 15, 16, 12, 16, 12, 16, 12, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["+", 64, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 64, 196, 0, 57, 64, 1, 0, 11, 12, 22], ["+", 0, 57, 64, 196, 0, 57, 64, 1, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 217
| 26
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp5 {
class Program {
static void Main(string[] args) {
string S = Console.ReadLine();
int count = 0;
int res = 0;
for (int i = 0; i < S.Length; i++) {
if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
count++;
} else {
if (count > res) {
res = count;
}
count = 0;
}
}
Console.WriteLine(res);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp5 {
class Program {
static void Main(string[] args) {
string S = Console.ReadLine();
int count = 0;
int res = 0;
S = S + "%";
for (int i = 0;; i++) {
if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
count++;
} else {
if (count > res) {
res = count;
}
count = 0;
if (S[i] == '%') {
break;
}
}
}
Console.WriteLine(res);
}
}
}
|
[["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 0, 1, 0, 11, 12, 16, 12, 5, 0, 62], ["+", 0, 1, 0, 11, 12, 16, 12, 5, 0, 222], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["-", 8, 196, 0, 7, 15, 16, 12, 214, 205, 22], ["-", 8, 196, 0, 7, 15, 16, 12, 214, 0, 131], ["-", 8, 196, 0, 7, 15, 16, 12, 214, 141, 22], ["+", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 24], ["+", 75, 196, 0, 57, 15, 16, 31, 204, 205, 22], ["+", 0, 57, 15, 16, 31, 204, 206, 207, 0, 70], ["+", 15, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 57, 15, 16, 31, 204, 206, 207, 0, 73], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 17, 60], ["+", 75, 196, 0, 57, 15, 16, 12, 252, 0, 104], ["+", 75, 196, 0, 57, 15, 16, 12, 252, 0, 253], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 25], ["+", 0, 57, 75, 196, 0, 57, 64, 196, 0, 45], ["+", 75, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 0, 57, 75, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 152
| 28
|
using System;
namespace AtCoder.ABC._122 {
class b {
static void Main(string[] args) {
var line = Console.ReadLine().Trim();
var S = line.ToCharArray();
var cnt = 0;
var max = 0;
foreach (var c in S) {
if ("ACGT".Contains(c.ToString())) {
++cnt;
} else {
if (max < cnt) {
max = cnt;
}
cnt = 0;
}
}
Console.WriteLine(max);
}
}
}
|
using System;
namespace AtCoder.ABC._122 {
class b {
static void Main(string[] args) {
var line = Console.ReadLine().Trim();
var S = line.ToCharArray();
var cnt = 0;
var max = 0;
foreach (var c in S) {
if ("ACGT".Contains(c.ToString())) {
++cnt;
} else {
if (max < cnt) {
max = cnt;
}
cnt = 0;
}
}
if (max < cnt) {
max = cnt;
}
Console.WriteLine(max);
}
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 113
| 12
|
using System;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
string str = Console.ReadLine();
int count = 0;
List<int> max = new List<int>();
for (int cnt = 0; cnt < str.Length; cnt++) {
char s = str[cnt];
if (s == 'A' || s == 'C' || s == 'G' || s == 'T') {
count++;
} else {
max.Add(count);
count = 0;
}
}
int fin = 0;
foreach (int c in max) {
if (c > fin)
fin = c;
}
Console.WriteLine(fin);
}
}
|
using System;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
string str = Console.ReadLine();
int count = 0;
List<int> max = new List<int>();
for (int cnt = 0; cnt < str.Length; cnt++) {
char s = str[cnt];
if (s == 'A' || s == 'C' || s == 'G' || s == 'T') {
count++;
if (cnt == str.Length - 1)
max.Add(count);
} else {
max.Add(count);
count = 0;
}
}
int fin = 0;
foreach (int c in max) {
if (c > fin)
fin = c;
}
Console.WriteLine(fin);
}
}
|
[["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 57, 15, 16, 12, 16, 31, 214, 205, 22], ["+", 0, 57, 15, 16, 12, 16, 31, 214, 0, 131], ["+", 0, 57, 15, 16, 12, 16, 31, 214, 141, 22], ["+", 64, 196, 0, 57, 15, 16, 12, 16, 17, 33], ["+", 64, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 205, 22], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 0, 131], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 141, 22], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 24], ["+", 64, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 25], ["+", 0, 57, 64, 196, 0, 57, 64, 1, 0, 35]]
| 8
| 155
| 17
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
namespace AtCoder {
class Program {
static void Main() {
var S = ReadLine();
var ans = 0;
var buf = 0;
for (int i = 0; i < S.Length; i++) {
if (S[i] != 'A' && S[i] != 'C' && S[i] != 'G' && S[i] != 'T') {
ans = Math.Max(ans, buf);
buf = 0;
} else
buf++;
}
WriteLine(ans);
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
namespace AtCoder {
class Program {
static void Main() {
var S = ReadLine();
var ans = 0;
var buf = 0;
for (int i = 0; i < S.Length; i++) {
if (S[i] != 'A' && S[i] != 'C' && S[i] != 'G' && S[i] != 'T') {
ans = Math.Max(ans, buf);
buf = 0;
} else
buf++;
}
if (buf > ans)
ans = buf;
WriteLine(ans);
}
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35]]
| 8
| 145
| 10
|
using System;
using System.Collections.Generic;
using System.Linq;
class Procon {
public Procon() {}
static void Main(string[] agrs) { new Procon().Do(); }
Scanner cin;
string S;
public void Do() {
cin = new Scanner();
S = cin.nextString();
int ans = 0;
int tmpAns = 0;
for (int i = 0; i < S.Length; i++) {
if (S[i] == 'A' || S[i] == 'G' || S[i] == 'T' || S[i] == 'C') {
tmpAns++;
} else {
if (tmpAns > ans) {
ans = tmpAns;
}
tmpAns = 0;
}
}
Console.WriteLine(ans);
}
}
class Scanner {
string[] s;
int i;
int max_i;
public Scanner() {
s = new string[0];
max_i = 0;
i = 0;
}
public string nextString() {
if (i >= s.Length) {
s = Console.ReadLine().Split(' ');
max_i = s.Length;
i = 0;
if (max_i == 0) {
return "";
}
return s[i++];
} else {
return s[i++];
}
}
public int nextInt() { return int.Parse(nextString()); }
public long nextLong() { return long.Parse(nextString()); }
public double nextDouble() { return double.Parse(nextString()); }
public string[] arrayString() { return Console.ReadLine().Split(' '); }
public int[] arrayInt() {
string[] str = Console.ReadLine().Split(' ');
int[] array = new int[str.Length];
for (int i = 0; i < str.Length; i++) {
array[i] = int.Parse(str[i]);
}
return array;
}
public long[] arrayLong() {
string[] str = Console.ReadLine().Split(' ');
long[] array = new long[str.Length];
for (int i = 0; i < str.Length; i++) {
array[i] = long.Parse(str[i]);
}
return array;
}
public double[] arrayDouble() {
string[] str = Console.ReadLine().Split(' ');
double[] array = new double[str.Length];
for (int i = 0; i < str.Length; i++) {
array[i] = double.Parse(str[i]);
}
return array;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Procon {
public Procon() {}
static void Main(string[] agrs) { new Procon().Do(); }
Scanner cin;
string S;
public void Do() {
cin = new Scanner();
S = cin.nextString();
int ans = 0;
int tmpAns = 0;
for (int i = 0; i < S.Length; i++) {
if (S[i] == 'A' || S[i] == 'G' || S[i] == 'T' || S[i] == 'C') {
tmpAns++;
} else {
if (tmpAns > ans) {
ans = tmpAns;
}
tmpAns = 0;
}
}
Console.WriteLine(Math.Max(ans, tmpAns));
}
}
class Scanner {
string[] s;
int i;
int max_i;
public Scanner() {
s = new string[0];
max_i = 0;
i = 0;
}
public string nextString() {
if (i >= s.Length) {
s = Console.ReadLine().Split(' ');
max_i = s.Length;
i = 0;
if (max_i == 0) {
return "";
}
return s[i++];
} else {
return s[i++];
}
}
public int nextInt() { return int.Parse(nextString()); }
public long nextLong() { return long.Parse(nextString()); }
public double nextDouble() { return double.Parse(nextString()); }
public string[] arrayString() { return Console.ReadLine().Split(' '); }
public int[] arrayInt() {
string[] str = Console.ReadLine().Split(' ');
int[] array = new int[str.Length];
for (int i = 0; i < str.Length; i++) {
array[i] = int.Parse(str[i]);
}
return array;
}
public long[] arrayLong() {
string[] str = Console.ReadLine().Split(' ');
long[] array = new long[str.Length];
for (int i = 0; i < str.Length; i++) {
array[i] = long.Parse(str[i]);
}
return array;
}
public double[] arrayDouble() {
string[] str = Console.ReadLine().Split(' ');
double[] array = new double[str.Length];
for (int i = 0; i < str.Length; i++) {
array[i] = double.Parse(str[i]);
}
return array;
}
}
|
[["+", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 21], ["+", 0, 28, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25]]
| 8
| 580
| 7
|
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main(string[] args) {
string input = ReadLine();
int count = 0;
int currentCount = 0;
bool IsStarted = false;
for (int i = 0; i < input.Length; i++) {
if (Check(input[i])) {
if (!IsStarted) {
IsStarted = true;
++currentCount;
} else {
++currentCount;
}
} else {
if (IsStarted) {
if (count < currentCount) {
count = currentCount;
}
IsStarted = false;
currentCount = 0;
}
}
}
WriteLine(count);
ReadKey();
}
static bool Check(char c) {
if (c == 'A' || c == 'C' || c == 'G' || c == 'T') {
return true;
} else {
return false;
}
}
}
static class MyUtil {
public static int[] ReadIntArray() {
return Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
}
/// <summary>
/// <see
/// cref="IEnumerable{T}"/>の各要素を並べてコンソールに出力します。各要素の間には半角スペースが一つ入ります。
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="ts"></param>
public static void WriteToConsole<T>(this IEnumerable<T> ts) {
StringBuilder stringBuilder = new StringBuilder();
foreach (T t in ts) {
stringBuilder.Append(t.ToString());
stringBuilder.Append(" ");
}
stringBuilder.Remove(stringBuilder.Length - 1, 1);
Console.WriteLine(stringBuilder.ToString());
}
}
|
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main(string[] args) {
string input = ReadLine();
int count = 0;
int currentCount = 0;
bool IsStarted = false;
for (int i = 0; i < input.Length; i++) {
if (Check(input[i])) {
if (!IsStarted) {
IsStarted = true;
++currentCount;
} else {
++currentCount;
}
} else {
if (IsStarted) {
if (count < currentCount) {
count = currentCount;
}
IsStarted = false;
currentCount = 0;
}
}
}
if (IsStarted) {
if (count < currentCount) {
count = currentCount;
}
}
WriteLine(count);
ReadKey();
}
static bool Check(char c) {
if (c == 'A' || c == 'C' || c == 'G' || c == 'T') {
return true;
} else {
return false;
}
}
}
static class MyUtil {
public static int[] ReadIntArray() {
return Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
}
/// <summary>
/// <see
/// cref="IEnumerable{T}"/>の各要素を並べてコンソールに出力します。各要素の間には半角スペースが一つ入ります。
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="ts"></param>
public static void WriteToConsole<T>(this IEnumerable<T> ts) {
StringBuilder stringBuilder = new StringBuilder();
foreach (T t in ts) {
stringBuilder.Append(t.ToString());
stringBuilder.Append(" ");
}
stringBuilder.Remove(stringBuilder.Length - 1, 1);
Console.WriteLine(stringBuilder.ToString());
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 15, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["+", 64, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 333
| 18
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace abc119d {
class Program {
static void Main(string[] args) {
var S = Console.ReadLine();
var cnt = 0;
var max = 0;
foreach (var s in S) {
if (s == 'A' || s == 'C' || s == 'G' || s == 'T') {
cnt++;
} else {
max = (max < cnt) ? cnt : max;
cnt = 0;
}
}
Console.WriteLine(max);
#if DEBUG
Console.ReadKey();
#endif
}
private static bool IsRange(int a, int from,
int to) => (from <= a && a <= to);
private static int ReadInt() => int.Parse(Console.ReadLine());
private static List<int>
ReadIntList() => Console.ReadLine().Split().Select(int.Parse).ToList();
private static double ReadDouble() => double.Parse(Console.ReadLine());
private static List<double>
ReadDoubleList() => Console.ReadLine().Split().Select(double.Parse).ToList();
private static long ReadLong() => long.Parse(Console.ReadLine());
private static List<long>
ReadLongList() => Console.ReadLine().Split().Select(long.Parse).ToList();
private static List<int> Int2Digits(int a) =>
a.ToString().ToCharArray().Select(_ => int.Parse(_.ToString())).ToList();
private static int
BinarySearch<Type>(IReadOnlyList<Type> s,
Type target) // target 以下の最大要素のインデックスを返す
where Type : IComparable {
var lower = 0;
var upper = s.Count - 1;
while (upper - lower > 1) {
var mid = lower + (upper - lower) / 2;
if (s[mid].CompareTo(target) <= 0) {
lower = mid;
} else {
upper = mid;
}
}
return lower;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace abc119d {
class Program {
static void Main(string[] args) {
var S = Console.ReadLine();
var cnt = 0;
var max = 0;
foreach (var s in S) {
if (s == 'A' || s == 'C' || s == 'G' || s == 'T') {
cnt++;
} else {
max = (max < cnt) ? cnt : max;
cnt = 0;
}
}
Console.WriteLine(max = (max < cnt) ? cnt : max);
#if DEBUG
Console.ReadKey();
#endif
}
private static bool IsRange(int a, int from,
int to) => (from <= a && a <= to);
private static int ReadInt() => int.Parse(Console.ReadLine());
private static List<int>
ReadIntList() => Console.ReadLine().Split().Select(int.Parse).ToList();
private static double ReadDouble() => double.Parse(Console.ReadLine());
private static List<double>
ReadDoubleList() => Console.ReadLine().Split().Select(double.Parse).ToList();
private static long ReadLong() => long.Parse(Console.ReadLine());
private static List<long>
ReadLongList() => Console.ReadLine().Split().Select(long.Parse).ToList();
private static List<int> Int2Digits(int a) =>
a.ToString().ToCharArray().Select(_ => int.Parse(_.ToString())).ToList();
private static int
BinarySearch<Type>(IReadOnlyList<Type> s,
Type target) // target 以下の最大要素のインデックスを返す
where Type : IComparable {
var lower = 0;
var upper = s.Count - 1;
while (upper - lower > 1) {
var mid = lower + (upper - lower) / 2;
if (s[mid].CompareTo(target) <= 0) {
lower = mid;
} else {
upper = mid;
}
}
return lower;
}
}
}
|
[["+", 3, 4, 0, 28, 0, 11, 0, 202, 0, 32], ["+", 0, 28, 0, 11, 12, 41, 15, 23, 0, 24], ["+", 0, 11, 12, 41, 15, 23, 0, 16, 31, 22], ["+", 0, 11, 12, 41, 15, 23, 0, 16, 17, 18], ["+", 0, 11, 12, 41, 15, 23, 0, 16, 12, 22], ["+", 0, 28, 0, 11, 12, 41, 15, 23, 0, 25], ["+", 3, 4, 0, 28, 0, 11, 12, 41, 0, 101], ["+", 3, 4, 0, 28, 0, 11, 12, 41, 64, 22], ["+", 3, 4, 0, 28, 0, 11, 12, 41, 0, 102], ["+", 3, 4, 0, 28, 0, 11, 12, 41, 75, 22]]
| 8
| 447
| 10
|
using System;
using System.Collections.Generic;
using static System.Console;
using System.Linq;
namespace ConsoleApp2 {
class Program {
static void Main(string[] Args) {
var chars = new List<char> { 'A', 'T', 'C', 'G' };
var convs = new List<char>(ReadLine().ToCharArray())
.Select(chars.Contains)
.ToList<bool>();
int res = 0;
int tmp = 0;
for (int i = 0; i < convs.Count(); i++) {
if (convs[i])
tmp++;
else {
res = Math.Max(res, tmp);
tmp = 0;
}
}
WriteLine(res);
ReadLine();
}
}
}
|
using System;
using System.Collections.Generic;
using static System.Console;
using System.Linq;
namespace ConsoleApp2 {
class Program {
static void Main(string[] Args) {
var chars = new List<char> { 'A', 'T', 'C', 'G' };
var convs = new List<char>(ReadLine().ToCharArray())
.Select(chars.Contains)
.ToList<bool>();
int res = 0;
int tmp = 0;
for (int i = 0; i < convs.Count(); i++) {
if (convs[i])
tmp++;
else {
res = Math.Max(res, tmp);
tmp = 0;
}
}
res = Math.Max(res, tmp);
WriteLine(res);
ReadLine();
}
}
}
|
[["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 205, 22], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["+", 0, 11, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 165
| 11
|
using System;
namespace ConsoleApp {
class Program {
static void Main(string[] args) {
var str = Console.ReadLine();
var max = 0;
var length = 0;
foreach (var item in str) {
if (item == 'A' || item == 'C' || item == 'G' || item == 'T') {
length++;
} else {
if (max < length) {
max = length;
}
length = 0;
}
}
Console.WriteLine(max);
}
}
}
|
using System;
namespace ConsoleApp {
class Program {
static void Main(string[] args) {
var str = Console.ReadLine();
var max = 0;
var length = 0;
foreach (var item in str) {
if (item == 'A' || item == 'C' || item == 'G' || item == 'T') {
length++;
} else {
if (max < length) {
max = length;
}
length = 0;
}
}
if (max < length) {
max = length;
}
Console.WriteLine(max);
}
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 107
| 12
|
using System;
namespace ABC122_B {
class Program {
static void Main(string[] args) {
var s = Console.ReadLine();
var cnt = 0;
var ans = 0;
for (int i = 0; i < s.Length; i++) {
if (s[i] != 'A' && s[i] != 'C' && s[i] != 'G' && s[i] != 'T') {
ans = Math.Max(ans, cnt);
cnt = 0;
} else {
cnt++;
}
}
Console.WriteLine(ans);
}
}
}
|
using System;
namespace ABC122_B {
class Program {
static void Main(string[] args) {
var s = Console.ReadLine();
var cnt = 0;
var ans = 0;
for (int i = 0; i < s.Length; i++) {
if (s[i] != 'A' && s[i] != 'C' && s[i] != 'G' && s[i] != 'T') {
ans = Math.Max(ans, cnt);
cnt = 0;
} else {
cnt++;
}
}
ans = Math.Max(ans, cnt);
Console.WriteLine(ans);
}
}
}
|
[["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 205, 22], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["+", 0, 11, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 127
| 11
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Program {
#region library
static int n = 0;
static int r = 0;
static int c = 0;
static string s = "";
static string[] ss;
static long sum = 0;
static long cnt = 0;
static long max = -1;
static long min = 2147483647;
static bool flg = false;
static string alpha = "abcdefghijklmnopqrstuvwxyz";
static long mod = 1000000007;
static long[] arr;
static char[,] map;
static int[,] imap;
static Queue<int> qx = new Queue<int>();
static Queue<int> qy = new Queue<int>();
public class Input {
static readonly char[] separator = { ' ', '\r', '\n' };
readonly StreamReader sr;
readonly Queue<string> queue;
public Input(string path = "") {
queue = new Queue<string>();
if (string.IsNullOrEmpty(path)) {
sr = new StreamReader(Console.OpenStandardInput());
} else {
sr = new StreamReader(path);
}
}
public void SetText(IEnumerable<string> items) {
foreach (var item in items) {
SetText(item);
}
}
public bool SetText(string s) {
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
queue.Enqueue(elem);
}
return true;
}
public bool Any() { return queue.Any() || Read(); }
bool Read() {
if (!SetText(sr.ReadLine()))
return false;
if (!queue.Any())
return Read();
return queue.Any();
}
public string Next() {
if (!queue.Any() && !Read()) {
return "";
}
return queue.Dequeue();
}
bool Accumulate(int n) {
while (queue.Count() < n) {
if (!Read())
return false;
}
return true;
}
public int NextInt() { return int.Parse(Next()); }
public long NextLong() { return long.Parse(Next()); }
public double NextDouble() { return double.Parse(Next()); }
T[] NextT<T>(int n, T offset, Func<string, T> parse, Func<T, T, T> add) {
if (!Accumulate(n))
return null;
var a = new T[n];
for (int i = 0; i < n; i++)
a[i] = add(parse(queue.Dequeue()), offset);
return a;
}
public string[] Next(int n) { return NextT(n, "", x => x, (x, y) => x); }
public int[] NextInt(int n, int offset = 0) {
return NextT(n, offset, int.Parse, (x, y) => x + y);
}
public long[] NextLong(int n, long offset = 0) {
return NextT(n, offset, long.Parse, (x, y) => x + y);
}
public double[] NextDouble(int n, double offset = 0.0) {
return NextT(n, offset, double.Parse, (x, y) => x + y);
}
}
static Input input;
static int Int() { return input.NextInt(); }
static long Long() { return input.NextLong(); }
static double Double() { return input.NextDouble(); }
static string Text() { return input.Next(); }
static void wl(object obj = null) { Console.WriteLine(obj); }
static void w(object obj) { Console.Write(obj); }
static void Yes() { wl("YES"); }
static void No() { wl("NO"); }
static void Sum() { wl(sum); }
static void Cnt() { wl(cnt); }
static void SetArray(long num = -1) {
if (n == 0) {
n = Int();
}
arr = new long[n];
for (int i = 0; i < n; i++) {
if (num == -1)
arr[i] = Int();
else
arr[i] = num;
}
}
static void ShowArray() {
for (int i = 0; i < arr.Length; i++) {
if (i > 0)
w(" ");
w(arr[i]);
}
wl();
}
static void SetMap(char def = '@') {
if (r == 0 && c == 0) {
r = Int();
c = Int();
}
map = new char[r, c];
for (int i = 0; i < r; i++) {
if (def == '@')
s = Text();
for (int j = 0; j < c; j++) {
map[i, j] = (def == '@') ? s[j] : def;
}
}
}
static void SetIMap(int def = -1) {
if (r == 0 && c == 0) {
r = Int();
c = Int();
}
imap = new int[r, c];
for (int i = 0; i < r; i++) {
for (int j = 0; j < c; j++) {
imap[i, j] = (def == -1) ? Int() : def;
}
}
}
static void ShowMap() {
for (int i = 0; i < r; i++) {
for (int j = 0; j < c; j++) {
w(map[i, j]);
}
wl();
}
}
static void ShowIMap() {
for (int i = 0; i < r; i++) {
for (int j = 0; j < c; j++) {
w(imap[i, j]);
}
wl();
}
}
#endregion
#region main
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
input = new Input();
try {
Solve();
} catch (Exception ex) {
wl(ex);
}
Console.Out.Flush();
}
public static void Solve() {
n = Int();
int q = Int();
s = Text();
var S = new int[n + 1];
S[0] = 0;
for (int i = 1; i < n + 1; i++) {
if (i < n && s[i - 1] == 'A' && s[i] == 'C')
S[i] = S[i - 1] + 1;
else
S[i] = S[i - 1];
}
for (int i = 0; i < q; i++) {
int l = Int();
int r = Int();
int ans = S[r] - S[l - 1];
if (s[r - 1] == 'A')
ans--;
wl(ans);
}
}
#endregion
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Program {
#region library
static int n = 0;
static int r = 0;
static int c = 0;
static string s = "";
static string[] ss;
static long sum = 0;
static long cnt = 0;
static long max = -1;
static long min = 2147483647;
static bool flg = false;
static string alpha = "abcdefghijklmnopqrstuvwxyz";
static long mod = 1000000007;
static long[] arr;
static char[,] map;
static int[,] imap;
static Queue<int> qx = new Queue<int>();
static Queue<int> qy = new Queue<int>();
public class Input {
static readonly char[] separator = { ' ', '\r', '\n' };
readonly StreamReader sr;
readonly Queue<string> queue;
public Input(string path = "") {
queue = new Queue<string>();
if (string.IsNullOrEmpty(path)) {
sr = new StreamReader(Console.OpenStandardInput());
} else {
sr = new StreamReader(path);
}
}
public void SetText(IEnumerable<string> items) {
foreach (var item in items) {
SetText(item);
}
}
public bool SetText(string s) {
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
queue.Enqueue(elem);
}
return true;
}
public bool Any() { return queue.Any() || Read(); }
bool Read() {
if (!SetText(sr.ReadLine()))
return false;
if (!queue.Any())
return Read();
return queue.Any();
}
public string Next() {
if (!queue.Any() && !Read()) {
return "";
}
return queue.Dequeue();
}
bool Accumulate(int n) {
while (queue.Count() < n) {
if (!Read())
return false;
}
return true;
}
public int NextInt() { return int.Parse(Next()); }
public long NextLong() { return long.Parse(Next()); }
public double NextDouble() { return double.Parse(Next()); }
T[] NextT<T>(int n, T offset, Func<string, T> parse, Func<T, T, T> add) {
if (!Accumulate(n))
return null;
var a = new T[n];
for (int i = 0; i < n; i++)
a[i] = add(parse(queue.Dequeue()), offset);
return a;
}
public string[] Next(int n) { return NextT(n, "", x => x, (x, y) => x); }
public int[] NextInt(int n, int offset = 0) {
return NextT(n, offset, int.Parse, (x, y) => x + y);
}
public long[] NextLong(int n, long offset = 0) {
return NextT(n, offset, long.Parse, (x, y) => x + y);
}
public double[] NextDouble(int n, double offset = 0.0) {
return NextT(n, offset, double.Parse, (x, y) => x + y);
}
}
static Input input;
static int Int() { return input.NextInt(); }
static long Long() { return input.NextLong(); }
static double Double() { return input.NextDouble(); }
static string Text() { return input.Next(); }
static void wl(object obj = null) { Console.WriteLine(obj); }
static void w(object obj) { Console.Write(obj); }
static void Yes() { wl("YES"); }
static void No() { wl("NO"); }
static void Sum() { wl(sum); }
static void Cnt() { wl(cnt); }
static void SetArray(long num = -1) {
if (n == 0) {
n = Int();
}
arr = new long[n];
for (int i = 0; i < n; i++) {
if (num == -1)
arr[i] = Int();
else
arr[i] = num;
}
}
static void ShowArray() {
for (int i = 0; i < arr.Length; i++) {
if (i > 0)
w(" ");
w(arr[i]);
}
wl();
}
static void SetMap(char def = '@') {
if (r == 0 && c == 0) {
r = Int();
c = Int();
}
map = new char[r, c];
for (int i = 0; i < r; i++) {
if (def == '@')
s = Text();
for (int j = 0; j < c; j++) {
map[i, j] = (def == '@') ? s[j] : def;
}
}
}
static void SetIMap(int def = -1) {
if (r == 0 && c == 0) {
r = Int();
c = Int();
}
imap = new int[r, c];
for (int i = 0; i < r; i++) {
for (int j = 0; j < c; j++) {
imap[i, j] = (def == -1) ? Int() : def;
}
}
}
static void ShowMap() {
for (int i = 0; i < r; i++) {
for (int j = 0; j < c; j++) {
w(map[i, j]);
}
wl();
}
}
static void ShowIMap() {
for (int i = 0; i < r; i++) {
for (int j = 0; j < c; j++) {
w(imap[i, j]);
}
wl();
}
}
#endregion
#region main
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
input = new Input();
try {
Solve();
} catch (Exception ex) {
wl(ex);
}
Console.Out.Flush();
}
public static void Solve() {
n = Int();
int q = Int();
s = Text();
var S = new int[n + 1];
S[0] = 0;
for (int i = 1; i < n + 1; i++) {
if (i < n && s[i - 1] == 'A' && s[i] == 'C')
S[i] = S[i - 1] + 1;
else
S[i] = S[i - 1];
}
for (int i = 0; i < q; i++) {
int l = Int();
int r = Int();
int ans = S[r] - S[l - 1];
if (r < n && s[r - 1] == 'A' && s[r] == 'C')
ans--;
wl(ans);
}
}
#endregion
}
|
[["+", 0, 57, 15, 16, 31, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 17, 18], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 12, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 98], ["+", 15, 16, 31, 16, 12, 16, 12, 252, 0, 104], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 0, 57, 15, 16, 12, 16, 31, 204, 205, 22], ["+", 15, 16, 12, 16, 31, 204, 206, 207, 0, 70], ["+", 12, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 15, 16, 12, 16, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 0, 57, 15, 16, 12, 16, 12, 252, 0, 104], ["+", 0, 57, 15, 16, 12, 16, 12, 252, 0, 253]]
| 8
| 1,583
| 13
|
using System;
using System.Linq;
namespace CSharp {
class Program {
static void Main() {
var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var N = input[0];
var Q = input[1];
var S = Console.ReadLine();
var lr = new int [Q][];
for (int i = 0; i < Q; i++) {
lr[i] = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
var t = new int[N + 1];
for (int i = 0; i < N; i++) {
if (S[i] == 'A' && S[i + 1] == 'C') {
t[i + 1] = t[i] + 1;
} else {
t[i + 1] = t[i];
}
}
for (int i = 0; i < Q; i++) {
Console.WriteLine(t[lr[i][1] - 1] - t[lr[i][0] - 1]);
}
}
}
}
|
using System;
using System.Linq;
namespace CSharp {
class Program {
static void Main() {
var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var N = input[0];
var Q = input[1];
var S = Console.ReadLine();
var lr = new int [Q][];
for (int i = 0; i < Q; i++) {
lr[i] = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
var t = new int[N + 1];
for (int i = 1; i < N; i++) {
if (S[i - 1] == 'A' && S[i] == 'C') {
t[i + 1] = t[i] + 1;
} else {
t[i + 1] = t[i];
}
}
for (int i = 0; i < Q; i++) {
Console.WriteLine(t[lr[i][1]] - t[lr[i][0]]);
}
}
}
}
|
[["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 17, 72], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203]]
| 8
| 258
| 10
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
class Program {
const long beki = 1000000007;
static void Main(string[] args) {
//入力を受け取る
int[] NQ =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
int N = NQ[0];
int Q = NQ[1];
var S = Console.ReadLine();
var ACamount = new int[N + 1];
for (int i = 0; i < N - 1; i++) {
if (S[i] == 'A' && S[i + 1] == 'C') {
ACamount[i] = ACamount[i - 1] + 1;
} else {
ACamount[i] = ACamount[i - 1];
}
}
for (int i = 0; i < Q; i++) {
int[] lr =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
int l = lr[0];
int r = lr[1];
Console.WriteLine(ACamount[r - 1] - ACamount[l]);
}
}
}
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
class Program {
const long beki = 1000000007;
static void Main(string[] args) {
//入力を受け取る
int[] NQ =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
int N = NQ[0];
int Q = NQ[1];
var S = Console.ReadLine();
var ACamount = new int[N + 1];
for (int i = 0; i < N - 1; i++) {
if (S[i] == 'A' && S[i + 1] == 'C') {
ACamount[i + 1] = ACamount[i] + 1;
} else {
ACamount[i + 1] = ACamount[i];
}
}
for (int i = 0; i < Q; i++) {
int[] lr =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
int l = lr[0];
int r = lr[1];
Console.WriteLine(ACamount[r - 1] - ACamount[l - 1]);
}
}
}
|
[["+", 31, 204, 206, 207, 0, 28, 0, 16, 17, 72], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203]]
| 8
| 277
| 10
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
return;
}
public void Solve(ConsoleInput cin) {
var N = cin.ReadInt;
var Q = cin.ReadInt;
var S = cin.ReadLine.ToCharArray();
int[] l = new int[Q];
int[] r = new int[Q];
for (int i = 0; i < Q; i++) {
l[i] = cin.ReadInt;
r[i] = cin.ReadInt;
}
int[] t = new int[N + 1];
t[0] = 0;
for (int i = 0; i < N; i++) {
int ac = 0;
if (S[i] == 'A' && S[i + 1] == 'C') {
ac = 1;
} else {
ac = 0;
}
t[i + 1] = t[i] + ac;
}
for (int i = 0; i < Q; i++) {
Console.WriteLine(t[r[i] - 1] - t[l[i] - 1]);
}
}
}
public static class Extensions {
public static string Reverse(this string sourse) {
char[] chrAry = sourse.ToCharArray();
Array.Reverse(chrAry);
return new string(chrAry);
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
return;
}
public void Solve(ConsoleInput cin) {
var N = cin.ReadInt;
var Q = cin.ReadInt;
var S = cin.ReadLine.ToCharArray();
int[] l = new int[Q];
int[] r = new int[Q];
for (int i = 0; i < Q; i++) {
l[i] = cin.ReadInt;
r[i] = cin.ReadInt;
}
int[] t = new int[N + 1];
t[0] = 0;
for (int i = 1; i < N; i++) {
int ac = 0;
if (S[i - 1] == 'A' && S[i] == 'C') {
ac = 1;
} else {
ac = 0;
}
t[i] = t[i - 1] + ac;
}
for (int i = 0; i < Q; i++) {
Console.WriteLine(t[r[i] - 1] - t[l[i] - 1]);
}
}
}
public static class Extensions {
public static string Reverse(this string sourse) {
char[] chrAry = sourse.ToCharArray();
Array.Reverse(chrAry);
return new string(chrAry);
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
[["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 17, 72], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 12, 203]]
| 8
| 680
| 10
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using static System.Console;
using static System.Math;
class Program {
static void Main(string[] args) {
int[] NQ = ReadLineParseIntArray();
string S = ReadLine();
int[] counts = new int[NQ[1]];
int[] memo = new int[NQ[0] + 1];
for (int i = 2; i <= NQ[0]; i++) {
memo[i] = memo[i - 1];
memo[i] += S[i - 1] == 'C' && S[i - 2] == 'A' ? 1 : 0;
}
foreach (var i in memo)
WriteLine(i);
for (int i = 0; i < NQ[1]; i++) {
int[] lr = ReadLineParseIntArray();
counts[i] = memo[lr[1]] - memo[lr[0]];
}
for (int i = 0; i < NQ[1]; i++)
WriteLine(counts[i]);
}
static int ReadLineParseInt() => int.Parse(ReadLine());
static int[] ReadLineParseIntArray() =>
ReadLine().Split(' ').Select(int.Parse).ToArray();
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using static System.Console;
using static System.Math;
class Program {
static void Main(string[] args) {
int[] NQ = ReadLineParseIntArray();
string S = ReadLine();
int[] counts = new int[NQ[1]];
int[] memo = new int[NQ[0] + 1];
for (int i = 2; i <= NQ[0]; i++) {
memo[i] = memo[i - 1];
memo[i] += S[i - 1] == 'C' && S[i - 2] == 'A' ? 1 : 0;
}
for (int i = 0; i < NQ[1]; i++) {
int[] lr = ReadLineParseIntArray();
counts[i] = memo[lr[1]] - memo[lr[0]];
}
for (int i = 0; i < NQ[1]; i++)
WriteLine(counts[i]);
}
static int ReadLineParseInt() => int.Parse(ReadLine());
static int[] ReadLineParseIntArray() =>
ReadLine().Split(' ').Select(int.Parse).ToArray();
}
|
[["-", 8, 201, 0, 195, 8, 196, 0, 210, 0, 266], ["-", 8, 201, 0, 195, 8, 196, 0, 210, 0, 24], ["-", 0, 195, 8, 196, 0, 210, 39, 216, 0, 217], ["-", 8, 201, 0, 195, 8, 196, 0, 210, 31, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 210, 0, 267], ["-", 8, 201, 0, 195, 8, 196, 0, 210, 12, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 210, 0, 25], ["-", 8, 196, 0, 210, 8, 1, 0, 213, 63, 22], ["-", 0, 210, 8, 1, 0, 213, 3, 4, 0, 24], ["-", 8, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 0, 210, 8, 1, 0, 213, 3, 4, 0, 25], ["-", 0, 195, 8, 196, 0, 210, 8, 1, 0, 35]]
| 8
| 286
| 12
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.