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;
class CF2016QAC {
static public void Main(string[] args) {
string s = Console.ReadLine();
int K = int.Parse(Console.ReadLine());
int[] c = new int[s.Length];
for (int i = 0; i < c.Length; i++) {
c[i] = s[i] - 'a';
}
for (int i = 0; i < c.Length; i++) {
if (c[i] == 0)
continue;
else {
if (26 - c[i] < K) {
K -= 26 - c[i];
c[i] = 0;
}
}
}
c[c.Length - 1] = (c[c.Length - 1] + K) % 26;
for (int i = 0; i < c.Length; i++) {
Console.Write((char)('a' + c[i]));
}
Console.WriteLine();
}
}
|
using System;
class CF2016QAC {
static public void Main(string[] args) {
string s = Console.ReadLine();
int K = int.Parse(Console.ReadLine());
int[] c = new int[s.Length];
for (int i = 0; i < c.Length; i++) {
c[i] = s[i] - 'a';
}
for (int i = 0; i < c.Length; i++) {
if (c[i] == 0)
continue;
else {
if (26 - c[i] <= K) {
K -= 26 - c[i];
c[i] = 0;
}
}
// Console.WriteLine("K={0}", K);
// Console.WriteLine("c[{0}]={1}", i, c[i]);
}
c[c.Length - 1] = (c[c.Length - 1] + K) % 26;
for (int i = 0; i < c.Length; i++) {
Console.Write((char)('a' + c[i]));
}
Console.WriteLine();
}
}
|
[["-", 0, 57, 75, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 17, 19]]
| 8
| 215
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;
class Program {
public Program() {}
static void Main(string[] args) { new Program().prog(); }
Scanner cin;
const int MOD = 1000000007;
const int INF = int.MaxValue;
const double EPS = 1e-7;
const double PI = 3.1415926536;
void prog() {
cin = new Scanner();
int[,] dir8 = new int[8, 2] { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 },
{ 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 } };
int[,] dir4 = new int[4, 2] { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };
char[] str = cin.next().ToCharArray();
int K = cin.nextInt();
int res = 0;
char c;
for (int i = 0; i < str.Length; i++) {
c = str[i];
res = 'z' - c + 1;
if (res <= K) {
K -= res;
str[i] = 'a';
}
}
str[str.Length - 1] = (char)(str[str.Length - 1] + (K % 26));
Console.WriteLine(new string(str));
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
i = 0;
return next();
}
public int nextInt() { return int.Parse(next()); }
public long nextLong() { return long.Parse(next()); }
public double nextDouble() { return double.Parse(next()); }
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;
class Program {
public Program() {}
static void Main(string[] args) { new Program().prog(); }
Scanner cin;
const int MOD = 1000000007;
const int INF = int.MaxValue;
const double EPS = 1e-7;
const double PI = 3.1415926536;
void prog() {
cin = new Scanner();
int[,] dir8 = new int[8, 2] { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 },
{ 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 } };
int[,] dir4 = new int[4, 2] { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };
char[] str = cin.next().ToCharArray();
int K = cin.nextInt();
int res = 0;
char c;
for (int i = 0; i < str.Length; i++) {
c = str[i];
res = 'z' - c + 1;
if (res != 26 && res <= K) {
K -= res;
str[i] = 'a';
}
}
str[str.Length - 1] = (char)(str[str.Length - 1] + (K % 26));
Console.WriteLine(new string(str));
}
}
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()); }
}
|
[["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 79], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22]]
| 8
| 520
| 4
|
using System;
using System.Collections.Generic;
using System.Text;
class Solve {
string s;
int n;
int[] x;
long k;
public Solve() {}
public static int Main() {
new Solve().Calc();
return 0;
}
void Calc() {
string ans;
getinput();
StringBuilder sb = new StringBuilder(n);
for (int i = 0; i < n; i++) {
if (i == n - 1) {
sb.Append((char)(('a' + ((k + 26 - x[i]) % 26))) + "");
} else {
if (x[i] < k) {
sb.Append("a");
k -= x[i];
} else {
sb.Append(s[i] + "");
}
}
}
ans = sb.ToString();
Console.WriteLine(ans);
}
void getinput() {
s = Console.ReadLine();
n = s.Length;
x = new int[n];
for (int i = 0; i < n; i++) {
if (s[i] == 'a')
x[i] = 0;
else
x[i] = 'z' - s[i] + 1;
}
k = Int64.Parse(Console.ReadLine());
}
}
|
using System;
using System.Collections.Generic;
using System.Text;
class Solve {
string s;
int n;
int[] x;
long k;
public Solve() {}
public static int Main() {
new Solve().Calc();
return 0;
}
void Calc() {
string ans;
getinput();
StringBuilder sb = new StringBuilder(n);
for (int i = 0; i < n; i++) {
if (i == n - 1) {
sb.Append((char)(('a' + ((k + 26 - x[i]) % 26))) + "");
} else {
if (x[i] <= k) {
sb.Append("a");
k -= x[i];
} else {
sb.Append(s[i] + "");
}
}
}
ans = sb.ToString();
Console.WriteLine(ans);
}
void getinput() {
s = Console.ReadLine();
n = s.Length;
x = new int[n];
for (int i = 0; i < n; i++) {
if (s[i] == 'a')
x[i] = 0;
else
x[i] = 'z' - s[i] + 1;
}
k = Int64.Parse(Console.ReadLine());
}
}
|
[["-", 0, 57, 75, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 17, 19]]
| 8
| 294
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace c {
class Program {
static void Main(string[] args) {
char[] s = Console.ReadLine().ToCharArray();
int k = int.Parse(Console.ReadLine());
for (int i = 0; i < s.Length; i++) {
if (s[i] == 'a')
continue;
if ('z' - s[i] > k) {
k -= ('z' - s[i] + 1);
s[i] = 'a';
}
}
k %= 26;
if (s[s.Length - 1] + k <= 'z') {
s[s.Length - 1] = (char)(s[s.Length - 1] + k);
} else {
s[s.Length - 1] = (char)(s[s.Length - 1] + k - 26);
}
Console.WriteLine(s);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace c {
class Program {
static void Main(string[] args) {
char[] s = Console.ReadLine().ToCharArray();
int k = int.Parse(Console.ReadLine());
for (int i = 0; i < s.Length; i++) {
if (s[i] == 'a')
continue;
if ('z' - s[i] < k) {
k -= ('z' - s[i] + 1);
s[i] = 'a';
}
}
k %= 26;
if (s[s.Length - 1] + k <= 'z') {
s[s.Length - 1] = (char)(s[s.Length - 1] + k);
} else {
s[s.Length - 1] = (char)(s[s.Length - 1] + k - 26);
}
Console.WriteLine(s);
}
}
}
|
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 18]]
| 8
| 230
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;
class E {
static void Main() => new K();
}
class K {
const long InfL = 4011686018427387913L;
int F => int.Parse(Console.ReadLine());
int[] G => Console.ReadLine().Split().Select(_ => int.Parse(_)).ToArray();
int X, Y, V, N;
List<Tuple<int, int>>[] es;
void AddOneEdge(int a, int b, int w) => es[a].Add(new Tuple<int, int>(b, w));
void AddEdge(int a, int b, int w) {
AddOneEdge(a, b, w);
AddOneEdge(b, a, w);
}
public K() {
var I = G;
X = I[0];
Y = I[1];
N = F;
V = X + Y;
es = new List<Tuple<int, int>>[V];
for (var i = 0; i < V; i++)
es[i] = new List<Tuple<int, int>>();
for (var i = 0; i < N; i++) {
I = G;
AddEdge(I[0] - 1, I[1] - 1, I[2]);
}
var used = new bool[V];
for (var i = 0; i < V; i++)
if (!used[i]) {
var com = new Dictionary<int, int> { [i] = 0 };
var queue = new Queue<Tuple<int, Tuple<int, int>>>();
queue.Enqueue(
new Tuple<int, Tuple<int, int>>(-1, new Tuple<int, int>(i, 0)));
while (queue.Count > 0) {
var t = queue.Dequeue();
var e = t.Item2;
int p = t.Item1, v = e.Item1, w = e.Item2;
if (used[v])
continue;
used[v] = true;
if (p >= 0)
com[v] = w - com[p];
foreach (var f in es[v])
queue.Enqueue(new Tuple<int, Tuple<int, int>>(v, f));
}
long mx = InfL, my = InfL;
foreach (var k in com.Keys) {
foreach (var e in es[k])
if (com[k] + com[e.Item1] != e.Item2) {
Console.WriteLine("No");
return;
}
if (k < X)
mx = Min(mx, com[k]);
else
my = Min(my, com[k]);
}
if (mx + my < 0) {
Console.WriteLine("No");
return;
}
}
Console.WriteLine("Yes");
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;
class E {
static void Main() => new K();
}
class K {
const long InfL = 4011686018427387913L;
int F => int.Parse(Console.ReadLine());
int[] G => Console.ReadLine().Split().Select(_ => int.Parse(_)).ToArray();
int X, Y, V, N;
List<Tuple<int, int>>[] es;
void AddOneEdge(int a, int b, int w) => es[a].Add(new Tuple<int, int>(b, w));
void AddEdge(int a, int b, int w) {
AddOneEdge(a, b, w);
AddOneEdge(b, a, w);
}
public K() {
var I = G;
X = I[0];
Y = I[1];
N = F;
V = X + Y;
es = new List<Tuple<int, int>>[V];
for (var i = 0; i < V; i++)
es[i] = new List<Tuple<int, int>>();
for (var i = 0; i < N; i++) {
I = G;
AddEdge(I[0] - 1, X + I[1] - 1, I[2]);
}
var used = new bool[V];
for (var i = 0; i < V; i++)
if (!used[i]) {
var com = new Dictionary<int, int> { [i] = 0 };
var queue = new Queue<Tuple<int, Tuple<int, int>>>();
queue.Enqueue(
new Tuple<int, Tuple<int, int>>(-1, new Tuple<int, int>(i, 0)));
while (queue.Count > 0) {
var t = queue.Dequeue();
var e = t.Item2;
int p = t.Item1, v = e.Item1, w = e.Item2;
if (used[v])
continue;
used[v] = true;
if (p >= 0)
com[v] = w - com[p];
foreach (var f in es[v])
queue.Enqueue(new Tuple<int, Tuple<int, int>>(v, f));
}
long mx = InfL, my = InfL;
foreach (var k in com.Keys) {
foreach (var e in es[k])
if (com[k] + com[e.Item1] != e.Item2) {
Console.WriteLine("No");
return;
}
if (k < X)
mx = Min(mx, com[k]);
else
my = Min(my, com[k]);
}
if (mx + my < 0) {
Console.WriteLine("No");
return;
}
}
Console.WriteLine("Yes");
}
}
|
[["+", 3, 4, 0, 28, 0, 16, 31, 16, 31, 22], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 17, 72]]
| 8
| 645
| 2
|
using System;
using System.Collections.Generic;
class Solve {
int n;
int m;
int q;
int[] a;
public Solve() {}
public static int Main() {
new Solve().Calc();
return 0;
}
void Calc() {
getinput();
bool[] check = new bool[m];
int[] counts = new int[m];
int[] place = new int[m];
int[] s = new int[m];
int count = m - 2;
for (int i = 0; i < m; i++) {
check[i] = false;
counts[i] = 0;
}
{
int j = 0;
for (int i = q - 1; i >= 0; i--) {
if (!check[a[i]]) {
check[a[i]] = true;
place[a[i]] = j;
s[j] = a[i];
j++;
}
}
for (int i = 0; i < m; i++) {
if (!check[i]) {
place[i] = j;
s[j] = i;
j++;
}
}
}
for (int i = q - 1; i >= 0; i--) {
if (counts[place[a[i]]] < n) {
if (place[a[i]] != 0 && counts[place[a[i]] - 1] > counts[place[a[i]]]) {
counts[place[a[i]]]++;
}
}
}
while (count >= 0) {
if (s[count] < s[count + 1]) {
count--;
} else {
break;
}
}
if (count >= 0 && counts[count] < n) {
Console.WriteLine("No");
} else {
Console.WriteLine("Yes");
}
// for(int i=0;i<=count;i++){
// if(counts[i]<n){
// Console.WriteLine("No");
// return;
// }
// }
// Console.WriteLine("Yes");
}
void getinput() {
string[] str = Console.ReadLine().Split(' ');
n = int.Parse(str[0]);
m = int.Parse(str[1]);
q = int.Parse(Console.ReadLine());
str = Console.ReadLine().Split(' ');
a = new int[q];
for (int i = 0; i < q; i++) {
a[i] = int.Parse(str[i]) - 1;
}
}
}
|
using System;
using System.Collections.Generic;
class Solve {
int n;
int m;
int q;
int[] a;
public Solve() {}
public static int Main() {
new Solve().Calc();
return 0;
}
void Calc() {
getinput();
bool[] check = new bool[m];
int[] counts = new int[m];
int[] place = new int[m];
int[] s = new int[m];
int count = m - 2;
for (int i = 0; i < m; i++) {
check[i] = false;
counts[i] = 0;
}
{
int j = 0;
for (int i = q - 1; i >= 0; i--) {
if (!check[a[i]]) {
check[a[i]] = true;
place[a[i]] = j;
s[j] = a[i];
j++;
}
}
for (int i = 0; i < m; i++) {
if (!check[i]) {
place[i] = j;
s[j] = i;
j++;
}
}
}
for (int i = q - 1; i >= 0; i--) {
if (counts[place[a[i]]] < n) {
if (place[a[i]] == 0 || counts[place[a[i]] - 1] > counts[place[a[i]]]) {
counts[place[a[i]]]++;
}
}
}
while (count >= 0) {
if (s[count] < s[count + 1]) {
count--;
} else {
break;
}
}
if (count >= 0 && counts[count] < n) {
Console.WriteLine("No");
} else {
Console.WriteLine("Yes");
}
// for(int i=0;i<=count;i++){
// if(counts[i]<n){
// Console.WriteLine("No");
// return;
// }
// }
// Console.WriteLine("Yes");
}
void getinput() {
string[] str = Console.ReadLine().Split(' ');
n = int.Parse(str[0]);
m = int.Parse(str[1]);
q = int.Parse(Console.ReadLine());
str = Console.ReadLine().Split(' ');
a = new int[q];
for (int i = 0; i < q; i++) {
a[i] = int.Parse(str[i]) - 1;
}
}
}
|
[["-", 64, 196, 0, 57, 15, 16, 31, 16, 17, 79], ["+", 64, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["-", 0, 57, 64, 196, 0, 57, 15, 16, 17, 98], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 106]]
| 8
| 536
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC045A {
class Program {
static void Main(string[] args) {
int a = int.Parse(Console.ReadLine());
int b = int.Parse(Console.ReadLine());
int h = int.Parse(Console.ReadLine());
Console.WriteLine((a * b) * h / 2);
Console.ReadKey();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC045A {
class Program {
static void Main(string[] args) {
int a = int.Parse(Console.ReadLine());
int b = int.Parse(Console.ReadLine());
int h = int.Parse(Console.ReadLine());
Console.WriteLine((a + b) * h / 2);
Console.ReadKey();
}
}
}
|
[["-", 0, 16, 31, 16, 31, 23, 0, 16, 17, 48], ["+", 0, 16, 31, 16, 31, 23, 0, 16, 17, 72]]
| 8
| 109
| 2
|
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
namespace Atcoder {
class Program {
static void Main(string[] args) {
var a = InputNum();
var b = InputNum();
var c = InputNum();
WriteLine(a * b * c / 2);
}
static int InputNum() { return int.Parse(ReadLine()); }
static List<int> InputNumList() {
return ReadLine().Split(' ').Select(int.Parse).ToList();
}
}
}
|
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
namespace Atcoder {
class Program {
static void Main(string[] args) {
var a = InputNum();
var b = InputNum();
var c = InputNum();
WriteLine((a + b) * c / 2);
}
static int InputNum() { return int.Parse(ReadLine()); }
static List<int> InputNumList() {
return ReadLine().Split(' ').Select(int.Parse).ToList();
}
}
}
|
[["+", 0, 28, 0, 16, 31, 16, 31, 23, 0, 24], ["-", 0, 28, 0, 16, 31, 16, 31, 16, 17, 48], ["+", 0, 16, 31, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 28, 0, 16, 31, 16, 31, 23, 0, 25]]
| 8
| 122
| 4
|
using System;
using System.Linq;
using System.Collections.Generic;
class P {
static void Main() {
string s = Console.ReadLine();
char lastc = s[0];
int res = 0;
foreach (var c in s) {
if (c != lastc) {
res++;
lastc = c;
}
}
Console.WriteLine(res - 1);
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
class P {
static void Main() {
string s = Console.ReadLine();
char lastc = s[0];
int res = 0;
foreach (var c in s) {
if (c != lastc) {
res++;
lastc = c;
}
}
Console.WriteLine(res);
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
| 8
| 81
| 2
|
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using Enu = System.Linq.Enumerable;
public class Program {
static readonly int INF = (int)1e9;
int N, K;
int[][] G;
int[] Val, MinVal, MaxVal;
public void Solve() {
N = Reader.Int();
G = EdgeRead(N);
K = Reader.Int();
Val = new int[N];
MinVal = Enu.Repeat(-INF, N).ToArray();
MaxVal = Enu.Repeat(INF, N).ToArray();
for (int i = 0; i < K; i++) {
int at = Reader.Int() - 1;
Val[at] = MinVal[at] = MaxVal[at] = Reader.Int();
}
DFS(0, -1);
if (!GenAnswer(0, -1)) {
Console.WriteLine("No");
return;
}
Console.WriteLine("Yes\n" + string.Join("\n", Val));
}
bool DFS(int v, int prev) {
foreach (int child in G[v])
if (child != prev) {
if (!DFS(child, v))
return false;
MinVal[v] = Math.Max(MinVal[v], MinVal[child] - 1);
MaxVal[v] = Math.Min(MaxVal[v], MaxVal[child] + 1);
}
return MinVal[v] <= MaxVal[v];
}
bool GenAnswer(int v, int prev) {
if (prev == -1)
Val[v] = MinVal[v];
else if (Val[prev] - 1 >= MinVal[v])
Val[v] = Val[prev] - 1;
else if (Val[prev] + 1 <= MaxVal[v])
Val[v] = Val[prev] + 1;
else
return false;
foreach (int child in G[v])
if (child != prev)
if (!GenAnswer(child, v))
return false;
return true;
}
int[][] EdgeRead(int V, int E = -1, int origin = 1) {
if (E == -1)
E = V - 1;
var es = new List<int>[V];
for (int i = 0; i < V; i++)
es[i] = new List<int>();
for (int i = 0; i < E; i++) {
int a = Reader.Int() - origin, b = Reader.Int() - origin;
es[a].Add(b);
es[b].Add(a);
}
return es.Select(a => a.ToArray()).ToArray();
}
}
class Entry {
static void Main() { new Program().Solve(); }
}
class Reader {
static TextReader reader = Console.In;
static readonly char[] separator = { ' ' };
static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
static string[] A = new string[0];
static int i;
static void Init() { A = new string[0]; }
public static void Set(TextReader r) {
reader = r;
Init();
}
public static void Set(string file) {
reader = new StreamReader(file);
Init();
}
public static bool HasNext() { return CheckNext(); }
public static string String() { return Next(); }
public static int Int() { return int.Parse(Next()); }
public static long Long() { return long.Parse(Next()); }
public static double Double() { return double.Parse(Next()); }
public static int[] IntLine() {
return Array.ConvertAll(Split(Line()), int.Parse);
}
public static int[] IntArray(int N) { return Range(N, Int); }
public static int[][] IntTable(int H) { return Range(H, IntLine); }
public static string[] StringArray(int N) { return Range(N, Next); }
public static string[][] StringTable(int N) {
return Range(N, () => Split(Line()));
}
public static string Line() { return reader.ReadLine().Trim(); }
public static T[] Range<T>(int N, Func<T> f) {
var r = new T[N];
for (int i = 0; i < N; r[i++] = f())
;
return r;
}
static string[] Split(string s) { return s.Split(separator, op); }
static string Next() {
CheckNext();
return A[i++];
}
static bool CheckNext() {
if (i < A.Length)
return true;
string line = reader.ReadLine();
if (line == null)
return false;
if (line == "")
return CheckNext();
A = Split(line);
i = 0;
return true;
}
}
|
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using Enu = System.Linq.Enumerable;
public class Program {
static readonly int INF = (int)1e9;
int N, K;
int[][] G;
int[] Val, MinVal, MaxVal;
public void Solve() {
N = Reader.Int();
G = EdgeRead(N);
K = Reader.Int();
Val = new int[N];
MinVal = Enu.Repeat(-INF, N).ToArray();
MaxVal = Enu.Repeat(INF, N).ToArray();
for (int i = 0; i < K; i++) {
int at = Reader.Int() - 1;
Val[at] = MinVal[at] = MaxVal[at] = Reader.Int();
}
if (!DFS(0, -1) || !GenAnswer(0, -1)) {
Console.WriteLine("No");
return;
}
Console.WriteLine("Yes\n" + string.Join("\n", Val));
}
bool DFS(int v, int prev) {
foreach (int child in G[v])
if (child != prev) {
if (!DFS(child, v))
return false;
MinVal[v] = Math.Max(MinVal[v], MinVal[child] - 1);
MaxVal[v] = Math.Min(MaxVal[v], MaxVal[child] + 1);
}
return MinVal[v] <= MaxVal[v];
}
bool GenAnswer(int v, int prev) {
if (prev == -1)
Val[v] = MinVal[v];
else if (Val[prev] - 1 >= MinVal[v])
Val[v] = Val[prev] - 1;
else if (Val[prev] + 1 <= MaxVal[v])
Val[v] = Val[prev] + 1;
else
return false;
foreach (int child in G[v])
if (child != prev)
if (!GenAnswer(child, v))
return false;
return true;
}
int[][] EdgeRead(int V, int E = -1, int origin = 1) {
if (E == -1)
E = V - 1;
var es = new List<int>[V];
for (int i = 0; i < V; i++)
es[i] = new List<int>();
for (int i = 0; i < E; i++) {
int a = Reader.Int() - origin, b = Reader.Int() - origin;
es[a].Add(b);
es[b].Add(a);
}
return es.Select(a => a.ToArray()).ToArray();
}
}
class Entry {
static void Main() { new Program().Solve(); }
}
class Reader {
static TextReader reader = Console.In;
static readonly char[] separator = { ' ' };
static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
static string[] A = new string[0];
static int i;
static void Init() { A = new string[0]; }
public static void Set(TextReader r) {
reader = r;
Init();
}
public static void Set(string file) {
reader = new StreamReader(file);
Init();
}
public static bool HasNext() { return CheckNext(); }
public static string String() { return Next(); }
public static int Int() { return int.Parse(Next()); }
public static long Long() { return long.Parse(Next()); }
public static double Double() { return double.Parse(Next()); }
public static int[] IntLine() {
return Array.ConvertAll(Split(Line()), int.Parse);
}
public static int[] IntArray(int N) { return Range(N, Int); }
public static int[][] IntTable(int H) { return Range(H, IntLine); }
public static string[] StringArray(int N) { return Range(N, Next); }
public static string[][] StringTable(int N) {
return Range(N, () => Split(Line()));
}
public static string Line() { return reader.ReadLine().Trim(); }
public static T[] Range<T>(int N, Func<T> f) {
var r = new T[N];
for (int i = 0; i < N; r[i++] = f())
;
return r;
}
static string[] Split(string s) { return s.Split(separator, op); }
static string Next() {
CheckNext();
return A[i++];
}
static bool CheckNext() {
if (i < A.Length)
return true;
string line = reader.ReadLine();
if (line == null)
return false;
if (line == "")
return CheckNext();
A = Split(line);
i = 0;
return true;
}
}
|
[["+", 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, 241, 0, 111], ["-", 8, 201, 0, 195, 8, 196, 0, 1, 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, 17, 106]]
| 8
| 1,121
| 7
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace ARC063E {
public class Program {
// Atcoder Live 解説を参考にしました。
public static void Main(string[] args) {
var sr = new StreamReader();
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
//---------------------------------
//すべての辺をコスト1とする
var N = sr.Next<int>();
var dj = new Dijkstra(N + 1);
for (var i = 0; i < N - 1; i++) {
var A = sr.Next<int>();
var B = sr.Next<int>();
dj.AddUndirectedEdge(A, B, 1);
}
//頂点0(新しく作る)と整数Pが書かれている頂点をコストPの辺として結ぶ
var K = sr.Next<int>();
var dic = new Dictionary<int, int>();
for (var i = 0; i < K; i++) {
var V = sr.Next<int>();
var P = sr.Next<int>();
dj.AddUndirectedEdge(0, V, P);
dic.Add(V, P);
}
//頂点0からの最短距離を求める
var res = dj.Solve(0);
//整数Pが書かれている頂点に対して、最短距離と一致しなかったら"No"
if (dic.Keys.Any(v => res[v] != dic[v])) {
sw.WriteLine("No");
return;
}
//辺で結ばれている2つの頂点の差が1でなかったら"No"
for (var i = 1; i <= N; i++) {
if (dj.Adj[i].Any(e => e.To != 0 && Math.Abs(res[i] - res[e.To]) != 1)) {
sw.WriteLine("No");
return;
}
}
//頂点0を除いた最短距離をそのまま出力
sw.WriteLine("Yes");
sw.WriteLine(string.Join("\n", res.Skip(1)));
//---------------------------------
sw.Flush();
}
}
public class Dijkstra {
public class Edge {
public int To;
public int Cost;
}
public class Node : IComparable<Node> {
public int Id;
public int Cost;
public int CompareTo(Node node) { return Math.Sign(Cost - node.Cost); }
}
public readonly List<Edge>[] Adj;
public Dijkstra(int v) {
Adj = new List<Edge>[v];
for (var i = 0; i < v; i++)
Adj[i] = new List<Edge>();
}
public void AddEdge(int from, int to, int cost) {
Adj[from].Add(new Edge { To = to, Cost = cost });
}
public void AddUndirectedEdge(int v1, int v2, int cost) {
AddEdge(v1, v2, cost);
AddEdge(v2, v1, cost);
}
public int[] Solve(int start) {
var v = Adj.Length;
var dist = new int[v];
for (var i = 0; i < v; i++)
dist[i] = int.MaxValue;
dist[start] = 0;
var pq = new PriorityQueue<Node>();
pq.Enqueue(new Node { Id = start, Cost = 0 });
while (pq.Count > 0) {
var node = pq.Dequeue();
var from = node.Id;
foreach (var edge in Adj[from]) {
var to = edge.To;
var cost = node.Cost + edge.Cost;
if (cost >= dist[to])
continue;
dist[to] = cost;
pq.Enqueue(new Node { Id = to, Cost = cost });
}
}
return dist;
}
}
public class PriorityQueue<T> : IEnumerable<T>
where T : IComparable<T> {
private readonly List<T> _list = new List<T>();
public int Count => _list.Count;
IEnumerator<T> IEnumerable<T>.GetEnumerator() {
return _list.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator() { return _list.GetEnumerator(); }
public void Clear() { _list.Clear(); }
public bool Contains(T value) { return _list.Contains(value); }
public T Peek() { return _list[0]; }
public void Enqueue(T value) {
_list.Add(value);
PushHeap();
}
public T Dequeue() {
var ret = _list[0];
_list[0] = _list[Count - 1];
_list.RemoveAt(Count - 1);
PopHeap();
return ret;
}
private void PushHeap() {
var i = Count - 1;
while (i != 0) {
var p = (i - 1) / 2;
if (_list[i].CompareTo(_list[p]) > 0)
return;
SwapIndex(i, i = p);
}
}
private void PopHeap() {
var i = 0;
while (true) {
var l = 2 * i + 1;
var r = l + 1;
var maxi = i;
if (l < Count && _list[maxi].CompareTo(_list[l]) > 0)
maxi = l;
if (r < Count && _list[maxi].CompareTo(_list[r]) > 0)
maxi = r;
if (maxi == i)
return;
SwapIndex(i, i = maxi);
}
}
private void SwapIndex(int left, int right) {
var tmp = _list[left];
_list[left] = _list[right];
_list[right] = tmp;
}
}
public class StreamReader {
private readonly char[] _c = { ' ' };
private int _index = -1;
private string[] _input = new string[0];
private readonly System.IO.StreamReader _sr =
new System.IO.StreamReader(Console.OpenStandardInput());
public T Next<T>() {
if (_index == _input.Length - 1) {
_index = -1;
while (true) {
string rl = _sr.ReadLine();
if (rl == null) {
if (typeof(T).IsClass)
return default(T);
return (T) typeof(T).GetField("MinValue").GetValue(null);
}
if (rl != "") {
_input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
break;
}
}
}
return (T)Convert.ChangeType(
_input[++_index], typeof(T),
System.Globalization.CultureInfo.InvariantCulture);
}
public T[] Next<T>(int x) {
var ret = new T[x];
for (var i = 0; i < x; ++i)
ret[i] = Next<T>();
return ret;
}
public T[][] Next<T>(int y, int x) {
var ret = new T[y][];
for (var i = 0; i < y; ++i)
ret[i] = Next<T>(x);
return ret;
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace ARC063E {
public class Program {
// Atcoder Live 解説を参考にしました。
public static void Main(string[] args) {
var sr = new StreamReader();
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
//---------------------------------
//すべての辺をコスト1とする
var N = sr.Next<int>();
var dj = new Dijkstra(N + 1);
for (var i = 0; i < N - 1; i++) {
var A = sr.Next<int>();
var B = sr.Next<int>();
dj.AddUndirectedEdge(A, B, 1);
}
//頂点0(新しく作る)と整数Pが書かれている頂点をコストPの辺として結ぶ
var K = sr.Next<int>();
var dic = new Dictionary<int, int>();
for (var i = 0; i < K; i++) {
var V = sr.Next<int>();
var P = sr.Next<int>();
dj.AddUndirectedEdge(0, V, P);
dic.Add(V, P);
}
//頂点0からの最短距離を求める
var res = dj.Solve(0);
//整数Pが書かれている頂点に対して、最短距離と一致しなかったら"No"
if (dic.Keys.Any(v => res[v] != dic[v])) {
Console.WriteLine("No");
return;
}
//辺で結ばれている2つの頂点の差が1でなかったら"No"
for (var i = 1; i <= N; i++) {
if (dj.Adj[i].Any(e => e.To != 0 && Math.Abs(res[i] - res[e.To]) != 1)) {
Console.WriteLine("No");
return;
}
}
//頂点0を除いた最短距離をそのまま出力
sw.WriteLine("Yes");
sw.WriteLine(string.Join("\n", res.Skip(1)));
//---------------------------------
sw.Flush();
}
}
public class Dijkstra {
public class Edge {
public int To;
public int Cost;
}
public class Node : IComparable<Node> {
public int Id;
public int Cost;
public int CompareTo(Node node) { return Math.Sign(Cost - node.Cost); }
}
public readonly List<Edge>[] Adj;
public Dijkstra(int v) {
Adj = new List<Edge>[v];
for (var i = 0; i < v; i++)
Adj[i] = new List<Edge>();
}
public void AddEdge(int from, int to, int cost) {
Adj[from].Add(new Edge { To = to, Cost = cost });
}
public void AddUndirectedEdge(int v1, int v2, int cost) {
AddEdge(v1, v2, cost);
AddEdge(v2, v1, cost);
}
public int[] Solve(int start) {
var v = Adj.Length;
var dist = new int[v];
for (var i = 0; i < v; i++)
dist[i] = int.MaxValue;
dist[start] = 0;
var pq = new PriorityQueue<Node>();
pq.Enqueue(new Node { Id = start, Cost = 0 });
while (pq.Count > 0) {
var node = pq.Dequeue();
var from = node.Id;
foreach (var edge in Adj[from]) {
var to = edge.To;
var cost = node.Cost + edge.Cost;
if (cost >= dist[to])
continue;
dist[to] = cost;
pq.Enqueue(new Node { Id = to, Cost = cost });
}
}
return dist;
}
}
public class PriorityQueue<T> : IEnumerable<T>
where T : IComparable<T> {
private readonly List<T> _list = new List<T>();
public int Count => _list.Count;
IEnumerator<T> IEnumerable<T>.GetEnumerator() {
return _list.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator() { return _list.GetEnumerator(); }
public void Clear() { _list.Clear(); }
public bool Contains(T value) { return _list.Contains(value); }
public T Peek() { return _list[0]; }
public void Enqueue(T value) {
_list.Add(value);
PushHeap();
}
public T Dequeue() {
var ret = _list[0];
_list[0] = _list[Count - 1];
_list.RemoveAt(Count - 1);
PopHeap();
return ret;
}
private void PushHeap() {
var i = Count - 1;
while (i != 0) {
var p = (i - 1) / 2;
if (_list[i].CompareTo(_list[p]) > 0)
return;
SwapIndex(i, i = p);
}
}
private void PopHeap() {
var i = 0;
while (true) {
var l = 2 * i + 1;
var r = l + 1;
var maxi = i;
if (l < Count && _list[maxi].CompareTo(_list[l]) > 0)
maxi = l;
if (r < Count && _list[maxi].CompareTo(_list[r]) > 0)
maxi = r;
if (maxi == i)
return;
SwapIndex(i, i = maxi);
}
}
private void SwapIndex(int left, int right) {
var tmp = _list[left];
_list[left] = _list[right];
_list[right] = tmp;
}
}
public class StreamReader {
private readonly char[] _c = { ' ' };
private int _index = -1;
private string[] _input = new string[0];
private readonly System.IO.StreamReader _sr =
new System.IO.StreamReader(Console.OpenStandardInput());
public T Next<T>() {
if (_index == _input.Length - 1) {
_index = -1;
while (true) {
string rl = _sr.ReadLine();
if (rl == null) {
if (typeof(T).IsClass)
return default(T);
return (T) typeof(T).GetField("MinValue").GetValue(null);
}
if (rl != "") {
_input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
break;
}
}
}
return (T)Convert.ChangeType(
_input[++_index], typeof(T),
System.Globalization.CultureInfo.InvariantCulture);
}
public T[] Next<T>(int x) {
var ret = new T[x];
for (var i = 0; i < x; ++i)
ret[i] = Next<T>();
return ret;
}
public T[][] Next<T>(int y, int x) {
var ret = new T[y][];
for (var i = 0; i < y; ++i)
ret[i] = Next<T>(x);
return ret;
}
}
}
|
[["-", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22]]
| 8
| 1,450
| 4
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;
namespace atcorder2 {
class Program {
public static long Read() { return long.Parse(Console.ReadLine()); }
public static long[] Reads() {
return Console.ReadLine().Split().Select(long.Parse).ToArray();
}
public static long GCM(long x, long y) {
if (x < y)
GCM(y, x);
while (y > 0) {
var z = y;
y = x % y;
x = z;
}
return x;
}
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var n = Read();
var s = ReadLine();
var t = ReadLine();
long ans = 0;
bool f = true;
for (int i = 0; i < n; i++) {
f = true;
for (int j = i; j < n; j++) {
if (t[j - i] != s[j])
f = false;
}
if (f) {
ans = i;
break;
}
}
WriteLine(f ? n + ans : n + ans + 1);
Console.Out.Flush();
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;
namespace atcorder2 {
class Program {
public static long Read() { return long.Parse(Console.ReadLine()); }
public static long[] Reads() {
return Console.ReadLine().Split().Select(long.Parse).ToArray();
}
public static long GCM(long x, long y) {
if (x < y)
GCM(y, x);
while (y > 0) {
var z = y;
y = x % y;
x = z;
}
return x;
}
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var n = Read();
var s = ReadLine();
var t = ReadLine();
long ans = 0;
bool f = true;
for (int i = 0; i < n; i++) {
f = true;
for (int j = i; j < n; j++) {
if (t[j - i] != s[j])
f = false;
}
if (f) {
ans = i;
break;
}
}
WriteLine(f ? n + ans : 2 * n);
Console.Out.Flush();
}
}
}
|
[["+", 3, 4, 0, 28, 0, 41, 75, 16, 31, 203], ["+", 3, 4, 0, 28, 0, 41, 75, 16, 17, 48], ["-", 0, 28, 0, 41, 75, 16, 31, 16, 17, 72], ["-", 0, 28, 0, 41, 75, 16, 31, 16, 12, 22], ["-", 3, 4, 0, 28, 0, 41, 75, 16, 17, 72], ["-", 3, 4, 0, 28, 0, 41, 75, 16, 12, 203]]
| 8
| 294
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;
namespace AtCoder {
class AC {
const int MOD = 1000000007;
const int INF = int.MaxValue / 2;
const long SINF = long.MaxValue / 2;
const double EPS = 1e-8;
static readonly int[] dx = { 0, 1, 0, -1 };
static readonly int[] dy = { 1, 0, -1, 0 };
static List<List<int>> G = new List<List<int>>();
// static List<List<Edge>>G = new List<List<Edge>>();
// static List<Edge> E = new List<Edge>();
static void Main(string[] args) {
// var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush =
// false }; Console.SetOut(sw);
var cin = new Scanner();
int N = int.Parse(Console.ReadLine());
var s = Console.ReadLine();
var t = Console.ReadLine();
if (s == t) {
Console.WriteLine(s.Length);
return;
}
for (var i = 1; i < N; i++) {
// Console.WriteLine($"{s.Substring(i)} {t.Substring(0, N - i)}");
if (s.Substring(i) == t.Substring(0, N - i)) {
Console.WriteLine((s + t.Substring(i - 1)).Length);
return;
}
}
Console.WriteLine((s + t).Length);
// Console.Out.Flush();
}
struct Edge {
public int from;
public int to;
public long dist;
public Edge(int t, long c) {
from = -1;
to = t;
dist = c;
}
public Edge(int f, int t, long c) {
from = f;
to = t;
dist = c;
}
}
}
public class Scanner {
public int[] ReadSplit() {
return ConvertAll(Console.ReadLine().Split(), int.Parse);
}
public long[] ReadSplitL() {
return ConvertAll(Console.ReadLine().Split(), long.Parse);
}
public double[] ReadSplitD() {
return ConvertAll(Console.ReadLine().Split(), double.Parse);
}
}
public static class Tool {
static public void Initialize<T>(ref T[] array, T initialvalue) {
for (var i = 0; i < array.Length; i++) {
array[i] = initialvalue;
}
}
static public void Swap<T>(ref T a, ref T b) {
T keep = a;
a = b;
b = keep;
}
static public void Display<T>(T[,] array2d, int n, int m) {
for (var i = 0; i < n; i++) {
for (var j = 0; j < m; j++) {
Console.Write($"{array2d[i, j]} ");
}
Console.WriteLine();
}
}
static long LPow(int a, int b) { return (long)Pow(a, b); }
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;
namespace AtCoder {
class AC {
const int MOD = 1000000007;
const int INF = int.MaxValue / 2;
const long SINF = long.MaxValue / 2;
const double EPS = 1e-8;
static readonly int[] dx = { 0, 1, 0, -1 };
static readonly int[] dy = { 1, 0, -1, 0 };
static List<List<int>> G = new List<List<int>>();
// static List<List<Edge>>G = new List<List<Edge>>();
// static List<Edge> E = new List<Edge>();
static void Main(string[] args) {
// var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush =
// false }; Console.SetOut(sw);
var cin = new Scanner();
int N = int.Parse(Console.ReadLine());
var s = Console.ReadLine();
var t = Console.ReadLine();
if (s == t) {
Console.WriteLine(s.Length);
return;
}
for (var i = 1; i < N; i++) {
// Console.WriteLine($"{s.Substring(i)} {t.Substring(0, N - i)}");
if (s.Substring(i) == t.Substring(0, N - i)) {
Console.WriteLine((s + t.Substring(N - i)).Length);
return;
}
}
Console.WriteLine((s + t).Length);
// Console.Out.Flush();
}
struct Edge {
public int from;
public int to;
public long dist;
public Edge(int t, long c) {
from = -1;
to = t;
dist = c;
}
public Edge(int f, int t, long c) {
from = f;
to = t;
dist = c;
}
}
}
public class Scanner {
public int[] ReadSplit() {
return ConvertAll(Console.ReadLine().Split(), int.Parse);
}
public long[] ReadSplitL() {
return ConvertAll(Console.ReadLine().Split(), long.Parse);
}
public double[] ReadSplitD() {
return ConvertAll(Console.ReadLine().Split(), double.Parse);
}
}
public static class Tool {
static public void Initialize<T>(ref T[] array, T initialvalue) {
for (var i = 0; i < array.Length; i++) {
array[i] = initialvalue;
}
}
static public void Swap<T>(ref T a, ref T b) {
T keep = a;
a = b;
b = keep;
}
static public void Display<T>(T[,] array2d, int n, int m) {
for (var i = 0; i < n; i++) {
for (var j = 0; j < m; j++) {
Console.Write($"{array2d[i, j]} ");
}
Console.WriteLine();
}
}
static long LPow(int a, int b) { return (long)Pow(a, b); }
}
}
|
[["-", 12, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["-", 12, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 12, 22]]
| 8
| 622
| 4
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P {
public static void Main() {
int n = int.Parse(Console.ReadLine());
var s = Console.ReadLine();
var t = Console.ReadLine();
for (int i = 0; i < n; i++) {
var res = s.Substring(0, i) + t;
if (res.Substring(0, n) == s) {
Console.WriteLine(res.Length);
return;
}
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P {
public static void Main() {
int n = int.Parse(Console.ReadLine());
var s = Console.ReadLine();
var t = Console.ReadLine();
for (int i = 0;; i++) {
var res = s.Substring(0, i) + t;
if (res.Substring(0, n) == s) {
Console.WriteLine(res.Length);
return;
}
}
}
}
|
[["-", 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]]
| 8
| 162
| 3
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
var N = sc.ReadInt();
var S = sc.ReadStr();
var T = sc.ReadStr();
var ans = 2 * N;
for (int i = 0; i < N; i++) {
if (S.Substring(i) == T.Substring(0, N - i)) {
ans -= N - i;
}
}
Console.WriteLine(ans);
}
static Scanner sc = new Scanner();
}
class Scanner {
string[] S = new string[0];
int Index = 0;
char[] Separators = new char[] { ' ' };
public string Next() {
if (this.Index < this.S.Length)
return this.S[this.Index++];
var line = "";
while (line == "")
line = Console.ReadLine();
this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
if (this.S.Length == 0)
return this.Next();
this.Index = 0;
return this.S[this.Index++];
}
public string ReadStr() { return this.Next(); }
public char ReadChar() { return this.Next()[0]; }
public int ReadInt() { return int.Parse(this.Next()); }
public uint ReadUInt() { return uint.Parse(this.Next()); }
public long ReadLong() { return long.Parse(this.Next()); }
public double ReadDouble() { return double.Parse(this.Next()); }
public Tuple<int, int> ReadTup(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add);
}
public Tuple<long, long> ReadTupLong(int add = 0) {
return Tuple.Create(this.ReadLong() + add, this.ReadLong() + add);
}
public Tuple<int, int, int> ReadTup3(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add);
}
public Tuple<int, int, int, int> ReadTup4(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add, this.ReadInt() + add);
}
public int[] ReadIntArray(int n) {
var array = new int[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadInt();
}
return array;
}
public long[] ReadLongArray(int n) {
var array = new long[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadLong();
}
return array;
}
public double[] ReadDoubleArray(int n) {
var array = new double[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadDouble();
}
return array;
}
public char[] ReadCharArray(int n) {
var array = new char[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadChar();
}
return array;
}
public string[] ReadStrArray(int n) {
var array = new string[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadStr();
}
return array;
}
public Tuple<long, long>[] ReadTupLongArray(int n, int add = 0) {
var array = new Tuple<long, long>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTupLong(add);
}
return array;
}
public Tuple<int, int>[] ReadTupArray(int n, int add = 0) {
var array = new Tuple<int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup(add);
}
return array;
}
public Tuple<int, int, int>[] ReadTup3Array(int n, int add = 0) {
var array = new Tuple<int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup3(add);
}
return array;
}
public Tuple<int, int, int, int>[] ReadTup4Array(int n, int add = 0) {
var array = new Tuple<int, int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup4(add);
}
return array;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
var N = sc.ReadInt();
var S = sc.ReadStr();
var T = sc.ReadStr();
var ans = 2 * N;
for (int i = 0; i < N; i++) {
if (S.Substring(i) == T.Substring(0, N - i)) {
ans -= N - i;
break;
}
}
Console.WriteLine(ans);
}
static Scanner sc = new Scanner();
}
class Scanner {
string[] S = new string[0];
int Index = 0;
char[] Separators = new char[] { ' ' };
public string Next() {
if (this.Index < this.S.Length)
return this.S[this.Index++];
var line = "";
while (line == "")
line = Console.ReadLine();
this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
if (this.S.Length == 0)
return this.Next();
this.Index = 0;
return this.S[this.Index++];
}
public string ReadStr() { return this.Next(); }
public char ReadChar() { return this.Next()[0]; }
public int ReadInt() { return int.Parse(this.Next()); }
public uint ReadUInt() { return uint.Parse(this.Next()); }
public long ReadLong() { return long.Parse(this.Next()); }
public double ReadDouble() { return double.Parse(this.Next()); }
public Tuple<int, int> ReadTup(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add);
}
public Tuple<long, long> ReadTupLong(int add = 0) {
return Tuple.Create(this.ReadLong() + add, this.ReadLong() + add);
}
public Tuple<int, int, int> ReadTup3(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add);
}
public Tuple<int, int, int, int> ReadTup4(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add, this.ReadInt() + add);
}
public int[] ReadIntArray(int n) {
var array = new int[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadInt();
}
return array;
}
public long[] ReadLongArray(int n) {
var array = new long[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadLong();
}
return array;
}
public double[] ReadDoubleArray(int n) {
var array = new double[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadDouble();
}
return array;
}
public char[] ReadCharArray(int n) {
var array = new char[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadChar();
}
return array;
}
public string[] ReadStrArray(int n) {
var array = new string[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadStr();
}
return array;
}
public Tuple<long, long>[] ReadTupLongArray(int n, int add = 0) {
var array = new Tuple<long, long>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTupLong(add);
}
return array;
}
public Tuple<int, int>[] ReadTupArray(int n, int add = 0) {
var array = new Tuple<int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup(add);
}
return array;
}
public Tuple<int, int, int>[] ReadTup3Array(int n, int add = 0) {
var array = new Tuple<int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup3(add);
}
return array;
}
public Tuple<int, int, int, int>[] ReadTup4Array(int n, int add = 0) {
var array = new Tuple<int, int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup4(add);
}
return array;
}
}
|
[["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 35]]
| 8
| 1,086
| 2
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
namespace AGC006A {
class Program {
static void Solve(Input input) {
var n = input.NextInt();
var s = input.Next();
var t = input.Next();
int len = n * 2;
for (int i = 0; i < n; i++) {
if (s.Skip(i).SequenceEqual(t.Take(s.Length - i))) {
len -= s.Length - i;
}
}
Console.WriteLine(len);
}
#region Competitive Template
static readonly int MOD = (int)1e9 + 7;
public static void Main(string[] args) {
// 出力が少ないときはこれをセットする方が時間かかるけれど
// その場合は出力がボトルネックになっていないので、まあ良しとする
var needsFlushOutput = true;
if (needsFlushOutput) {
// 細かく出力しないようにする
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
}
// 通常は引数無しで、ファイルから読み出したい場合はpath指定する
var input = new Input();
// 仮想的に標準入力をセットする
// input.SetText("");
Solve(input);
Console.Out.Flush();
}
class Input {
// 変な改行コードがたまに混じっているので、一応セパレート指定する
// スペース単独指定の方がもちろん早い
static readonly char[] separator = { ' ', '\r', '\n' };
Queue<string> q { get; set; }
StreamReader sr;
/// <summary>
/// 特定のファイルから読み出したい場合はpath指定する
/// </summary>
/// <param name="path"></param>
public Input(string path = "") {
q = new Queue<string>();
if (string.IsNullOrEmpty(path)) {
sr = new StreamReader(Console.OpenStandardInput());
} else {
sr = new StreamReader(path);
}
}
/// <summary>
/// 入力予約
/// </summary>
/// <param name="items"></param>
public void SetText(IEnumerable<string> items) {
foreach (var item in items) {
SetText(item);
}
}
/// <summary>
/// 入力予約
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public bool SetText(string s) {
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
q.Enqueue(elem);
}
return true;
}
/// <summary>
/// 内部queueに入力からの値をsplitして格納する
/// </summary>
/// <returns></returns>
bool read() {
var s = sr.ReadLine();
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
q.Enqueue(elem);
}
if (!q.Any())
return read();
return true;
}
/// <summary>
/// 次のstringを一つ読み込む
/// </summary>
/// <returns></returns>
public string Next() {
if (!q.Any()) {
if (!read()) {
return "";
}
}
return q.Dequeue();
}
/// <summary>
/// 指定個数queueにたまるまでenqueueし続ける
/// </summary>
/// <param name="n"></param>
/// <returns></returns>
bool accumulate(int n) {
while (q.Count() < n) {
if (!read())
return false;
}
return true;
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
/// <summary>
/// n個の要素をparseして、それぞれにoffsetをaddした配列を返す
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="n"></param>
/// <param name="offset"></param>
/// <param name="parse"></param>
/// <param name="add"></param>
/// <returns></returns>
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(q.Dequeue()), offset);
return a;
}
public string[] Next(int n) => NextT(n, "", x => x, (x, y) => x);
public int[] NextInt(int n, int offset = 0) => NextT(n, offset, int.Parse,
(x, y) => x + y);
public long[] NextLong(int n, long offset = 0) => NextT(n, offset,
long.Parse,
(x, y) => x + y);
public double[] NextDouble(int n, double offset = 0.0) =>
NextT(n, offset, double.Parse, (x, y) => x + y);
}
static class Utils {
public static void Print<T>(IEnumerable<T> ie, string sep = " ") =>
Console.WriteLine(string.Join(sep, ie));
public static void Print<T>(params T[] objs) => Print(objs);
public static T Max<T>(params T[] objs) => objs.Max();
public static T Min<T>(params T[] objs) => objs.Min();
public static void Swap<T>(ref T x, ref T y)
where T : struct {
var t = x;
x = y;
y = t;
}
public static void Swap<T>(IList<T> list, int i, int j)
where T : struct {
var t = list[i];
list[i] = list[j];
list[j] = t;
}
/// <summary>
/// vでfillされたT[d1][d2]配列を作成する
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="d1"></param>
/// <param name="d2"></param>
/// <param name="v"></param>
/// <returns></returns>
public static T[][] Create2DArray<T>(int d1, int d2, T v = default(T)) {
return Enumerable.Repeat(0, d1)
.Select(_ => Enumerable.Repeat(v, d2).ToArray())
.ToArray();
}
/// <summary>
/// vでfillされたT[d1][d2][d3]配列を作成する
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="d1"></param>
/// <param name="d2"></param>
/// <param name="d3"></param>
/// <param name="v"></param>
/// <returns></returns>
public static T[][][] Create3DArray<T>(int d1, int d2, int d3,
T v = default(T)) {
return Enumerable.Repeat(0, d1)
.Select(_ => Enumerable.Repeat(0, d2)
.Select(__ => Enumerable.Repeat(v, d3).ToArray())
.ToArray())
.ToArray();
}
}
#endregion
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
namespace AGC006A {
class Program {
static void Solve(Input input) {
var n = input.NextInt();
var s = input.Next();
var t = input.Next();
int len = n * 2;
for (int i = 0; i < n; i++) {
if (s.Skip(i).SequenceEqual(t.Take(s.Length - i))) {
len -= s.Length - i;
break;
}
}
Console.WriteLine(len);
}
#region Competitive Template
static readonly int MOD = (int)1e9 + 7;
public static void Main(string[] args) {
// 出力が少ないときはこれをセットする方が時間かかるけれど
// その場合は出力がボトルネックになっていないので、まあ良しとする
var needsFlushOutput = true;
if (needsFlushOutput) {
// 細かく出力しないようにする
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
}
// 通常は引数無しで、ファイルから読み出したい場合はpath指定する
var input = new Input();
// 仮想的に標準入力をセットする
// input.SetText("");
Solve(input);
Console.Out.Flush();
}
class Input {
// 変な改行コードがたまに混じっているので、一応セパレート指定する
// スペース単独指定の方がもちろん早い
static readonly char[] separator = { ' ', '\r', '\n' };
Queue<string> q { get; set; }
StreamReader sr;
/// <summary>
/// 特定のファイルから読み出したい場合はpath指定する
/// </summary>
/// <param name="path"></param>
public Input(string path = "") {
q = new Queue<string>();
if (string.IsNullOrEmpty(path)) {
sr = new StreamReader(Console.OpenStandardInput());
} else {
sr = new StreamReader(path);
}
}
/// <summary>
/// 入力予約
/// </summary>
/// <param name="items"></param>
public void SetText(IEnumerable<string> items) {
foreach (var item in items) {
SetText(item);
}
}
/// <summary>
/// 入力予約
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public bool SetText(string s) {
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
q.Enqueue(elem);
}
return true;
}
/// <summary>
/// 内部queueに入力からの値をsplitして格納する
/// </summary>
/// <returns></returns>
bool read() {
var s = sr.ReadLine();
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
q.Enqueue(elem);
}
if (!q.Any())
return read();
return true;
}
/// <summary>
/// 次のstringを一つ読み込む
/// </summary>
/// <returns></returns>
public string Next() {
if (!q.Any()) {
if (!read()) {
return "";
}
}
return q.Dequeue();
}
/// <summary>
/// 指定個数queueにたまるまでenqueueし続ける
/// </summary>
/// <param name="n"></param>
/// <returns></returns>
bool accumulate(int n) {
while (q.Count() < n) {
if (!read())
return false;
}
return true;
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
/// <summary>
/// n個の要素をparseして、それぞれにoffsetをaddした配列を返す
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="n"></param>
/// <param name="offset"></param>
/// <param name="parse"></param>
/// <param name="add"></param>
/// <returns></returns>
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(q.Dequeue()), offset);
return a;
}
public string[] Next(int n) => NextT(n, "", x => x, (x, y) => x);
public int[] NextInt(int n, int offset = 0) => NextT(n, offset, int.Parse,
(x, y) => x + y);
public long[] NextLong(int n, long offset = 0) => NextT(n, offset,
long.Parse,
(x, y) => x + y);
public double[] NextDouble(int n, double offset = 0.0) =>
NextT(n, offset, double.Parse, (x, y) => x + y);
}
static class Utils {
public static void Print<T>(IEnumerable<T> ie, string sep = " ") =>
Console.WriteLine(string.Join(sep, ie));
public static void Print<T>(params T[] objs) => Print(objs);
public static T Max<T>(params T[] objs) => objs.Max();
public static T Min<T>(params T[] objs) => objs.Min();
public static void Swap<T>(ref T x, ref T y)
where T : struct {
var t = x;
x = y;
y = t;
}
public static void Swap<T>(IList<T> list, int i, int j)
where T : struct {
var t = list[i];
list[i] = list[j];
list[j] = t;
}
/// <summary>
/// vでfillされたT[d1][d2]配列を作成する
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="d1"></param>
/// <param name="d2"></param>
/// <param name="v"></param>
/// <returns></returns>
public static T[][] Create2DArray<T>(int d1, int d2, T v = default(T)) {
return Enumerable.Repeat(0, d1)
.Select(_ => Enumerable.Repeat(v, d2).ToArray())
.ToArray();
}
/// <summary>
/// vでfillされたT[d1][d2][d3]配列を作成する
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="d1"></param>
/// <param name="d2"></param>
/// <param name="d3"></param>
/// <param name="v"></param>
/// <returns></returns>
public static T[][][] Create3DArray<T>(int d1, int d2, int d3,
T v = default(T)) {
return Enumerable.Repeat(0, d1)
.Select(_ => Enumerable.Repeat(0, d2)
.Select(__ => Enumerable.Repeat(v, d3).ToArray())
.ToArray())
.ToArray();
}
}
#endregion
}
}
|
[["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 35]]
| 8
| 1,204
| 2
|
using System;
using System.Collections.Generic;
using System.Text;
namespace AtTest.AGC_Challenge {
class _006_A {
static void Main(string[] args) {
Method(args);
Console.ReadLine();
}
static void Method(string[] args) {
int n = ReadInt();
string ps = Read();
string ss = Read();
for (int i = 0; i <= n; i++) {
int shareCnt = 0;
for (int j = 0; j < n - i; j++) {
if (ps[i + j] != ss[j])
shareCnt++;
}
if (shareCnt == n - i) {
Console.WriteLine(i + n);
return;
}
}
}
private static string Read() { return Console.ReadLine(); }
private static int ReadInt() { return int.Parse(Read()); }
private static long ReadLong() { return long.Parse(Read()); }
private static double ReadDouble() { return double.Parse(Read()); }
private static int[] ReadInts() {
return Array.ConvertAll(Read().Split(), int.Parse);
}
private static long[] ReadLongs() {
return Array.ConvertAll(Read().Split(), long.Parse);
}
private static double[] ReadDoubles() {
return Array.ConvertAll(Read().Split(), double.Parse);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Text;
namespace AtTest.AGC_Challenge {
class _006_A {
static void Main(string[] args) {
Method(args);
Console.ReadLine();
}
static void Method(string[] args) {
int n = ReadInt();
string ps = Read();
string ss = Read();
for (int i = 0; i <= n; i++) {
int shareCnt = 0;
for (int j = 0; j < n - i; j++) {
if (ps[i + j] == ss[j])
shareCnt++;
}
if (shareCnt == n - i) {
Console.WriteLine(n + i);
return;
}
}
}
private static string Read() { return Console.ReadLine(); }
private static int ReadInt() { return int.Parse(Read()); }
private static long ReadLong() { return long.Parse(Read()); }
private static double ReadDouble() { return double.Parse(Read()); }
private static int[] ReadInts() {
return Array.ConvertAll(Read().Split(), int.Parse);
}
private static long[] ReadLongs() {
return Array.ConvertAll(Read().Split(), long.Parse);
}
private static double[] ReadDoubles() {
return Array.ConvertAll(Read().Split(), double.Parse);
}
}
}
|
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 79], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22]]
| 8
| 309
| 6
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using System.Threading.Tasks;
class Myon {
public Myon() {}
public static int Main() {
new Myon().calc();
return 0;
}
Scanner cin;
void calc() {
cin = new Scanner();
int N = cin.nextInt();
long[] X = cin.ArrayLong(N);
int M = cin.nextInt();
int K = cin.nextInt();
int[] A = cin.ArrayInt(M, -2);
int[] pos = new int[N - 1];
for (int i = 0; i < N - 1; i++) {
pos[i] = i;
}
for (int i = 0; i < M; i++) {
int a = A[i];
int b = A[i] + 1;
swap(ref pos[a], ref pos[b]);
}
// i -> pos[i]に移動というのが分かる
bool[] used = new bool[N - 1];
for (int i = 0; i < N - 1; i++) {
if (used[i])
continue;
List<int> l = new List<int>();
l.Add(i);
int now = pos[i];
while (now != i) {
l.Add(now);
now = pos[now];
}
int step = (int)(K % l.Count);
for (int j = 0; j < l.Count; j++) {
pos[l[j]] = l[(j + step) % l.Count];
}
foreach (var j in l) {
used[j] = true;
}
}
long[] diff = new long[N - 1];
for (int i = 0; i < N - 1; i++) {
int P = pos[i];
diff[i] = X[P + 1] - X[P];
}
long[] ans = new long[N];
ans[0] = X[0];
for (int i = 0; i < N - 1; i++) {
ans[i + 1] = ans[i] + diff[i];
}
for (int i = 0; i < N; i++) {
Console.WriteLine(ans[i]);
}
}
// swap
void swap<T>(ref T a, ref T b) {
T c = a;
a = b;
b = c;
}
}
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;
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using System.Threading.Tasks;
class Myon {
public Myon() {}
public static int Main() {
new Myon().calc();
return 0;
}
Scanner cin;
void calc() {
cin = new Scanner();
int N = cin.nextInt();
long[] X = cin.ArrayLong(N);
int M = cin.nextInt();
long K = cin.nextLong();
int[] A = cin.ArrayInt(M, -2);
int[] pos = new int[N - 1];
for (int i = 0; i < N - 1; i++) {
pos[i] = i;
}
for (int i = 0; i < M; i++) {
int a = A[i];
int b = A[i] + 1;
swap(ref pos[a], ref pos[b]);
}
// i -> pos[i]に移動というのが分かる
bool[] used = new bool[N - 1];
for (int i = 0; i < N - 1; i++) {
if (used[i])
continue;
List<int> l = new List<int>();
l.Add(i);
int now = pos[i];
while (now != i) {
l.Add(now);
now = pos[now];
}
int step = (int)(K % l.Count);
for (int j = 0; j < l.Count; j++) {
pos[l[j]] = l[(j + step) % l.Count];
}
foreach (var j in l) {
used[j] = true;
}
}
long[] diff = new long[N - 1];
for (int i = 0; i < N - 1; i++) {
int P = pos[i];
diff[i] = X[P + 1] - X[P];
}
long[] ans = new long[N];
ans[0] = X[0];
for (int i = 0; i < N - 1; i++) {
ans[i + 1] = ans[i] + diff[i];
}
for (int i = 0; i < N; i++) {
Console.WriteLine(ans[i]);
}
}
// swap
void swap<T>(ref T a, ref T b) {
T c = a;
a = b;
b = c;
}
}
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;
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22]]
| 8
| 913
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class AtCoderA {
static void Main() {
var sc = new Scanner();
string s = sc.Next();
long c = s.IndexOf('C');
long f = s.IndexOf('F');
bool ok = false;
if (c >= 0 && f >= 0 && c <= f) {
ok = true;
}
string answer = ok ? "Yes" : "No";
Console.WriteLine(answer);
}
class Scanner {
private string[] _line;
private int _index;
private const char Separator = ' ';
public Scanner() {
_line = new string[0];
_index = 0;
}
public string Next() {
while (_index >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_index = 0;
}
return _line[_index++];
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
public decimal NextDecimal() => decimal.Parse(Next());
public char NextChar() => Next()[0];
public char[] NextCharArray() => Next().ToCharArray();
public string[] Array() {
_line = Console.ReadLine().Split(Separator);
_index = _line.Length;
return _line;
}
public int[] IntArray() => Array().Select(int.Parse).ToArray();
public long[] LongArray() => Array().Select(long.Parse).ToArray();
public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class AtCoderA {
static void Main() {
var sc = new Scanner();
string s = sc.Next();
long c = s.IndexOf('C');
long f = s.LastIndexOf('F');
bool ok = false;
if (c >= 0 && f >= 0 && c <= f) {
ok = true;
}
string answer = ok ? "Yes" : "No";
Console.WriteLine(answer);
}
class Scanner {
private string[] _line;
private int _index;
private const char Separator = ' ';
public Scanner() {
_line = new string[0];
_index = 0;
}
public string Next() {
while (_index >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_index = 0;
}
return _line[_index++];
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
public decimal NextDecimal() => decimal.Parse(Next());
public char NextChar() => Next()[0];
public char[] NextCharArray() => Next().ToCharArray();
public string[] Array() {
_line = Console.ReadLine().Split(Separator);
_index = _line.Length;
return _line;
}
public int[] IntArray() => Array().Select(int.Parse).ToArray();
public long[] LongArray() => Array().Select(long.Parse).ToArray();
public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
}
}
|
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22]]
| 8
| 412
| 2
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;
namespace Atcoder {
class Program {
static StreamWriter sw =
new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
static void Main(string[] args) {
try {
SetOut(sw);
Solve.Answer();
Out.Flush();
} catch (Exception ex) {
WriteLine(ex.ToString());
}
}
}
public class Solve {
public static List<long[]> list = new List<long[]>();
public static void Answer() {
var s = ReadLine();
int c = s.IndexOf('C');
int f = s.IndexOf('F');
if (c == -1 || f == -1)
WriteLine("No");
else if (c < f)
WriteLine("Yes");
else
WriteLine("No");
}
}
public class IO {
#region Input
public static int RInt => int.Parse(ReadLine());
public static long RLong => long.Parse(ReadLine());
public static double RDouble => double.Parse(ReadLine());
public static string[] RSString => ReadLine().Split();
public static int[] RSInt =>
ReadLine().Split().Select(s => int.Parse(s)).ToArray();
public static long[] RSLong =>
ReadLine().Split().Select(s => long.Parse(s)).ToArray();
public static double[] RSDouble =>
ReadLine().Split().Select(s => double.Parse(s)).ToArray();
#endregion
#region Output
public static void
OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes"
: "No");
public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES"
: "NO");
#endregion
}
public class Mod {
#region
private readonly static long M = 1000000007;
public static long Add(long a, long b) => (a * b) % M;
public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M
: (a - b) % M + M;
public static long Multi(long a, long b) => (a * b) % M;
#endregion
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;
namespace Atcoder {
class Program {
static StreamWriter sw =
new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
static void Main(string[] args) {
try {
SetOut(sw);
Solve.Answer();
Out.Flush();
} catch (Exception ex) {
WriteLine(ex.ToString());
}
}
}
public class Solve {
public static List<long[]> list = new List<long[]>();
public static void Answer() {
var s = ReadLine();
int c = s.IndexOf('C');
int f = s.LastIndexOf('F');
if (c == -1 || f == -1)
WriteLine("No");
else if (c < f)
WriteLine("Yes");
else
WriteLine("No");
}
}
public class IO {
#region Input
public static int RInt => int.Parse(ReadLine());
public static long RLong => long.Parse(ReadLine());
public static double RDouble => double.Parse(ReadLine());
public static string[] RSString => ReadLine().Split();
public static int[] RSInt =>
ReadLine().Split().Select(s => int.Parse(s)).ToArray();
public static long[] RSLong =>
ReadLine().Split().Select(s => long.Parse(s)).ToArray();
public static double[] RSDouble =>
ReadLine().Split().Select(s => double.Parse(s)).ToArray();
#endregion
#region Output
public static void
OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes"
: "No");
public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES"
: "NO");
#endregion
}
public class Mod {
#region
private readonly static long M = 1000000007;
public static long Add(long a, long b) => (a * b) % M;
public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M
: (a - b) % M + M;
public static long Multi(long a, long b) => (a * b) % M;
#endregion
}
}
|
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22]]
| 8
| 556
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class MainClass {
public const long Giri = 1000000007;
public const long DpInf = 99999999999999;
public static void Main(string[] args) {
var s = Console.ReadLine();
bool c = false;
for (int i = 0; i < s.Length; i++) {
if (!c && s[i] == 'C')
c = true;
if (c && s[i] == 'F') {
Console.WriteLine("Yes");
}
}
Console.WriteLine("No");
}
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];
}
public static string[] Input() { return Console.ReadLine().Split(); }
}
public static class Smarter {
public static int ToInt(this string str) { return int.Parse(str); }
public static long ToLong(this string str) { return long.Parse(str); }
public static int[] ToInt(this string[] str, int offset = 0) {
var r = new int[str.Length];
for (int i = 0; i < str.Length; i++)
r[i] = str[i].ToInt() + offset;
return r;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class MainClass {
public const long Giri = 1000000007;
public const long DpInf = 99999999999999;
public static void Main(string[] args) {
var s = Console.ReadLine();
bool c = false;
for (int i = 0; i < s.Length; i++) {
if (!c && s[i] == 'C')
c = true;
if (c && s[i] == 'F') {
Console.WriteLine("Yes");
return;
}
}
Console.WriteLine("No");
}
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];
}
public static string[] Input() { return Console.ReadLine().Split(); }
}
public static class Smarter {
public static int ToInt(this string str) { return int.Parse(str); }
public static long ToLong(this string str) { return long.Parse(str); }
public static int[] ToInt(this string[] str, int offset = 0) {
var r = new int[str.Length];
for (int i = 0; i < str.Length; i++)
r[i] = str[i].ToInt() + offset;
return r;
}
}
|
[["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35]]
| 8
| 328
| 2
|
using System;
public class Hello {
public static void Main() {
var s = Console.ReadLine();
Console.WriteLine((s.IndexOf('C') >= 0 && s.IndexOf('C') < s.IndexOf('F'))
? "Yes"
: "No");
}
}
|
using System;
public class Hello {
public static void Main() {
var s = Console.ReadLine();
Console.WriteLine(
(s.IndexOf('C') >= 0 && s.IndexOf('C') < s.LastIndexOf('F')) ? "Yes"
: "No");
}
}
|
[["-", 0, 16, 12, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 16, 12, 16, 12, 213, 63, 214, 141, 22]]
| 8
| 69
| 2
|
using System;
namespace CodeFestival2016qualC {
class Program {
static void Main(string[] args) {
string s = Console.ReadLine();
int indexOfC = s.IndexOf('C');
int indexOfF = s.LastIndexOf('F');
if (indexOfC == -1 || indexOfF == -1) {
Console.WriteLine("No");
} else {
if (indexOfC < indexOfF) {
Console.WriteLine("YES");
} else {
Console.WriteLine("No");
}
}
}
}
}
|
using System;
namespace CodeFestival2016qualC {
class Program {
static void Main(string[] args) {
string s = Console.ReadLine();
int indexOfC = s.IndexOf('C');
int indexOfF = s.LastIndexOf('F');
if (indexOfC == -1 || indexOfF == -1) {
Console.WriteLine("No");
} else {
if (indexOfC < indexOfF) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 110
| 2
|
using System;
using System.Linq;
using System.Diagnostics;
namespace ConsoleApplication {
public class Program {
public static void Main(string[] args) {
var s = Console.ReadLine();
var c = s.IndexOf('C');
var f = s.IndexOf('F');
var result = c >= 0 && f >= 0 && c < f ? "Yes" : "No";
Console.WriteLine(result);
}
}
public static class Ex {
public static int ToInt(this string str) => int.Parse(str);
}
}
|
using System;
using System.Linq;
using System.Diagnostics;
namespace ConsoleApplication {
public class Program {
public static void Main(string[] args) {
var s = Console.ReadLine();
var c = s.IndexOf('C');
var f = s.LastIndexOf('F');
var result = c >= 0 && f >= 0 && c < f ? "Yes" : "No";
Console.WriteLine(result);
}
}
public static class Ex {
public static int ToInt(this string str) => int.Parse(str);
}
}
|
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22]]
| 8
| 120
| 2
|
using System;
public class Program {
public void Proc() {
Reader.IsDebug = false;
string inpt = Reader.ReadLine();
string ans = "No";
if (inpt != null && inpt.Length > 0) {
int idx = inpt.IndexOf('C');
if (idx >= 0 && inpt.IndexOf('F') > idx) {
ans = "Yes";
}
}
Console.WriteLine(ans);
}
public class Reader {
public static bool IsDebug = true;
private static string Input = @"
";
private static System.IO.StringReader rd;
public static string ReadLine() {
if (!IsDebug) {
return Console.ReadLine();
}
if (rd == null) {
rd = new System.IO.StringReader(Input.Trim());
}
return rd.ReadLine();
}
}
public static void Main(string[] args) {
Program prg = new Program();
prg.Proc();
}
}
|
using System;
public class Program {
public void Proc() {
Reader.IsDebug = false;
string inpt = Reader.ReadLine();
string ans = "No";
if (inpt != null && inpt.Length > 0) {
int idx = inpt.IndexOf('C');
if (idx >= 0 && inpt.LastIndexOf('F') > idx) {
ans = "Yes";
}
}
Console.WriteLine(ans);
}
public class Reader {
public static bool IsDebug = true;
private static string Input = @"
123
";
private static System.IO.StringReader rd;
public static string ReadLine() {
if (!IsDebug) {
return Console.ReadLine();
}
if (rd == null) {
rd = new System.IO.StringReader(Input.Trim());
}
return rd.ReadLine();
}
}
public static void Main(string[] args) {
Program prg = new Program();
prg.Proc();
}
}
|
[["-", 15, 16, 12, 16, 31, 213, 63, 214, 141, 22], ["+", 15, 16, 12, 16, 31, 213, 63, 214, 141, 22], ["-", 0, 124, 0, 198, 0, 200, 0, 212, 0, 258], ["+", 0, 124, 0, 198, 0, 200, 0, 212, 0, 258]]
| 8
| 202
| 4
|
using System;
namespace CF2016CA {
public class Program {
public static void Main(string[] args) {
var sr = new StreamReader();
//---------------------------------
var S = sr.Next<string>();
var c = S.IndexOf('C');
var f = S.IndexOf('F');
var res = c != -1 && f != -1 && c < f;
Console.WriteLine(res ? "Yes" : "No");
//---------------------------------
}
}
public class StreamReader {
private readonly char[] _c = { ' ' };
private int _index = -1;
private string[] _input = new string[0];
private readonly System.IO.StreamReader _sr =
new System.IO.StreamReader(Console.OpenStandardInput());
public T Next<T>() {
if (_index == _input.Length - 1) {
_index = -1;
while (true) {
string rl = _sr.ReadLine();
if (rl == null) {
if (typeof(T).IsClass)
return default(T);
return (T) typeof(T).GetField("MinValue").GetValue(null);
}
if (rl != "") {
_input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
break;
}
}
}
return (T)Convert.ChangeType(
_input[++_index], typeof(T),
System.Globalization.CultureInfo.InvariantCulture);
}
public T[] Next<T>(int x) {
var ret = new T[x];
for (var i = 0; i < x; ++i)
ret[i] = Next<T>();
return ret;
}
public T[][] Next<T>(int y, int x) {
var ret = new T[y][];
for (var i = 0; i < y; ++i)
ret[i] = Next<T>(x);
return ret;
}
}
}
|
using System;
namespace CF2016CA {
public class Program {
public static void Main(string[] args) {
var sr = new StreamReader();
//---------------------------------
var S = sr.Next<string>();
var c = S.IndexOf('C');
var f = S.LastIndexOf('F');
var res = c != -1 && f != -1 && c < f;
Console.WriteLine(res ? "Yes" : "No");
//---------------------------------
}
}
public class StreamReader {
private readonly char[] _c = { ' ' };
private int _index = -1;
private string[] _input = new string[0];
private readonly System.IO.StreamReader _sr =
new System.IO.StreamReader(Console.OpenStandardInput());
public T Next<T>() {
if (_index == _input.Length - 1) {
_index = -1;
while (true) {
string rl = _sr.ReadLine();
if (rl == null) {
if (typeof(T).IsClass)
return default(T);
return (T) typeof(T).GetField("MinValue").GetValue(null);
}
if (rl != "") {
_input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
break;
}
}
}
return (T)Convert.ChangeType(
_input[++_index], typeof(T),
System.Globalization.CultureInfo.InvariantCulture);
}
public T[] Next<T>(int x) {
var ret = new T[x];
for (var i = 0; i < x; ++i)
ret[i] = Next<T>();
return ret;
}
public T[][] Next<T>(int y, int x) {
var ret = new T[y][];
for (var i = 0; i < y; ++i)
ret[i] = Next<T>(x);
return ret;
}
}
}
|
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22]]
| 8
| 412
| 2
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
// using System.Numerics; //comment out if AOJ
using System.Text;
using Problem = Tmp.Problem;
using MyIO;
#pragma warning disable // for AOJ
namespace Tmp {
class Problem : IDisposable {
bool IsGCJ;
int Repeat;
Scanner sc;
Printer pr;
public Problem(bool isGCJ, Scanner scanner, Printer printer) {
sc = scanner;
pr = printer;
IsGCJ = isGCJ;
if (isGCJ)
Repeat = sc.nextInt();
else
Read();
}
public Problem(bool isGCJ) : this(isGCJ, new Scanner(), new Printer()) {}
public Problem(bool isGCJ, Scanner scanner)
: this(isGCJ, scanner, new Printer()) {}
public Problem(bool isGCJ, Printer printer)
: this(isGCJ, new Scanner(), printer) {}
public void Solve() {
if (IsGCJ)
for (var i = 0; i < Repeat; i++) {
Read();
pr.Write("Case #" + (i + 1) + ": ");
SolveOne();
}
else
SolveOne();
}
public void Dispose() {
sc.Dispose();
pr.Dispose();
}
public int Size {
get { return 1; }
}
public const long Mod = 1000000007;
// 使用する変数をここに書く
// string S;
// int a;
/// <summary>
/// 読み込み処理をここに書く
/// </summary>
void Read() {}
/// <summary>
/// メイン処理をここに書く
/// </summary>
void SolveOne() {
string s = sc.next();
bool c = false;
bool f = false;
for (int i = 0; i < s.Length; i++) {
if (s[i] == 'C')
c = true;
if (s[i] == 'F' && c)
f = true;
}
pr.WriteLine(f);
}
}
}
class Program {
// public static RandomSFMT rand = new RandomSFMT();
public static bool IsJudgeMode = true;
public static bool IsGCJMode = false;
public static bool IsSolveCreated = true;
static void Main() {
if (IsJudgeMode)
if (IsGCJMode)
using (var problem =
new Problem(true, new Scanner("C-large-practice.in.txt"),
new Printer("output.txt"))) problem.Solve();
else
using (var problem = new Problem(false, new Printer())) problem.Solve();
else {
var num = 1;
int size = 0;
decimal time = 0;
for (var tmp = 0; tmp < num; tmp++) {
using (var P = IsSolveCreated
? new Problem(false, new Scanner("input.txt"),
new Printer())
: new Problem(false)) {
size = P.Size;
// time += Func.MeasureTime(() => P.Solve());
}
}
Console.WriteLine("{0}, {1}ms", size, time / num);
}
}
}
/// <summary>
/// カスタマイズしたIO
/// </summary>
namespace MyIO {
class Printer : IDisposable {
bool isConsole;
TextWriter file;
public Printer() {
file = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
isConsole = true;
}
public Printer(string path) {
file = new StreamWriter(path, false) { AutoFlush = false };
isConsole = false;
}
public void Write<T>(T value) { file.Write(value); }
public void Write(bool b) { file.Write(b ? "YES" : "NO"); }
public void Write(string str, params object[] args) { file.Write(str, args); }
public void WriteLine() { file.WriteLine(); }
public void WriteLine<T>(T value) { file.WriteLine(value); }
public void WriteLine(bool b) { file.WriteLine(b ? "YES" : "NO"); }
public void WriteLine<T>(IEnumerable<T> list) {
foreach (var x in list)
file.WriteLine(x);
}
public void WriteLine<T>(List<T> list) {
foreach (var x in list)
file.WriteLine(x);
}
public void WriteLine<T>(T[] list) {
foreach (var x in list)
file.WriteLine(x);
}
public void WriteLine(string str, params object[] args) {
file.WriteLine(str, args);
}
public void Dispose() {
file.Flush();
if (!isConsole)
file.Dispose();
}
}
class Scanner : IDisposable {
bool isConsole;
TextReader file;
public Scanner() { file = Console.In; }
public Scanner(string path) {
file = new StreamReader(path);
isConsole = false;
}
public void Dispose() {
if (!isConsole)
file.Dispose();
}
#region next読み込み
string[] nextBuffer = new string[0];
int BufferCnt = 0;
char[] cs = new char[] { ' ' };
public string next() {
while (BufferCnt >= nextBuffer.Length) {
string st = file.ReadLine();
while (st == "")
st = file.ReadLine();
nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
BufferCnt = 0;
}
return nextBuffer[BufferCnt++];
}
public int nextInt() { return int.Parse(next()); }
public long nextLong() { return long.Parse(next()); }
public double nextDouble() { return double.Parse(next()); }
private T[] enumerate<T>(int n, Func<T> f) {
var a = new T[n];
for (int i = 0; i < n; ++i)
a[i] = f();
return a;
}
public string[] next(int n) { return enumerate(n, next); }
public double[] nextDouble(int n) { return enumerate(n, nextDouble); }
public int[] nextInt(int n) { return enumerate(n, nextInt); }
public long[] nextLong(int n) { return enumerate(n, nextLong); }
#endregion
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
// using System.Numerics; //comment out if AOJ
using System.Text;
using Problem = Tmp.Problem;
using MyIO;
#pragma warning disable // for AOJ
namespace Tmp {
class Problem : IDisposable {
bool IsGCJ;
int Repeat;
Scanner sc;
Printer pr;
public Problem(bool isGCJ, Scanner scanner, Printer printer) {
sc = scanner;
pr = printer;
IsGCJ = isGCJ;
if (isGCJ)
Repeat = sc.nextInt();
else
Read();
}
public Problem(bool isGCJ) : this(isGCJ, new Scanner(), new Printer()) {}
public Problem(bool isGCJ, Scanner scanner)
: this(isGCJ, scanner, new Printer()) {}
public Problem(bool isGCJ, Printer printer)
: this(isGCJ, new Scanner(), printer) {}
public void Solve() {
if (IsGCJ)
for (var i = 0; i < Repeat; i++) {
Read();
pr.Write("Case #" + (i + 1) + ": ");
SolveOne();
}
else
SolveOne();
}
public void Dispose() {
sc.Dispose();
pr.Dispose();
}
public int Size {
get { return 1; }
}
public const long Mod = 1000000007;
// 使用する変数をここに書く
// string S;
// int a;
/// <summary>
/// 読み込み処理をここに書く
/// </summary>
void Read() {}
/// <summary>
/// メイン処理をここに書く
/// </summary>
void SolveOne() {
string s = sc.next();
bool c = false;
bool f = false;
for (int i = 0; i < s.Length; i++) {
if (s[i] == 'C')
c = true;
if (s[i] == 'F' && c)
f = true;
}
pr.WriteLine(f);
}
}
}
class Program {
// public static RandomSFMT rand = new RandomSFMT();
public static bool IsJudgeMode = true;
public static bool IsGCJMode = false;
public static bool IsSolveCreated = true;
static void Main() {
if (IsJudgeMode)
if (IsGCJMode)
using (var problem =
new Problem(true, new Scanner("C-large-practice.in.txt"),
new Printer("output.txt"))) problem.Solve();
else
using (var problem = new Problem(false, new Printer())) problem.Solve();
else {
var num = 1;
int size = 0;
decimal time = 0;
for (var tmp = 0; tmp < num; tmp++) {
using (var P = IsSolveCreated
? new Problem(false, new Scanner("input.txt"),
new Printer())
: new Problem(false)) {
size = P.Size;
// time += Func.MeasureTime(() => P.Solve());
}
}
Console.WriteLine("{0}, {1}ms", size, time / num);
}
}
}
/// <summary>
/// カスタマイズしたIO
/// </summary>
namespace MyIO {
class Printer : IDisposable {
bool isConsole;
TextWriter file;
public Printer() {
file = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
isConsole = true;
}
public Printer(string path) {
file = new StreamWriter(path, false) { AutoFlush = false };
isConsole = false;
}
public void Write<T>(T value) { file.Write(value); }
public void Write(bool b) { file.Write(b ? "YES" : "NO"); }
public void Write(string str, params object[] args) { file.Write(str, args); }
public void WriteLine() { file.WriteLine(); }
public void WriteLine<T>(T value) { file.WriteLine(value); }
public void WriteLine(bool b) { file.WriteLine(b ? "Yes" : "No"); }
public void WriteLine<T>(IEnumerable<T> list) {
foreach (var x in list)
file.WriteLine(x);
}
public void WriteLine<T>(List<T> list) {
foreach (var x in list)
file.WriteLine(x);
}
public void WriteLine<T>(T[] list) {
foreach (var x in list)
file.WriteLine(x);
}
public void WriteLine(string str, params object[] args) {
file.WriteLine(str, args);
}
public void Dispose() {
file.Flush();
if (!isConsole)
file.Dispose();
}
}
class Scanner : IDisposable {
bool isConsole;
TextReader file;
public Scanner() { file = Console.In; }
public Scanner(string path) {
file = new StreamReader(path);
isConsole = false;
}
public void Dispose() {
if (!isConsole)
file.Dispose();
}
#region next読み込み
string[] nextBuffer = new string[0];
int BufferCnt = 0;
char[] cs = new char[] { ' ' };
public string next() {
while (BufferCnt >= nextBuffer.Length) {
string st = file.ReadLine();
while (st == "")
st = file.ReadLine();
nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
BufferCnt = 0;
}
return nextBuffer[BufferCnt++];
}
public int nextInt() { return int.Parse(next()); }
public long nextLong() { return long.Parse(next()); }
public double nextDouble() { return double.Parse(next()); }
private T[] enumerate<T>(int n, Func<T> f) {
var a = new T[n];
for (int i = 0; i < n; ++i)
a[i] = f();
return a;
}
public string[] next(int n) { return enumerate(n, next); }
public double[] nextDouble(int n) { return enumerate(n, nextDouble); }
public int[] nextInt(int n) { return enumerate(n, nextInt); }
public long[] nextLong(int n) { return enumerate(n, nextLong); }
#endregion
}
}
|
[["-", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["-", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222]]
| 8
| 1,240
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class AtCoderA {
static void Main() {
var sc = new Scanner();
long k = sc.NextLong();
long t = sc.NextLong();
long[] aa = sc.LongArray();
long sum = aa.Sum();
long max = aa.Max();
if (sum / 2 >= max) {
Console.WriteLine(0);
return;
}
long answer = max * 2 - sum;
Console.WriteLine(answer);
}
class Scanner {
private string[] _line;
private int _index;
private const char Separator = ' ';
public Scanner() {
_line = new string[0];
_index = 0;
}
public string Next() {
while (_index >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_index = 0;
}
return _line[_index++];
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
public decimal NextDecimal() => decimal.Parse(Next());
public char NextChar() => Next()[0];
public char[] NextCharArray() => Next().ToCharArray();
public string[] Array() {
_line = Console.ReadLine().Split(Separator);
_index = _line.Length;
return _line;
}
public int[] IntArray() => Array().Select(int.Parse).ToArray();
public long[] LongArray() => Array().Select(long.Parse).ToArray();
public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class AtCoderA {
static void Main() {
var sc = new Scanner();
long k = sc.NextLong();
long t = sc.NextLong();
long[] aa = sc.LongArray();
long sum = aa.Sum();
long max = aa.Max();
if (sum / 2 >= max) {
Console.WriteLine(0);
return;
}
long answer = max * 2 - sum - 1;
Console.WriteLine(answer);
}
class Scanner {
private string[] _line;
private int _index;
private const char Separator = ' ';
public Scanner() {
_line = new string[0];
_index = 0;
}
public string Next() {
while (_index >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_index = 0;
}
return _line[_index++];
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
public decimal NextDecimal() => decimal.Parse(Next());
public char NextChar() => Next()[0];
public char[] NextCharArray() => Next().ToCharArray();
public string[] Array() {
_line = Console.ReadLine().Split(Separator);
_index = _line.Length;
return _line;
}
public int[] IntArray() => Array().Select(int.Parse).ToArray();
public long[] LongArray() => Array().Select(long.Parse).ToArray();
public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
}
}
|
[["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 33], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203]]
| 8
| 416
| 2
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Numerics;
using System.IO;
using System.Runtime.InteropServices;
using static System.Math;
using static Math2;
using static io;
using static Utils;
public class CompetitiveProgramming {
public void Solve() {
var o = Ints;
var K = o[0];
var T = o[1];
var a = Ints;
Write(a.Max() - 1 - (K - a.Max()));
}
}
public static class Math2 {
public const int INF = 1 << 29;
public const long INFL = 1L << 60;
public const long MOD = 1000000007;
public const int MOD2 = 998244353;
public static long Power(long a, long b, long MOD = 1000000007) // i^N
{
long res = 1;
while (b > 0) {
if ((b & 1) != 0)
res = res * a % MOD;
a = a * a % MOD;
b >>= 1;
}
return res;
}
public static long Power2(long a, long b) // i^N
{
long res = 1;
while (b > 0) {
if ((b & 1) != 0)
res = res * a;
a = a * a;
b >>= 1;
}
return res;
}
public static long GCD(long a, long b) {
while (b > 0) {
var r = a % b;
a = b;
b = r;
}
return a;
}
public static long LCM(long a, long b) => (b / GCD(a, b)) * a;
public static long Comb(long n, long r, int MOD = 1000000007) {
long ret = 1;
long x = 1;
for (long i = n; i >= n - r + 1; --i) {
ret = ret / x * i;
ret %= MOD;
x++;
}
return ret;
}
public static long Comb2(long n, long r) {
long Nume = 1;
long Deno = 1;
if (r > n - r)
r = n - r;
for (long i = 1; i <= r; ++i) {
Deno *= i;
Nume *= n - i + 1;
}
return Nume / Deno;
}
}
public static class Utils {
public static void Swap<T>(ref T A, ref T B) {
T x = A;
A = B;
B = x;
}
public static int DigitSum(int N) {
string s = N.ToString();
int ret = 0;
for (int i = 0; i < s.Length; ++i)
ret += s[i] - '0';
return ret;
}
}
class Program {
static void Main(string[] args) {
var CompetitiveProgramming = new CompetitiveProgramming();
CompetitiveProgramming.Solve();
}
}
public static class io {
public static string Str => Console.ReadLine();
public static string[] Strs => Str.Split(' ');
public static long[] Longs => Strs.Select(long.Parse).ToArray();
public static int[] Ints => Strs.Select(int.Parse).ToArray();
public static char[] Chars => Str.ToArray();
public static double[] Doubles => Strs.Select(double.Parse).ToArray();
public static long Long1 => Longs[0];
public static int Int1 => Ints[0];
public static char Char1 => Chars[0];
public static double Double1 => Doubles[0];
public static long[] VerticalRead(int N) {
long[] A = new long[N];
for (int i = 0; i < N; ++i)
A[i] = Long1;
return A;
}
public static void Write(string a) => Console.WriteLine(a);
public static void Write(params object[] i) => Write(string.Join(" ", i));
public static void Write<T>(IEnumerable<T> a) => Write(string.Join(" ", a));
public static void Verticalwrite<T>(IEnumerable<T> a) {
foreach (var z in a)
Write(z);
}
public static void YN(bool i) {
if (i)
Write("Yes");
else
Write("No");
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Numerics;
using System.IO;
using System.Runtime.InteropServices;
using static System.Math;
using static Math2;
using static io;
using static Utils;
public class CompetitiveProgramming {
public void Solve() {
var o = Ints;
var K = o[0];
var T = o[1];
var a = Ints;
Write(Max(0, a.Max() - 1 - (K - a.Max())));
}
}
public static class Math2 {
public const int INF = 1 << 29;
public const long INFL = 1L << 60;
public const long MOD = 1000000007;
public const int MOD2 = 998244353;
public static long Power(long a, long b, long MOD = 1000000007) // i^N
{
long res = 1;
while (b > 0) {
if ((b & 1) != 0)
res = res * a % MOD;
a = a * a % MOD;
b >>= 1;
}
return res;
}
public static long Power2(long a, long b) // i^N
{
long res = 1;
while (b > 0) {
if ((b & 1) != 0)
res = res * a;
a = a * a;
b >>= 1;
}
return res;
}
public static long GCD(long a, long b) {
while (b > 0) {
var r = a % b;
a = b;
b = r;
}
return a;
}
public static long LCM(long a, long b) => (b / GCD(a, b)) * a;
public static long Comb(long n, long r, int MOD = 1000000007) {
long ret = 1;
long x = 1;
for (long i = n; i >= n - r + 1; --i) {
ret = ret / x * i;
ret %= MOD;
x++;
}
return ret;
}
public static long Comb2(long n, long r) {
long Nume = 1;
long Deno = 1;
if (r > n - r)
r = n - r;
for (long i = 1; i <= r; ++i) {
Deno *= i;
Nume *= n - i + 1;
}
return Nume / Deno;
}
}
public static class Utils {
public static void Swap<T>(ref T A, ref T B) {
T x = A;
A = B;
B = x;
}
public static int DigitSum(int N) {
string s = N.ToString();
int ret = 0;
for (int i = 0; i < s.Length; ++i)
ret += s[i] - '0';
return ret;
}
}
class Program {
static void Main(string[] args) {
var CompetitiveProgramming = new CompetitiveProgramming();
CompetitiveProgramming.Solve();
}
}
public static class io {
public static string Str => Console.ReadLine();
public static string[] Strs => Str.Split(' ');
public static long[] Longs => Strs.Select(long.Parse).ToArray();
public static int[] Ints => Strs.Select(int.Parse).ToArray();
public static char[] Chars => Str.ToArray();
public static double[] Doubles => Strs.Select(double.Parse).ToArray();
public static long Long1 => Longs[0];
public static int Int1 => Ints[0];
public static char Char1 => Chars[0];
public static double Double1 => Doubles[0];
public static long[] VerticalRead(int N) {
long[] A = new long[N];
for (int i = 0; i < N; ++i)
A[i] = Long1;
return A;
}
public static void Write(string a) => Console.WriteLine(a);
public static void Write(params object[] i) => Write(string.Join(" ", i));
public static void Write<T>(IEnumerable<T> a) => Write(string.Join(" ", a));
public static void Verticalwrite<T>(IEnumerable<T> a) {
foreach (var z in a)
Write(z);
}
public static void YN(bool i) {
if (i)
Write("Yes");
else
Write("No");
}
}
|
[["+", 0, 213, 3, 4, 0, 28, 0, 213, 63, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 0, 28, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 21], ["+", 12, 23, 0, 16, 12, 213, 3, 4, 0, 25]]
| 8
| 938
| 5
|
using System;
using System.Collections.Generic;
using System.Linq;
#if !DEBUG
using System.IO;
#endif
public class Program {
public static void Main() {
#region SetAutoFlushIsFalse
#if !DEBUG
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
#endif
#endregion
var kt = ReadLib.ReadAsIntArray();
var arr = ReadLib.ReadAsIntArray();
Console.WriteLine(Calculation.Calc(kt[0], kt[1], arr));
#region Flush
#if !DEBUG
Console.Out.Flush();
sw.Close();
#endif
#endregion
}
}
static class Calculation {
internal static int Calc(int k, int t, int[] arr) {
var max = arr.Max();
var upTo = k % 2 == 0 ? k / 2 : (int)Math.Ceiling(k / (decimal)2);
if (max <= upTo) {
return 0;
}
if (k % 2 == 0) {
return 1 + (max - upTo + 1) * 2;
}
return (max - upTo) * 2;
}
}
static class ReadLib {
public static long ReadAsLong() { return long.Parse(Console.ReadLine()); }
public static int ReadAsInt() { return int.Parse(Console.ReadLine()); }
public static int[] ReadAsIntArray(int step = 0) {
return Console.ReadLine()
.Split(' ')
.Select(s => int.Parse(s) + step)
.ToArray();
}
public static long[] ReadAsLongArray(int step = 0) {
return Console.ReadLine()
.Split(' ')
.Select(s => long.Parse(s) + step)
.ToArray();
}
public static ulong[] ReadAsULongArray() {
return Console.ReadLine().Split(' ').Select(s => ulong.Parse(s)).ToArray();
}
public static string[] ReadAsStringArray() {
return Console.ReadLine().Split(' ');
}
public static int[] ReadNTimesAsInt(int n, int step = 0) {
return Enumerable.Range(1, n)
.Select(s => int.Parse(Console.ReadLine()) + step)
.ToArray();
}
public static int[][] ReadNTimesAsIntArray(int n, int step = 0) {
return Enumerable.Range(1, n).Select(s => ReadAsIntArray(step)).ToArray();
}
public static string[] ReadNTimesAsString(int n) {
return Enumerable.Range(1, n).Select(s => Console.ReadLine()).ToArray();
}
}
static class MyMath {
/// <summary>階乗</summary>
public static long Factorial(int n) {
if (n == 0) {
return 1;
}
return Permutation(n, 0);
}
public static long Permutation(int n, int k) {
return Enumerable.Range(0, n - k)
.Select(i => n - i)
.Aggregate(1, (b, i) => b * i);
}
///// <summary>nCr, 組み合わせ</summary>
// public static long Combination(int n, int r) {
// if (r == 0) {
// return 1;
// }
// // 分子
// var moleculeArr = Enumerable
// .Range(0, Math.Min(n - r, r))
// .Select(i => n - i)
// .ToArray();
// var moleculeArrLength = moleculeArr.Length;
// // 分母
// var denominatorArr = Enumerable
// .Range(1, Math.Max(n - r, r))
// .ToArray();
// for (var m = 0; m < moleculeArrLength; m++) {
// while (true) {
// var mVal = moleculeArr[m];
// var gcds = denominatorArr.Select(b => Gcd(mVal, b));
// var maxGcd = gcds.Max();
// var maxI = gcds.ToList().IndexOf(maxGcd);
// if (maxGcd == 1) {
// break;
// }
// denominatorArr[maxI] /= (int)maxGcd;
// moleculeArr[m] /= (int)maxGcd;
// }
// }
// return FullPower(moleculeArr);
//}
#region FullPower
/// <summary>総乗、π</summary>
public static long FullPower(IEnumerable<long> vs) {
return vs.Aggregate(1L, (a, b) => a * b);
}
public static long FullPower(IEnumerable<int> vs) {
return vs.Aggregate(1L, (a, b) => a * b);
}
#endregion
/// <summary>最大公約数</summary>
public static long Gcd(long item1, long item2) {
var a = Math.Max(item1, item2);
var b = Math.Min(item1, item2);
while (true) {
long mod;
Math.DivRem(a, b, out mod);
if (mod == 0) {
break;
}
a = b;
b = mod;
}
return b;
}
/// <summary>約分。最大公約数で割ったものを返す。</summary>
public static Tuple<long, long> DeviedByGcd(long item1, long item2) {
var gcd = Gcd(item1, item2);
return new Tuple<long, long>(item1 / gcd, item2 / gcd);
}
public static long Lcm(int item1, int item2) {
return Math.BigMul(item1, item2) / Gcd(item1, item2);
}
}
static class MyMethod {
/// <summary>数え上げて、key, 出現回数に変換</summary>
public static Dictionary<T, int> CountUp<T>(IEnumerable<T> str) {
return str.GroupBy(c => c)
.Select(g => new KeyValuePair<T, int>(g.Key, g.Count()))
.ToDictionary(e => e.Key, e => e.Value);
}
}
/// <summary>あまりを計算するためのintのラッパー</summary>
struct ModInt {
int Value { get; }
int Mod { get; }
public override string ToString() { return Value.ToString(); }
public static explicit operator ModInt(long value) {
return new ModInt(value);
}
public ModInt(long value, int mod = 1000000007) {
this.Value = (int)(value % mod);
this.Mod = mod;
}
public static explicit operator int(ModInt modInt) { return modInt.Value; }
private static void CheckNotEqualMod(ModInt item1, ModInt item2) {
if (item1.Mod != item2.Mod) {
throw new Exception("mod not equal");
}
}
public static ModInt operator +(ModInt item1, ModInt item2) {
CheckNotEqualMod(item1, item2);
long value = item1.Value + item2.Value;
return new ModInt(value, item1.Mod);
}
public static ModInt operator *(ModInt item1, ModInt item2) {
CheckNotEqualMod(item1, item2);
long value = Math.BigMul(item1.Value, item2.Value);
return new ModInt(value, item1.Mod);
}
public static ModInt operator +(ModInt item1, int item2) {
long value = item1.Value + item2;
return new ModInt(value, item1.Mod);
}
public static ModInt operator *(ModInt item1, int item2) {
long value = Math.BigMul(item1.Value, item2);
return new ModInt(value, item1.Mod);
}
public override int GetHashCode() { return this.Value; }
public override bool Equals(object obj) {
if (obj == null || this.GetType() != obj.GetType()) {
return false;
}
var modIntObj = (ModInt)obj;
return modIntObj.Value == this.Value;
}
public static bool operator ==(ModInt item1, ModInt item2) {
return item1.Value == item2.Value;
}
public static bool operator !=(ModInt item1, ModInt item2) {
return !(item1 == item2);
}
public static bool operator ==(ModInt item1, int item2) {
return item1.Value == item2;
}
public static bool operator !=(ModInt item1, int item2) {
return !(item1.Value == item2);
}
public static bool operator >=(ModInt item1, ModInt item2) {
return item1.Value >= item2.Value;
}
public static bool operator <=(ModInt item1, ModInt item2) {
return item1.Value <= item2.Value;
}
public static bool operator >=(ModInt item1, int item2) {
return item1.Value >= item2;
}
public static bool operator <=(ModInt item1, int item2) {
return item1.Value <= item2;
}
public static bool operator>(ModInt item1, ModInt item2) {
return item1.Value > item2.Value;
}
public static bool operator<(ModInt item1, ModInt item2) {
return item1.Value < item2.Value;
}
public static bool operator>(ModInt item1, int item2) {
return item1.Value >= item2;
}
public static bool operator<(ModInt item1, int item2) {
return item1.Value <= item2;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
#if !DEBUG
using System.IO;
#endif
public class Program {
public static void Main() {
#region SetAutoFlushIsFalse
#if !DEBUG
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
#endif
#endregion
var kt = ReadLib.ReadAsIntArray();
var arr = ReadLib.ReadAsIntArray();
Console.WriteLine(Calculation.Calc(kt[0], kt[1], arr));
#region Flush
#if !DEBUG
Console.Out.Flush();
sw.Close();
#endif
#endregion
}
}
static class Calculation {
internal static int Calc(int k, int t, int[] arr) {
var max = arr.Max();
var upTo = k % 2 == 0 ? k / 2 : (int)Math.Ceiling(k / (decimal)2);
if (max <= upTo) {
return 0;
}
if (k % 2 == 0) {
return 1 + (max - upTo - 1) * 2;
}
return (max - upTo) * 2;
}
}
static class ReadLib {
public static long ReadAsLong() { return long.Parse(Console.ReadLine()); }
public static int ReadAsInt() { return int.Parse(Console.ReadLine()); }
public static int[] ReadAsIntArray(int step = 0) {
return Console.ReadLine()
.Split(' ')
.Select(s => int.Parse(s) + step)
.ToArray();
}
public static long[] ReadAsLongArray(int step = 0) {
return Console.ReadLine()
.Split(' ')
.Select(s => long.Parse(s) + step)
.ToArray();
}
public static ulong[] ReadAsULongArray() {
return Console.ReadLine().Split(' ').Select(s => ulong.Parse(s)).ToArray();
}
public static string[] ReadAsStringArray() {
return Console.ReadLine().Split(' ');
}
public static int[] ReadNTimesAsInt(int n, int step = 0) {
return Enumerable.Range(1, n)
.Select(s => int.Parse(Console.ReadLine()) + step)
.ToArray();
}
public static int[][] ReadNTimesAsIntArray(int n, int step = 0) {
return Enumerable.Range(1, n).Select(s => ReadAsIntArray(step)).ToArray();
}
public static string[] ReadNTimesAsString(int n) {
return Enumerable.Range(1, n).Select(s => Console.ReadLine()).ToArray();
}
}
static class MyMath {
/// <summary>階乗</summary>
public static long Factorial(int n) {
if (n == 0) {
return 1;
}
return Permutation(n, 0);
}
public static long Permutation(int n, int k) {
return Enumerable.Range(0, n - k)
.Select(i => n - i)
.Aggregate(1, (b, i) => b * i);
}
///// <summary>nCr, 組み合わせ</summary>
// public static long Combination(int n, int r) {
// if (r == 0) {
// return 1;
// }
// // 分子
// var moleculeArr = Enumerable
// .Range(0, Math.Min(n - r, r))
// .Select(i => n - i)
// .ToArray();
// var moleculeArrLength = moleculeArr.Length;
// // 分母
// var denominatorArr = Enumerable
// .Range(1, Math.Max(n - r, r))
// .ToArray();
// for (var m = 0; m < moleculeArrLength; m++) {
// while (true) {
// var mVal = moleculeArr[m];
// var gcds = denominatorArr.Select(b => Gcd(mVal, b));
// var maxGcd = gcds.Max();
// var maxI = gcds.ToList().IndexOf(maxGcd);
// if (maxGcd == 1) {
// break;
// }
// denominatorArr[maxI] /= (int)maxGcd;
// moleculeArr[m] /= (int)maxGcd;
// }
// }
// return FullPower(moleculeArr);
//}
#region FullPower
/// <summary>総乗、π</summary>
public static long FullPower(IEnumerable<long> vs) {
return vs.Aggregate(1L, (a, b) => a * b);
}
public static long FullPower(IEnumerable<int> vs) {
return vs.Aggregate(1L, (a, b) => a * b);
}
#endregion
/// <summary>最大公約数</summary>
public static long Gcd(long item1, long item2) {
var a = Math.Max(item1, item2);
var b = Math.Min(item1, item2);
while (true) {
long mod;
Math.DivRem(a, b, out mod);
if (mod == 0) {
break;
}
a = b;
b = mod;
}
return b;
}
/// <summary>約分。最大公約数で割ったものを返す。</summary>
public static Tuple<long, long> DeviedByGcd(long item1, long item2) {
var gcd = Gcd(item1, item2);
return new Tuple<long, long>(item1 / gcd, item2 / gcd);
}
public static long Lcm(int item1, int item2) {
return Math.BigMul(item1, item2) / Gcd(item1, item2);
}
}
static class MyMethod {
/// <summary>数え上げて、key, 出現回数に変換</summary>
public static Dictionary<T, int> CountUp<T>(IEnumerable<T> str) {
return str.GroupBy(c => c)
.Select(g => new KeyValuePair<T, int>(g.Key, g.Count()))
.ToDictionary(e => e.Key, e => e.Value);
}
}
/// <summary>あまりを計算するためのintのラッパー</summary>
struct ModInt {
int Value { get; }
int Mod { get; }
public override string ToString() { return Value.ToString(); }
public static explicit operator ModInt(long value) {
return new ModInt(value);
}
public ModInt(long value, int mod = 1000000007) {
this.Value = (int)(value % mod);
this.Mod = mod;
}
public static explicit operator int(ModInt modInt) { return modInt.Value; }
private static void CheckNotEqualMod(ModInt item1, ModInt item2) {
if (item1.Mod != item2.Mod) {
throw new Exception("mod not equal");
}
}
public static ModInt operator +(ModInt item1, ModInt item2) {
CheckNotEqualMod(item1, item2);
long value = item1.Value + item2.Value;
return new ModInt(value, item1.Mod);
}
public static ModInt operator *(ModInt item1, ModInt item2) {
CheckNotEqualMod(item1, item2);
long value = Math.BigMul(item1.Value, item2.Value);
return new ModInt(value, item1.Mod);
}
public static ModInt operator +(ModInt item1, int item2) {
long value = item1.Value + item2;
return new ModInt(value, item1.Mod);
}
public static ModInt operator *(ModInt item1, int item2) {
long value = Math.BigMul(item1.Value, item2);
return new ModInt(value, item1.Mod);
}
public override int GetHashCode() { return this.Value; }
public override bool Equals(object obj) {
if (obj == null || this.GetType() != obj.GetType()) {
return false;
}
var modIntObj = (ModInt)obj;
return modIntObj.Value == this.Value;
}
public static bool operator ==(ModInt item1, ModInt item2) {
return item1.Value == item2.Value;
}
public static bool operator !=(ModInt item1, ModInt item2) {
return !(item1 == item2);
}
public static bool operator ==(ModInt item1, int item2) {
return item1.Value == item2;
}
public static bool operator !=(ModInt item1, int item2) {
return !(item1.Value == item2);
}
public static bool operator >=(ModInt item1, ModInt item2) {
return item1.Value >= item2.Value;
}
public static bool operator <=(ModInt item1, ModInt item2) {
return item1.Value <= item2.Value;
}
public static bool operator >=(ModInt item1, int item2) {
return item1.Value >= item2;
}
public static bool operator <=(ModInt item1, int item2) {
return item1.Value <= item2;
}
public static bool operator>(ModInt item1, ModInt item2) {
return item1.Value > item2.Value;
}
public static bool operator<(ModInt item1, ModInt item2) {
return item1.Value < item2.Value;
}
public static bool operator>(ModInt item1, int item2) {
return item1.Value >= item2;
}
public static bool operator<(ModInt item1, int item2) {
return item1.Value <= item2;
}
}
|
[["-", 0, 16, 12, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 16, 12, 16, 31, 23, 0, 16, 17, 33]]
| 8
| 1,613
| 2
|
using System;
using System.Linq;
using static System.Console;
using static System.Math;
class E {
static void Main() => new K();
}
class K {
int[] G() => ReadLine().Split().Select(x => int.Parse(x)).ToArray();
public K() {
var I = G();
int Y = I[0], X = I[1];
var m = new char[X, Y];
for (var y = 0; y < Y; y++) {
var s = ReadLine();
for (var x = 0; x < X; x++)
m[x, y] = s[y];
}
var ans = 0L;
for (var x = 0; x < X - 1; x++) {
var p = new int[Y + 1, Y + 1];
for (var i = 0; i < Y; i++)
if (m[x, i] == m[x + 1, i])
p[0, 0]++;
for (var a = 1; a <= Y; a++)
for (var i = 0; i < Y - a; i++)
if (m[x, i] == m[x + 1, i + a])
p[a, 0]++;
for (var b = 1; b <= Y; b++)
for (var i = 0; i < Y - b; i++)
if (m[x, i + b] == m[x + 1, i])
p[0, b]++;
for (var a = 1; a <= Y; a++)
for (var b = 1; b <= Y; b++)
p[a, b] = p[a - 1, b - 1] - (m[x, Y - a] == m[x + 1, Y - b] ? 1 : 0);
var dp = new int[Y + 1, Y + 1];
for (var a = Y - 1; a >= 0; a--)
for (var b = Y - 1; b >= 0; b--)
dp[a, b] = p[a, b] + Min(dp[a, b + 1], dp[a + 1, b]);
ans += dp[0, 0];
}
Console.WriteLine(ans);
}
}
|
using System;
using System.Linq;
using static System.Console;
using static System.Math;
class E {
static void Main() => new K();
}
class K {
int[] G() => ReadLine().Split().Select(x => int.Parse(x)).ToArray();
public K() {
var I = G();
int Y = I[0], X = I[1];
var m = new char[X, Y];
for (var y = 0; y < Y; y++) {
var s = ReadLine();
for (var x = 0; x < X; x++)
m[x, y] = s[x];
}
var ans = 0L;
for (var x = 0; x < X - 1; x++) {
var p = new int[Y + 1, Y + 1];
for (var i = 0; i < Y; i++)
if (m[x, i] == m[x + 1, i])
p[0, 0]++;
for (var a = 1; a <= Y; a++)
for (var i = 0; i < Y - a; i++)
if (m[x, i] == m[x + 1, i + a])
p[a, 0]++;
for (var b = 1; b <= Y; b++)
for (var i = 0; i < Y - b; i++)
if (m[x, i + b] == m[x + 1, i])
p[0, b]++;
for (var a = 1; a <= Y; a++)
for (var b = 1; b <= Y; b++)
p[a, b] = p[a - 1, b - 1] - (m[x, Y - a] == m[x + 1, Y - b] ? 1 : 0);
var dp = new int[Y + 1, Y + 1];
for (var a = Y - 1; a >= 0; a--)
for (var b = Y - 1; b >= 0; b--)
dp[a, b] = p[a, b] + Min(dp[a, b + 1], dp[a + 1, b]);
ans += dp[0, 0];
}
Console.WriteLine(ans);
}
}
|
[["-", 0, 11, 12, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 11, 12, 204, 206, 207, 0, 28, 0, 22]]
| 8
| 522
| 2
|
using System;
using System.Collections.Generic;
namespace cswork {
class Program {
static void Main(string[] args) {
List<long> ll = ReadList();
if (ll[0] == ll[1] && ll[1] == ll[2]) {
Write(1);
} else if (ll[0] == ll[1] || ll[1] == ll[2] || ll[2] == ll[0]) {
Write(2);
} else {
Write(1);
}
Exit();
}
public static void Write(string str) { Console.WriteLine(str); }
public static void Write(int i) { Console.WriteLine(i); }
public static void Write(double d) { Console.WriteLine(d); }
public static string ReadStr() { return Console.ReadLine(); }
public static int ReadInt() { return int.Parse(Console.ReadLine()); }
public static long Read() { return long.Parse(Console.ReadLine()); }
public static double ReadDouble() { return double.Parse(Console.ReadLine()); }
public static void Exit() {}
public static List<string> ReadListStr() {
return new List<string>(ReadStr().Split(" "));
}
public static List<long> ReadList() {
return ReadListStr().ConvertAll(x => long.Parse(x));
}
public static List<int> ReadListInt() {
return ReadListStr().ConvertAll(x => int.Parse(x));
}
}
}
|
using System;
using System.Collections.Generic;
namespace cswork {
class Program {
static void Main(string[] args) {
List<long> ll = ReadList();
if (ll[0] == ll[1] && ll[1] == ll[2]) {
Write(1);
} else if (ll[0] == ll[1] || ll[1] == ll[2] || ll[2] == ll[0]) {
Write(2);
} else {
Write(3);
}
Exit();
}
public static void Write(string str) { Console.WriteLine(str); }
public static void Write(int i) { Console.WriteLine(i); }
public static void Write(double d) { Console.WriteLine(d); }
public static string ReadStr() { return Console.ReadLine(); }
public static int ReadInt() { return int.Parse(Console.ReadLine()); }
public static long Read() { return long.Parse(Console.ReadLine()); }
public static double ReadDouble() { return double.Parse(Console.ReadLine()); }
public static void Exit() {}
public static List<string> ReadListStr() {
return new List<string>(ReadStr().Split(" "));
}
public static List<long> ReadList() {
return ReadListStr().ConvertAll(x => long.Parse(x));
}
public static List<int> ReadListInt() {
return ReadListStr().ConvertAll(x => int.Parse(x));
}
}
}
|
[["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203]]
| 8
| 340
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;
using static Read;
class Program {
public static void Main() {
var n = IntArray();
Sort(n);
int count = 0;
for (int i = 1; i < n.Length; i++) {
if (n[i - 1] != n[i]) {
count++;
}
}
WriteLine($"{count}");
}
}
static class Read {
static Queue<string> queue = new Queue<string>();
static void Enqueue() {
ReadLine().Split(' ').ToList().ForEach(a => queue.Enqueue(a));
}
public static int Int() {
if (queue.Count == 0)
Enqueue();
return int.Parse(queue.Dequeue());
}
public static long Long() {
if (queue.Count == 0)
Enqueue();
return long.Parse(queue.Dequeue());
}
public static double Double() {
if (queue.Count == 0)
Enqueue();
return double.Parse(queue.Dequeue());
}
public static string String() {
if (queue.Count == 0)
Enqueue();
return queue.Dequeue();
}
public static int[] IntArray() {
return ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
}
public static long[] LongArray() {
return ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
}
public static double[] DoubleArray() {
return ReadLine().Split(' ').Select(a => double.Parse(a)).ToArray();
}
public static string[] StringArray() { return ReadLine().Split(' '); }
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;
using static Read;
class Program {
public static void Main() {
var n = IntArray();
Sort(n);
int count = 1;
for (int i = 1; i < n.Length; i++) {
if (n[i - 1] != n[i]) {
count++;
}
}
WriteLine($"{count}");
}
}
static class Read {
static Queue<string> queue = new Queue<string>();
static void Enqueue() {
ReadLine().Split(' ').ToList().ForEach(a => queue.Enqueue(a));
}
public static int Int() {
if (queue.Count == 0)
Enqueue();
return int.Parse(queue.Dequeue());
}
public static long Long() {
if (queue.Count == 0)
Enqueue();
return long.Parse(queue.Dequeue());
}
public static double Double() {
if (queue.Count == 0)
Enqueue();
return double.Parse(queue.Dequeue());
}
public static string String() {
if (queue.Count == 0)
Enqueue();
return queue.Dequeue();
}
public static int[] IntArray() {
return ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
}
public static long[] LongArray() {
return ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
}
public static double[] DoubleArray() {
return ReadLine().Split(' ').Select(a => double.Parse(a)).ToArray();
}
public static string[] StringArray() { return ReadLine().Split(' '); }
}
|
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203]]
| 8
| 430
| 2
|
using System;
namespace ABC026A {
class Program {
static void Main(string[] args) {
int a, b, c;
var word = Console.ReadLine().Split(' ');
a = int.Parse(word[0]);
b = int.Parse(word[1]);
c = int.Parse(word[2]);
int n;
if (a == b && b == c && c == a)
n = 1;
else if (a == b || b == c || c == a)
n = 2;
else
n = 1;
Console.WriteLine(n);
Console.ReadKey();
}
}
}
|
using System;
namespace ABC026A {
class Program {
static void Main(string[] args) {
int a, b, c;
var word = Console.ReadLine().Split(' ');
a = int.Parse(word[0]);
b = int.Parse(word[1]);
c = int.Parse(word[2]);
int n;
if (a == b && b == c && c == a)
n = 1;
else if (a == b || b == c || c == a)
n = 2;
else
n = 3;
Console.WriteLine(n);
Console.ReadKey();
}
}
}
|
[["-", 0, 57, 75, 57, 75, 1, 0, 11, 12, 203], ["+", 0, 57, 75, 57, 75, 1, 0, 11, 12, 203]]
| 8
| 139
| 2
|
using System;
namespace ABC046A {
class Program {
static void Main(string[] args) {
int a, b, c, x = 2;
var word = Console.ReadLine().Split(' ');
a = int.Parse(word[0]);
b = int.Parse(word[1]);
c = int.Parse(word[1]);
if (a != b && a != c && b != c)
x = 3;
else if (a == b && a == c && b == c)
x = 1;
Console.WriteLine(x);
Console.ReadKey();
}
}
}
|
using System;
namespace ABC046A {
class Program {
static void Main(string[] args) {
int a, b, c, x = 2;
var word = Console.ReadLine().Split(' ');
a = int.Parse(word[0]);
b = int.Parse(word[1]);
c = int.Parse(word[2]);
if (a != b && a != c && b != c)
x = 3;
else if (a == b && a == c && b == c)
x = 1;
Console.WriteLine(x);
Console.ReadKey();
}
}
}
|
[["-", 0, 28, 0, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 28, 0, 204, 206, 207, 0, 28, 0, 203]]
| 8
| 135
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder.Io;
namespace AtCoder {
class Program {
static void Main() {
var abc = ReadIntArray();
Console.WriteLine($"{abc.Sum()}");
}
}
public static class Io {
public static string ReadString() => Console.ReadLine();
public static string[] ReadStringArray() => ReadString().Split(' ');
public static int ReadInt() => int.Parse(ReadString());
public static long ReadLong() => long.Parse(ReadString());
public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
public static long[] ReadLongArray() =>
ReadStringArray().ParseLong().ToArray();
public static IEnumerable<int>
ParseInt(this IEnumerable<string> source) => source.Select(int.Parse);
public static IEnumerable<long>
ParseLong(this IEnumerable<string> source) => source.Select(long.Parse);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder.Io;
namespace AtCoder {
class Program {
static void Main() {
var abc = ReadIntArray();
Console.WriteLine($"{abc.Distinct().Count()}");
}
}
public static class Io {
public static string ReadString() => Console.ReadLine();
public static string[] ReadStringArray() => ReadString().Split(' ');
public static int ReadInt() => int.Parse(ReadString());
public static long ReadLong() => long.Parse(ReadString());
public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
public static long[] ReadLongArray() =>
ReadStringArray().ParseLong().ToArray();
public static IEnumerable<int>
ParseInt(this IEnumerable<string> source) => source.Select(int.Parse);
public static IEnumerable<long>
ParseLong(this IEnumerable<string> source) => source.Select(long.Parse);
}
}
|
[["-", 0, 283, 0, 284, 0, 213, 63, 214, 141, 22], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["+", 0, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["+", 0, 283, 0, 284, 0, 213, 63, 214, 0, 131], ["+", 0, 283, 0, 284, 0, 213, 63, 214, 141, 22]]
| 8
| 221
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
class Myon {
public Myon() {}
public static int Main() {
new Myon().calc();
return 0;
}
Scanner cin;
Func cin2;
void calc() {
cin = new Scanner();
cin2 = new Func();
int[] abc = cin.ArrayInt(3, 0);
Array.Sort(abc);
int ans = 3;
if (abc[0] == abc[2])
ans = 1;
else if (abc[0] == abc[1] && abc[0] != abc[2])
ans = 2;
Console.WriteLine(ans);
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public 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 Answer {
public void Int2DArrayAns(int[,] x, char c) {
for (int i = 0; i < x.GetLength(0); i++) {
for (int j = 0; j < x.GetLength(1) - 1; j++) {
Console.Write(x[i, j]);
Console.Write(c);
}
Console.WriteLine(x[i, x.GetLength(1) - 1]);
}
}
public void Char2DArrayAns(char[,] x, char c) {
for (int i = 0; i < x.GetLength(0); i++) {
for (int j = 0; j < x.GetLength(1) - 1; j++) {
Console.Write(x[i, j]);
Console.Write(c);
}
Console.WriteLine(x[i, x.GetLength(1) - 1]);
}
}
}
class Func {
public long GCDLong(long a, long b) {
while (a != 0) {
long t = a;
a = b % a;
b = t;
}
return b;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
class Myon {
public Myon() {}
public static int Main() {
new Myon().calc();
return 0;
}
Scanner cin;
Func cin2;
void calc() {
cin = new Scanner();
cin2 = new Func();
int[] abc = cin.ArrayInt(3, 0);
Array.Sort(abc);
int ans = 3;
if (abc[0] == abc[2])
ans = 1;
else if (abc[0] == abc[1] || abc[1] == abc[2])
ans = 2;
Console.WriteLine(ans);
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public 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 Answer {
public void Int2DArrayAns(int[,] x, char c) {
for (int i = 0; i < x.GetLength(0); i++) {
for (int j = 0; j < x.GetLength(1) - 1; j++) {
Console.Write(x[i, j]);
Console.Write(c);
}
Console.WriteLine(x[i, x.GetLength(1) - 1]);
}
}
public void Char2DArrayAns(char[,] x, char c) {
for (int i = 0; i < x.GetLength(0); i++) {
for (int j = 0; j < x.GetLength(1) - 1; j++) {
Console.Write(x[i, j]);
Console.Write(c);
}
Console.WriteLine(x[i, x.GetLength(1) - 1]);
}
}
}
class Func {
public long GCDLong(long a, long b) {
while (a != 0) {
long t = a;
a = b % a;
b = t;
}
return b;
}
}
|
[["-", 8, 196, 0, 57, 75, 57, 15, 16, 17, 98], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 106], ["-", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 57, 75, 57, 15, 16, 12, 16, 17, 79], ["+", 0, 57, 75, 57, 15, 16, 12, 16, 17, 60]]
| 8
| 759
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ziyuutyou {
class Program {
static void Main(string[] args) {
var str = Console.ReadLine().Split(' ');
var a = int.Parse(str[0]);
var b = int.Parse(str[1]);
var c = int.Parse(str[2]);
if (a == b && b == c) {
Console.WriteLine(1);
} else if (a == b || b == c) {
Console.WriteLine(2);
} else {
Console.WriteLine(3);
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ziyuutyou {
class Program {
static void Main(string[] args) {
var str = Console.ReadLine().Split(' ');
var a = int.Parse(str[0]);
var b = int.Parse(str[1]);
var c = int.Parse(str[2]);
if (a == b && b == c) {
Console.WriteLine(1);
} else if (a == b || b == c || a == c) {
Console.WriteLine(2);
} else {
Console.WriteLine(3);
}
}
}
}
|
[["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 106], ["+", 0, 57, 75, 57, 15, 16, 12, 16, 31, 22], ["+", 0, 57, 75, 57, 15, 16, 12, 16, 17, 60], ["+", 0, 57, 75, 57, 15, 16, 12, 16, 12, 22]]
| 8
| 138
| 4
|
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) {
var res = MyUtil.ReadIntArray();
int a = res[0];
int b = res[1];
int c = res[2];
if (a == b && b == c)
WriteLine(1);
if (a == b || b == c || c == a)
WriteLine(2);
else
WriteLine(3);
ReadKey();
}
}
static class MyUtil {
public static int[] ReadIntArray() {
return 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) {
var res = MyUtil.ReadIntArray();
int a = res[0];
int b = res[1];
int c = res[2];
if (a == b && b == c)
WriteLine(1);
else if (a == b || b == c || c == a)
WriteLine(2);
else
WriteLine(3);
ReadKey();
}
}
static class MyUtil {
public static int[] ReadIntArray() {
return 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, 95]]
| 8
| 252
| 1
|
using System;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split();
int[] IntInput = new int[3];
for (int i = 0; i < 3; i++) {
IntInput[i] = int.Parse(input[i]);
}
if (IntInput[0] == IntInput[1] && IntInput[0] == IntInput[2]) {
Console.WriteLine(1);
} else if (IntInput[0] == IntInput[1] || IntInput[0] == IntInput[1] ||
IntInput[1] == IntInput[2]) {
Console.WriteLine(2);
} else {
Console.WriteLine(3);
}
}
}
}
|
using System;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split();
int[] IntInput = new int[3];
for (int i = 0; i < 3; i++) {
IntInput[i] = int.Parse(input[i]);
}
if (IntInput[0] == IntInput[1] && IntInput[0] == IntInput[2]) {
Console.WriteLine(1);
} else if (IntInput[0] == IntInput[1] || IntInput[0] == IntInput[2] ||
IntInput[1] == IntInput[2]) {
Console.WriteLine(2);
} else {
Console.WriteLine(3);
}
}
}
}
|
[["-", 12, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 12, 16, 12, 204, 206, 207, 0, 28, 0, 203]]
| 8
| 162
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atcoder {
class Atcoderrrrrr {
static void Main(string[] args) {
string[] s = Console.ReadLine().Split(' ');
int a = int.Parse(s[0]);
int b = int.Parse(s[1]);
int c = int.Parse(s[2]);
if (a == b && a == c) {
Console.WriteLine(3);
} else if (a == b && b != c || b == c && a != b || a == c && b != c) {
Console.WriteLine(2);
} else {
Console.WriteLine(1);
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atcoder {
class Atcoderrrrrr {
static void Main(string[] args) {
string[] s = Console.ReadLine().Split(' ');
int a = int.Parse(s[0]);
int b = int.Parse(s[1]);
int c = int.Parse(s[2]);
if (a == b && a == c) {
Console.WriteLine(1);
} else if (a == b && b != c || b == c && a != b || a == c && b != c) {
Console.WriteLine(2);
} else {
Console.WriteLine(3);
}
}
}
}
|
[["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203]]
| 8
| 168
| 4
|
using System;
class Trapezoids {
public static void Main(String[] args) {
int a, b, h;
a = int.Parse(Console.ReadLine());
b = int.Parse(Console.ReadLine());
h = int.Parse(Console.ReadLine());
Console.WriteLine(a + b * h / 2);
}
}
|
using System;
class Trapezoids {
public static void Main(String[] args) {
int a, b, h;
a = int.Parse(Console.ReadLine());
b = int.Parse(Console.ReadLine());
h = int.Parse(Console.ReadLine());
Console.WriteLine((a + b) * h / 2);
}
}
|
[["+", 0, 28, 0, 16, 31, 16, 31, 23, 0, 24], ["+", 0, 28, 0, 16, 31, 16, 31, 23, 0, 25]]
| 8
| 78
| 2
|
using System;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
int a = int.Parse(Console.ReadLine());
int b = int.Parse(Console.ReadLine());
int h = int.Parse(Console.ReadLine());
Console.WriteLine((a != b) ? (a + b) * h / h : a * h);
}
}
|
using System;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
int a = int.Parse(Console.ReadLine());
int b = int.Parse(Console.ReadLine());
int h = int.Parse(Console.ReadLine());
Console.WriteLine((a != b) ? (a + b) * h / 2 : a * h);
}
}
|
[["-", 3, 4, 0, 28, 0, 41, 64, 16, 12, 22], ["+", 3, 4, 0, 28, 0, 41, 64, 16, 12, 203]]
| 8
| 92
| 2
|
using System;
using System.Collections;
using System.IO;
using System.Linq;
namespace CompetitiveProgramming {
class Solve {
const int INF = (int)(1e9) + 10;
private void Main() {
int a = int.Parse(Console.ReadLine());
int b = int.Parse(Console.ReadLine());
int h = int.Parse(Console.ReadLine());
Console.WriteLine(((a + b) / 2) * h);
}
public Solve() {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
Main();
Console.Out.Flush();
}
}
class Program {
static void Main(string[] args) { new Solve(); }
}
}
|
using System;
using System.Collections;
using System.IO;
using System.Linq;
namespace CompetitiveProgramming {
class Solve {
const int INF = (int)(1e9) + 10;
private void Main() {
int a = int.Parse(Console.ReadLine());
int b = int.Parse(Console.ReadLine());
int h = int.Parse(Console.ReadLine());
Console.WriteLine((a + b) * h / 2);
}
public Solve() {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
Main();
Console.Out.Flush();
}
}
class Program {
static void Main(string[] args) { new Solve(); }
}
}
|
[["-", 0, 16, 31, 23, 0, 16, 31, 23, 0, 24], ["-", 0, 16, 31, 23, 0, 16, 31, 23, 0, 25], ["-", 0, 28, 0, 16, 31, 23, 0, 16, 17, 85], ["-", 0, 28, 0, 16, 31, 23, 0, 16, 12, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 85], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
| 8
| 163
| 6
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;
namespace AtCoder {
public class Program {
static public long[] Sarray() {
return ReadLine().Split().Select(long.Parse).ToArray();
}
static public List<long> Slist() {
return ReadLine().Split().Select(long.Parse).ToList();
}
static public (T1 a, T2 b) Slice<T1, T2>() {
var t = ReadLine().Split();
return ((T1)Convert.ChangeType(t[0], typeof(T1)),
(T2)Convert.ChangeType(t[1], typeof(T2)));
}
static long Mod = (long)1e9 + 7;
public static void Main(string[] args) {
// SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
Solve();
// Out.Flush();
Read();
}
static void Solve() {
var dct = new Dictionary<char, string>();
dct['a'] = ReadLine();
dct['b'] = ReadLine();
dct['c'] = ReadLine();
var n = 'a';
while (true) {
if (string.IsNullOrEmpty(dct[n])) {
WriteLine((char)(n + 'A' - 'a'));
return;
}
n = dct[n][0];
dct[n] = dct[n].Remove(0, 1);
}
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;
namespace AtCoder {
public class Program {
static public long[] Sarray() {
return ReadLine().Split().Select(long.Parse).ToArray();
}
static public List<long> Slist() {
return ReadLine().Split().Select(long.Parse).ToList();
}
static public (T1 a, T2 b) Slice<T1, T2>() {
var t = ReadLine().Split();
return ((T1)Convert.ChangeType(t[0], typeof(T1)),
(T2)Convert.ChangeType(t[1], typeof(T2)));
}
static long Mod = (long)1e9 + 7;
public static void Main(string[] args) {
// SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
Solve();
// Out.Flush();
Read();
}
static void Solve() {
var dct = new Dictionary<char, string>();
dct['a'] = ReadLine();
dct['b'] = ReadLine();
dct['c'] = ReadLine();
var n = 'a';
while (true) {
if (string.IsNullOrEmpty(dct[n])) {
WriteLine((char)(n + 'A' - 'a'));
return;
}
var nn = dct[n][0];
dct[n] = dct[n].Remove(0, 1);
n = nn;
}
}
}
}
|
[["-", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 12, 22]]
| 8
| 341
| 7
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;
class Program {
public static void Main() {
var n = new string[3];
for (int i = 0; i < 3; i++) {
n[i] = ReadLine();
}
int index = 0;
while (n[index] != "") {
int next = n[index][0] - 'a';
n[index] = n[index].Substring(1, n[index].Length - 1);
index = next;
}
WriteLine($"{(char)(index + 'a')}");
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;
class Program {
public static void Main() {
var n = new string[3];
for (int i = 0; i < 3; i++) {
n[i] = ReadLine();
}
int index = 0;
while (n[index] != "") {
int next = n[index][0] - 'a';
n[index] = n[index].Substring(1, n[index].Length - 1);
index = next;
}
WriteLine($"{(char)(index + 'A')}");
}
}
|
[["-", 0, 74, 51, 23, 0, 16, 12, 252, 0, 253], ["+", 0, 74, 51, 23, 0, 16, 12, 252, 0, 253]]
| 8
| 162
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main(string[] args) {
string sa = Console.ReadLine();
string sb = Console.ReadLine();
string sc = Console.ReadLine();
int countA = 0;
int countB = 0;
int countC = 0;
char answer = 'a';
bool endFlg = false;
string endAns = null;
while (endFlg) {
if (answer == 'a') {
if (countA >= sa.Count()) {
endFlg = true;
endAns = "A";
break;
}
answer = sa[countA];
countA++;
} else if (answer == 'b') {
if (countB >= sb.Count()) {
endFlg = true;
endAns = "B";
break;
}
answer = sb[countB];
countB++;
} else if (answer == 'c') {
if (countC >= sc.Count()) {
endFlg = true;
endAns = "C";
break;
}
answer = sc[countC];
countC++;
}
}
Console.Write(endAns);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main(string[] args) {
string sa = Console.ReadLine();
string sb = Console.ReadLine();
string sc = Console.ReadLine();
int countA = 0;
int countB = 0;
int countC = 0;
char answer = 'a';
bool endFlg = false;
string endAns = "A";
while (!endFlg) {
if (answer == 'a') {
if (countA >= sa.Count()) {
endFlg = true;
endAns = "A";
break;
}
answer = sa[countA];
countA++;
} else if (answer == 'b') {
if (countB >= sb.Count()) {
endFlg = true;
endAns = "B";
break;
}
answer = sb[countB];
countB++;
} else if (answer == 'c') {
if (countC >= sc.Count()) {
endFlg = true;
endAns = "C";
break;
}
answer = sc[countC];
countC++;
}
}
Console.Write(endAns);
}
}
|
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 215], ["+", 0, 198, 0, 200, 0, 212, 0, 5, 0, 62], ["+", 0, 198, 0, 200, 0, 212, 0, 5, 0, 222], ["+", 0, 195, 8, 196, 0, 52, 15, 241, 0, 111]]
| 8
| 248
| 5
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp7 {
class Program {
static void Main(string[] args) {
string A = Console.ReadLine();
string B = Console.ReadLine();
string C = Console.ReadLine();
int countA = 0; //
int countB = -1;
int countC = -1;
var flagA = true;
var flagB = false;
var flagC = false;
while (A.Length > countA && B.Length > countB && C.Length > countC) {
if (flagA == true) {
flagA = false;
if (A[countA] == 'a') {
countA++;
flagA = true;
} else if (A[countA] == 'b') {
countB++;
flagB = true;
} else if (A[countA] == 'c') {
countC++;
flagC = true;
}
} else if (flagB == true) {
flagB = false;
if (B[countB] == 'a') {
countA++;
flagA = true;
} else if (B[countB] == 'b') {
countB++;
flagB = true;
} else if (B[countB] == 'c') {
countC++;
flagC = true;
}
} else if (flagC == true) {
flagC = false;
if (C[countC] == 'a') {
countA++;
flagA = true;
} else if (C[countC] == 'b') {
countB++;
flagB = true;
} else if (C[countC] == 'c') {
countC++;
flagC = true;
}
}
}
if (flagA == true) {
Console.WriteLine('a');
} else if (flagB == true) {
Console.WriteLine('b');
} else {
Console.WriteLine('c');
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp7 {
class Program {
static void Main(string[] args) {
string A = Console.ReadLine();
string B = Console.ReadLine();
string C = Console.ReadLine();
int countA = 0; //
int countB = -1;
int countC = -1;
var flagA = true;
var flagB = false;
var flagC = false;
while (A.Length > countA && B.Length > countB && C.Length > countC) {
if (flagA == true) {
flagA = false;
if (A[countA] == 'a') {
countA++;
flagA = true;
} else if (A[countA] == 'b') {
countB++;
flagB = true;
} else if (A[countA] == 'c') {
countC++;
flagC = true;
}
} else if (flagB == true) {
flagB = false;
if (B[countB] == 'a') {
countA++;
flagA = true;
} else if (B[countB] == 'b') {
countB++;
flagB = true;
} else if (B[countB] == 'c') {
countC++;
flagC = true;
}
} else if (flagC == true) {
flagC = false;
if (C[countC] == 'a') {
countA++;
flagA = true;
} else if (C[countC] == 'b') {
countB++;
flagB = true;
} else if (C[countC] == 'c') {
countC++;
flagC = true;
}
}
}
if (flagA == true) {
Console.WriteLine('A');
} else if (flagB == true) {
Console.WriteLine('B');
} else {
Console.WriteLine('C');
}
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 252, 0, 253], ["+", 0, 213, 3, 4, 0, 28, 0, 252, 0, 253]]
| 8
| 399
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atcoder {
class ABC045B {
static void Main() {
List<Queue<int>> qs = new List<Queue<int>>();
for (int i = 0; i < 3; i++) {
List<int> buff = Console.ReadLine().Select(x => x - 'a').ToList();
Queue<int> q = new Queue<int>();
foreach (int n in buff) {
q.Enqueue(n);
}
qs.Add(q);
}
int num = 0;
while (qs[num].Count() != 0) {
num = qs[num].Dequeue();
}
Console.WriteLine((char)(num + 'a'));
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atcoder {
class ABC045B {
static void Main() {
List<Queue<int>> qs = new List<Queue<int>>();
for (int i = 0; i < 3; i++) {
List<int> buff = Console.ReadLine().Select(x => x - 'a').ToList();
Queue<int> q = new Queue<int>();
foreach (int n in buff) {
q.Enqueue(n);
}
qs.Add(q);
}
int num = 0;
while (qs[num].Count() != 0) {
num = qs[num].Dequeue();
}
Console.WriteLine((char)(num + 'A'));
}
}
}
|
[["-", 0, 74, 51, 23, 0, 16, 12, 252, 0, 253], ["+", 0, 74, 51, 23, 0, 16, 12, 252, 0, 253]]
| 8
| 189
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
List<char> ah = cin.next().ToCharArray().ToList();
List<char> bh = cin.next().ToCharArray().ToList();
List<char> ch = cin.next().ToCharArray().ToList();
List<char>[] hands = new List<char>[] { ah, bh, ch };
int turn = 0;
while (hands[turn].Count > 0) {
turn = hands[turn].First() - 'a';
hands[turn].RemoveAt(0);
}
Console.WriteLine((char)(turn + 'A'));
}
}
public class cin {
private static string[] s = new string[0];
private static int i = 0;
private static char[] cs = new char[] { ' ' };
public static 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 static int ni() { return int.Parse(next()); }
public static long nextLong() { return long.Parse(next()); }
public static double nextDouble() { return double.Parse(next()); }
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
List<char> ah = cin.next().ToCharArray().ToList();
List<char> bh = cin.next().ToCharArray().ToList();
List<char> ch = cin.next().ToCharArray().ToList();
List<char>[] hands = new List<char>[] { ah, bh, ch };
int turn = 0;
while (hands[turn].Count > 0) {
int tmpTurn = hands[turn].First() - 'a';
hands[turn].RemoveAt(0);
turn = tmpTurn;
}
Console.WriteLine((char)(turn + 'A'));
}
}
public class cin {
private static string[] s = new string[0];
private static int i = 0;
private static char[] cs = new char[] { ' ' };
public static 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 static int ni() { return int.Parse(next()); }
public static long nextLong() { return long.Parse(next()); }
public static double nextDouble() { return double.Parse(next()); }
}
|
[["-", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 12, 22]]
| 8
| 337
| 7
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class AtCoderA {
static void Main() {
var sc = new Scanner();
string s = sc.Next();
int length = s.Length;
int[] nums = new int[length];
for (int i = 0; i < length; i++) {
nums[i] = int.Parse(s[i].ToString());
}
long answer = 0;
for (int i = 0; i < Math.Pow(2, length - 1); i++) {
long sum = 0;
long current = nums[0];
for (int j = 0; j < length - 1; j++) {
if ((1 & (i >> j)) == 1) {
sum += current;
current = nums[j + 1];
} else {
current *= 10;
current += nums[j + 1];
}
if (j == length - 2) {
sum += current;
}
}
answer += sum;
}
if (length == 0) {
answer = nums[0];
}
Console.WriteLine(answer);
}
class Scanner {
private string[] _line;
private int _index;
private const char Separator = ' ';
public Scanner() {
_line = new string[0];
_index = 0;
}
public string Next() {
while (_index >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_index = 0;
}
return _line[_index++];
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
public decimal NextDecimal() => decimal.Parse(Next());
public char NextChar() => Next()[0];
public char[] NextCharArray() => Next().ToCharArray();
public string[] Array() {
_line = Console.ReadLine().Split(Separator);
_index = _line.Length;
return _line;
}
public int[] IntArray() => Array().Select(int.Parse).ToArray();
public long[] LongArray() => Array().Select(long.Parse).ToArray();
public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class AtCoderA {
static void Main() {
var sc = new Scanner();
string s = sc.Next();
int length = s.Length;
int[] nums = new int[length];
for (int i = 0; i < length; i++) {
nums[i] = int.Parse(s[i].ToString());
}
long answer = 0;
for (int i = 0; i < Math.Pow(2, length - 1); i++) {
long sum = 0;
long current = nums[0];
for (int j = 0; j < length - 1; j++) {
if ((1 & (i >> j)) == 1) {
sum += current;
current = nums[j + 1];
} else {
current *= 10;
current += nums[j + 1];
}
if (j == length - 2) {
sum += current;
}
}
answer += sum;
}
if (length == 1) {
answer = nums[0];
}
Console.WriteLine(answer);
}
class Scanner {
private string[] _line;
private int _index;
private const char Separator = ' ';
public Scanner() {
_line = new string[0];
_index = 0;
}
public string Next() {
while (_index >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_index = 0;
}
return _line[_index++];
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
public decimal NextDecimal() => decimal.Parse(Next());
public char NextChar() => Next()[0];
public char[] NextCharArray() => Next().ToCharArray();
public string[] Array() {
_line = Console.ReadLine().Split(Separator);
_index = _line.Length;
return _line;
}
public int[] IntArray() => Array().Select(int.Parse).ToArray();
public long[] LongArray() => Array().Select(long.Parse).ToArray();
public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
}
}
|
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203]]
| 8
| 542
| 2
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Program {
static int[] L;
static void Main(string[] args) {
var input = Console.ReadLine();
string[] S = new string[input.Length];
for (int i = 0; i < input.Length; i++) {
S[i] = input[i].ToString();
}
Console.WriteLine(LowerBound(S));
}
public static long LowerBound(string[] S) {
var N = S.Length;
var res = 0L;
for (int i = 0; i < Math.Pow(2, N - 1); i++) {
var numst = S[0];
for (int j = 1; j < N; j++) {
int bit = (int)Math.Pow(2, j - 1);
if ((i & bit) != 0) {
res += int.Parse(numst);
numst = S[j];
} else {
numst = String.Concat(numst, S[j]);
}
}
res += int.Parse(numst);
}
return res;
}
}
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Program {
static int[] L;
static void Main(string[] args) {
var input = Console.ReadLine();
string[] S = new string[input.Length];
for (int i = 0; i < input.Length; i++) {
S[i] = input[i].ToString();
}
Console.WriteLine(LowerBound(S));
}
public static long LowerBound(string[] S) {
var N = S.Length;
var res = 0L;
for (int i = 0; i < Math.Pow(2, N - 1); i++) {
var numst = S[0];
for (int j = 1; j < N; j++) {
int bit = (int)Math.Pow(2, j - 1);
if ((i & bit) != 0) {
res += int.Parse(numst);
numst = S[j];
} else {
numst = String.Concat(numst, S[j]);
}
}
res += long.Parse(numst);
}
return res;
}
}
|
[["-", 0, 1, 0, 11, 12, 213, 63, 214, 205, 199], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 205, 199]]
| 8
| 253
| 2
|
using System;
using static System.Console;
using static cp;
using System.Text;
using System.Linq;
using static System.Math;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
class Program {
static void Main(string[] args) {
var alg = new cp();
var s = alg.inputString();
int total = 0;
for (int a = 0; a < (1 << (s.Length - 1)); a++) {
var list = new List<string>();
list.Add(s[0].ToString());
for (int b = 0; b < s.Length - 1; b++) {
if ((a & (1 << b)) != 0) {
list.Add("");
}
list[list.Count - 1] += s[b + 1].ToString();
}
total += list.Sum(i => int.Parse(i));
}
WriteLine(total);
}
}
class cp {
public cp() {}
public int GCD(int a, int b) { return a % b == 0 ? b : GCD(b, a % b); }
public int LCM(int a, int b) { return a * b / GCD(a, b); }
public int countChar(string s, string key) {
return s.Length - s.Replace(key, "").Length;
}
public string YesNo(bool f, string type = null) {
string str;
if (f)
str = "Yes";
else
str = "No";
if (type == "lower")
return str.ToLower();
else if (type == "upper")
return str.ToUpper();
else
return str;
}
public void inputSkip() {
ReadLine();
return;
}
public string inputString() { return ReadLine(); }
public string[] inputSplitString() { return ReadLine().Split(); }
public string[] inputLinesString(int len) {
var arr = new string[len];
for (int a = 0; a < len; a++) {
arr[a] = ReadLine();
}
return arr;
}
public string[][] inputJaggedArrayString(int len) {
var arr = new string[len][];
for (int a = 0; a < len; a++) {
arr[a] = ReadLine().Split();
}
return arr;
}
public int inputInt() { return int.Parse(ReadLine()); }
public int[] inputSplitInt() {
return ReadLine().Split().Select(i => int.Parse(i)).ToArray();
}
public int[] inputLinesInt(int len) {
var arr = new int[len];
for (int a = 0; a < len; a++) {
arr[a] = int.Parse(ReadLine());
}
return arr;
}
public int[][] inputJaggedArrayInt(int len) {
var arr = new int [len][];
for (int a = 0; a < len; a++) {
arr[a] = ReadLine().Split().Select(i => int.Parse(i)).ToArray();
}
return arr;
}
public long inputLong() { return long.Parse(ReadLine()); }
public long[] inputSplitLong() {
return ReadLine().Split().Select(i => long.Parse(i)).ToArray();
}
public long[] inputLinesLong(int len) {
var arr = new long[len];
for (int a = 0; a < len; a++) {
arr[a] = long.Parse(ReadLine());
}
return arr;
}
public long[][] inputJaggedArrayLong(int len) {
var arr = new long [len][];
for (int a = 0; a < len; a++) {
arr[a] = ReadLine().Split().Select(i => long.Parse(i)).ToArray();
}
return arr;
}
public double inputDouble() { return double.Parse(ReadLine()); }
public double[] inputSplitDouble() {
return ReadLine().Split().Select(i => double.Parse(i)).ToArray();
}
public double[] inputLinesDouble(int len) {
var arr = new double[len];
for (int a = 0; a < len; a++) {
arr[a] = double.Parse(ReadLine());
}
return arr;
}
public double[][] inputJaggedArrayDouble(int len) {
var arr = new double [len][];
for (int a = 0; a < len; a++) {
arr[a] = ReadLine().Split().Select(i => double.Parse(i)).ToArray();
}
return arr;
}
}
|
using System;
using static System.Console;
using static cp;
using System.Text;
using System.Linq;
using static System.Math;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
class Program {
static void Main(string[] args) {
var alg = new cp();
var s = alg.inputString();
long total = 0;
for (long a = 0; a < (1 << (s.Length - 1)); a++) {
var list = new List<string>();
list.Add(s[0].ToString());
for (int b = 0; b < s.Length - 1; b++) {
if ((a & (1 << b)) != 0) {
list.Add("");
}
list[list.Count - 1] += s[b + 1].ToString();
}
total += list.Sum(i => long.Parse(i));
}
WriteLine(total);
}
}
class cp {
public cp() {}
public int GCD(int a, int b) { return a % b == 0 ? b : GCD(b, a % b); }
public int LCM(int a, int b) { return a * b / GCD(a, b); }
public int countChar(string s, string key) {
return s.Length - s.Replace(key, "").Length;
}
public string YesNo(bool f, string type = null) {
string str;
if (f)
str = "Yes";
else
str = "No";
if (type == "lower")
return str.ToLower();
else if (type == "upper")
return str.ToUpper();
else
return str;
}
public void inputSkip() {
ReadLine();
return;
}
public string inputString() { return ReadLine(); }
public string[] inputSplitString() { return ReadLine().Split(); }
public string[] inputLinesString(int len) {
var arr = new string[len];
for (int a = 0; a < len; a++) {
arr[a] = ReadLine();
}
return arr;
}
public string[][] inputJaggedArrayString(int len) {
var arr = new string[len][];
for (int a = 0; a < len; a++) {
arr[a] = ReadLine().Split();
}
return arr;
}
public int inputInt() { return int.Parse(ReadLine()); }
public int[] inputSplitInt() {
return ReadLine().Split().Select(i => int.Parse(i)).ToArray();
}
public int[] inputLinesInt(int len) {
var arr = new int[len];
for (int a = 0; a < len; a++) {
arr[a] = int.Parse(ReadLine());
}
return arr;
}
public int[][] inputJaggedArrayInt(int len) {
var arr = new int [len][];
for (int a = 0; a < len; a++) {
arr[a] = ReadLine().Split().Select(i => int.Parse(i)).ToArray();
}
return arr;
}
public long inputLong() { return long.Parse(ReadLine()); }
public long[] inputSplitLong() {
return ReadLine().Split().Select(i => long.Parse(i)).ToArray();
}
public long[] inputLinesLong(int len) {
var arr = new long[len];
for (int a = 0; a < len; a++) {
arr[a] = long.Parse(ReadLine());
}
return arr;
}
public long[][] inputJaggedArrayLong(int len) {
var arr = new long [len][];
for (int a = 0; a < len; a++) {
arr[a] = ReadLine().Split().Select(i => long.Parse(i)).ToArray();
}
return arr;
}
public double inputDouble() { return double.Parse(ReadLine()); }
public double[] inputSplitDouble() {
return ReadLine().Split().Select(i => double.Parse(i)).ToArray();
}
public double[] inputLinesDouble(int len) {
var arr = new double[len];
for (int a = 0; a < len; a++) {
arr[a] = double.Parse(ReadLine());
}
return arr;
}
public double[][] inputJaggedArrayDouble(int len) {
var arr = new double [len][];
for (int a = 0; a < len; a++) {
arr[a] = ReadLine().Split().Select(i => double.Parse(i)).ToArray();
}
return arr;
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["-", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["+", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199]]
| 8
| 1,063
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
class Program {
public void Slove() {
var inputs = Console.ReadLine().Split();
int height = int.Parse(inputs[0]);
int width = int.Parse(inputs[1]);
int n = int.Parse(inputs[2]);
Dictionary<long, int> blackCount = new Dictionary<long, int>();
foreach (var i in Enumerable.Range(0, n)) {
inputs = Console.ReadLine().Split();
int row = int.Parse(inputs[0]) - 1;
int column = int.Parse(inputs[1]) - 1;
foreach (int my in Enumerable.Range(-1, 3)
.Select(x => x + row)
.Where(x => x > 0 && x < height - 1))
foreach (int mx in Enumerable.Range(-1, 3)
.Select(x => x + column)
.Where(x => x > 0 && x < width - 1)) {
long key = (my)*width + mx;
if (blackCount.ContainsKey(key))
blackCount[key]++;
else {
blackCount.Add(key, 1);
}
}
}
long[] hist = new long[9];
foreach (int count in blackCount.Values) {
hist[count]++;
}
hist[0] = (long)(height - 2) * (width - 2) - hist.Sum();
Console.WriteLine(string.Join("\n", hist));
}
static void Main(string[] args) { new Program().Slove(); }
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
class Program {
public void Slove() {
var inputs = Console.ReadLine().Split();
int height = int.Parse(inputs[0]);
int width = int.Parse(inputs[1]);
int n = int.Parse(inputs[2]);
Dictionary<long, int> blackCount = new Dictionary<long, int>();
foreach (var i in Enumerable.Range(0, n)) {
inputs = Console.ReadLine().Split();
int row = int.Parse(inputs[0]) - 1;
int column = int.Parse(inputs[1]) - 1;
foreach (int my in Enumerable.Range(-1, 3)
.Select(x => x + row)
.Where(x => x > 0 && x < height - 1))
foreach (int mx in Enumerable.Range(-1, 3)
.Select(x => x + column)
.Where(x => x > 0 && x < width - 1)) {
long key = (long)(my)*width + mx;
if (blackCount.ContainsKey(key))
blackCount[key]++;
else {
blackCount.Add(key, 1);
}
}
}
long[] hist = new long[10];
foreach (int count in blackCount.Values) {
hist[count]++;
}
hist[0] = (long)(height - 2) * (width - 2) - hist.Sum();
Console.WriteLine(string.Join("\n", hist));
}
static void Main(string[] args) { new Program().Slove(); }
}
|
[["+", 0, 212, 0, 16, 31, 16, 31, 74, 39, 199], ["+", 0, 212, 0, 16, 31, 16, 31, 74, 0, 25], ["+", 0, 16, 31, 16, 31, 74, 51, 23, 0, 24], ["-", 0, 212, 0, 227, 39, 224, 225, 226, 0, 203], ["+", 0, 212, 0, 227, 39, 224, 225, 226, 0, 203]]
| 8
| 367
| 5
|
using System;
namespace test {
class Program {
static void Main(string[] args) {
string input = "9999999999"; // Console.ReadLine();
Console.WriteLine(SumAll(input, 0));
}
static string[] SplitByIndex(string str, int i) {
string[] res = new string[2];
res[0] = str.Substring(0, i);
res[1] = str.Substring(i, str.Length - i);
return res;
}
static long SumAll(string str, long begin) {
long res = 0;
if (str.Length == 1) {
return begin + long.Parse(str);
} else {
res += begin + long.Parse(str);
for (int i = 1; i < str.Length; i++) {
string[] parts = SplitByIndex(str, i);
int a = int.Parse(parts[0]);
res += SumAll(parts[1], a + begin);
}
return res;
}
}
}
}
|
using System;
namespace test {
class Program {
static void Main(string[] args) {
string input = Console.ReadLine();
Console.WriteLine(SumAll(input, 0));
}
static string[] SplitByIndex(string str, int i) {
string[] res = new string[2];
res[0] = str.Substring(0, i);
res[1] = str.Substring(i, str.Length - i);
return res;
}
static long SumAll(string str, long begin) {
long res = 0;
if (str.Length == 1) {
return begin + long.Parse(str);
} else {
res += begin + long.Parse(str);
for (int i = 1; i < str.Length; i++) {
string[] parts = SplitByIndex(str, i);
int a = int.Parse(parts[0]);
res += SumAll(parts[1], a + begin);
}
return res;
}
}
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 5, 0, 62], ["-", 0, 198, 0, 200, 0, 212, 0, 5, 0, 222], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25]]
| 8
| 213
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp38 {
class Program {
static void Main(string[] args) {
string S = Console.ReadLine();
int l = S.Length; //文字数
long ans = 0;
for (int s = 0; s < (1 << (l - 1)); s++) {
string now = "";
now += S[0];
for (int i = 0; i < (l - 1); i++) {
//上からi桁目のビットが立っているかどうか
if ((s & (1 << ((l - 1) - i - 1))) != 0) {
now += "+";
}
now += S[i + 1];
}
//文字列を解釈する
var num = now.Split('+').Select(x => int.Parse(x)).ToArray();
ans += num.Sum();
}
Console.WriteLine(ans);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp38 {
class Program {
static void Main(string[] args) {
string S = Console.ReadLine();
int l = S.Length; //文字数
long ans = 0;
for (int s = 0; s < (1 << (l - 1)); s++) {
string now = "";
now += S[0];
for (int i = 0; i < (l - 1); i++) {
//上からi桁目のビットが立っているかどうか
if ((s & (1 << ((l - 1) - i - 1))) != 0) {
now += "+";
}
now += S[i + 1];
}
// Console.WriteLine(now);
//文字列を解釈する
var num = now.Split('+').Select(x => long.Parse(x)).ToArray();
ans += num.Sum();
}
Console.WriteLine(ans);
}
}
}
|
[["-", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["+", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199]]
| 8
| 211
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCorder {
class Program {
static void Main(string[] args) {
// ARC061A
var S = Console.ReadLine();
var k = S.Count() - 1;
int a = 0;
for (int i = 0; i < (1 << k); i++) {
int s = int.Parse(S[0].ToString());
for (int j = 0; j < k; j++) {
// 前からjからjけた目の右側にプラスにが存在するかどうかを論理積とって判断する。
if ((i & (1 << j)) != 0) {
a += s;
s = 0;
}
// +
// が存在しない場合は数字を積み上げるので10倍し、合計に足さないで保持して次のけたの数字と連結
// ↑で+されている場合は0なので単純に次けたの数値を取得しているだけ。
s = ((s * 10) + (int.Parse(S[j + 1].ToString())));
}
a += s;
}
Console.WriteLine(a);
Console.ReadKey();
}
#region MyRegion
public static int ReadInt() { return int.Parse(Console.ReadLine()); }
/// <summary>
/// 空白区切の数値を取得する
/// </summary>
/// <returns>The read split int.</returns>
public static int[] ReadSplitInt() {
return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
}
/// <summary>
/// 空白区切の数値を取得
/// </summary>
/// <returns>The read split long.</returns>
public static long[] ReadSplitLong() {
return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
}
public static int[][] ReadSplitIntLines(int n) {
return Enumerable.Range(0, n).Select(x => ReadSplitInt()).ToArray();
}
public static long[][] ReadSplitLongLines(int n) {
return Enumerable.Range(0, n).Select(x => ReadSplitLong()).ToArray();
}
public static long[][] ReadSplitLongLines(long n) {
var ret = new List<long[]>();
for (long i = 0; i < n; i++) {
ret.Add(ReadSplitLong().ToArray());
}
return ret.ToArray();
}
#endregion
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCorder {
class Program {
static void Main(string[] args) {
// ARC061A
var S = Console.ReadLine();
var k = S.Count() - 1;
long a = 0;
for (int i = 0; i < (1 << k); i++) {
var s = long.Parse(S[0].ToString());
for (int j = 0; j < k; j++) {
// 前からjからjけた目の右側にプラスにが存在するかどうかを論理積とって判断する。
if ((i & (1 << j)) != 0) {
a += s;
s = 0;
}
// +
// が存在しない場合は数字を積み上げるので10倍し、合計に足さないで保持して次のけたの数字と連結
// ↑で+されている場合は0なので単純に次けたの数値を取得しているだけ。
s = ((s * 10) + (long.Parse(S[j + 1].ToString())));
}
a += s;
}
Console.WriteLine(a);
Console.ReadKey();
}
#region MyRegion
public static int ReadInt() { return int.Parse(Console.ReadLine()); }
/// <summary>
/// 空白区切の数値を取得する
/// </summary>
/// <returns>The read split int.</returns>
public static int[] ReadSplitInt() {
return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
}
/// <summary>
/// 空白区切の数値を取得
/// </summary>
/// <returns>The read split long.</returns>
public static long[] ReadSplitLong() {
return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
}
public static int[][] ReadSplitIntLines(int n) {
return Enumerable.Range(0, n).Select(x => ReadSplitInt()).ToArray();
}
public static long[][] ReadSplitLongLines(int n) {
return Enumerable.Range(0, n).Select(x => ReadSplitLong()).ToArray();
}
public static long[][] ReadSplitLongLines(long n) {
var ret = new List<long[]>();
for (long i = 0; i < n; i++) {
ret.Add(ReadSplitLong().ToArray());
}
return ret.ToArray();
}
#endregion
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["-", 0, 16, 12, 23, 0, 213, 63, 214, 205, 199], ["+", 0, 16, 12, 23, 0, 213, 63, 214, 205, 199]]
| 8
| 448
| 8
|
using System;
using System.Collections;
using System.Linq;
public class Test {
public static int n = 0;
public static int ans = 0;
public static string str = "";
public static void Main() {
str = Console.ReadLine();
string s = "";
bit(s);
Console.WriteLine(ans);
}
public static void bit(string s) {
if (s.Length == str.Length - 1) {
calc(s);
} else {
bit(s + "0");
bit(s + "1");
}
}
public static void calc(string s) {
string ss = "";
char[] nums = str.ToCharArray();
char[] c = s.ToCharArray();
ss += nums[0].ToString();
for (int i = 0; i < c.Length; i++) {
if (c[i] == '1') {
ans += int.Parse(ss);
ss = "";
}
ss += nums[i + 1].ToString();
}
ans += int.Parse(ss);
}
}
|
using System;
using System.Collections;
using System.Linq;
public class Test {
public static long n = 0;
public static long ans = 0;
public static string str = "";
public static void Main() {
str = Console.ReadLine();
string s = "";
bit(s);
Console.WriteLine(ans);
}
public static void bit(string s) {
if (s.Length == str.Length - 1) {
calc(s);
} else {
bit(s + "0");
bit(s + "1");
}
}
public static void calc(string s) {
string ss = "";
char[] nums = str.ToCharArray();
char[] c = s.ToCharArray();
ss += nums[0].ToString();
for (int i = 0; i < c.Length; i++) {
if (c[i] == '1') {
ans += long.Parse(ss);
ss = "";
}
ss += nums[i + 1].ToString();
}
ans += long.Parse(ss);
}
}
|
[["-", 0, 235, 8, 201, 0, 124, 0, 198, 39, 199], ["+", 0, 235, 8, 201, 0, 124, 0, 198, 39, 199], ["-", 0, 1, 0, 11, 12, 213, 63, 214, 205, 199], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 205, 199]]
| 8
| 240
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) { C(); }
static void C() {
var S = ReadLong();
var sum = 0;
for (int i = 0; i < Math.Pow(2, S.ToString().Length - 1); i++) {
var sList = S.ToString().ToList();
var k = 1;
for (int j = 0; j < S.ToString().Length - 1; j++) {
if ((i >> j & 1) == 1) {
sList.Insert(j + k, '+');
k++;
}
}
sum += Join(sList).Split('+').Select(int.Parse).Sum();
}
Println(sum);
}
static IEnumerable<int> Range(int start, int stop) {
if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
return new List<int>();
return Enumerable.Range(start, stop - start);
}
static bool IsDigit(string str) {
var i = 0;
return int.TryParse(str, out i);
}
static int DigitsSum(long num) {
return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
}
static int[] ToIntArray(string str) {
return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
}
static string Read() => Console.ReadLine();
static int ReadInt() => int.Parse(Read());
static long ReadLong() => long.Parse(Read());
static List<string> ReadSplit() => Read().Split().ToList();
static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
static void Print(object value) => Console.Write(value.ToString());
static void Println(object value) => Console.WriteLine(value.ToString());
static string Join<T>(IEnumerable<T> list) => string.Join("", list);
}
public static class MyExtensions {
public static string Slice(this string str, int start = 0, int stop = 0) {
if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
return "";
if (stop == 0)
stop = str.Length;
return str.Substring(start, stop - start);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) { C(); }
static void C() {
var S = ReadLong();
long sum = 0;
for (long i = 0; i < Math.Pow(2, S.ToString().Length - 1); i++) {
var sList = S.ToString().ToList();
var k = 1;
for (int j = 0; j < S.ToString().Length - 1; j++) {
if ((i >> j & 1) == 1) {
sList.Insert(j + k, '+');
k++;
}
}
sum += Join(sList).Split('+').Select(long.Parse).Sum();
}
Println(sum);
}
static IEnumerable<int> Range(int start, int stop) {
if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
return new List<int>();
return Enumerable.Range(start, stop - start);
}
static bool IsDigit(string str) {
var i = 0;
return int.TryParse(str, out i);
}
static int DigitsSum(long num) {
return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
}
static int[] ToIntArray(string str) {
return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
}
static string Read() => Console.ReadLine();
static int ReadInt() => int.Parse(Read());
static long ReadLong() => long.Parse(Read());
static List<string> ReadSplit() => Read().Split().ToList();
static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
static void Print(object value) => Console.Write(value.ToString());
static void Println(object value) => Console.WriteLine(value.ToString());
static string Join<T>(IEnumerable<T> list) => string.Join("", list);
}
public static class MyExtensions {
public static string Slice(this string str, int start = 0, int stop = 0) {
if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
return "";
if (stop == 0)
stop = str.Length;
return str.Substring(start, stop - start);
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["-", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199]]
| 8
| 575
| 6
|
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using Enu = System.Linq.Enumerable;
public class Program {
static readonly long Big = (long)1e9;
public void Solve() {
int N = Reader.Int(), M = Reader.Int();
var E = new List<Edge>[N * 3];
for (int i = 0; i < E.Length; i++)
E[i] = new List<Edge>();
var dic = new Dictionary<long, int>();
int numNodes = N;
Func<int, int, int> ColorNode = (at, color) => {
long key = (long)at * Big + color;
if (dic.ContainsKey(key))
return dic[key];
return dic[key] = numNodes++;
};
Action<int, int, int> AddEdge = (a, b, c) => {
E[a].Add(new Edge(b, c));
E[b].Add(new Edge(a, c));
};
for (int i = 0; i < M; i++) {
int a = Reader.Int() - 1, b = Reader.Int() - 1, c = Reader.Int();
int a2 = ColorNode(a, c);
int b2 = ColorNode(b, c);
AddEdge(a, a2, 1);
AddEdge(b, b2, 1);
AddEdge(a2, b2, 0);
}
var cost = ShortestPath(0, E);
Console.WriteLine((cost[N - 1] == INF) ? -1 : cost[N - 1] / 2);
}
static readonly int INF = (int)1e9;
int[] ShortestPath(int start, List<Edge>[] E) {
int N = E.Length;
bool[] inQue = new bool[N];
var que = new Queue<int>();
que.Enqueue(start);
var minCost = new int[N];
for (int i = 0; i < N; i++)
minCost[i] = INF;
minCost[start] = 0;
while (que.Count > 0) {
int v = que.Dequeue();
inQue[v] = false;
foreach (var e in E[v])
if (minCost[v] + e.cost < minCost[e.to]) {
minCost[e.to] = minCost[v] + e.cost;
if (!inQue[e.to]) {
inQue[e.to] = true;
que.Enqueue(e.to);
}
}
}
return minCost;
}
struct Edge {
public int to;
public int cost;
public Edge(int to, int cost) {
this.to = to;
this.cost = cost;
}
public override string ToString() { return "to:" + to + " cost:" + cost; }
}
}
class Entry {
static void Main() { new Program().Solve(); }
}
class Reader {
static TextReader reader = Console.In;
static readonly char[] separator = { ' ' };
static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
static string[] A = new string[0];
static int i;
static void Init() { A = new string[0]; }
public static void Set(TextReader r) {
reader = r;
Init();
}
public static void Set(string file) {
reader = new StreamReader(file);
Init();
}
public static bool HasNext() { return CheckNext(); }
public static string String() { return Next(); }
public static int Int() { return int.Parse(Next()); }
public static long Long() { return long.Parse(Next()); }
public static double Double() { return double.Parse(Next()); }
public static int[] IntLine() {
return Array.ConvertAll(Split(Line()), int.Parse);
}
public static int[] IntArray(int N) { return Range(N, Int); }
public static int[][] IntTable(int H) { return Range(H, IntLine); }
public static string[] StringArray(int N) { return Range(N, Next); }
public static string[][] StringTable(int N) {
return Range(N, () => Split(Line()));
}
public static string Line() { return reader.ReadLine().Trim(); }
static string[] Split(string s) { return s.Split(separator, op); }
static T[] Range<T>(int N, Func<T> f) {
var r = new T[N];
for (int i = 0; i < N; r[i++] = f())
;
return r;
}
static string Next() {
CheckNext();
return A[i++];
}
static bool CheckNext() {
if (i < A.Length)
return true;
string line = reader.ReadLine();
if (line == null)
return false;
if (line == "")
return CheckNext();
A = Split(line);
i = 0;
return true;
}
}
|
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using Enu = System.Linq.Enumerable;
public class Program {
static readonly long Big = (long)1e9;
public void Solve() {
int N = Reader.Int(), M = Reader.Int();
var E = new List<Edge>[N + M * 2];
for (int i = 0; i < E.Length; i++)
E[i] = new List<Edge>();
var dic = new Dictionary<long, int>();
int numNodes = N;
Func<int, int, int> ColorNode = (at, color) => {
long key = (long)at * Big + color;
if (dic.ContainsKey(key))
return dic[key];
return dic[key] = numNodes++;
};
Action<int, int, int> AddEdge = (a, b, c) => {
E[a].Add(new Edge(b, c));
E[b].Add(new Edge(a, c));
};
for (int i = 0; i < M; i++) {
int a = Reader.Int() - 1, b = Reader.Int() - 1, c = Reader.Int();
int a2 = ColorNode(a, c);
int b2 = ColorNode(b, c);
AddEdge(a, a2, 1);
AddEdge(b, b2, 1);
AddEdge(a2, b2, 0);
}
var cost = ShortestPath(0, E);
Console.WriteLine((cost[N - 1] == INF) ? -1 : cost[N - 1] / 2);
}
static readonly int INF = (int)1e9;
int[] ShortestPath(int start, List<Edge>[] E) {
int N = E.Length;
bool[] inQue = new bool[N];
var que = new Queue<int>();
que.Enqueue(start);
var minCost = new int[N];
for (int i = 0; i < N; i++)
minCost[i] = INF;
minCost[start] = 0;
while (que.Count > 0) {
int v = que.Dequeue();
inQue[v] = false;
foreach (var e in E[v])
if (minCost[v] + e.cost < minCost[e.to]) {
minCost[e.to] = minCost[v] + e.cost;
if (!inQue[e.to]) {
inQue[e.to] = true;
que.Enqueue(e.to);
}
}
}
return minCost;
}
struct Edge {
public int to;
public int cost;
public Edge(int to, int cost) {
this.to = to;
this.cost = cost;
}
public override string ToString() { return "to:" + to + " cost:" + cost; }
}
}
class Entry {
static void Main() { new Program().Solve(); }
}
class Reader {
static TextReader reader = Console.In;
static readonly char[] separator = { ' ' };
static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
static string[] A = new string[0];
static int i;
static void Init() { A = new string[0]; }
public static void Set(TextReader r) {
reader = r;
Init();
}
public static void Set(string file) {
reader = new StreamReader(file);
Init();
}
public static bool HasNext() { return CheckNext(); }
public static string String() { return Next(); }
public static int Int() { return int.Parse(Next()); }
public static long Long() { return long.Parse(Next()); }
public static double Double() { return double.Parse(Next()); }
public static int[] IntLine() {
return Array.ConvertAll(Split(Line()), int.Parse);
}
public static int[] IntArray(int N) { return Range(N, Int); }
public static int[][] IntTable(int H) { return Range(H, IntLine); }
public static string[] StringArray(int N) { return Range(N, Next); }
public static string[][] StringTable(int N) {
return Range(N, () => Split(Line()));
}
public static string Line() { return reader.ReadLine().Trim(); }
static string[] Split(string s) { return s.Split(separator, op); }
static T[] Range<T>(int N, Func<T> f) {
var r = new T[N];
for (int i = 0; i < N; r[i++] = f())
;
return r;
}
static string Next() {
CheckNext();
return A[i++];
}
static bool CheckNext() {
if (i < A.Length)
return true;
string line = reader.ReadLine();
if (line == null)
return false;
if (line == "")
return CheckNext();
A = Split(line);
i = 0;
return true;
}
}
|
[["+", 0, 227, 39, 224, 225, 226, 0, 16, 17, 72], ["+", 39, 224, 225, 226, 0, 16, 12, 16, 31, 22], ["-", 0, 227, 39, 224, 225, 226, 0, 16, 12, 203], ["+", 39, 224, 225, 226, 0, 16, 12, 16, 12, 203]]
| 8
| 1,144
| 4
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;
namespace Atcoder {
class Program {
static StreamWriter sw =
new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
static void Main(string[] args) {
try {
SetOut(sw);
Solve.Answer();
Out.Flush();
} catch (Exception ex) {
WriteLine(ex.ToString());
}
}
}
public class Solve {
public static void Answer() {
var abc = IO.RSInt;
if (abc.Where(x => x % 2 == 0).Count() >= 1)
WriteLine(0);
else {
Array.Sort(abc);
WriteLine(abc[0] * abc[1]);
}
}
}
public class IO {
#region Input
public static int RInt => int.Parse(ReadLine());
public static long RLong => long.Parse(ReadLine());
public static double RDouble => double.Parse(ReadLine());
public static string[] RSString => ReadLine().Split();
public static int[] RSInt =>
ReadLine().Split().Select(s => int.Parse(s)).ToArray();
public static long[] RSLong =>
ReadLine().Split().Select(s => long.Parse(s)).ToArray();
public static double[] RSDouble =>
ReadLine().Split().Select(s => double.Parse(s)).ToArray();
#endregion
#region Output
public static void
OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes"
: "No");
public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES"
: "NO");
#endregion
}
public class Mod {
#region
private readonly static long M = 1000000007;
public static long Add(long a, long b) => (a * b) % M;
public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M
: (a - b) % M + M;
public static long Multi(long a, long b) => (a * b) % M;
#endregion
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;
namespace Atcoder {
class Program {
static StreamWriter sw =
new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
static void Main(string[] args) {
try {
SetOut(sw);
Solve.Answer();
Out.Flush();
} catch (Exception ex) {
WriteLine(ex.ToString());
}
}
}
public class Solve {
public static void Answer() {
var abc = IO.RSLong;
if (abc.Where(x => x % 2 == 0).Count() >= 1)
WriteLine(0);
else {
Array.Sort(abc);
WriteLine(abc[0] * abc[1]);
}
}
}
public class IO {
#region Input
public static int RInt => int.Parse(ReadLine());
public static long RLong => long.Parse(ReadLine());
public static double RDouble => double.Parse(ReadLine());
public static string[] RSString => ReadLine().Split();
public static int[] RSInt =>
ReadLine().Split().Select(s => int.Parse(s)).ToArray();
public static long[] RSLong =>
ReadLine().Split().Select(s => long.Parse(s)).ToArray();
public static double[] RSDouble =>
ReadLine().Split().Select(s => double.Parse(s)).ToArray();
#endregion
#region Output
public static void
OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes"
: "No");
public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES"
: "NO");
#endregion
}
public class Mod {
#region
private readonly static long M = 1000000007;
public static long Add(long a, long b) => (a * b) % M;
public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M
: (a - b) % M + M;
public static long Multi(long a, long b) => (a * b) % M;
#endregion
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 214, 141, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 141, 22]]
| 8
| 520
| 2
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder {
partial class Program {
static long mod = 1000000007;
static void Swap<T>(ref T a, ref T b) {
T temp = a;
a = b;
b = temp;
}
static void Main() {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
Solve();
Console.Out.Flush();
Console.ReadKey();
}
//ここから
static void Solve() {
var A = GetLongArray();
var ans = A.All(a => a % 2 == 0)
? 0
: Math.Min(Math.Min(A[0] * A[1], A[0] * A[2]), A[1] * A[2]);
Console.WriteLine(ans);
}
}
//拡張メソッド
public static class Ex {
public static List<string> FastSort(this List<string> s) {
s.Sort(StringComparer.Ordinal);
return s.ToList();
}
public static string yesno(this bool b) { return b ? "yes" : "no"; }
public static string YesNo(this bool b) { return b ? "Yes" : "No"; }
public static string YESNO(this bool b) { return b ? "YES" : "NO"; }
}
partial class Program {
static public string GetStr() { return Console.ReadLine().Trim(); }
static public char GetChar() { return Console.ReadLine().Trim()[0]; }
static public int GetInt() { return int.Parse(Console.ReadLine().Trim()); }
static public long GetLong() { return long.Parse(Console.ReadLine().Trim()); }
static public double GetDouble() {
return double.Parse(Console.ReadLine().Trim());
}
static public string[] GetStrArray() {
return Console.ReadLine().Trim().Split(' ');
}
static public int[] GetIntArray() {
return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
}
static public long[] GetLongArray() {
return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
}
static public char[] GetCharArray() {
return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray();
}
static public double[] GetDoubleArray() {
return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();
}
static public T[][] CreateJaggedArray<T>(int H, int W, T value) {
return Enumerable.Repeat(0, H)
.Select(s => Enumerable.Repeat(value, W).ToArray())
.ToArray();
}
static public int[][] GetIntJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetIntArray().ToArray())
.ToArray();
}
static public long[][] GetLongJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetLongArray().ToArray())
.ToArray();
}
static public char[][] GetCharJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetStr().ToCharArray())
.ToArray();
}
static public double[][] GetDoubleJaggedArray(int N) {
return Enumerable.Repeat(0, N).Select(s => GetDoubleArray()).ToArray();
}
static public void WriteObjects<T>(IReadOnlyCollection<T> values) {
var array = values.ToArray();
var num = array.Length;
if (num == 0)
return;
Console.Write(array[0]);
for (int i = 1; i < num; i++) {
Console.Write(" " + array[i]);
}
Console.WriteLine();
}
static bool eq<T, U>() => typeof(T).Equals(typeof(U));
static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
: eq<T, long>() ? ct<T, long>(long.Parse(s))
: eq<T, double>() ? ct<T, double>(double.Parse(s))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
static void Multi<T>(out T a) => a = cv<T>(GetStr());
static void Multi<T, U>(out T a, out U b) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
static void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
static void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
}
static void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d,
out X e) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
}
static void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d,
out X e, out Y f) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
f = cv<Y>(ar[5]);
}
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder {
partial class Program {
static long mod = 1000000007;
static void Swap<T>(ref T a, ref T b) {
T temp = a;
a = b;
b = temp;
}
static void Main() {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
Solve();
Console.Out.Flush();
Console.ReadKey();
}
//ここから
static void Solve() {
var A = GetLongArray();
var ans = A.Any(a => a % 2 == 0)
? 0
: Math.Min(Math.Min(A[0] * A[1], A[0] * A[2]), A[1] * A[2]);
Console.WriteLine(ans);
}
}
//拡張メソッド
public static class Ex {
public static List<string> FastSort(this List<string> s) {
s.Sort(StringComparer.Ordinal);
return s.ToList();
}
public static string yesno(this bool b) { return b ? "yes" : "no"; }
public static string YesNo(this bool b) { return b ? "Yes" : "No"; }
public static string YESNO(this bool b) { return b ? "YES" : "NO"; }
}
partial class Program {
static public string GetStr() { return Console.ReadLine().Trim(); }
static public char GetChar() { return Console.ReadLine().Trim()[0]; }
static public int GetInt() { return int.Parse(Console.ReadLine().Trim()); }
static public long GetLong() { return long.Parse(Console.ReadLine().Trim()); }
static public double GetDouble() {
return double.Parse(Console.ReadLine().Trim());
}
static public string[] GetStrArray() {
return Console.ReadLine().Trim().Split(' ');
}
static public int[] GetIntArray() {
return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
}
static public long[] GetLongArray() {
return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
}
static public char[] GetCharArray() {
return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray();
}
static public double[] GetDoubleArray() {
return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();
}
static public T[][] CreateJaggedArray<T>(int H, int W, T value) {
return Enumerable.Repeat(0, H)
.Select(s => Enumerable.Repeat(value, W).ToArray())
.ToArray();
}
static public int[][] GetIntJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetIntArray().ToArray())
.ToArray();
}
static public long[][] GetLongJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetLongArray().ToArray())
.ToArray();
}
static public char[][] GetCharJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetStr().ToCharArray())
.ToArray();
}
static public double[][] GetDoubleJaggedArray(int N) {
return Enumerable.Repeat(0, N).Select(s => GetDoubleArray()).ToArray();
}
static public void WriteObjects<T>(IReadOnlyCollection<T> values) {
var array = values.ToArray();
var num = array.Length;
if (num == 0)
return;
Console.Write(array[0]);
for (int i = 1; i < num; i++) {
Console.Write(" " + array[i]);
}
Console.WriteLine();
}
static bool eq<T, U>() => typeof(T).Equals(typeof(U));
static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
: eq<T, long>() ? ct<T, long>(long.Parse(s))
: eq<T, double>() ? ct<T, double>(double.Parse(s))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
static void Multi<T>(out T a) => a = cv<T>(GetStr());
static void Multi<T, U>(out T a, out U b) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
static void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
static void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
}
static void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d,
out X e) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
}
static void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d,
out X e, out Y f) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
f = cv<Y>(ar[5]);
}
}
}
|
[["-", 0, 212, 0, 41, 15, 213, 63, 214, 141, 22], ["+", 0, 212, 0, 41, 15, 213, 63, 214, 141, 22]]
| 8
| 1,557
| 2
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace Algorithm {
class Program {
static void Main(string[] args) {
var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
int a = l[0], b = l[1], c = l[2];
if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
Console.WriteLine(0);
else
Console.WriteLine(Math.Min(Math.Min(a * b, b * c), a * c));
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace Algorithm {
class Program {
static void Main(string[] args) {
var l = Console.ReadLine().Split().Select(long.Parse).ToArray();
long a = l[0], b = l[1], c = l[2];
if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
Console.WriteLine(0);
else
Console.WriteLine(Math.Min(Math.Min(a * b, b * c), a * c));
}
}
}
|
[["-", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
| 8
| 135
| 4
|
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
namespace AtCoder {
class Practice {
static void Main() => CustomMain();
static void Solve() {
var a = ReadIntArray();
foreach (var num in a) {
if (IsEven(num)) {
WriteAnswer(0);
return;
}
}
Array.Sort(a);
long ans = a[0] * a[1];
WriteAnswer(ans);
}
static void CustomMain() {
#if DEBUG
// ファイルからテストケースを読み込む
global::Common.ChangeStdIn();
// 時間計測
var stopwatch = new Stopwatch();
stopwatch.Start();
#endif
// 出力高速化
var streamWriter =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(streamWriter);
// 回答
Solve();
#if DEBUG
stopwatch.Stop();
Console.WriteLine(stopwatch.Elapsed);
#endif
Console.Out.Flush();
}
static string ReadString() => Console.ReadLine().Trim();
static int ReadInt() => int.Parse(ReadString());
static long ReadLong() => long.Parse(ReadString());
static float ReadFloat() => float.Parse(ReadString());
static double ReadDouble => double.Parse(ReadString());
static string[] ReadStringArray() => ReadString().Split(' ');
static int[] ReadIntArray() => Array.ConvertAll(ReadString().Split(' '),
int.Parse);
static long[] ReadLongArray() => Array.ConvertAll(ReadString().Split(' '),
long.Parse);
static float[] ReadFloatArray() => Array.ConvertAll(ReadString().Split(' '),
float.Parse);
static double[] ReadDoubleArray() => Array.ConvertAll(ReadString().Split(' '),
double.Parse);
static T TypeConversion<T>(string s) {
if (typeof(T) == typeof(int)) {
return (T)Convert.ChangeType(int.Parse(s), typeof(T));
} else if (typeof(T) == typeof(long)) {
return (T)Convert.ChangeType(long.Parse(s), typeof(T));
} else if (typeof(T) == typeof(double)) {
return (T)Convert.ChangeType(double.Parse(s), typeof(T));
} else {
return (T)Convert.ChangeType(s, typeof(T));
}
}
static void ReadMulti<T, U>(out T a, out U b) {
var str = ReadStringArray();
a = TypeConversion<T>(str[0]);
b = TypeConversion<U>(str[1]);
}
static void ReadMulti<T, U, V>(out T a, out U b, out V c) {
var str = ReadStringArray();
a = TypeConversion<T>(str[0]);
b = TypeConversion<U>(str[1]);
c = TypeConversion<V>(str[2]);
}
static void WriteAnswer(object ans) => Console.WriteLine(ans);
static bool IsOdd(long num) { return (num & 1) == 1; }
static bool IsEven(long num) { return (num & 1) == 0; }
static long GCD(long a, long b) { return b != 0 ? GCD(b, a % b) : a; }
}
}
|
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
namespace AtCoder {
class Practice {
static void Main() => CustomMain();
static void Solve() {
var a = ReadIntArray();
foreach (var num in a) {
if (IsEven(num)) {
WriteAnswer(0);
return;
}
}
Array.Sort(a);
long ans = (long)a[0] * a[1];
WriteAnswer(ans);
}
static void CustomMain() {
#if DEBUG
// ファイルからテストケースを読み込む
global::Common.ChangeStdIn();
// 時間計測
var stopwatch = new Stopwatch();
stopwatch.Start();
#endif
// 出力高速化
var streamWriter =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(streamWriter);
// 回答
Solve();
#if DEBUG
stopwatch.Stop();
Console.WriteLine(stopwatch.Elapsed);
#endif
Console.Out.Flush();
}
static string ReadString() => Console.ReadLine().Trim();
static int ReadInt() => int.Parse(ReadString());
static long ReadLong() => long.Parse(ReadString());
static float ReadFloat() => float.Parse(ReadString());
static double ReadDouble => double.Parse(ReadString());
static string[] ReadStringArray() => ReadString().Split(' ');
static int[] ReadIntArray() => Array.ConvertAll(ReadString().Split(' '),
int.Parse);
static long[] ReadLongArray() => Array.ConvertAll(ReadString().Split(' '),
long.Parse);
static float[] ReadFloatArray() => Array.ConvertAll(ReadString().Split(' '),
float.Parse);
static double[] ReadDoubleArray() => Array.ConvertAll(ReadString().Split(' '),
double.Parse);
static T TypeConversion<T>(string s) {
if (typeof(T) == typeof(int)) {
return (T)Convert.ChangeType(int.Parse(s), typeof(T));
} else if (typeof(T) == typeof(long)) {
return (T)Convert.ChangeType(long.Parse(s), typeof(T));
} else if (typeof(T) == typeof(double)) {
return (T)Convert.ChangeType(double.Parse(s), typeof(T));
} else {
return (T)Convert.ChangeType(s, typeof(T));
}
}
static void ReadMulti<T, U>(out T a, out U b) {
var str = ReadStringArray();
a = TypeConversion<T>(str[0]);
b = TypeConversion<U>(str[1]);
}
static void ReadMulti<T, U, V>(out T a, out U b, out V c) {
var str = ReadStringArray();
a = TypeConversion<T>(str[0]);
b = TypeConversion<U>(str[1]);
c = TypeConversion<V>(str[2]);
}
static void WriteAnswer(object ans) => Console.WriteLine(ans);
static bool IsOdd(long num) { return (num & 1) == 1; }
static bool IsEven(long num) { return (num & 1) == 0; }
static long GCD(long a, long b) { return b != 0 ? GCD(b, a % b) : a; }
}
}
|
[["+", 0, 200, 0, 212, 0, 16, 31, 74, 0, 24], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 39, 199], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 0, 25]]
| 8
| 747
| 3
|
using System;
using System.Linq;
class c {
static void Main() {
var inp = Array.ConvertAll(Console.ReadLine().Split(), int.Parse)
.OrderBy(f => f)
.ToArray();
Console.WriteLine(inp.Count(f => f % 2 == 0) > 0 ? 0 : inp[0] * inp[1]);
}
}
|
using System;
using System.Linq;
class c {
static void Main() {
var inp = Array.ConvertAll(Console.ReadLine().Split(), long.Parse)
.OrderBy(f => f)
.ToArray();
Console.WriteLine(inp.Count(f => f % 2 == 0) > 0 ? 0 : inp[0] * inp[1]);
}
}
|
[["-", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199]]
| 8
| 84
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
class Program {
static void Main(string[] args) {
var abc = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
for (var i = 0; i < 3; i++)
if (abc[i] % 2 == 0) {
WriteLine(0);
return;
}
Array.Sort(abc);
WriteLine(abc[1] * abc[0]);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
class Program {
static void Main(string[] args) {
var abc = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
for (var i = 0; i < 3; i++)
if (abc[i] % 2 == 0) {
WriteLine(0);
return;
}
Array.Sort(abc);
WriteLine((long)abc[1] * abc[0]);
}
}
|
[["+", 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]]
| 8
| 125
| 3
|
using System;
using System.Linq;
class Program {
static void Main() {
var arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
int a = arr[0];
int b = arr[1];
int c = arr[2];
if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
Console.WriteLine(0);
} else {
Console.WriteLine(Math.Min(a * b, Math.Min(a * c, b * c)));
}
}
}
|
using System;
using System.Linq;
class Program {
static void Main() {
var arr = Console.ReadLine().Split().Select(long.Parse).ToArray();
var a = arr[0];
var b = arr[1];
var c = arr[2];
if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
Console.WriteLine(0);
} else {
Console.WriteLine(Math.Min(a * b, Math.Min(a * c, b * c)));
}
}
}
|
[["-", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217]]
| 8
| 126
| 8
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
var a = Console.ReadLine()
.Split(' ')
.Select(x => long.Parse(x))
.OrderByDescending(x => x)
.ToArray();
Console.WriteLine(a[0] * a[1] * a[2] % 2 * a[0] * a[1]);
}
}
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
var a = Console.ReadLine()
.Split(' ')
.Select(x => long.Parse(x))
.OrderBy(x => x)
.ToArray();
Console.WriteLine(a[0] * a[1] * a[2] % 2 * a[0] * a[1]);
}
}
|
[["-", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22]]
| 8
| 94
| 2
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
namespace AtCoder {
class MainClass {
// C#7.0
long[] abc;
void Solve() {
io.ini(out abc, 3);
bool isEven = false;
for (int i = 0; i < 3; i++) {
if (abc[i] % 2 == 0) {
isEven = true;
break;
}
}
long ans =
isEven ? 0 : Mat.Min(abc[0] * abc[1], abc[1] * abc[2], abc[2] * abc[1]);
io.o(ans);
}
public static void Main(string[] args) { new MainClass().Stream(); }
IO io = new IO();
void Stream() {
Solve();
io.writeFlush();
}
}
class IO {
string[] nextBuffer;
int BufferCnt;
char[] cs = new char[] { ' ' };
StreamWriter sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
public IO() {
nextBuffer = new string[0];
BufferCnt = 0;
Console.SetOut(sw);
}
public string next() {
if (BufferCnt < nextBuffer.Length)
return nextBuffer[BufferCnt++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
BufferCnt = 0;
return nextBuffer[BufferCnt++];
}
public char nextChar() { return char.Parse(next()); }
public int nextInt() { return int.Parse(next()); }
public long nextLong() { return long.Parse(next()); }
public double nextDouble() { return double.Parse(next()); }
public string[] arr() { return Console.ReadLine().Split(' '); }
public char[] arrayChar() { return Array.ConvertAll(arr(), char.Parse); }
public int[] arrayInt() { return Array.ConvertAll(arr(), int.Parse); }
public long[] arrayLong() { return Array.ConvertAll(arr(), long.Parse); }
public double[] arrayDouble() {
return Array.ConvertAll(arr(), double.Parse);
}
private bool typeEQ<T, U>() { return typeof(T).Equals(typeof(U)); }
private T convertType<T, U>(U v) {
return (T)Convert.ChangeType(v, typeof(T));
}
private T suitType<T>(string s) {
if (typeEQ<T, int>())
return convertType<T, int>(int.Parse(s));
if (typeEQ<T, long>())
return convertType<T, long>(long.Parse(s));
if (typeEQ<T, double>())
return convertType<T, double>(double.Parse(s));
if (typeEQ<T, char>())
return convertType<T, char>(char.Parse(s));
return convertType<T, string>(s);
}
public void i<T>(out T v) { v = suitType<T>(next()); }
public void i<T, U>(out T v1, out U v2) {
var a = arr();
v1 = suitType<T>(a[0]);
v2 = suitType<U>(a[1]);
}
public void i<T, U, V>(out T v1, out U v2, out V v3) {
var a = arr();
v1 = suitType<T>(a[0]);
v2 = suitType<U>(a[1]);
v3 = suitType<V>(a[2]);
}
public void i<T, U, V, W>(out T v1, out U v2, out V v3, out W v4) {
var a = arr();
v1 = suitType<T>(a[0]);
v2 = suitType<U>(a[1]);
v3 = suitType<V>(a[2]);
v4 = suitType<W>(a[3]);
}
public void ini(out int[] a, int size) {
a = new int[size];
for (int i = 0; i < size; i++)
a[i] = nextInt();
}
public void ini(out long[] a, int size) {
a = new long[size];
for (int i = 0; i < size; i++)
a[i] = nextInt();
}
public void ini(out int[] a1, out int[] a2, int size) {
a1 = new int[size];
a2 = new int[size];
for (int i = 0; i < size; i++) {
a1[i] = nextInt();
a2[i] = nextInt();
}
}
public void ini(out string[] a, int size) {
a = new string[size];
for (int i = 0; i < size; i++)
a[i] = next();
}
public void inii(out int[] a, int size) {
a = new int[size];
for (int i = 0; i < size; i++)
a[i] = nextInt() - 1;
}
public void inii(out int[] a1, out int[] a2, int size) {
a1 = new int[size];
a2 = new int[size];
for (int i = 0; i < size; i++) {
a1[i] = nextInt() - 1;
a2[i] = nextInt() - 1;
}
}
public void inii(out int[,] a, int size) {
a = new int[size, size];
for (int i = 0; i < size; i++)
for (int j = 0; j < size; j++) {
a[i, j] = nextInt() - 1;
}
}
public void o<T>(T v) { Console.WriteLine(v); }
public void o<T>(params T[] a) {
foreach (T v in a)
Console.WriteLine(v);
}
public void o<T>(List<T> l) {
foreach (T v in l)
sw.WriteLine(v);
}
public void ol<T>(T v) { Console.Write(v + " "); }
public void ol<T>(params T[] a) {
foreach (T v in a)
Console.Write(v + " ");
Console.WriteLine("");
}
public void YN(bool f) { Console.WriteLine(f ? "YES" : "NO"); }
public void Yn(bool f) { Console.WriteLine(f ? "Yes" : "No"); }
public void yn(bool f) { Console.WriteLine(f ? "yes" : "no"); }
public void br() { Console.WriteLine(""); }
public void writeFlush() { Console.Out.Flush(); }
public string pad0<T>(T v, int n) { return v.ToString().PadLeft(n, '0'); }
}
class AssociativeArray<T> {
public Dictionary<T, int> dic;
public void init(T[] a) {
dic = new Dictionary<T, int>();
for (int i = 0; i < a.Length; i++) {
if (!dic.ContainsKey(a[i]))
dic[a[i]] = 0;
dic[a[i]]++;
}
}
public int ValueSum() {
int s = 0;
foreach (var i in dic)
s += i.Value;
return s;
}
public int KeyNum() { return dic.Keys.Count; }
public int Max() { return dic.Values.Max(); }
public int Min() { return dic.Values.Min(); }
public T MaxKey() { return dic.First(d => d.Value == Max()).Key; }
public T MinKey() { return dic.First(d => d.Value == Min()).Key; }
public bool isContainsK(T k) { return dic.ContainsKey(k); }
public bool anyContainsK(params T[] k) {
bool f = false;
foreach (T v in k)
f |= isContainsK(v);
return f;
}
public bool allContainsK(params T[] k) {
bool f = true;
foreach (T v in k)
f &= isContainsK(v);
return f;
}
public void Show() {
foreach (var v in dic) {
Console.WriteLine(v.Key + " : " + v.Value);
}
}
//:sort->array
}
class Time {
public bool isLeapYear(int y) {
return (y % 400 == 0 || (y % 4 == 0 && y % 100 != 0));
}
}
class BucketSort {
public int[] bucket;
public void Init(int[] a) {
bucket = new int[a.Max() + 1];
for (int i = 0; i < a.Length; ++i)
++bucket[a[i]];
for (int i = 0, j = 0; j < bucket.Length; ++j)
for (int k = bucket[j]; k != 0; --k, ++i)
a[i] = j;
}
}
// static
static class Mat {
public static int mod = 1000000007; // 10^9+7
public static long Pow(long a, long b) {
if (b == 0)
return 1;
if (b % 2 == 1)
return (a % mod * Pow(a % mod, b - 1) % mod) % mod;
else
return Pow(a * a % mod, b / 2) % mod;
}
public static long Fact(long n) {
return (n != 0) ? (n % mod * (Fact(n - 1) % mod) % mod) : 1;
}
public static long C(long n, long r) {
if (r == 0 || n == r)
return 1;
else
return (Fact(n) % mod *
Pow((Fact(n - r) % mod * Fact(r) % mod) % mod, mod - 2) % mod) %
mod;
}
public static long Sum(params long[] a) {
return a.Aggregate((v, next) => (v % mod + next) % mod);
}
public static int GCD(int a, int b) {
if (a < b)
Swap(ref a, ref b);
return b == 0 ? a : GCD(b, a % b);
}
public static int GCD(int[] array) {
return array.Aggregate((v, next) => GCD(v, next));
}
public static void Swap<T>(ref T a, ref T b) {
T tmp = a;
a = b;
b = tmp;
}
public static T Max<T>(params T[] v) { return v.Max(); }
public static T Min<T>(params T[] v) { return v.Min(); }
public static double Dis(int x1, int y1, int x2, int y2) {
return Math.Sqrt(Math.Pow((x2 - x1), 2) + Math.Pow((y2 - y1), 2));
}
public static int Digit(long n) {
return (n == 0) ? 1 : (int)Math.Log10(n) + 1;
}
public static int Clamp(int n, int a, int b) {
return (n < a) ? a : (b < n) ? b : n;
}
public static long Clamp(long n, long a, long b) {
return (n < a) ? a : (b < n) ? b : n;
}
public static double Clamp(double n, double a, double b) {
return (n < a) ? a : (b < n) ? b : n;
}
public static long Tousa(long a, long d, int n) { return a + (n - 1) * d; }
public static long TousaSum(long a, long d, int n) {
return n * (2 * a + (n - 1) * d) / 2;
}
}
static class StringEX {
public static string Reversed(this string s) {
return string.Join("", s.Reverse());
}
public static string Repeat(this string s, int n) {
return string.Concat(Enumerable.Repeat(s, n).ToArray());
}
}
static class CharEX {
public static int toInt(this char c) { return int.Parse(c.ToString()); }
}
static class ArrayEX {
public static T[] Sort<T>(this T[] a) {
Array.Sort(a);
return a;
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
namespace AtCoder {
class MainClass {
// C#7.0
long[] abc;
void Solve() {
io.ini(out abc, 3);
bool isEven = false;
for (int i = 0; i < 3; i++) {
if (abc[i] % 2 == 0) {
isEven = true;
break;
}
}
long ans =
isEven ? 0 : Mat.Min(abc[0] * abc[1], abc[1] * abc[2], abc[2] * abc[0]);
io.o(ans);
}
public static void Main(string[] args) { new MainClass().Stream(); }
IO io = new IO();
void Stream() {
Solve();
io.writeFlush();
}
}
class IO {
string[] nextBuffer;
int BufferCnt;
char[] cs = new char[] { ' ' };
StreamWriter sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
public IO() {
nextBuffer = new string[0];
BufferCnt = 0;
Console.SetOut(sw);
}
public string next() {
if (BufferCnt < nextBuffer.Length)
return nextBuffer[BufferCnt++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
BufferCnt = 0;
return nextBuffer[BufferCnt++];
}
public char nextChar() { return char.Parse(next()); }
public int nextInt() { return int.Parse(next()); }
public long nextLong() { return long.Parse(next()); }
public double nextDouble() { return double.Parse(next()); }
public string[] arr() { return Console.ReadLine().Split(' '); }
public char[] arrayChar() { return Array.ConvertAll(arr(), char.Parse); }
public int[] arrayInt() { return Array.ConvertAll(arr(), int.Parse); }
public long[] arrayLong() { return Array.ConvertAll(arr(), long.Parse); }
public double[] arrayDouble() {
return Array.ConvertAll(arr(), double.Parse);
}
private bool typeEQ<T, U>() { return typeof(T).Equals(typeof(U)); }
private T convertType<T, U>(U v) {
return (T)Convert.ChangeType(v, typeof(T));
}
private T suitType<T>(string s) {
if (typeEQ<T, int>())
return convertType<T, int>(int.Parse(s));
if (typeEQ<T, long>())
return convertType<T, long>(long.Parse(s));
if (typeEQ<T, double>())
return convertType<T, double>(double.Parse(s));
if (typeEQ<T, char>())
return convertType<T, char>(char.Parse(s));
return convertType<T, string>(s);
}
public void i<T>(out T v) { v = suitType<T>(next()); }
public void i<T, U>(out T v1, out U v2) {
var a = arr();
v1 = suitType<T>(a[0]);
v2 = suitType<U>(a[1]);
}
public void i<T, U, V>(out T v1, out U v2, out V v3) {
var a = arr();
v1 = suitType<T>(a[0]);
v2 = suitType<U>(a[1]);
v3 = suitType<V>(a[2]);
}
public void i<T, U, V, W>(out T v1, out U v2, out V v3, out W v4) {
var a = arr();
v1 = suitType<T>(a[0]);
v2 = suitType<U>(a[1]);
v3 = suitType<V>(a[2]);
v4 = suitType<W>(a[3]);
}
public void ini(out int[] a, int size) {
a = new int[size];
for (int i = 0; i < size; i++)
a[i] = nextInt();
}
public void ini(out long[] a, int size) {
a = new long[size];
for (int i = 0; i < size; i++)
a[i] = nextInt();
}
public void ini(out int[] a1, out int[] a2, int size) {
a1 = new int[size];
a2 = new int[size];
for (int i = 0; i < size; i++) {
a1[i] = nextInt();
a2[i] = nextInt();
}
}
public void ini(out string[] a, int size) {
a = new string[size];
for (int i = 0; i < size; i++)
a[i] = next();
}
public void inii(out int[] a, int size) {
a = new int[size];
for (int i = 0; i < size; i++)
a[i] = nextInt() - 1;
}
public void inii(out int[] a1, out int[] a2, int size) {
a1 = new int[size];
a2 = new int[size];
for (int i = 0; i < size; i++) {
a1[i] = nextInt() - 1;
a2[i] = nextInt() - 1;
}
}
public void inii(out int[,] a, int size) {
a = new int[size, size];
for (int i = 0; i < size; i++)
for (int j = 0; j < size; j++) {
a[i, j] = nextInt() - 1;
}
}
public void o<T>(T v) { Console.WriteLine(v); }
public void o<T>(params T[] a) {
foreach (T v in a)
Console.WriteLine(v);
}
public void o<T>(List<T> l) {
foreach (T v in l)
sw.WriteLine(v);
}
public void ol<T>(T v) { Console.Write(v + " "); }
public void ol<T>(params T[] a) {
foreach (T v in a)
Console.Write(v + " ");
Console.WriteLine("");
}
public void YN(bool f) { Console.WriteLine(f ? "YES" : "NO"); }
public void Yn(bool f) { Console.WriteLine(f ? "Yes" : "No"); }
public void yn(bool f) { Console.WriteLine(f ? "yes" : "no"); }
public void br() { Console.WriteLine(""); }
public void writeFlush() { Console.Out.Flush(); }
public string pad0<T>(T v, int n) { return v.ToString().PadLeft(n, '0'); }
}
class AssociativeArray<T> {
public Dictionary<T, int> dic;
public void init(T[] a) {
dic = new Dictionary<T, int>();
for (int i = 0; i < a.Length; i++) {
if (!dic.ContainsKey(a[i]))
dic[a[i]] = 0;
dic[a[i]]++;
}
}
public int ValueSum() {
int s = 0;
foreach (var i in dic)
s += i.Value;
return s;
}
public int KeyNum() { return dic.Keys.Count; }
public int Max() { return dic.Values.Max(); }
public int Min() { return dic.Values.Min(); }
public T MaxKey() { return dic.First(d => d.Value == Max()).Key; }
public T MinKey() { return dic.First(d => d.Value == Min()).Key; }
public bool isContainsK(T k) { return dic.ContainsKey(k); }
public bool anyContainsK(params T[] k) {
bool f = false;
foreach (T v in k)
f |= isContainsK(v);
return f;
}
public bool allContainsK(params T[] k) {
bool f = true;
foreach (T v in k)
f &= isContainsK(v);
return f;
}
public void Show() {
foreach (var v in dic) {
Console.WriteLine(v.Key + " : " + v.Value);
}
}
//:sort->array
}
class Time {
public bool isLeapYear(int y) {
return (y % 400 == 0 || (y % 4 == 0 && y % 100 != 0));
}
}
class BucketSort {
public int[] bucket;
public void Init(int[] a) {
bucket = new int[a.Max() + 1];
for (int i = 0; i < a.Length; ++i)
++bucket[a[i]];
for (int i = 0, j = 0; j < bucket.Length; ++j)
for (int k = bucket[j]; k != 0; --k, ++i)
a[i] = j;
}
}
// static
static class Mat {
public static int mod = 1000000007; // 10^9+7
public static long Pow(long a, long b) {
if (b == 0)
return 1;
if (b % 2 == 1)
return (a % mod * Pow(a % mod, b - 1) % mod) % mod;
else
return Pow(a * a % mod, b / 2) % mod;
}
public static long Fact(long n) {
return (n != 0) ? (n % mod * (Fact(n - 1) % mod) % mod) : 1;
}
public static long C(long n, long r) {
if (r == 0 || n == r)
return 1;
else
return (Fact(n) % mod *
Pow((Fact(n - r) % mod * Fact(r) % mod) % mod, mod - 2) % mod) %
mod;
}
public static long Sum(params long[] a) {
return a.Aggregate((v, next) => (v % mod + next) % mod);
}
public static int GCD(int a, int b) {
if (a < b)
Swap(ref a, ref b);
return b == 0 ? a : GCD(b, a % b);
}
public static int GCD(int[] array) {
return array.Aggregate((v, next) => GCD(v, next));
}
public static void Swap<T>(ref T a, ref T b) {
T tmp = a;
a = b;
b = tmp;
}
public static T Max<T>(params T[] v) { return v.Max(); }
public static T Min<T>(params T[] v) { return v.Min(); }
public static double Dis(int x1, int y1, int x2, int y2) {
return Math.Sqrt(Math.Pow((x2 - x1), 2) + Math.Pow((y2 - y1), 2));
}
public static int Digit(long n) {
return (n == 0) ? 1 : (int)Math.Log10(n) + 1;
}
public static int Clamp(int n, int a, int b) {
return (n < a) ? a : (b < n) ? b : n;
}
public static long Clamp(long n, long a, long b) {
return (n < a) ? a : (b < n) ? b : n;
}
public static double Clamp(double n, double a, double b) {
return (n < a) ? a : (b < n) ? b : n;
}
public static long Tousa(long a, long d, int n) { return a + (n - 1) * d; }
public static long TousaSum(long a, long d, int n) {
return n * (2 * a + (n - 1) * d) / 2;
}
}
static class StringEX {
public static string Reversed(this string s) {
return string.Join("", s.Reverse());
}
public static string Repeat(this string s, int n) {
return string.Concat(Enumerable.Repeat(s, n).ToArray());
}
}
static class CharEX {
public static int toInt(this char c) { return int.Parse(c.ToString()); }
}
static class ArrayEX {
public static T[] Sort<T>(this T[] a) {
Array.Sort(a);
return a;
}
}
}
|
[["-", 0, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 16, 12, 204, 206, 207, 0, 28, 0, 203]]
| 8
| 2,847
| 2
|
using System;
using System.Linq;
namespace agc004_a {
class Program {
static void Main(string[] args) {
int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
if (x[0] % 2 == 0 || x[1] % 2 == 0 || x[2] % 2 == 0) {
Console.WriteLine(0);
} else {
Array.Sort(x);
Console.WriteLine(x[0] * x[1]);
}
}
}
}
|
using System;
using System.Linq;
namespace agc004_a {
class Program {
static void Main(string[] args) {
long[] x = Console.ReadLine().Split().Select(long.Parse).ToArray();
if (x[0] % 2 == 0 || x[1] % 2 == 0 || x[2] % 2 == 0) {
Console.WriteLine(0);
} else {
Array.Sort(x);
Console.WriteLine(x[0] * x[1]);
}
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199]]
| 8
| 116
| 4
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
class Magatro {
static void Main() {
int[] s = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
Array.Sort(s);
if (s.Count(a => a % 2 == 0) > 0) {
Console.WriteLine(0);
return;
}
Console.WriteLine(s[0] * s[1]);
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
class Magatro {
static void Main() {
long[] s = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
Array.Sort(s);
if (s.Count(a => a % 2 == 0) > 0) {
Console.WriteLine(0);
return;
}
Console.WriteLine(s[0] * s[1]);
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199]]
| 8
| 129
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace A {
class Program {
static void Main(string[] args) {
var abc = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
int a = abc[0], b = abc[1], c = abc[2];
if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
Console.WriteLine(0);
} else {
var m = Math.Min(Math.Min(a * b, b * c), c * a);
Console.WriteLine(m);
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace A {
class Program {
static void Main(string[] args) {
var abc = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
long a = abc[0], b = abc[1], c = abc[2];
if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
Console.WriteLine(0);
} else {
var m = Math.Min(Math.Min(a * b, b * c), c * a);
Console.WriteLine(m);
}
}
}
}
|
[["-", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
| 8
| 159
| 4
|
using System;
using System.Collections.Generic;
class Solve {
public int a;
public int b;
public int c;
public Solve() {}
public static int Main() {
new Solve().Calc();
return 0;
}
void Calc() {
getinput();
if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
Console.WriteLine(0);
} else {
if (a < b) {
if (b < c) {
Console.WriteLine(a * b);
} else {
Console.WriteLine(a * c);
}
} else {
if (a < c) {
Console.WriteLine(a * b);
} else {
Console.WriteLine(b * c);
}
}
}
}
void getinput() {
string[] str = Console.ReadLine().Split(' ');
a = int.Parse(str[0]);
b = int.Parse(str[1]);
c = int.Parse(str[2]);
}
}
|
using System;
using System.Collections.Generic;
class Solve {
public long a;
public long b;
public long c;
public Solve() {}
public static int Main() {
new Solve().Calc();
return 0;
}
void Calc() {
getinput();
if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
Console.WriteLine(0);
} else {
if (a < b) {
if (b < c) {
Console.WriteLine(a * b);
} else {
Console.WriteLine(a * c);
}
} else {
if (a < c) {
Console.WriteLine(a * b);
} else {
Console.WriteLine(b * c);
}
}
}
}
void getinput() {
string[] str = Console.ReadLine().Split(' ');
a = int.Parse(str[0]);
b = int.Parse(str[1]);
c = int.Parse(str[2]);
}
}
|
[["-", 0, 235, 8, 201, 0, 124, 0, 198, 39, 199], ["+", 0, 235, 8, 201, 0, 124, 0, 198, 39, 199]]
| 8
| 223
| 6
|
using System;
namespace AGC004A {
public class Program {
public static void Main(string[] args) {
var sr = new StreamReader();
//---------------------------------
var A = sr.Next<int>();
var B = sr.Next<int>();
var C = sr.Next<int>();
if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {
Console.WriteLine(0);
return;
}
Console.WriteLine(Ex.Min(A * B, B * C, C * A));
//---------------------------------
}
}
public class Ex {
public static T Min<T>(params T[] values)
where T : IComparable {
var ret = values[0];
foreach (var v in values)
ret = ret.CompareTo(v) < 0 ? ret : v;
return ret;
}
}
public class StreamReader {
private readonly char[] _c = { ' ' };
private int _index = -1;
private string[] _input = new string[0];
private readonly System.IO.StreamReader _sr =
new System.IO.StreamReader(Console.OpenStandardInput());
public T Next<T>() {
if (_index == _input.Length - 1) {
_index = -1;
while (true) {
string rl = _sr.ReadLine();
if (rl == null) {
if (typeof(T).IsClass)
return default(T);
return (T) typeof(T).GetField("MinValue").GetValue(null);
}
if (rl != "") {
_input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
break;
}
}
}
return (T)Convert.ChangeType(
_input[++_index], typeof(T),
System.Globalization.CultureInfo.InvariantCulture);
}
public T[] Next<T>(int x) {
var ret = new T[x];
for (var i = 0; i < x; ++i)
ret[i] = Next<T>();
return ret;
}
public T[][] Next<T>(int y, int x) {
var ret = new T[y][];
for (var i = 0; i < y; ++i)
ret[i] = Next<T>(x);
return ret;
}
}
}
|
using System;
namespace AGC004A {
public class Program {
public static void Main(string[] args) {
var sr = new StreamReader();
//---------------------------------
var A = sr.Next<long>();
var B = sr.Next<long>();
var C = sr.Next<long>();
if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {
Console.WriteLine(0);
return;
}
Console.WriteLine(Ex.Min(A * B, B * C, C * A));
//---------------------------------
}
}
public class Ex {
public static T Min<T>(params T[] values)
where T : IComparable {
var ret = values[0];
foreach (var v in values)
ret = ret.CompareTo(v) < 0 ? ret : v;
return ret;
}
}
public class StreamReader {
private readonly char[] _c = { ' ' };
private int _index = -1;
private string[] _input = new string[0];
private readonly System.IO.StreamReader _sr =
new System.IO.StreamReader(Console.OpenStandardInput());
public T Next<T>() {
if (_index == _input.Length - 1) {
_index = -1;
while (true) {
string rl = _sr.ReadLine();
if (rl == null) {
if (typeof(T).IsClass)
return default(T);
return (T) typeof(T).GetField("MinValue").GetValue(null);
}
if (rl != "") {
_input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
break;
}
}
}
return (T)Convert.ChangeType(
_input[++_index], typeof(T),
System.Globalization.CultureInfo.InvariantCulture);
}
public T[] Next<T>(int x) {
var ret = new T[x];
for (var i = 0; i < x; ++i)
ret[i] = Next<T>();
return ret;
}
public T[][] Next<T>(int y, int x) {
var ret = new T[y][];
for (var i = 0; i < y; ++i)
ret[i] = Next<T>(x);
return ret;
}
}
}
|
[["-", 0, 213, 63, 214, 141, 236, 237, 238, 0, 199], ["+", 0, 213, 63, 214, 141, 236, 237, 238, 0, 199]]
| 8
| 491
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
class Program {
const int M = 1000000007;
const double eps = 1e-9;
static int[] dd = { 0, 1, 0, -1, 0 };
static void Main() {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
var sc = new Scan();
var a = sc.IntArr;
if (a.Count(x => x % 2 == 0) > 0) {
Console.WriteLine(0);
return;
}
Array.Sort(a);
sw.WriteLine(a[0] * a[1]);
sw.Flush();
}
static void swap<T>(ref T a, ref T b) {
var t = a;
a = b;
b = t;
}
static void swap<T>(IList<T> a, int i, int j) {
var t = a[i];
a[i] = a[j];
a[j] = t;
}
static T Max<T>(params T[] a) { return a.Max(); }
static T Min<T>(params T[] a) { return a.Min(); }
static void DBG<T>(params T[] a) { Console.WriteLine(string.Join(" ", a)); }
static void DBG(params object[] a) { Console.WriteLine(string.Join(" ", a)); }
static T[] copy<T>(IList<T> a) {
var ret = new T[a.Count];
for (int i = 0; i < a.Count; i++)
ret[i] = a[i];
return ret;
}
}
class Scan {
public int Int {
get { return int.Parse(Str); }
}
public long Long {
get { return long.Parse(Str); }
}
public double Double {
get { return double.Parse(Str); }
}
public string Str {
get { return Console.ReadLine().Trim(); }
}
public int[] IntArr {
get { return StrArr.Select(int.Parse).ToArray(); }
}
public int[] IntArrWithSep(char sep) {
return Str.Split(sep).Select(int.Parse).ToArray();
}
public long[] LongArr {
get { return StrArr.Select(long.Parse).ToArray(); }
}
public double[] DoubleArr {
get { return StrArr.Select(double.Parse).ToArray(); }
}
public string[] StrArr {
get { return Str.Split(); }
}
T cv<T>(string inp) {
if (typeof(T).Equals(typeof(int)))
return (T)Convert.ChangeType(int.Parse(inp), typeof(T));
if (typeof(T).Equals(typeof(long)))
return (T)Convert.ChangeType(long.Parse(inp), typeof(T));
if (typeof(T).Equals(typeof(double)))
return (T)Convert.ChangeType(double.Parse(inp), typeof(T));
if (typeof(T).Equals(typeof(char)))
return (T)Convert.ChangeType(inp[0], typeof(T));
return (T)Convert.ChangeType(inp, typeof(T));
}
public void Multi<T>(out T a) { a = cv<T>(Str); }
public void Multi<T, U>(out T a, out U b) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
public void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
public void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
}
public void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d,
out X e) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
}
}
class mymath {
static int Mod = 1000000007;
public void setMod(int m) { Mod = m; }
public bool isprime(long a) {
if (a < 2)
return false;
for (long i = 2; i * i <= a; i++)
if (a % i == 0)
return false;
return true;
}
public bool[] sieve(int n) {
var isp = new bool[n + 1];
for (int i = 2; i <= n; i++)
isp[i] = true;
for (int i = 2; i * i <= n; i++)
if (isp[i])
for (int j = i * i; j <= n; j += i)
isp[j] = false;
return isp;
}
public List<int> getprimes(int n) {
var prs = new List<int>();
var isp = sieve(n);
for (int i = 2; i <= n; i++)
if (isp[i])
prs.Add(i);
return prs;
}
public long[][] E(int n) {
var ret = new long [n][];
for (int i = 0; i < n; i++) {
ret[i] = new long[n];
ret[i][i] = 1;
}
return ret;
}
public long[][] powmat(long[][] A, long n) {
if (n == 0)
return E(A.Length);
var t = powmat(A, n / 2);
if ((n & 1) == 0)
return mulmat(t, t);
return mulmat(mulmat(t, t), A);
}
public long[] mulmat(long[][] A, long[] x) {
int n = A.Length, m = x.Length;
var ans = new long[n];
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
ans[i] = (ans[i] + x[j] * A[i][j]) % Mod;
return ans;
}
public long[][] mulmat(long[][] A, long[][] B) {
int n = A.Length, m = B[0].Length, l = B.Length;
var ans = new long [n][];
for (int i = 0; i < n; i++) {
ans[i] = new long[m];
for (int j = 0; j < m; j++)
for (int k = 0; k < l; k++)
ans[i][j] = (ans[i][j] + A[i][k] * B[k][j]) % Mod;
}
return ans;
}
public long powmod(long a, long b) {
if (a >= Mod)
return powmod(a % Mod, b);
if (a == 0)
return 0;
if (b == 0)
return 1;
var t = powmod(a, b / 2);
if ((b & 1) == 0)
return t * t % Mod;
return t * t % Mod * a % Mod;
}
public long gcd(long a, long b) {
while (b > 0) {
var t = a % b;
a = b;
b = t;
}
return a;
}
public long lcm(long a, long b) { return a * (b / gcd(a, b)); }
public long Comb(int n, int r) {
if (n < 0 || r < 0 || r > n)
return 0;
if (n - r < r)
r = n - r;
if (r == 0)
return 1;
if (r == 1)
return n;
var numerator = new int[r];
var denominator = new int[r];
for (int k = 0; k < r; k++) {
numerator[k] = n - r + k + 1;
denominator[k] = k + 1;
}
for (int p = 2; p <= r; p++) {
int pivot = denominator[p - 1];
if (pivot > 1) {
int offset = (n - r) % p;
for (int k = p - 1; k < r; k += p) {
numerator[k - offset] /= pivot;
denominator[k] /= pivot;
}
}
}
long result = 1;
for (int k = 0; k < r; k++)
if (numerator[k] > 1)
result = result * numerator[k] % Mod;
return result;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
class Program {
const int M = 1000000007;
const double eps = 1e-9;
static int[] dd = { 0, 1, 0, -1, 0 };
static void Main() {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
var sc = new Scan();
var a = sc.LongArr;
if (a.Count(x => x % 2 == 0) > 0) {
Console.WriteLine(0);
return;
}
Array.Sort(a);
sw.WriteLine(a[0] * a[1]);
sw.Flush();
}
static void swap<T>(ref T a, ref T b) {
var t = a;
a = b;
b = t;
}
static void swap<T>(IList<T> a, int i, int j) {
var t = a[i];
a[i] = a[j];
a[j] = t;
}
static T Max<T>(params T[] a) { return a.Max(); }
static T Min<T>(params T[] a) { return a.Min(); }
static void DBG<T>(params T[] a) { Console.WriteLine(string.Join(" ", a)); }
static void DBG(params object[] a) { Console.WriteLine(string.Join(" ", a)); }
static T[] copy<T>(IList<T> a) {
var ret = new T[a.Count];
for (int i = 0; i < a.Count; i++)
ret[i] = a[i];
return ret;
}
}
class Scan {
public int Int {
get { return int.Parse(Str); }
}
public long Long {
get { return long.Parse(Str); }
}
public double Double {
get { return double.Parse(Str); }
}
public string Str {
get { return Console.ReadLine().Trim(); }
}
public int[] IntArr {
get { return StrArr.Select(int.Parse).ToArray(); }
}
public int[] IntArrWithSep(char sep) {
return Str.Split(sep).Select(int.Parse).ToArray();
}
public long[] LongArr {
get { return StrArr.Select(long.Parse).ToArray(); }
}
public double[] DoubleArr {
get { return StrArr.Select(double.Parse).ToArray(); }
}
public string[] StrArr {
get { return Str.Split(); }
}
T cv<T>(string inp) {
if (typeof(T).Equals(typeof(int)))
return (T)Convert.ChangeType(int.Parse(inp), typeof(T));
if (typeof(T).Equals(typeof(long)))
return (T)Convert.ChangeType(long.Parse(inp), typeof(T));
if (typeof(T).Equals(typeof(double)))
return (T)Convert.ChangeType(double.Parse(inp), typeof(T));
if (typeof(T).Equals(typeof(char)))
return (T)Convert.ChangeType(inp[0], typeof(T));
return (T)Convert.ChangeType(inp, typeof(T));
}
public void Multi<T>(out T a) { a = cv<T>(Str); }
public void Multi<T, U>(out T a, out U b) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
public void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
public void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
}
public void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d,
out X e) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
}
}
class mymath {
static int Mod = 1000000007;
public void setMod(int m) { Mod = m; }
public bool isprime(long a) {
if (a < 2)
return false;
for (long i = 2; i * i <= a; i++)
if (a % i == 0)
return false;
return true;
}
public bool[] sieve(int n) {
var isp = new bool[n + 1];
for (int i = 2; i <= n; i++)
isp[i] = true;
for (int i = 2; i * i <= n; i++)
if (isp[i])
for (int j = i * i; j <= n; j += i)
isp[j] = false;
return isp;
}
public List<int> getprimes(int n) {
var prs = new List<int>();
var isp = sieve(n);
for (int i = 2; i <= n; i++)
if (isp[i])
prs.Add(i);
return prs;
}
public long[][] E(int n) {
var ret = new long [n][];
for (int i = 0; i < n; i++) {
ret[i] = new long[n];
ret[i][i] = 1;
}
return ret;
}
public long[][] powmat(long[][] A, long n) {
if (n == 0)
return E(A.Length);
var t = powmat(A, n / 2);
if ((n & 1) == 0)
return mulmat(t, t);
return mulmat(mulmat(t, t), A);
}
public long[] mulmat(long[][] A, long[] x) {
int n = A.Length, m = x.Length;
var ans = new long[n];
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
ans[i] = (ans[i] + x[j] * A[i][j]) % Mod;
return ans;
}
public long[][] mulmat(long[][] A, long[][] B) {
int n = A.Length, m = B[0].Length, l = B.Length;
var ans = new long [n][];
for (int i = 0; i < n; i++) {
ans[i] = new long[m];
for (int j = 0; j < m; j++)
for (int k = 0; k < l; k++)
ans[i][j] = (ans[i][j] + A[i][k] * B[k][j]) % Mod;
}
return ans;
}
public long powmod(long a, long b) {
if (a >= Mod)
return powmod(a % Mod, b);
if (a == 0)
return 0;
if (b == 0)
return 1;
var t = powmod(a, b / 2);
if ((b & 1) == 0)
return t * t % Mod;
return t * t % Mod * a % Mod;
}
public long gcd(long a, long b) {
while (b > 0) {
var t = a % b;
a = b;
b = t;
}
return a;
}
public long lcm(long a, long b) { return a * (b / gcd(a, b)); }
public long Comb(int n, int r) {
if (n < 0 || r < 0 || r > n)
return 0;
if (n - r < r)
r = n - r;
if (r == 0)
return 1;
if (r == 1)
return n;
var numerator = new int[r];
var denominator = new int[r];
for (int k = 0; k < r; k++) {
numerator[k] = n - r + k + 1;
denominator[k] = k + 1;
}
for (int p = 2; p <= r; p++) {
int pivot = denominator[p - 1];
if (pivot > 1) {
int offset = (n - r) % p;
for (int k = p - 1; k < r; k += p) {
numerator[k - offset] /= pivot;
denominator[k] /= pivot;
}
}
}
long result = 1;
for (int k = 0; k < r; k++)
if (numerator[k] > 1)
result = result * numerator[k] % Mod;
return result;
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 214, 141, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 141, 22]]
| 8
| 2,090
| 2
|
using System;
using System.Linq;
public class Program {
public static void Main() {
int[] size = Console.ReadLine()
.Split()
.Select(i => int.Parse(i))
.OrderBy(i => i)
.ToArray();
Console.WriteLine(size.Any(i => i % 2 == 0) ? 0 : size[0] * size[1]);
}
}
|
using System;
using System.Linq;
public class Program {
public static void Main() {
long[] size = Console.ReadLine()
.Split()
.Select(i => long.Parse(i))
.OrderBy(i => i)
.ToArray();
Console.WriteLine(size.Any(i => i % 2 == 0) ? 0 : size[0] * size[1]);
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["+", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199]]
| 8
| 89
| 4
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace ABC {
class MainClass {
public static void Main(string[] args) {
var a = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
long result = 0;
if (a[0] % 2 == 0 || a[1] % 2 == 0 || a[2] % 2 == 0)
result = 0;
else
result = Math.Min(Math.Min(a[0] * a[1], a[1] * a[2]), a[2] * a[1]);
Console.WriteLine(result);
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace ABC {
class MainClass {
public static void Main(string[] args) {
var a = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
long result = 0;
if (a[0] % 2 == 0 || a[1] % 2 == 0 || a[2] % 2 == 0)
result = 0;
else
result = Math.Min(Math.Min(a[0] * a[1], a[1] * a[2]), a[2] * a[0]);
Console.WriteLine(result);
}
}
}
|
[["-", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["+", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["-", 0, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 16, 12, 204, 206, 207, 0, 28, 0, 203]]
| 8
| 152
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static int ReadInt() { return int.Parse(Console.ReadLine()); }
static int[] ReadInts() {
return Console.ReadLine().Split().Select(int.Parse).ToArray();
}
static string[] ReadStrings() { return Console.ReadLine().Split(); }
static int Calc(int a, int b, int c) {
if (a % 2 == 1 && b % 2 == 1 && c % 2 == 1) {
var xs = new[] { a, b, c }.OrderBy(e => e).Take(2).ToArray();
return xs[0] * xs[1];
}
return 0;
}
static void Main() {
var abc = ReadInts();
int a = abc[0], b = abc[1], c = abc[2];
Console.WriteLine(Calc(a, b, c));
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static int ReadInt() { return int.Parse(Console.ReadLine()); }
static int[] ReadInts() {
return Console.ReadLine().Split().Select(int.Parse).ToArray();
}
static string[] ReadStrings() { return Console.ReadLine().Split(); }
static long Calc(long a, long b, long c) {
if (a % 2 == 1 && b % 2 == 1 && c % 2 == 1) {
var xs = new[] { a, b, c }.OrderBy(e => e).Take(2).ToArray();
return xs[0] * xs[1];
}
return 0;
}
static void Main() {
var abc = ReadInts();
int a = abc[0], b = abc[1], c = abc[2];
Console.WriteLine(Calc(a, b, c));
}
}
|
[["-", 0, 208, 0, 235, 8, 201, 0, 195, 39, 199], ["+", 0, 208, 0, 235, 8, 201, 0, 195, 39, 199], ["-", 8, 201, 0, 195, 54, 55, 0, 220, 39, 199], ["+", 8, 201, 0, 195, 54, 55, 0, 220, 39, 199]]
| 8
| 220
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AGC04_A {
class Program {
static void Main(string[] args) {
var t = scan;
long[] a = { t[0] * t[1], t[0] * t[2], t[1] * t[2] };
if (t.Any(i => i % 2 == 0))
Console.WriteLine(0);
else
Console.WriteLine(a.Min());
}
static int[] scan {
get { return Array.ConvertAll(Console.ReadLine().Split(), int.Parse); }
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AGC04_A {
class Program {
static void Main(string[] args) {
var t = scan;
long[] a = { t[0] * t[1], t[0] * t[2], t[1] * t[2] };
if (t.Any(i => i % 2 == 0))
Console.WriteLine(0);
else
Console.WriteLine(a.Min());
}
static long[] scan {
get { return Array.ConvertAll(Console.ReadLine().Split(), long.Parse); }
}
}
}
|
[["-", 0, 235, 8, 201, 0, 277, 39, 224, 39, 199], ["+", 0, 235, 8, 201, 0, 277, 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
| 152
| 4
|
using System;
using System.Linq;
class A {
static void Main() {
var n = Console.ReadLine().Split().Select(int.Parse).ToArray();
if (Array.Exists(n, (a) => { return a % 2 == 0; })) {
Console.WriteLine(0);
} else {
Array.Sort(n);
Console.WriteLine(n[0] * n[1]);
}
}
}
|
using System;
using System.Linq;
class A {
static void Main() {
var n = Console.ReadLine().Split().Select(long.Parse).ToArray();
if (Array.Exists(n, (a) => { return a % 2 == 0; })) {
Console.WriteLine(0);
} else {
Array.Sort(n);
Console.WriteLine(n[0] * n[1]);
}
}
}
|
[["-", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199]]
| 8
| 100
| 2
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace Contest {
class Program {
static void Main(string[] args) { AGC004.B(); }
class AGC004 {
public static void A() {
var A = Read.Long();
var B = Read.Long();
var C = Read.Long();
if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {
Console.WriteLine(0);
return;
}
var min = A * B;
min = Math.Min(min, A * C);
min = Math.Min(min, B * C);
Console.WriteLine(min);
}
public static void B() {
var N = Read.Int();
var X = Read.Long();
var A = Read.LongN();
long min = Int64.MaxValue;
long[] times = A.ToArray();
for (int i = 0; i < N; ++i) {
min = Math.Min(min, i * X + times.Sum());
for (int j = 0; j < N; ++j) {
times[j] = Math.Min(times[j], times[(j - i - 1 + N) % N]);
}
}
Console.WriteLine(min);
}
}
class Util {}
static class Read {
static Queue<string> queue = new Queue<string>();
static void Enqueue() {
var ss = Console.ReadLine().Split(' ');
foreach (var s in ss) {
queue.Enqueue(s);
}
}
public static int Int() {
if (queue.Count == 0) {
Enqueue();
}
return Convert.ToInt32(queue.Dequeue());
}
public static long Long() {
if (queue.Count == 0) {
Enqueue();
}
return Convert.ToInt64(queue.Dequeue());
}
public static string Str() {
if (queue.Count == 0) {
Enqueue();
}
return queue.Dequeue();
}
public static int[] IntN() {
return Console.ReadLine()
.Split(' ')
.Select(s => Convert.ToInt32(s))
.ToArray();
}
public static long[] LongN() {
return Console.ReadLine()
.Split(' ')
.Select(s => Convert.ToInt64(s))
.ToArray();
}
public static string[] StrN() { return Console.ReadLine().Split(' '); }
public static Tuple<int, int>[] TupleInt(int n) {
List<Tuple<int, int>> list = new List<Tuple<int, int>>();
for (int i = 0; i < n; ++i) {
var ab = Read.IntN();
list.Add(new Tuple<int, int>(ab[0], ab[1]));
}
return list.ToArray();
}
public static Tuple<long, long>[] TupleLong(int n) {
List<Tuple<long, long>> list = new List<Tuple<long, long>>();
for (int i = 0; i < n; ++i) {
var ab = Read.LongN();
list.Add(new Tuple<long, long>(ab[0], ab[1]));
}
return list.ToArray();
}
public static Tuple<string, string>[] TupleStr(int n) {
List<Tuple<string, string>> list = new List<Tuple<string, string>>();
for (int i = 0; i < n; ++i) {
var ab = Read.StrN();
list.Add(new Tuple<string, string>(ab[0], ab[1]));
}
return list.ToArray();
}
public static Tuple<double, double>[] TupleDouble(int n) {
List<Tuple<double, double>> list = new List<Tuple<double, double>>();
for (int i = 0; i < n; ++i) {
var ab = Read.LongN();
list.Add(new Tuple<double, double>(ab[0], ab[1]));
}
return list.ToArray();
}
public static long[,] LongMatrix(int r, int c) {
var mat = new long[r, c];
for (int i = 0; i < r; ++i) {
var x = Read.LongN();
for (int j = 0; j < c; ++j) {
mat[i, j] = x[j];
}
}
return mat;
}
public static Dictionary<int, HashSet<int>> AdjacencyList(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 = Read.IntN();
dict[ab[0]].Add(ab[1]);
dict[ab[1]].Add(ab[0]);
}
return dict;
}
public static Dictionary<int, Dictionary<int, long>>
AdjacencyListWithWeight(int N, int M) {
Dictionary<int, Dictionary<int, long>> dict =
new Dictionary<int, Dictionary<int, long>>();
for (int i = 0; i <= N; ++i) {
dict.Add(i, new Dictionary<int, long>());
}
for (int i = 0; i < M; ++i) {
var ab = Read.IntN();
dict[ab[0]].Add(ab[1], ab[2]);
dict[ab[1]].Add(ab[0], ab[2]);
}
return dict;
}
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace Contest {
class Program {
static void Main(string[] args) { AGC004.B(); }
class AGC004 {
public static void A() {
var A = Read.Long();
var B = Read.Long();
var C = Read.Long();
if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {
Console.WriteLine(0);
return;
}
var min = A * B;
min = Math.Min(min, A * C);
min = Math.Min(min, B * C);
Console.WriteLine(min);
}
public static void B() {
var N = Read.Int();
var X = Read.Long();
var A = Read.LongN();
long min = Int64.MaxValue;
long[] times = A.ToArray();
for (int i = 0; i < N; ++i) {
min = Math.Min(min, i * X + times.Sum());
for (int j = 0; j < N; ++j) {
times[j] = Math.Min(times[j], A[(j - i - 1 + N) % N]);
}
}
Console.WriteLine(min);
}
}
class Util {}
static class Read {
static Queue<string> queue = new Queue<string>();
static void Enqueue() {
var ss = Console.ReadLine().Split(' ');
foreach (var s in ss) {
queue.Enqueue(s);
}
}
public static int Int() {
if (queue.Count == 0) {
Enqueue();
}
return Convert.ToInt32(queue.Dequeue());
}
public static long Long() {
if (queue.Count == 0) {
Enqueue();
}
return Convert.ToInt64(queue.Dequeue());
}
public static string Str() {
if (queue.Count == 0) {
Enqueue();
}
return queue.Dequeue();
}
public static int[] IntN() {
return Console.ReadLine()
.Split(' ')
.Select(s => Convert.ToInt32(s))
.ToArray();
}
public static long[] LongN() {
return Console.ReadLine()
.Split(' ')
.Select(s => Convert.ToInt64(s))
.ToArray();
}
public static string[] StrN() { return Console.ReadLine().Split(' '); }
public static Tuple<int, int>[] TupleInt(int n) {
List<Tuple<int, int>> list = new List<Tuple<int, int>>();
for (int i = 0; i < n; ++i) {
var ab = Read.IntN();
list.Add(new Tuple<int, int>(ab[0], ab[1]));
}
return list.ToArray();
}
public static Tuple<long, long>[] TupleLong(int n) {
List<Tuple<long, long>> list = new List<Tuple<long, long>>();
for (int i = 0; i < n; ++i) {
var ab = Read.LongN();
list.Add(new Tuple<long, long>(ab[0], ab[1]));
}
return list.ToArray();
}
public static Tuple<string, string>[] TupleStr(int n) {
List<Tuple<string, string>> list = new List<Tuple<string, string>>();
for (int i = 0; i < n; ++i) {
var ab = Read.StrN();
list.Add(new Tuple<string, string>(ab[0], ab[1]));
}
return list.ToArray();
}
public static Tuple<double, double>[] TupleDouble(int n) {
List<Tuple<double, double>> list = new List<Tuple<double, double>>();
for (int i = 0; i < n; ++i) {
var ab = Read.LongN();
list.Add(new Tuple<double, double>(ab[0], ab[1]));
}
return list.ToArray();
}
public static long[,] LongMatrix(int r, int c) {
var mat = new long[r, c];
for (int i = 0; i < r; ++i) {
var x = Read.LongN();
for (int j = 0; j < c; ++j) {
mat[i, j] = x[j];
}
}
return mat;
}
public static Dictionary<int, HashSet<int>> AdjacencyList(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 = Read.IntN();
dict[ab[0]].Add(ab[1]);
dict[ab[1]].Add(ab[0]);
}
return dict;
}
public static Dictionary<int, Dictionary<int, long>>
AdjacencyListWithWeight(int N, int M) {
Dictionary<int, Dictionary<int, long>> dict =
new Dictionary<int, Dictionary<int, long>>();
for (int i = 0; i <= N; ++i) {
dict.Add(i, new Dictionary<int, long>());
}
for (int i = 0; i < M; ++i) {
var ab = Read.IntN();
dict[ab[0]].Add(ab[1], ab[2]);
dict[ab[1]].Add(ab[0], ab[2]);
}
return dict;
}
}
}
}
|
[["-", 12, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["+", 12, 213, 3, 4, 0, 28, 0, 204, 205, 22]]
| 8
| 1,316
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
public class Prog {
private const int INF = 1000000007;
private struct Pair {
public int x, y;
public Pair(int x, int y) {
this.x = x;
this.y = y;
}
}
public static void Solve() {
int N = NextInt();
int x = NextInt();
long[] a = LineLong();
long[] b = a.ToArray();
//全部飼う
long ans = a.Sum();
for (int k = 0; k < N; k++) {
// k回魔法唱える
long cost = k * x;
for (int i = 0; i < N; i++)
b[i] = Math.Min(b[i], a[(i - k + N) % N]);
cost += b.Sum();
ans = Math.Min(ans, cost);
}
Console.WriteLine(ans);
}
public static void Main() {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
}
public class Input {
private static Queue<string> q = new Queue<string>();
private static void Confirm() {
if (q.Count == 0)
foreach (var s in Console.ReadLine().Split(' '))
q.Enqueue(s);
}
public static int NextInt() {
Confirm();
return int.Parse(q.Dequeue());
}
public static long NextLong() {
Confirm();
return long.Parse(q.Dequeue());
}
public static char NextChar() {
Confirm();
return char.Parse(q.Dequeue());
}
public static string NextString() {
Confirm();
return q.Dequeue();
}
public static double NextDouble() {
Confirm();
return double.Parse(q.Dequeue());
}
public static int[] LineInt() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
public static long[] LineLong() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
}
public static string[] LineString() {
return Console.ReadLine().Split(' ').ToArray();
}
public static double[] LineDouble() {
return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
public class Prog {
private const int INF = 1000000007;
private struct Pair {
public int x, y;
public Pair(int x, int y) {
this.x = x;
this.y = y;
}
}
public static void Solve() {
int N = NextInt();
long x = NextLong();
long[] a = LineLong();
long[] b = a.ToArray();
//全部飼う
long ans = a.Sum();
for (int k = 0; k < N; k++) {
// k回魔法唱える
long cost = k * x;
for (int i = 0; i < N; i++)
b[i] = Math.Min(b[i], a[(i - k + N) % N]);
cost += b.Sum();
ans = Math.Min(ans, cost);
}
Console.WriteLine(ans);
}
public static void Main() {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
}
public class Input {
private static Queue<string> q = new Queue<string>();
private static void Confirm() {
if (q.Count == 0)
foreach (var s in Console.ReadLine().Split(' '))
q.Enqueue(s);
}
public static int NextInt() {
Confirm();
return int.Parse(q.Dequeue());
}
public static long NextLong() {
Confirm();
return long.Parse(q.Dequeue());
}
public static char NextChar() {
Confirm();
return char.Parse(q.Dequeue());
}
public static string NextString() {
Confirm();
return q.Dequeue();
}
public static double NextDouble() {
Confirm();
return double.Parse(q.Dequeue());
}
public static int[] LineInt() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
public static long[] LineLong() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
}
public static string[] LineString() {
return Console.ReadLine().Split(' ').ToArray();
}
public static double[] LineDouble() {
return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 198, 0, 200, 0, 212, 0, 213, 63, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 213, 63, 22]]
| 8
| 568
| 4
|
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
class P {
static void Main() {
var nx = Console.ReadLine().Split().Select(int.Parse).ToList();
int n = nx[0];
long x = nx[1];
//どっか決め打ちして二分探索!(素振り)
//増殖回数決め撃ちしそう(こなみかん
var a = Console.ReadLine().Split().Select(long.Parse).ToList();
long[][] costMin =
Enumerable.Repeat(0, n).Select(_ => new long[n]).ToArray();
costMin[0] = a.ToArray();
long min = a.Sum();
for (int i = 1; i < n; i++) {
for (int j = 0; j < n; j++)
costMin[i][(j + i) % n] =
Min(costMin[i - 1][(j + i) % n], costMin[i - 1][j]);
min = Min(min, costMin[i].Sum() + i * x);
}
Console.WriteLine(min);
}
}
|
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
class P {
static void Main() {
var nx = Console.ReadLine().Split().Select(int.Parse).ToList();
int n = nx[0];
long x = nx[1];
var a = Console.ReadLine().Split().Select(long.Parse).ToList();
long[][] costMin =
Enumerable.Repeat(0, n).Select(_ => new long[n]).ToArray();
costMin[0] = a.ToArray();
long min = a.Sum();
for (int i = 1; i < n; i++) {
for (int j = 0; j < n; j++)
costMin[i][(j + 1) % n] =
Min(costMin[i - 1][(j + 1) % n], costMin[i - 1][j]);
min = Min(min, costMin[i].Sum() + i * x);
}
Console.WriteLine(min);
}
}
|
[["-", 0, 28, 0, 16, 31, 23, 0, 16, 12, 22], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 12, 203]]
| 8
| 276
| 4
|
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
namespace AtTest.AGC_Challenge {
class _004_B {
static void Main(string[] args) {
Method(args);
Console.ReadLine();
}
static void Method(string[] args) {
int[] nx = ReadInts();
int n = nx[0];
long x = nx[1];
int[] array = ReadInts();
Array.Reverse(array);
long resTime = int.MaxValue;
var times = new long[n];
for (int i = 0; i < n; i++) {
long time = 0;
for (int j = 0; j < n; j++) {
if (i == 0)
times[j] = array[j];
else
times[j] = Math.Min(times[j], array[(j + i) % n]);
time += times[j];
}
resTime = Math.Min(resTime, time + x * i);
}
Console.WriteLine(resTime);
}
private static string Read() { return Console.ReadLine(); }
private static int ReadInt() { return int.Parse(Read()); }
private static long ReadLong() { return long.Parse(Read()); }
private static double ReadDouble() { return double.Parse(Read()); }
private static int[] ReadInts() {
return Array.ConvertAll(Read().Split(), int.Parse);
}
private static long[] ReadLongs() {
return Array.ConvertAll(Read().Split(), long.Parse);
}
private static double[] ReadDoubles() {
return Array.ConvertAll(Read().Split(), double.Parse);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
namespace AtTest.AGC_Challenge {
class _004_B {
static void Main(string[] args) {
Method(args);
Console.ReadLine();
}
static void Method(string[] args) {
int[] nx = ReadInts();
int n = nx[0];
long x = nx[1];
int[] array = ReadInts();
Array.Reverse(array);
long resTime = long.MaxValue;
var times = new long[n];
for (int i = 0; i < n; i++) {
long time = 0;
for (int j = 0; j < n; j++) {
if (i == 0)
times[j] = array[j];
else
times[j] = Math.Min(times[j], array[(j + i) % n]);
time += times[j];
}
resTime = Math.Min(resTime, time + x * i);
}
Console.WriteLine(resTime);
}
private static string Read() { return Console.ReadLine(); }
private static int ReadInt() { return int.Parse(Read()); }
private static long ReadLong() { return long.Parse(Read()); }
private static double ReadDouble() { return double.Parse(Read()); }
private static int[] ReadInts() {
return Array.ConvertAll(Read().Split(), int.Parse);
}
private static long[] ReadLongs() {
return Array.ConvertAll(Read().Split(), long.Parse);
}
private static double[] ReadDoubles() {
return Array.ConvertAll(Read().Split(), double.Parse);
}
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 214, 205, 199], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 205, 199]]
| 8
| 382
| 2
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;
public class Hello {
static public int mod = 1000000007;
public static void Main() {
string read = rstr();
int s = Min(0, read.IndexOf("S"));
int n = Min(0, read.IndexOf("N"));
int w = Min(0, read.IndexOf("W"));
int e = Min(0, read.IndexOf("E"));
if (s + n < 0 || w + e < 0) {
WriteLine("No");
} else {
WriteLine("Yes");
}
}
static int ncr(int n, int r) {
r = Min(r, n - r);
long nn = 1;
for (int i = n - r + 1; i <= n; i++) {
nn = nn * i % mod;
}
long rr = 1;
for (int i = 1; i <= r; i++) {
rr = rr * i % mod;
}
rr = square((int)rr, mod - 2);
nn = nn * rr % mod;
return (int)nn;
}
// a^b mod
static int square(int a, int b) {
string binary = Convert.ToString(b, 2);
int bileng = binary.Length;
long a_power = a;
long value = 1;
for (int i = bileng - 1; i >= 0; i--) {
if (binary[i] == '1') {
value = value * a_power % mod;
}
a_power = a_power * a_power % mod;
}
return (int)value;
}
// static int square2(long a,long b,long m){var list = new List<int>();int
// temp = 1;long n2 = a;list.Add(1);int count = 1;while(temp <
// b){list.Add((int)n2);temp*=2;count++;n2 = n2*n2%m;}long ret = 1;while(b >
// 0){if(temp <= b){b -= temp;ret =
// ret*list[count]%1000000007;}count--;temp/=2;}return(int)ret;} 各種読取
static string rstr() { return ReadLine(); }
static int rint() { return int.Parse(ReadLine()); }
static long rlong() { return long.Parse(ReadLine()); }
static string[] stra() { return ReadLine().Split(' '); }
static int[] inta() {
string[] read_str_array = ReadLine().Split(' ');
int[] return_int_array = new int[read_str_array.Length];
for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
}
return return_int_array;
}
static int[,] inta2(int num_array, int in_array) {
int[,] int_array2 = new int[num_array, in_array];
for (int i = 0; i < num_array; i++) {
int[] temp_array = inta();
for (int j = 0; j < in_array; j++) {
int_array2[i, j] = temp_array[j];
}
}
return int_array2;
}
static long[] longa() {
string[] read_str_array = ReadLine().Split(' ');
long[] return_long_array = new long[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_long_array[countup_i] = long.Parse(read_str_array[countup_i]);
}
return return_long_array;
}
static double[] doublea() {
string[] read_str_array = ReadLine().Split(' ');
double[] return_double_array = new double[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_double_array[countup_i] = long.Parse(read_str_array[countup_i]);
}
return return_double_array;
}
// -----------------------------
static long divideup(long divided, long divid) {
long temp_divide = divided / divid;
if (divided % divid > 0) {
temp_divide++;
}
return temp_divide;
}
static long GCD(long a, long b) {
if (a < b) {
long temp = a;
a = b;
b = temp;
}
if (a % b == 0) {
return b;
} else {
long temp = b;
b = a % b;
a = temp;
return GCD(a, b);
}
}
static long LCM(long a, long b) { return a * b / GCD(a, b); }
}
//知見
// (string) hogestr -> (char[]) hoge
// char hoge = hogestr.ToCharArray();
// (char[]) hoge -> (string) hogestr
// string hoge = new string(hoge);
// Hashtable × Dictionary ○
// Dictionary hoge<string,int>
// hoge.ContainsKey(string) -> return boolean
// hoge[string] -> return int
// hoge[int] -> CE
// Dictionary hoge<int1,int2>
// hoge<int1,int2>: hoge[int1] -> return int2
// KeyValuePair<int,int> k <-> k.Key == int1 / k.Value == int2
// SortedDictionary() > SortedList() ???
// キュー -> 幅優先 ???
// スタック -> 深さ優先 ???
// if (list?.Count > 0) リストが空でもnullでもない
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;
public class Hello {
static public int mod = 1000000007;
public static void Main() {
string read = rstr();
int s = Min(0, read.IndexOf("S"));
int n = Min(0, read.IndexOf("N"));
int w = Min(0, read.IndexOf("W"));
int e = Min(0, read.IndexOf("E"));
if (s + n == -1 || w + e == -1) {
WriteLine("No");
} else {
WriteLine("Yes");
}
}
static int ncr(int n, int r) {
r = Min(r, n - r);
long nn = 1;
for (int i = n - r + 1; i <= n; i++) {
nn = nn * i % mod;
}
long rr = 1;
for (int i = 1; i <= r; i++) {
rr = rr * i % mod;
}
rr = square((int)rr, mod - 2);
nn = nn * rr % mod;
return (int)nn;
}
// a^b mod
static int square(int a, int b) {
string binary = Convert.ToString(b, 2);
int bileng = binary.Length;
long a_power = a;
long value = 1;
for (int i = bileng - 1; i >= 0; i--) {
if (binary[i] == '1') {
value = value * a_power % mod;
}
a_power = a_power * a_power % mod;
}
return (int)value;
}
// static int square2(long a,long b,long m){var list = new List<int>();int
// temp = 1;long n2 = a;list.Add(1);int count = 1;while(temp <
// b){list.Add((int)n2);temp*=2;count++;n2 = n2*n2%m;}long ret = 1;while(b >
// 0){if(temp <= b){b -= temp;ret =
// ret*list[count]%1000000007;}count--;temp/=2;}return(int)ret;} 各種読取
static string rstr() { return ReadLine(); }
static int rint() { return int.Parse(ReadLine()); }
static long rlong() { return long.Parse(ReadLine()); }
static string[] stra() { return ReadLine().Split(' '); }
static int[] inta() {
string[] read_str_array = ReadLine().Split(' ');
int[] return_int_array = new int[read_str_array.Length];
for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
}
return return_int_array;
}
static int[,] inta2(int num_array, int in_array) {
int[,] int_array2 = new int[num_array, in_array];
for (int i = 0; i < num_array; i++) {
int[] temp_array = inta();
for (int j = 0; j < in_array; j++) {
int_array2[i, j] = temp_array[j];
}
}
return int_array2;
}
static long[] longa() {
string[] read_str_array = ReadLine().Split(' ');
long[] return_long_array = new long[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_long_array[countup_i] = long.Parse(read_str_array[countup_i]);
}
return return_long_array;
}
static double[] doublea() {
string[] read_str_array = ReadLine().Split(' ');
double[] return_double_array = new double[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_double_array[countup_i] = long.Parse(read_str_array[countup_i]);
}
return return_double_array;
}
// -----------------------------
static long divideup(long divided, long divid) {
long temp_divide = divided / divid;
if (divided % divid > 0) {
temp_divide++;
}
return temp_divide;
}
static long GCD(long a, long b) {
if (a < b) {
long temp = a;
a = b;
b = temp;
}
if (a % b == 0) {
return b;
} else {
long temp = b;
b = a % b;
a = temp;
return GCD(a, b);
}
}
static long LCM(long a, long b) { return a * b / GCD(a, b); }
}
//知見
// (string) hogestr -> (char[]) hoge
// char hoge = hogestr.ToCharArray();
// (char[]) hoge -> (string) hogestr
// string hoge = new string(hoge);
// Hashtable × Dictionary ○
// Dictionary hoge<string,int>
// hoge.ContainsKey(string) -> return boolean
// hoge[string] -> return int
// hoge[int] -> CE
// Dictionary hoge<int1,int2>
// hoge<int1,int2>: hoge[int1] -> return int2
// KeyValuePair<int,int> k <-> k.Key == int1 / k.Value == int2
// SortedDictionary() > SortedList() ???
// キュー -> 幅優先 ???
// スタック -> 深さ優先 ???
// if (list?.Count > 0) リストが空でもnullでもない
|
[["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 18], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 0, 57, 15, 16, 31, 16, 12, 241, 0, 33], ["+", 0, 57, 15, 16, 31, 16, 12, 241, 0, 203], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 18], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 0, 57, 15, 16, 12, 16, 12, 241, 0, 33], ["+", 0, 57, 15, 16, 12, 16, 12, 241, 0, 203]]
| 8
| 896
| 10
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
class Program {
static void Main(string[] args) {
var str = ReadLine();
if ((str.Contains('W') && str.Contains('N') && str.Contains('E') &&
str.Contains('S')) ||
(str.Contains('W') && str.Contains('E') && !str.Contains('N') &&
!str.Contains('S')) ||
(str.Contains('N') && str.Contains('S') && !str.Contains('W') &&
!str.Contains('W')))
WriteLine("Yes");
else
WriteLine("No");
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
class Program {
static void Main(string[] args) {
var str = ReadLine();
if ((str.Contains('W') && str.Contains('N') && str.Contains('E') &&
str.Contains('S')) ||
(str.Contains('W') && str.Contains('E') && !str.Contains('N') &&
!str.Contains('S')) ||
(str.Contains('N') && str.Contains('S') && !str.Contains('W') &&
!str.Contains('E')))
WriteLine("Yes");
else
WriteLine("No");
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 252, 0, 253], ["+", 0, 213, 3, 4, 0, 28, 0, 252, 0, 253]]
| 8
| 190
| 2
|
using System;
using System.Linq;
using System.Collections.Generic;
class P {
static void Main() {
string t = Console.ReadLine();
bool n = t.Contains('N');
bool e = t.Contains('E');
bool w = t.Contains('W');
bool s = t.Contains('S');
Console.WriteLine((n && s && !e && !w) || (!n && !s && e && w) ||
(n && s && e && w)
? "YES"
: "NO");
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
class P {
static void Main() {
string t = Console.ReadLine();
bool n = t.Contains('N');
bool e = t.Contains('E');
bool w = t.Contains('W');
bool s = t.Contains('S');
Console.WriteLine((n && s && !e && !w) || (!n && !s && e && w) ||
(n && s && e && w)
? "Yes"
: "No");
}
}
|
[["-", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["-", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222]]
| 8
| 130
| 4
|
using System;
using System.Text.RegularExpressions;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Numerics;
using System.Text;
namespace ConsoleApplication1 {
class Program {
static void Main(string[] args) {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
var str = Console.ReadLine();
if (((str.Count(c => c == 'E') == 0 && str.Count(c => c == 'W') == 0) ||
(str.Count(c => c == 'E') > 0 && str.Count(c => c == 'W') > 0)) &&
((str.Count(c => c == 'N') == 0 && str.Count(c => c == 'S') == 0) ||
(str.Count(c => c == 'N') > 0 && str.Count(c => c == 'S') > 0))) {
Console.WriteLine("YES");
} else {
Console.WriteLine("NO");
}
Console.Out.Flush();
}
static string ReadLine() {
StringBuilder sb = new StringBuilder();
while (true) {
int ch = Console.Read();
if (ch == -1)
break;
if (ch == '\r' || ch == '\n') {
if (ch == '\r')
Console.Read();
return sb.ToString();
}
sb.Append((char)ch);
}
if (sb.Length > 0)
return sb.ToString();
return null;
}
}
}
|
using System;
using System.Text.RegularExpressions;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Numerics;
using System.Text;
namespace ConsoleApplication1 {
class Program {
static void Main(string[] args) {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
var str = Console.ReadLine();
if (((str.Count(c => c == 'E') == 0 && str.Count(c => c == 'W') == 0) ||
(str.Count(c => c == 'E') > 0 && str.Count(c => c == 'W') > 0)) &&
((str.Count(c => c == 'N') == 0 && str.Count(c => c == 'S') == 0) ||
(str.Count(c => c == 'N') > 0 && str.Count(c => c == 'S') > 0))) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
Console.Out.Flush();
}
static string ReadLine() {
StringBuilder sb = new StringBuilder();
while (true) {
int ch = Console.Read();
if (ch == -1)
break;
if (ch == '\r' || ch == '\n') {
if (ch == '\r')
Console.Read();
return sb.ToString();
}
sb.Append((char)ch);
}
if (sb.Length > 0)
return sb.ToString();
return null;
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 354
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
// using static System.Globalization.CultureInfo;
class Program {
static void Main(string[] args) {
var num = Input.num;
var ar = Enumerable.Repeat(0, num).Select(v => Input.num).ToArray();
var res = 0L;
for (var i = 0; i < num - 1; i++) {
res += ar[i] / 2;
ar[i] %= 2;
if (ar[i] == 1 && ar[i + 1] % 2 == 1) {
res++;
ar[i + 1]--;
}
}
WriteLine(res + ar[num - 1] / 2);
}
}
public class Input {
public static string read => ReadLine();
public static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
public static int num => ToInt32(read);
public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
public static long numL => ToInt64(read);
public static int[][] twodim(int num) =>
Enumerable.Repeat(0, num).Select(v => ar).ToArray();
public static long[][] twodimL(int num) =>
Enumerable.Repeat(0, num).Select(v => arL).ToArray();
public const string Alfa = "abcdefghijklmnopqrstuvwxyz";
public const int MOD = 1000000007;
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
// using static System.Globalization.CultureInfo;
class Program {
static void Main(string[] args) {
var num = Input.num;
var ar = Enumerable.Repeat(0, num).Select(v => Input.num).ToArray();
var res = 0L;
for (var i = 0; i < num - 1; i++) {
res += ar[i] / 2;
ar[i] %= 2;
if (ar[i] == 1 && ar[i + 1] != 0) {
res++;
ar[i + 1]--;
}
}
WriteLine(res + ar[num - 1] / 2);
}
}
public class Input {
public static string read => ReadLine();
public static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
public static int num => ToInt32(read);
public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
public static long numL => ToInt64(read);
public static int[][] twodim(int num) =>
Enumerable.Repeat(0, num).Select(v => ar).ToArray();
public static long[][] twodimL(int num) =>
Enumerable.Repeat(0, num).Select(v => arL).ToArray();
public const string Alfa = "abcdefghijklmnopqrstuvwxyz";
public const int MOD = 1000000007;
}
|
[["-", 0, 57, 15, 16, 12, 16, 31, 16, 17, 109], ["-", 0, 57, 15, 16, 12, 16, 31, 16, 12, 203], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 79], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203]]
| 8
| 333
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program {
private int N;
private int[] A;
public void Solve() {
N = int.Parse(Console.ReadLine());
A = new int[N];
for (int i = 0; i < N; i++) {
A[i] = int.Parse(Console.ReadLine());
}
long ans = 0;
long sum = 0;
for (int i = 0; i < N; i++) {
if (A[i] == 0) {
ans += sum / 2;
sum = 0;
} else {
sum += A[i];
}
}
Console.WriteLine(ans);
}
static void Main() { new Program().Solve(); }
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program {
private int N;
private int[] A;
public void Solve() {
N = int.Parse(Console.ReadLine());
A = new int[N];
for (int i = 0; i < N; i++) {
A[i] = int.Parse(Console.ReadLine());
}
long ans = 0;
long sum = 0;
for (int i = 0; i < N; i++) {
if (A[i] == 0) {
ans += sum / 2;
sum = 0;
} else {
sum += A[i];
}
}
ans += sum / 2;
Console.WriteLine(ans);
}
static void Main() { new Program().Solve(); }
}
|
[["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 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, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 174
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class _C {
void _() {
var N = _Ns()[0];
long ans = 0;
long A = _Ns()[0];
for (int i = 1; i < N; i++) {
long AA = _Ns()[0];
ans += A / 2;
if (A % 2 == 1) {
if (AA >= 1) {
ans += 1;
A = AA - 1;
} else
A = AA;
} else
A = AA;
}
Console.WriteLine(ans);
}
static void Main(string[] args) { new _C()._(); }
#region
string _S() { return Console.ReadLine(); }
string[] _Ss() { return Console.ReadLine().Split(); }
int[] _N(int n) {
var x = new int[n];
for (var i = 0; i < n; i++) {
x[i] = int.Parse(Console.ReadLine());
}
return x;
}
int[] _Ns() {
var ss = Console.ReadLine().Split();
var x = new int[ss.Length];
for (var i = 0; i < ss.Length; i++)
x[i] = int.Parse(ss[i]);
return x;
}
#endregion
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class _C {
void _() {
var N = _Ns()[0];
long ans = 0;
long A = _Ns()[0];
for (int i = 1; i < N; i++) {
long AA = _Ns()[0];
ans += A / 2;
if (A % 2 == 1) {
if (AA >= 1) {
ans += 1;
A = AA - 1;
} else
A = AA;
} else
A = AA;
}
ans += A / 2;
Console.WriteLine(ans);
}
static void Main(string[] args) { new _C()._(); }
#region
string _S() { return Console.ReadLine(); }
string[] _Ss() { return Console.ReadLine().Split(); }
int[] _N(int n) {
var x = new int[n];
for (var i = 0; i < n; i++) {
x[i] = int.Parse(Console.ReadLine());
}
return x;
}
int[] _Ns() {
var ss = Console.ReadLine().Split();
var x = new int[ss.Length];
for (var i = 0; i < ss.Length; i++)
x[i] = int.Parse(ss[i]);
return x;
}
#endregion
}
|
[["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 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, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 315
| 6
|
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
// (づ°ω°)づミe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver {
public void Solve() {
int n = ReadInt();
var a = ReadAndTransposeIntMatrix(n)[0];
long ans = 0;
for (int i = 0; i < n; i++) {
ans += a[i] / 2;
if (a[i] % 2 > 0 && i < n - 1 && a[i + 1] % 2 > 0) {
ans++;
a[i + 1]--;
}
}
Write(ans);
}
#region Main
protected static TextReader reader;
protected static TextWriter writer;
static void Main() {
#if DEBUG
reader = new StreamReader("..\\..\\input.txt");
// reader = new StreamReader(Console.OpenStandardInput());
writer = Console.Out;
// writer = new StreamWriter("..\\..\\output.txt");
#else
reader = new StreamReader(Console.OpenStandardInput());
writer = new StreamWriter(Console.OpenStandardOutput());
// reader = new StreamReader("input.txt");
// writer = new StreamWriter("output.txt");
#endif
try {
new Solver().Solve();
// var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
// thread.Start();
// thread.Join();
} catch (Exception ex) {
#if DEBUG
Console.WriteLine(ex);
#else
throw;
#endif
}
reader.Close();
writer.Close();
}
#endregion
#region Read / Write
private static Queue<string> currentLineTokens = new Queue<string>();
private static string[] ReadAndSplitLine() {
return reader.ReadLine().Split(
new[] {
' ',
'\t',
},
StringSplitOptions.RemoveEmptyEntries);
}
public static string ReadToken() {
while (currentLineTokens.Count == 0)
currentLineTokens = new Queue<string>(ReadAndSplitLine());
return currentLineTokens.Dequeue();
}
public static int ReadInt() { return int.Parse(ReadToken()); }
public static long ReadLong() { return long.Parse(ReadToken()); }
public static double ReadDouble() {
return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
}
public static int[] ReadIntArray() {
return ReadAndSplitLine().Select(int.Parse).ToArray();
}
public static long[] ReadLongArray() {
return ReadAndSplitLine().Select(long.Parse).ToArray();
}
public static double[] ReadDoubleArray() {
return ReadAndSplitLine()
.Select(s => double.Parse(s, CultureInfo.InvariantCulture))
.ToArray();
}
public static int[][] ReadIntMatrix(int numberOfRows) {
int[][] matrix = new int [numberOfRows][];
for (int i = 0; i < numberOfRows; i++)
matrix[i] = ReadIntArray();
return matrix;
}
public static int[][] ReadAndTransposeIntMatrix(int numberOfRows) {
int[][] matrix = ReadIntMatrix(numberOfRows);
int[][] ret = new int[matrix[0].Length][];
for (int i = 0; i < ret.Length; i++) {
ret[i] = new int[numberOfRows];
for (int j = 0; j < numberOfRows; j++)
ret[i][j] = matrix[j][i];
}
return ret;
}
public static string[] ReadLines(int quantity) {
string[] lines = new string[quantity];
for (int i = 0; i < quantity; i++)
lines[i] = reader.ReadLine().Trim();
return lines;
}
public static void WriteArray<T>(IEnumerable<T> array) {
writer.WriteLine(string.Join(" ", array));
}
public static void Write(params object[] array) { WriteArray(array); }
public static void WriteLines<T>(IEnumerable<T> array) {
foreach (var a in array)
writer.WriteLine(a);
}
private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue> {
public new TValue this[TKey key] {
get { return ContainsKey(key) ? base[key] : default(TValue);
}
set { base[key] = value; }
}
}
private static T[] Init<T>(int size)
where T : new() {
var ret = new T[size];
for (int i = 0; i < size; i++)
ret[i] = new T();
return ret;
}
#endregion
}
|
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
// (づ°ω°)づミe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver {
public void Solve() {
int n = ReadInt();
var a = ReadAndTransposeIntMatrix(n)[0];
long ans = 0;
for (int i = 0; i < n; i++) {
ans += a[i] / 2;
if (a[i] % 2 > 0 && i < n - 1 && a[i + 1] > 0) {
ans++;
a[i + 1]--;
}
}
Write(ans);
}
#region Main
protected static TextReader reader;
protected static TextWriter writer;
static void Main() {
#if DEBUG
reader = new StreamReader("..\\..\\input.txt");
// reader = new StreamReader(Console.OpenStandardInput());
writer = Console.Out;
// writer = new StreamWriter("..\\..\\output.txt");
#else
reader = new StreamReader(Console.OpenStandardInput());
writer = new StreamWriter(Console.OpenStandardOutput());
// reader = new StreamReader("input.txt");
// writer = new StreamWriter("output.txt");
#endif
try {
new Solver().Solve();
// var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
// thread.Start();
// thread.Join();
} catch (Exception ex) {
#if DEBUG
Console.WriteLine(ex);
#else
throw;
#endif
}
reader.Close();
writer.Close();
}
#endregion
#region Read / Write
private static Queue<string> currentLineTokens = new Queue<string>();
private static string[] ReadAndSplitLine() {
return reader.ReadLine().Split(
new[] {
' ',
'\t',
},
StringSplitOptions.RemoveEmptyEntries);
}
public static string ReadToken() {
while (currentLineTokens.Count == 0)
currentLineTokens = new Queue<string>(ReadAndSplitLine());
return currentLineTokens.Dequeue();
}
public static int ReadInt() { return int.Parse(ReadToken()); }
public static long ReadLong() { return long.Parse(ReadToken()); }
public static double ReadDouble() {
return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
}
public static int[] ReadIntArray() {
return ReadAndSplitLine().Select(int.Parse).ToArray();
}
public static long[] ReadLongArray() {
return ReadAndSplitLine().Select(long.Parse).ToArray();
}
public static double[] ReadDoubleArray() {
return ReadAndSplitLine()
.Select(s => double.Parse(s, CultureInfo.InvariantCulture))
.ToArray();
}
public static int[][] ReadIntMatrix(int numberOfRows) {
int[][] matrix = new int [numberOfRows][];
for (int i = 0; i < numberOfRows; i++)
matrix[i] = ReadIntArray();
return matrix;
}
public static int[][] ReadAndTransposeIntMatrix(int numberOfRows) {
int[][] matrix = ReadIntMatrix(numberOfRows);
int[][] ret = new int[matrix[0].Length][];
for (int i = 0; i < ret.Length; i++) {
ret[i] = new int[numberOfRows];
for (int j = 0; j < numberOfRows; j++)
ret[i][j] = matrix[j][i];
}
return ret;
}
public static string[] ReadLines(int quantity) {
string[] lines = new string[quantity];
for (int i = 0; i < quantity; i++)
lines[i] = reader.ReadLine().Trim();
return lines;
}
public static void WriteArray<T>(IEnumerable<T> array) {
writer.WriteLine(string.Join(" ", array));
}
public static void Write(params object[] array) { WriteArray(array); }
public static void WriteLines<T>(IEnumerable<T> array) {
foreach (var a in array)
writer.WriteLine(a);
}
private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue> {
public new TValue this[TKey key] {
get { return ContainsKey(key) ? base[key] : default(TValue);
}
set { base[key] = value; }
}
}
private static T[] Init<T>(int size)
where T : new() {
var ret = new T[size];
for (int i = 0; i < size; i++)
ret[i] = new T();
return ret;
}
#endregion
}
|
[["-", 0, 57, 15, 16, 12, 16, 31, 16, 17, 109], ["-", 0, 57, 15, 16, 12, 16, 31, 16, 12, 203]]
| 8
| 920
| 2
|
using System;
namespace agc003_c {
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
int[] x = new int[n];
int[] a = new int[n];
for (int i = 0; i < n; i++) {
x[i] = int.Parse(Console.ReadLine());
a[i] = i;
}
Array.Sort(x, a);
int ret = 1;
for (int i = 0; i < n; i++)
if ((a[i] - i) % 2 == 1)
ret++;
Console.WriteLine(ret / 2);
}
}
}
|
using System;
namespace agc003_c {
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
int[] x = new int[n];
int[] a = new int[n];
for (int i = 0; i < n; i++) {
x[i] = int.Parse(Console.ReadLine());
a[i] = i;
}
Array.Sort(x, a);
int ret = 1;
for (int i = 0; i < n; i++)
if (Math.Abs(a[i] - i) % 2 == 1)
ret++;
Console.WriteLine(ret / 2);
}
}
}
|
[["+", 15, 16, 31, 16, 31, 213, 63, 214, 205, 22], ["+", 15, 16, 31, 16, 31, 213, 63, 214, 0, 131], ["+", 15, 16, 31, 16, 31, 213, 63, 214, 141, 22]]
| 8
| 152
| 3
|
using System;
using System.Linq;
namespace agc004_b {
class Program {
static void Main(string[] args) {
int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
int n = x[0];
long[,] time = new long[n, n];
for (int i = 0; i < n; i++) //スライム決め
{
int min = a[i];
for (int j = 0; j < n; j++) //魔法使用回数
{
min = Math.Min(min, a[(i - j + n) % n]);
time[i, j] = min;
}
}
long ret = long.MaxValue;
for (int i = 0; i < n; i++) {
long now = 0;
for (int j = 0; j < n; j++) {
now += time[j, i];
}
ret = Math.Min(ret, now + x[1] * i);
}
Console.WriteLine(ret);
}
}
}
|
using System;
using System.Linq;
namespace agc004_b {
class Program {
static void Main(string[] args) {
int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
int n = x[0];
long[,] time = new long[n, n];
for (int i = 0; i < n; i++) //スライム決め
{
int min = a[i];
for (int j = 0; j < n; j++) //魔法使用回数
{
min = Math.Min(min, a[(i - j + n) % n]);
time[i, j] = min;
}
}
long ret = long.MaxValue;
for (long i = 0; i < n; i++) {
long now = 0;
for (int j = 0; j < n; j++) {
now += time[j, i];
}
ret = Math.Min(ret, now + x[1] * i);
}
Console.WriteLine(ret);
}
}
}
|
[["-", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199]]
| 8
| 252
| 2
|
using System;
class ColorfulSlimes {
static public void Main(string[] args) {
int N, x;
string[] vals = Console.ReadLine().Split(' ');
N = int.Parse(vals[0]);
x = int.Parse(vals[1]);
vals = Console.ReadLine().Split(' ');
int[] a = new int[N + 1];
for (int i = 1; i <= N; i++)
a[i] = int.Parse(vals[i - 1]);
int[,] b = new int[N + 1, N];
for (int i = 1; i <= N; i++) {
b[i, 0] = a[i];
}
for (int i = 1; i <= N; i++) {
for (int k = 1; k <= N - 1; k++) {
int j;
if (i - k >= 1)
j = i - k;
else
j = i - k + N;
b[i, k] = Math.Min(b[i, k - 1], a[j]);
}
}
long minTime = long.MaxValue;
for (int k = 0; k <= N - 1; k++) {
long t = 0;
for (int i = 1; i <= N; i++) {
t += b[i, k];
}
t += k * x;
if (t < minTime) {
minTime = t;
}
}
Console.WriteLine(minTime);
}
}
|
using System;
class ColorfulSlimes {
static public void Main(string[] args) {
int N, x;
string[] vals = Console.ReadLine().Split(' ');
N = int.Parse(vals[0]);
x = int.Parse(vals[1]);
vals = Console.ReadLine().Split(' ');
int[] a = new int[N + 1];
for (int i = 1; i <= N; i++)
a[i] = int.Parse(vals[i - 1]);
int[,] b = new int[N + 1, N];
for (int i = 1; i <= N; i++) {
b[i, 0] = a[i];
}
for (int i = 1; i <= N; i++) {
for (int k = 1; k <= N - 1; k++) {
int j;
if (i - k >= 1)
j = i - k;
else
j = i - k + N;
b[i, k] = Math.Min(b[i, k - 1], a[j]);
}
}
long minTime = long.MaxValue;
for (int k = 0; k <= N - 1; k++) {
long t = 0;
for (int i = 1; i <= N; i++) {
t += b[i, k];
}
t += (long)k * x;
if (t < minTime) {
minTime = t;
}
}
Console.WriteLine(minTime);
}
}
|
[["+", 0, 1, 0, 11, 12, 16, 31, 74, 0, 24], ["+", 0, 1, 0, 11, 12, 16, 31, 74, 39, 199], ["+", 0, 1, 0, 11, 12, 16, 31, 74, 0, 25]]
| 8
| 335
| 3
|
using System;
class Program {
static void Main(string[] args) {
// 整数の入力
// int a = int.Parse(Console.ReadLine());
// スペース区切りの整数の入力
string[] tmp = Console.ReadLine().Split(' ');
long N = int.Parse(tmp[0]);
long x = int.Parse(tmp[1]);
string[] a = Console.ReadLine().Split(' ');
long[,] b = new long[2001, 2001];
for (int xx = 0; xx < 2001; xx++) {
for (int yy = 0; yy < 2001; yy++) {
b[xx, yy] = 0;
}
}
long t = 0;
long bl = 0;
long s = 0;
long ans = 1000000000;
for (long k = 0; k < N; k++) {
for (int i = 0; i < N; i++) {
bl = (i < k) ? 1 : 0;
t = i - k + N * bl;
// Console.WriteLine(a[t]);
if (k == 0) {
b[k, i] = int.Parse(a[t]);
} else {
b[k, i] = Math.Min(b[k - 1, i], int.Parse(a[t]));
}
}
s = 0;
for (int z = 0; z < N; z++) {
s += b[k, z];
}
ans = Math.Min(s + x * k, ans);
// Console.WriteLine(ans);
}
//出力
Console.WriteLine(ans);
}
}
|
using System;
class Program {
static void Main(string[] args) {
// 整数の入力
// int a = int.Parse(Console.ReadLine());
// スペース区切りの整数の入力
string[] tmp = Console.ReadLine().Split(' ');
long N = int.Parse(tmp[0]);
long x = int.Parse(tmp[1]);
string[] a = Console.ReadLine().Split(' ');
long[,] b = new long[2001, 2001];
for (int xx = 0; xx < 2001; xx++) {
for (int yy = 0; yy < 2001; yy++) {
b[xx, yy] = 0;
}
}
long t = 0;
long bl = 0;
long s = 0;
long ans = long.MaxValue;
for (long k = 0; k < N; k++) {
for (int i = 0; i < N; i++) {
bl = (i < k) ? 1 : 0;
t = i - k + N * bl;
// Console.WriteLine(a[t]);
if (k == 0) {
b[k, i] = int.Parse(a[t]);
} else {
b[k, i] = Math.Min(b[k - 1, i], int.Parse(a[t]));
}
}
s = 0;
for (int z = 0; z < N; z++) {
s += b[k, z];
}
ans = Math.Min(s + x * k, ans);
// Console.WriteLine(ans);
}
//出力
Console.WriteLine(ans);
}
}
|
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 205, 199], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 0, 131], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 141, 22]]
| 8
| 325
| 4
|
using System;
using System.Linq;
namespace AGC004B {
public class Program {
public static void Main(string[] args) {
var sr = new StreamReader();
//---------------------------------
var N = sr.Next<int>();
var X = sr.Next<long>();
var A = sr.Next<long>(N);
var dp = new long[N];
for (var i = 0; i < N; i++) {
dp[i] = A[i];
}
var res = long.MaxValue;
for (var k = 0; k < N; k++) {
for (var i = 0; i < N; i++) {
dp[i] = Math.Min(dp[i], dp[(i - k + N) % N]);
}
res = Math.Min(res, dp.Sum() + k * X);
}
Console.WriteLine(res);
//---------------------------------
}
}
public class StreamReader {
private readonly char[] _c = { ' ' };
private int _index = -1;
private string[] _input = new string[0];
private readonly System.IO.StreamReader _sr =
new System.IO.StreamReader(Console.OpenStandardInput());
public T Next<T>() {
if (_index == _input.Length - 1) {
_index = -1;
while (true) {
string rl = _sr.ReadLine();
if (rl == null) {
if (typeof(T).IsClass)
return default(T);
return (T) typeof(T).GetField("MinValue").GetValue(null);
}
if (rl != "") {
_input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
break;
}
}
}
return (T)Convert.ChangeType(
_input[++_index], typeof(T),
System.Globalization.CultureInfo.InvariantCulture);
}
public T[] Next<T>(int x) {
var ret = new T[x];
for (var i = 0; i < x; ++i)
ret[i] = Next<T>();
return ret;
}
public T[][] Next<T>(int y, int x) {
var ret = new T[y][];
for (var i = 0; i < y; ++i)
ret[i] = Next<T>(x);
return ret;
}
}
}
|
using System;
using System.Linq;
namespace AGC004B {
public class Program {
public static void Main(string[] args) {
var sr = new StreamReader();
//---------------------------------
var N = sr.Next<int>();
var X = sr.Next<long>();
var A = sr.Next<long>(N);
var dp = new long[N];
for (var i = 0; i < N; i++) {
dp[i] = A[i];
}
var res = long.MaxValue;
for (var k = 0; k < N; k++) {
for (var i = 0; i < N; i++) {
dp[i] = Math.Min(dp[i], A[(i - k + N) % N]);
}
res = Math.Min(res, dp.Sum() + k * X);
}
Console.WriteLine(res);
//---------------------------------
}
}
public class StreamReader {
private readonly char[] _c = { ' ' };
private int _index = -1;
private string[] _input = new string[0];
private readonly System.IO.StreamReader _sr =
new System.IO.StreamReader(Console.OpenStandardInput());
public T Next<T>() {
if (_index == _input.Length - 1) {
_index = -1;
while (true) {
string rl = _sr.ReadLine();
if (rl == null) {
if (typeof(T).IsClass)
return default(T);
return (T) typeof(T).GetField("MinValue").GetValue(null);
}
if (rl != "") {
_input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
break;
}
}
}
return (T)Convert.ChangeType(
_input[++_index], typeof(T),
System.Globalization.CultureInfo.InvariantCulture);
}
public T[] Next<T>(int x) {
var ret = new T[x];
for (var i = 0; i < x; ++i)
ret[i] = Next<T>();
return ret;
}
public T[][] Next<T>(int y, int x) {
var ret = new T[y][];
for (var i = 0; i < y; ++i)
ret[i] = Next<T>(x);
return ret;
}
}
}
|
[["-", 12, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["+", 12, 213, 3, 4, 0, 28, 0, 204, 205, 22]]
| 8
| 514
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
class Program {
const int M = 1000000007;
const double eps = 1e-9;
static int[] dd = { 0, 1, 0, -1, 0 };
static void Main() {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
var sc = new Scan();
int n, x;
sc.Multi(out n, out x);
var a = sc.IntArr;
var mina = new int [n][];
for (int i = 0; i < n; i++) {
mina[i] = new int[n];
mina[i][i] = a[i];
for (int j = i + 1; j < n; j++) {
mina[i][j] = Math.Min(mina[i][j - 1], a[j]);
}
}
long ans = long.MaxValue;
for (int i = 0; i < n; i++) {
long sum = 0;
for (int j = 0; j < n; j++) {
if (i <= j) {
sum += mina[j - i][j];
} else {
sum += Math.Min(mina[0][j], mina[n - i + j][n - 1]);
}
}
ans = Math.Min(ans, sum + x * i);
}
sw.WriteLine(ans);
sw.Flush();
}
static void swap<T>(ref T a, ref T b) {
var t = a;
a = b;
b = t;
}
static void swap<T>(IList<T> a, int i, int j) {
var t = a[i];
a[i] = a[j];
a[j] = t;
}
static T Max<T>(params T[] a) { return a.Max(); }
static T Min<T>(params T[] a) { return a.Min(); }
static void DBG<T>(params T[] a) { Console.WriteLine(string.Join(" ", a)); }
static void DBG(params object[] a) { Console.WriteLine(string.Join(" ", a)); }
static T[] copy<T>(IList<T> a) {
var ret = new T[a.Count];
for (int i = 0; i < a.Count; i++)
ret[i] = a[i];
return ret;
}
}
class Scan {
public int Int {
get { return int.Parse(Str); }
}
public long Long {
get { return long.Parse(Str); }
}
public double Double {
get { return double.Parse(Str); }
}
public string Str {
get { return Console.ReadLine().Trim(); }
}
public int[] IntArr {
get { return StrArr.Select(int.Parse).ToArray(); }
}
public int[] IntArrWithSep(char sep) {
return Str.Split(sep).Select(int.Parse).ToArray();
}
public long[] LongArr {
get { return StrArr.Select(long.Parse).ToArray(); }
}
public double[] DoubleArr {
get { return StrArr.Select(double.Parse).ToArray(); }
}
public string[] StrArr {
get { return Str.Split(); }
}
T cv<T>(string inp) {
if (typeof(T).Equals(typeof(int)))
return (T)Convert.ChangeType(int.Parse(inp), typeof(T));
if (typeof(T).Equals(typeof(long)))
return (T)Convert.ChangeType(long.Parse(inp), typeof(T));
if (typeof(T).Equals(typeof(double)))
return (T)Convert.ChangeType(double.Parse(inp), typeof(T));
if (typeof(T).Equals(typeof(char)))
return (T)Convert.ChangeType(inp[0], typeof(T));
return (T)Convert.ChangeType(inp, typeof(T));
}
public void Multi<T>(out T a) { a = cv<T>(Str); }
public void Multi<T, U>(out T a, out U b) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
public void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
public void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
}
public void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d,
out X e) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
}
}
class mymath {
static int Mod = 1000000007;
public void setMod(int m) { Mod = m; }
public bool isprime(long a) {
if (a < 2)
return false;
for (long i = 2; i * i <= a; i++)
if (a % i == 0)
return false;
return true;
}
public bool[] sieve(int n) {
var isp = new bool[n + 1];
for (int i = 2; i <= n; i++)
isp[i] = true;
for (int i = 2; i * i <= n; i++)
if (isp[i])
for (int j = i * i; j <= n; j += i)
isp[j] = false;
return isp;
}
public List<int> getprimes(int n) {
var prs = new List<int>();
var isp = sieve(n);
for (int i = 2; i <= n; i++)
if (isp[i])
prs.Add(i);
return prs;
}
public long[][] E(int n) {
var ret = new long [n][];
for (int i = 0; i < n; i++) {
ret[i] = new long[n];
ret[i][i] = 1;
}
return ret;
}
public long[][] powmat(long[][] A, long n) {
if (n == 0)
return E(A.Length);
var t = powmat(A, n / 2);
if ((n & 1) == 0)
return mulmat(t, t);
return mulmat(mulmat(t, t), A);
}
public long[] mulmat(long[][] A, long[] x) {
int n = A.Length, m = x.Length;
var ans = new long[n];
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
ans[i] = (ans[i] + x[j] * A[i][j]) % Mod;
return ans;
}
public long[][] mulmat(long[][] A, long[][] B) {
int n = A.Length, m = B[0].Length, l = B.Length;
var ans = new long [n][];
for (int i = 0; i < n; i++) {
ans[i] = new long[m];
for (int j = 0; j < m; j++)
for (int k = 0; k < l; k++)
ans[i][j] = (ans[i][j] + A[i][k] * B[k][j]) % Mod;
}
return ans;
}
public long powmod(long a, long b) {
if (a >= Mod)
return powmod(a % Mod, b);
if (a == 0)
return 0;
if (b == 0)
return 1;
var t = powmod(a, b / 2);
if ((b & 1) == 0)
return t * t % Mod;
return t * t % Mod * a % Mod;
}
public long gcd(long a, long b) {
while (b > 0) {
var t = a % b;
a = b;
b = t;
}
return a;
}
public long lcm(long a, long b) { return a * (b / gcd(a, b)); }
public long Comb(int n, int r) {
if (n < 0 || r < 0 || r > n)
return 0;
if (n - r < r)
r = n - r;
if (r == 0)
return 1;
if (r == 1)
return n;
var numerator = new int[r];
var denominator = new int[r];
for (int k = 0; k < r; k++) {
numerator[k] = n - r + k + 1;
denominator[k] = k + 1;
}
for (int p = 2; p <= r; p++) {
int pivot = denominator[p - 1];
if (pivot > 1) {
int offset = (n - r) % p;
for (int k = p - 1; k < r; k += p) {
numerator[k - offset] /= pivot;
denominator[k] /= pivot;
}
}
}
long result = 1;
for (int k = 0; k < r; k++)
if (numerator[k] > 1)
result = result * numerator[k] % Mod;
return result;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
class Program {
const int M = 1000000007;
const double eps = 1e-9;
static int[] dd = { 0, 1, 0, -1, 0 };
static void Main() {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
var sc = new Scan();
int n, x;
sc.Multi(out n, out x);
var a = sc.IntArr;
var mina = new int [n][];
for (int i = 0; i < n; i++) {
mina[i] = new int[n];
mina[i][i] = a[i];
for (int j = i + 1; j < n; j++) {
mina[i][j] = Math.Min(mina[i][j - 1], a[j]);
}
}
long ans = long.MaxValue;
for (int i = 0; i < n; i++) {
long sum = 0;
for (int j = 0; j < n; j++) {
if (i <= j) {
sum += mina[j - i][j];
} else {
sum += Math.Min(mina[0][j], mina[n - i + j][n - 1]);
}
}
ans = Math.Min(ans, sum + (long)x * i);
}
sw.WriteLine(ans);
sw.Flush();
}
static void swap<T>(ref T a, ref T b) {
var t = a;
a = b;
b = t;
}
static void swap<T>(IList<T> a, int i, int j) {
var t = a[i];
a[i] = a[j];
a[j] = t;
}
static T Max<T>(params T[] a) { return a.Max(); }
static T Min<T>(params T[] a) { return a.Min(); }
static void DBG<T>(params T[] a) { Console.WriteLine(string.Join(" ", a)); }
static void DBG(params object[] a) { Console.WriteLine(string.Join(" ", a)); }
static T[] copy<T>(IList<T> a) {
var ret = new T[a.Count];
for (int i = 0; i < a.Count; i++)
ret[i] = a[i];
return ret;
}
}
class Scan {
public int Int {
get { return int.Parse(Str); }
}
public long Long {
get { return long.Parse(Str); }
}
public double Double {
get { return double.Parse(Str); }
}
public string Str {
get { return Console.ReadLine().Trim(); }
}
public int[] IntArr {
get { return StrArr.Select(int.Parse).ToArray(); }
}
public int[] IntArrWithSep(char sep) {
return Str.Split(sep).Select(int.Parse).ToArray();
}
public long[] LongArr {
get { return StrArr.Select(long.Parse).ToArray(); }
}
public double[] DoubleArr {
get { return StrArr.Select(double.Parse).ToArray(); }
}
public string[] StrArr {
get { return Str.Split(); }
}
T cv<T>(string inp) {
if (typeof(T).Equals(typeof(int)))
return (T)Convert.ChangeType(int.Parse(inp), typeof(T));
if (typeof(T).Equals(typeof(long)))
return (T)Convert.ChangeType(long.Parse(inp), typeof(T));
if (typeof(T).Equals(typeof(double)))
return (T)Convert.ChangeType(double.Parse(inp), typeof(T));
if (typeof(T).Equals(typeof(char)))
return (T)Convert.ChangeType(inp[0], typeof(T));
return (T)Convert.ChangeType(inp, typeof(T));
}
public void Multi<T>(out T a) { a = cv<T>(Str); }
public void Multi<T, U>(out T a, out U b) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
public void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
public void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
}
public void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d,
out X e) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
}
}
class mymath {
static int Mod = 1000000007;
public void setMod(int m) { Mod = m; }
public bool isprime(long a) {
if (a < 2)
return false;
for (long i = 2; i * i <= a; i++)
if (a % i == 0)
return false;
return true;
}
public bool[] sieve(int n) {
var isp = new bool[n + 1];
for (int i = 2; i <= n; i++)
isp[i] = true;
for (int i = 2; i * i <= n; i++)
if (isp[i])
for (int j = i * i; j <= n; j += i)
isp[j] = false;
return isp;
}
public List<int> getprimes(int n) {
var prs = new List<int>();
var isp = sieve(n);
for (int i = 2; i <= n; i++)
if (isp[i])
prs.Add(i);
return prs;
}
public long[][] E(int n) {
var ret = new long [n][];
for (int i = 0; i < n; i++) {
ret[i] = new long[n];
ret[i][i] = 1;
}
return ret;
}
public long[][] powmat(long[][] A, long n) {
if (n == 0)
return E(A.Length);
var t = powmat(A, n / 2);
if ((n & 1) == 0)
return mulmat(t, t);
return mulmat(mulmat(t, t), A);
}
public long[] mulmat(long[][] A, long[] x) {
int n = A.Length, m = x.Length;
var ans = new long[n];
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
ans[i] = (ans[i] + x[j] * A[i][j]) % Mod;
return ans;
}
public long[][] mulmat(long[][] A, long[][] B) {
int n = A.Length, m = B[0].Length, l = B.Length;
var ans = new long [n][];
for (int i = 0; i < n; i++) {
ans[i] = new long[m];
for (int j = 0; j < m; j++)
for (int k = 0; k < l; k++)
ans[i][j] = (ans[i][j] + A[i][k] * B[k][j]) % Mod;
}
return ans;
}
public long powmod(long a, long b) {
if (a >= Mod)
return powmod(a % Mod, b);
if (a == 0)
return 0;
if (b == 0)
return 1;
var t = powmod(a, b / 2);
if ((b & 1) == 0)
return t * t % Mod;
return t * t % Mod * a % Mod;
}
public long gcd(long a, long b) {
while (b > 0) {
var t = a % b;
a = b;
b = t;
}
return a;
}
public long lcm(long a, long b) { return a * (b / gcd(a, b)); }
public long Comb(int n, int r) {
if (n < 0 || r < 0 || r > n)
return 0;
if (n - r < r)
r = n - r;
if (r == 0)
return 1;
if (r == 1)
return n;
var numerator = new int[r];
var denominator = new int[r];
for (int k = 0; k < r; k++) {
numerator[k] = n - r + k + 1;
denominator[k] = k + 1;
}
for (int p = 2; p <= r; p++) {
int pivot = denominator[p - 1];
if (pivot > 1) {
int offset = (n - r) % p;
for (int k = p - 1; k < r; k += p) {
numerator[k - offset] /= pivot;
denominator[k] /= pivot;
}
}
}
long result = 1;
for (int k = 0; k < r; k++)
if (numerator[k] > 1)
result = result * numerator[k] % Mod;
return result;
}
}
|
[["+", 0, 28, 0, 16, 12, 16, 31, 74, 0, 24], ["+", 0, 28, 0, 16, 12, 16, 31, 74, 39, 199], ["+", 0, 28, 0, 16, 12, 16, 31, 74, 0, 25]]
| 8
| 2,271
| 3
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class TEST {
static void Main() {
Sol mySol = new Sol();
mySol.Solve();
}
}
class Sol {
public void Solve() {
long[][] B = new long [N][];
for (int i = 0; i < N; i++)
B[i] = new long[i];
for (int i = 0; i < N; i++) {
B[i][0] = A[i];
for (int j = 1; j < N; j++) {
B[i][j] = Math.Min(B[i][j - 1], A[(i + j) % N]);
}
}
long ans = A.Sum();
for (int t = 1; t < N; t++) {
long sum = 0;
for (int i = 0; i < N; i++) {
sum += B[i][t];
}
sum += (long)t * X;
ans = Math.Min(ans, sum);
}
Console.WriteLine(ans);
}
static long dist(int f, int t) {
if (t >= f)
return (long)t - (long)f;
return (long)(N - f + t);
}
static int N, X;
long[] A;
public Sol() {
var d = ria();
N = d[0];
X = d[1];
A = rla();
}
static String rs() { return Console.ReadLine(); }
static int ri() { return int.Parse(Console.ReadLine()); }
static long rl() { return long.Parse(Console.ReadLine()); }
static double rd() { return double.Parse(Console.ReadLine()); }
static String[] rsa(char sep = ' ') { return Console.ReadLine().Split(sep); }
static int[] ria(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e));
}
static long[] rla(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e));
}
static double[] rda(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Split(sep),
e => double.Parse(e));
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class TEST {
static void Main() {
Sol mySol = new Sol();
mySol.Solve();
}
}
class Sol {
public void Solve() {
long[][] B = new long [N][];
for (int i = 0; i < N; i++)
B[i] = new long[N];
for (int i = 0; i < N; i++) {
B[i][0] = A[i];
for (int j = 1; j < N; j++) {
B[i][j] = Math.Min(B[i][j - 1], A[(i + j) % N]);
}
}
long ans = A.Sum();
for (int t = 1; t < N; t++) {
long sum = 0;
for (int i = 0; i < N; i++) {
sum += B[i][t];
}
sum += (long)t * X;
ans = Math.Min(ans, sum);
}
Console.WriteLine(ans);
}
static long dist(int f, int t) {
if (t >= f)
return (long)t - (long)f;
return (long)(N - f + t);
}
static int N, X;
long[] A;
public Sol() {
var d = ria();
N = d[0];
X = d[1];
A = rla();
}
static String rs() { return Console.ReadLine(); }
static int ri() { return int.Parse(Console.ReadLine()); }
static long rl() { return long.Parse(Console.ReadLine()); }
static double rd() { return double.Parse(Console.ReadLine()); }
static String[] rsa(char sep = ' ') { return Console.ReadLine().Split(sep); }
static int[] ria(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e));
}
static long[] rla(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e));
}
static double[] rda(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Split(sep),
e => double.Parse(e));
}
}
|
[["-", 0, 11, 12, 227, 39, 224, 225, 226, 0, 22], ["+", 0, 11, 12, 227, 39, 224, 225, 226, 0, 22]]
| 8
| 569
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace b {
class Program {
static long n;
static void Main(string[] args) {
long[] nx = Console.ReadLine().Split().Select(long.Parse).ToArray();
long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
n = nx[0];
long x = nx[1];
long[,] data = new long[n, n];
long ans = 0;
for (long i = 0; i < n; i++) {
data[0, i] = a[i];
ans += a[i];
}
for (long magic = 1; magic < n; magic++) {
long tmp = magic * x;
for (long slime = 0; slime < n; slime++) {
data[magic, slime] = Math.Min(data[magic - 1, slime],
data[magic - 1, fixNum(slime - magic)]);
tmp += data[magic, slime];
}
ans = Math.Min(ans, tmp);
}
Console.WriteLine(ans);
}
static long fixNum(long i) {
if (i < 0)
return i + n;
return i;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace b {
class Program {
static long n;
static void Main(string[] args) {
long[] nx = Console.ReadLine().Split().Select(long.Parse).ToArray();
long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
n = nx[0];
long x = nx[1];
long[,] data = new long[n, n];
long ans = 0;
for (long i = 0; i < n; i++) {
data[0, i] = a[i];
ans += a[i];
}
for (long magic = 1; magic < n; magic++) {
long tmp = magic * x;
for (long slime = 0; slime < n; slime++) {
data[magic, slime] =
Math.Min(data[magic - 1, slime], data[0, fixNum(slime - magic)]);
tmp += data[magic, slime];
}
ans = Math.Min(ans, tmp);
}
Console.WriteLine(ans);
}
static long fixNum(long i) {
if (i < 0)
return i + n;
return i;
}
}
}
|
[["-", 0, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["-", 0, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["-", 0, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 0, 28, 0, 204, 206, 207, 0, 28, 0, 203]]
| 8
| 288
| 4
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.