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;
public class Hello {
public static void Main() {
int K = int.Parse(Console.ReadLine());
char X;
int count = 0;
int abc = 0;
for (int i = 0; i < K; i++) {
X = (char)Console.Read();
if (abc == 0 && X == ('A')) {
abc++;
} else if (abc == 1 && X == ('B')) {
abc++;
} else if (abc == 2 && X == ('C')) {
count++;
abc = 0;
} else {
abc = 0;
}
}
Console.Write(count);
}
}
|
using System;
public class Hello {
public static void Main() {
int K = int.Parse(Console.ReadLine());
char X;
int count = 0;
int abc = 0;
for (int i = 0; i < K; i++) {
X = (char)Console.Read();
if (X == ('A')) {
abc = 1;
} else if (abc == 1 && X == ('B')) {
abc = 2;
} else if (abc == 2 && X == ('C')) {
count++;
abc = 0;
} else {
abc = 0;
}
}
Console.Write(count);
}
}
|
[["-", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98], ["-", 0, 57, 64, 196, 0, 1, 0, 223, 0, 29], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["-", 75, 57, 64, 196, 0, 1, 0, 223, 0, 29], ["+", 75, 57, 64, 196, 0, 1, 0, 11, 12, 203]]
| 8
| 147
| 10
|
using System;
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
string s = Console.ReadLine();
int ans = 0;
for (int i = 0; i < n - 3; i++) {
if (s.Substring(i, 3) == "ABC") {
ans++;
}
}
Console.WriteLine(ans);
}
}
|
using System;
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
string s = Console.ReadLine();
int ans = 0;
for (int i = 0; i < n - 2; i++) {
if (s.Substring(i, 3) == "ABC") {
ans++;
}
}
Console.WriteLine(ans);
Console.ReadKey();
}
}
|
[["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24]]
| 8
| 91
| 8
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
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 void Main() {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var n = Read();
var s = Console.ReadLine();
long count = 0;
for (int i = 0; i < n - 2; i++) {
if (s[i] == 'A') {
i++;
if (s[i] == 'B') {
i++;
if (s[i] == 'C')
count++;
}
}
}
Console.WriteLine(count);
Console.Out.Flush();
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
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 void Main() {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var n = Read();
var s = Console.ReadLine();
long count = 0;
for (int i = 0; i < n - 2; i++) {
if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
count++;
}
Console.WriteLine(count);
Console.Out.Flush();
}
}
|
[["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 0, 57, 64, 196, 0, 1, 0, 223, 0, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 223, 0, 29], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 98], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 17, 72], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["-", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["-", 0, 57, 64, 196, 0, 57, 64, 196, 0, 45], ["-", 64, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 64, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["-", 64, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98], ["-", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 209
| 8
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
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 void Main() {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var n = Read();
var s = Console.ReadLine();
long count = 0;
for (int i = 0; i < n - 2; i++) {
if (s[i] == 'A') {
i++;
if (s[i] == 'B') {
i++;
if (s[i] == 'C')
count++;
}
}
}
Console.WriteLine(count);
Console.Out.Flush();
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
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 void Main() {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var n = Read();
var s = Console.ReadLine();
long count = 0;
for (int i = 0; i < n - 2; i++) {
if (s[i] == 'A') {
i++;
if (s[i] == 'B') {
i++;
if (s[i] == 'C')
count++;
else
i--;
} else
i--;
}
}
Console.WriteLine(count);
Console.Out.Flush();
}
}
|
[["+", 64, 196, 0, 57, 64, 196, 0, 57, 0, 95], ["+", 64, 196, 0, 57, 75, 1, 0, 223, 0, 22], ["+", 64, 196, 0, 57, 75, 1, 0, 223, 0, 68], ["+", 0, 57, 64, 196, 0, 57, 75, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 95]]
| 8
| 209
| 8
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
// get a integer
var S = Console.ReadLine();
var N = int.Parse(Console.ReadLine());
var count = 0;
for (int i = 0; i < N; i++) {
if (i > 0 && i < N - 1 && S[i - 1] == 'A' && S[i] == 'B' &&
S[i + 1] == 'C') {
count++;
}
}
Console.Write(count);
}
}
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
// get a integer
var N = int.Parse(Console.ReadLine());
var S = Console.ReadLine();
var count = 0;
for (int i = 0; i < N; i++) {
if (i > 0 && i < (N - 1) && S[i - 1] == 'A' && S[i] == 'B' &&
S[i + 1] == 'C') {
count++;
}
}
Console.Write(count);
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["+", 31, 16, 31, 16, 12, 16, 12, 23, 0, 24], ["+", 31, 16, 31, 16, 12, 16, 12, 23, 0, 25]]
| 8
| 123
| 16
|
using System;
namespace ABC20191027 {
class Program {
static void Main(string[] args) {
string st1 = Console.ReadLine();
string st2 = Console.ReadLine();
int n = int.Parse(st1);
int count = 0;
for (int i = 0; i < n - 3; i++) {
if (st2[i] == 'A') {
if (st2[i + 1] == 'B') {
if (st2[i + 2] == 'C') {
count++;
continue;
}
continue;
}
continue;
}
}
Console.WriteLine(count);
}
}
}
|
using System;
namespace ABC20191027 {
class Program {
static void Main(string[] args) {
string st1 = Console.ReadLine();
string st2 = Console.ReadLine();
int n = int.Parse(st1);
int count = 0;
for (int i = 0; i < n - 2; i++) {
if (st2[i] == 'A') {
if (st2[i + 1] == 'B') {
if (st2[i + 2] == 'C') {
count++;
}
}
}
}
Console.WriteLine(count);
}
}
}
|
[["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["-", 64, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 64, 196, 0, 57, 64, 196, 0, 116, 0, 117], ["-", 64, 196, 0, 57, 64, 196, 0, 116, 0, 35], ["-", 8, 196, 0, 57, 64, 196, 0, 116, 0, 117], ["-", 8, 196, 0, 57, 64, 196, 0, 116, 0, 35]]
| 8
| 132
| 8
|
using System;
namespace q2 {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
string S = Console.ReadLine();
int sum = 0;
int cnt = 0;
for (int i = 0; i < N; i++) {
if (cnt == 0 && S[i] == 'A') {
cnt++;
} else if (cnt == 1 && S[i] == 'B') {
cnt++;
} else if (cnt == 2 && S[i] == 'C') {
cnt = 0;
sum++;
} else {
cnt = 0;
}
}
Console.WriteLine(sum);
}
}
}
|
using System;
namespace q2 {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
string S = Console.ReadLine();
int sum = 0;
int cnt = 0;
for (int i = 0; i < N; i++) {
if (S[i] == 'A') {
cnt = 1;
} else if (cnt == 1 && S[i] == 'B') {
cnt = 2;
} else if (cnt == 2 && S[i] == 'C') {
cnt = 0;
sum++;
} else {
cnt = 0;
}
}
Console.WriteLine(sum);
}
}
}
|
[["-", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98], ["-", 0, 57, 64, 196, 0, 1, 0, 223, 0, 29], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["-", 75, 57, 64, 196, 0, 1, 0, 223, 0, 29], ["+", 75, 57, 64, 196, 0, 1, 0, 11, 12, 203]]
| 8
| 151
| 10
|
using System;
namespace ABC150 {
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
string s = Console.ReadLine();
string word = "ABC";
int counter = 0;
int index = s.IndexOf(word);
int next;
if (index >= 0) {
while (true) {
next = index + word.Length;
if (next < s.Length) {
index = s.IndexOf(word, next);
counter++;
if (index <= next) {
break;
}
} else {
break;
}
}
}
Console.WriteLine(counter);
}
}
}
|
using System;
namespace ABC150 {
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
string s = Console.ReadLine();
string word = "ABC";
int counter = 0;
int index = s.IndexOf(word);
int next;
if (index >= 0) {
counter++;
while (true) {
next = index + word.Length;
if (next < s.Length) {
index = s.IndexOf(word, next);
if (index < next) {
break;
}
counter++;
} else {
break;
}
}
}
Console.WriteLine(counter);
}
}
}
|
[["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 29], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 0, 57, 64, 196, 0, 1, 0, 223, 0, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 223, 0, 29], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 0, 57, 64, 196, 0, 57, 15, 16, 17, 19], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 18]]
| 8
| 138
| 11
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace AtCorder {
public class Program {
static void Main(string[] args) {
var cin = new Scanner2();
int n = cin.Int();
var p = cin.ArrayInt(n);
var q = cin.ArrayInt(n);
int[] nums = Enumerable.Range(1, n).ToArray();
long count = 1;
long pi = -1;
long qi = -1;
while (pi == -1 || qi == -1) {
Permutation.Next(nums);
if (pi == -1) {
bool ok = true;
for (int i = 0; i < n; i++) {
if (p[i] != nums[i]) {
ok = false;
break;
}
}
if (ok) {
pi = count;
}
}
if (qi == -1) {
bool ok = true;
for (int i = 0; i < n; i++) {
if (q[i] != nums[i]) {
ok = false;
break;
}
}
if (ok) {
qi = count;
}
}
++count;
}
Console.WriteLine(Math.Abs(pi - qi));
}
}
static class Permutation {
public static IReadOnlyList<T[]> All<T>(IEnumerable<T> src) {
var perms = new List<T[]>();
Search(perms, new Stack<T>(), src.ToArray());
return perms;
}
public static IReadOnlyList<int[]> All(int n) {
return All<int>(Enumerable.Range(1, n));
}
public static bool Next<T>(T[] src)
where T : IComparable<T> { return Next(src, 0, src.Length); }
public static bool Next<T>(T[] src, int index, int length)
where T : IComparable<T> {
if (length <= 1) {
return false;
}
int last = index + length - 1;
int i = last;
while (true) {
int ii = i;
--i;
if (src[i].CompareTo(src[ii]) < 0) {
int j = last;
while (src[i].CompareTo(src[j]) >= 0) {
--j;
}
T temp = src[i];
src[i] = src[j];
src[j] = temp;
Array.Reverse(src, ii, last - ii + 1);
return true;
}
if (i == index) {
Array.Reverse(src, index, length);
return false;
}
}
}
public static bool Prev<T>(T[] src)
where T : IComparable<T> { return Prev(src, 0, src.Length); }
public static bool Prev<T>(T[] src, int index, int length)
where T : IComparable<T> {
if (length <= 1) {
return false;
}
int last = index + length - 1;
int i = last;
while (true) {
int ii = i;
--i;
if (src[ii].CompareTo(src[i]) < 0) {
int j = last;
while (src[j].CompareTo(src[i]) >= 0) {
--j;
}
T temp = src[i];
src[i] = src[j];
src[j] = temp;
Array.Reverse(src, ii, last - ii + 1);
return true;
}
if (i == index) {
Array.Reverse(src, index, length);
return false;
}
}
}
private static void Search<T>(List<T[]> perms, Stack<T> stack, T[] a) {
int n = a.Length;
if (n == 0) {
perms.Add(stack.Reverse().ToArray());
} else {
var b = new T[n - 1];
Array.Copy(a, 1, b, 0, n - 1);
for (int i = 0; i < a.Length; ++i) {
stack.Push(a[i]);
Search(perms, stack, b);
if (i < b.Length) {
b[i] = a[i];
}
stack.Pop();
}
}
}
}
public class Scanner2 {
private readonly char[] delimiter_ = new char[] { ' ' };
private readonly string filePath_;
private readonly Func<string> reader_;
private string[] buf_;
private int index_;
public Scanner2(string file = "") {
if (string.IsNullOrWhiteSpace(file)) {
reader_ = Console.ReadLine;
} else {
filePath_ = file;
var fs = new StreamReader(file);
reader_ = fs.ReadLine;
}
buf_ = new string[0];
index_ = 0;
}
public string Next() {
if (index_ < buf_.Length) {
return buf_[index_++];
}
string st = reader_();
while (st == "") {
st = reader_();
}
buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
if (buf_.Length == 0) {
return Next();
}
index_ = 0;
return buf_[index_++];
}
public int Int() => int.Parse(Next());
public long Long() => long.Parse(Next());
public double Double() => double.Parse(Next());
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = Int() + add;
}
return Array;
}
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = Long() + add;
}
return Array;
}
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = Double() + add;
}
return Array;
}
public void Save(string text) {
if (string.IsNullOrWhiteSpace(filePath_)) {
return;
}
File.WriteAllText(filePath_ + "_output.txt", text);
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace AtCorder {
public class Program {
static void Main(string[] args) {
var cin = new Scanner2();
int n = cin.Int();
var p = cin.ArrayInt(n);
var q = cin.ArrayInt(n);
int[] nums = Enumerable.Range(1, n).ToArray();
long count = 1;
long pi = -1;
long qi = -1;
while (pi == -1 || qi == -1) {
if (pi == -1) {
bool ok = true;
for (int i = 0; i < n; i++) {
if (p[i] != nums[i]) {
ok = false;
break;
}
}
if (ok) {
pi = count;
}
}
if (qi == -1) {
bool ok = true;
for (int i = 0; i < n; i++) {
if (q[i] != nums[i]) {
ok = false;
break;
}
}
if (ok) {
qi = count;
}
}
Permutation.Next(nums);
++count;
}
Console.WriteLine(Math.Abs(pi - qi));
}
}
static class Permutation {
public static IReadOnlyList<T[]> All<T>(IEnumerable<T> src) {
var perms = new List<T[]>();
Search(perms, new Stack<T>(), src.ToArray());
return perms;
}
public static IReadOnlyList<int[]> All(int n) {
return All<int>(Enumerable.Range(1, n));
}
public static bool Next<T>(T[] src)
where T : IComparable<T> { return Next(src, 0, src.Length); }
public static bool Next<T>(T[] src, int index, int length)
where T : IComparable<T> {
if (length <= 1) {
return false;
}
int last = index + length - 1;
int i = last;
while (true) {
int ii = i;
--i;
if (src[i].CompareTo(src[ii]) < 0) {
int j = last;
while (src[i].CompareTo(src[j]) >= 0) {
--j;
}
T temp = src[i];
src[i] = src[j];
src[j] = temp;
Array.Reverse(src, ii, last - ii + 1);
return true;
}
if (i == index) {
Array.Reverse(src, index, length);
return false;
}
}
}
public static bool Prev<T>(T[] src)
where T : IComparable<T> { return Prev(src, 0, src.Length); }
public static bool Prev<T>(T[] src, int index, int length)
where T : IComparable<T> {
if (length <= 1) {
return false;
}
int last = index + length - 1;
int i = last;
while (true) {
int ii = i;
--i;
if (src[ii].CompareTo(src[i]) < 0) {
int j = last;
while (src[j].CompareTo(src[i]) >= 0) {
--j;
}
T temp = src[i];
src[i] = src[j];
src[j] = temp;
Array.Reverse(src, ii, last - ii + 1);
return true;
}
if (i == index) {
Array.Reverse(src, index, length);
return false;
}
}
}
private static void Search<T>(List<T[]> perms, Stack<T> stack, T[] a) {
int n = a.Length;
if (n == 0) {
perms.Add(stack.Reverse().ToArray());
} else {
var b = new T[n - 1];
Array.Copy(a, 1, b, 0, n - 1);
for (int i = 0; i < a.Length; ++i) {
stack.Push(a[i]);
Search(perms, stack, b);
if (i < b.Length) {
b[i] = a[i];
}
stack.Pop();
}
}
}
}
public class Scanner2 {
private readonly char[] delimiter_ = new char[] { ' ' };
private readonly string filePath_;
private readonly Func<string> reader_;
private string[] buf_;
private int index_;
public Scanner2(string file = "") {
if (string.IsNullOrWhiteSpace(file)) {
reader_ = Console.ReadLine;
} else {
filePath_ = file;
var fs = new StreamReader(file);
reader_ = fs.ReadLine;
}
buf_ = new string[0];
index_ = 0;
}
public string Next() {
if (index_ < buf_.Length) {
return buf_[index_++];
}
string st = reader_();
while (st == "") {
st = reader_();
}
buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
if (buf_.Length == 0) {
return Next();
}
index_ = 0;
return buf_[index_++];
}
public int Int() => int.Parse(Next());
public long Long() => long.Parse(Next());
public double Double() => double.Parse(Next());
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = Int() + add;
}
return Array;
}
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = Long() + add;
}
return Array;
}
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = Double() + add;
}
return Array;
}
public void Save(string text) {
if (string.IsNullOrWhiteSpace(filePath_)) {
return;
}
File.WriteAllText(filePath_ + "_output.txt", text);
}
}
}
|
[["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35]]
| 8
| 1,411
| 14
|
using System;
using System.Collections.Generic;
namespace CSharp {
class Program {
static void Main() {
var N = int.Parse(Console.ReadLine());
var P = Console.ReadLine().Replace(" ", "");
var Q = Console.ReadLine().Replace(" ", "");
var s = string.Empty;
for (int i = 1; i < N + 1; i++) {
s += i.ToString();
}
var l = Permutation(s);
var pi = 0;
var qi = 0;
for (int i = 0; i < l.Count; i++) {
if (l[i] == P) {
pi = i;
} else if (l[i] == Q) {
qi = i;
}
}
Console.WriteLine(Math.Abs(pi - qi));
}
static List<string> Permutation(string s) {
if (s.Length == 1) {
return new List<string>() { s };
}
var result = new List<string>();
for (int i = 0; i < s.Length; i++) {
foreach (var t in Permutation(s.Remove(i, 1))) {
result.Add(s[i] + t);
}
}
return result;
}
}
}
|
using System;
using System.Collections.Generic;
namespace CSharp {
class Program {
static void Main() {
var N = int.Parse(Console.ReadLine());
var P = Console.ReadLine().Replace(" ", "");
var Q = Console.ReadLine().Replace(" ", "");
var s = string.Empty;
for (int i = 1; i < N + 1; i++) {
s += i.ToString();
}
var l = Permutation(s);
var a = 0;
var b = 0;
for (int i = 0; i < l.Count; i++) {
if (l[i] == P) {
a = i;
}
if (l[i] == Q) {
b = i;
}
}
Console.WriteLine(Math.Abs(a - b));
}
static List<string> Permutation(string s) {
if (s.Length == 1) {
return new List<string>() { s };
}
var result = new List<string>();
for (int i = 0; i < s.Length; i++) {
foreach (var t in Permutation(s.Remove(i, 1))) {
result.Add(s[i] + t);
}
}
return result;
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["-", 75, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22]]
| 8
| 288
| 13
|
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program {
const int mod = (int)1e9 + 7;
static void Main() {
Sc sc = new Sc();
var s = sc.Ia;
var a = sc.Ia;
var b = sc.Ia;
var h = new Pe<int>(1, s[0]);
int c = 0, d = 0;
for (int i = 0; i < h.cnt; i++) {
var bo = false;
for (int j = 0; j < s[0]; j++) {
if (a[j] != h.li[i][j]) {
bo = true;
break;
}
}
if (!bo) {
c = i;
continue;
}
bo = false;
for (int j = 0; j < s[0]; j++) {
if (b[j] != h.li[i][j]) {
bo = true;
break;
}
}
if (!bo) {
d = i;
continue;
}
}
Console.WriteLine("{0}", Abs(d - c));
}
}
public class Pe<T> {
public int o, n, cnt = 0;
private T[] arr, h;
private bool[] b;
public List<T[]> li;
public Pe(int u, int v) {
o = v - u + 1;
n = o;
Fu1(u);
}
public Pe(int u, int v, int x) {
o = v - u + 1;
n = x;
Fu1(u);
}
public Pe(T[] a) {
n = a.Length;
Fu2(a);
}
public Pe(T[] a, int x) {
n = x;
Fu2(a);
}
public void Fu1(int u) {
h = new T[o];
for (int i = 0; i < o; i++) {
h[i] = (T)(object)(i + u);
}
Fu();
}
public void Fu2(T[] a) {
o = a.Length;
h = new T[o];
Array.Copy(a, h, o);
Fu();
}
public void Fu() {
b = new bool[o];
arr = new T[n];
li = new List<T[]>();
Rc(0);
}
private void Rc(int a) {
for (int i = 0; i < o; i++) {
if (!b[i]) {
arr[a] = h[i];
if (a == n - 1) {
li.Add(new T[n]);
Array.Copy(arr, li[li.Count - 1], n);
cnt++;
} else {
b[i] = true;
Rc(a + 1);
b[i] = false;
}
}
}
}
}
public class Sc {
public int I {
get { return int.Parse(Console.ReadLine()); }
}
public long L {
get { return long.Parse(Console.ReadLine()); }
}
public double D {
get { return double.Parse(Console.ReadLine()); }
}
public string S {
get { return Console.ReadLine(); }
}
public int[] Ia {
get { return Array.ConvertAll(Console.ReadLine().Split(), int.Parse); }
}
public long[] La {
get { return Array.ConvertAll(Console.ReadLine().Split(), long.Parse); }
}
public double[] Da {
get { return Array.ConvertAll(Console.ReadLine().Split(), double.Parse); }
}
public string[] Sa {
get { return Console.ReadLine().Split(); }
}
public object[] Oa {
get { return Console.ReadLine().Split(); }
}
public int[] Ia2 {
get {
return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(),
int.Parse);
}
}
public int[] Ia3(int a) {
return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(),
int.Parse);
}
public int[] Ia3(bool a, int b, bool c, int d) {
return Array.ConvertAll(((a ? b.ToString() + " " : "") +
Console.ReadLine() + (c ? " " + d.ToString() : ""))
.Split(),
int.Parse);
}
public long[] La2 {
get {
return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(),
long.Parse);
}
}
public long[] La3(int a) {
return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(),
long.Parse);
}
public long[] La3(bool a, int b, bool c, int d) {
return Array.ConvertAll(((a ? b.ToString() + " " : "") +
Console.ReadLine() + (c ? " " + d.ToString() : ""))
.Split(),
long.Parse);
}
public T[] Arr<T>(int n, Func<T> f) {
var a = new T[n];
for (int i = 0; i < n; i++) {
a[i] = f();
}
return a;
}
public T[] Arr<T>(int n, Func<int, T> f) {
var a = new T[n];
for (int i = 0; i < n; i++) {
a[i] = f(i);
}
return a;
}
public T[] Arr<T>(int n, Func<string[], T> f) {
var a = new T[n];
for (int i = 0; i < n; i++) {
a[i] = f(Console.ReadLine().Split());
}
return a;
}
public T[] Arr<T>(int n, Func<int, string[], T> f) {
var a = new T[n];
for (int i = 0; i < n; i++) {
a[i] = f(i, Console.ReadLine().Split());
}
return a;
}
}
|
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program {
const int mod = (int)1e9 + 7;
static void Main() {
Sc sc = new Sc();
var s = sc.Ia;
var a = sc.Ia;
var b = sc.Ia;
var h = new Pe<int>(1, s[0]);
int c = 0, d = 0;
for (int i = 0; i < h.cnt; i++) {
var bo = false;
for (int j = 0; j < s[0]; j++) {
if (a[j] != h.li[i][j]) {
bo = true;
break;
}
}
if (!bo) {
c = i + 1;
continue;
}
bo = false;
for (int j = 0; j < s[0]; j++) {
if (b[j] != h.li[i][j]) {
bo = true;
break;
}
}
if (!bo) {
d = i + 1;
continue;
}
}
if (c == 0 || d == 0) {
Console.WriteLine(0);
return;
}
Console.WriteLine("{0}", Abs(d - c));
}
}
public class Pe<T> {
public int o, n, cnt = 0;
private T[] arr, h;
private bool[] b;
public List<T[]> li;
public Pe(int u, int v) {
o = v - u + 1;
n = o;
Fu1(u);
}
public Pe(int u, int v, int x) {
o = v - u + 1;
n = x;
Fu1(u);
}
public Pe(T[] a) {
n = a.Length;
Fu2(a);
}
public Pe(T[] a, int x) {
n = x;
Fu2(a);
}
public void Fu1(int u) {
h = new T[o];
for (int i = 0; i < o; i++) {
h[i] = (T)(object)(i + u);
}
Fu();
}
public void Fu2(T[] a) {
o = a.Length;
h = new T[o];
Array.Copy(a, h, o);
Fu();
}
public void Fu() {
b = new bool[o];
arr = new T[n];
li = new List<T[]>();
Rc(0);
}
private void Rc(int a) {
for (int i = 0; i < o; i++) {
if (!b[i]) {
arr[a] = h[i];
if (a == n - 1) {
li.Add(new T[n]);
Array.Copy(arr, li[li.Count - 1], n);
cnt++;
} else {
b[i] = true;
Rc(a + 1);
b[i] = false;
}
}
}
}
}
public class Sc {
public int I {
get { return int.Parse(Console.ReadLine()); }
}
public long L {
get { return long.Parse(Console.ReadLine()); }
}
public double D {
get { return double.Parse(Console.ReadLine()); }
}
public string S {
get { return Console.ReadLine(); }
}
public int[] Ia {
get { return Array.ConvertAll(Console.ReadLine().Split(), int.Parse); }
}
public long[] La {
get { return Array.ConvertAll(Console.ReadLine().Split(), long.Parse); }
}
public double[] Da {
get { return Array.ConvertAll(Console.ReadLine().Split(), double.Parse); }
}
public string[] Sa {
get { return Console.ReadLine().Split(); }
}
public object[] Oa {
get { return Console.ReadLine().Split(); }
}
public int[] Ia2 {
get {
return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(),
int.Parse);
}
}
public int[] Ia3(int a) {
return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(),
int.Parse);
}
public int[] Ia3(bool a, int b, bool c, int d) {
return Array.ConvertAll(((a ? b.ToString() + " " : "") +
Console.ReadLine() + (c ? " " + d.ToString() : ""))
.Split(),
int.Parse);
}
public long[] La2 {
get {
return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(),
long.Parse);
}
}
public long[] La3(int a) {
return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(),
long.Parse);
}
public long[] La3(bool a, int b, bool c, int d) {
return Array.ConvertAll(((a ? b.ToString() + " " : "") +
Console.ReadLine() + (c ? " " + d.ToString() : ""))
.Split(),
long.Parse);
}
public T[] Arr<T>(int n, Func<T> f) {
var a = new T[n];
for (int i = 0; i < n; i++) {
a[i] = f();
}
return a;
}
public T[] Arr<T>(int n, Func<int, T> f) {
var a = new T[n];
for (int i = 0; i < n; i++) {
a[i] = f(i);
}
return a;
}
public T[] Arr<T>(int n, Func<string[], T> f) {
var a = new T[n];
for (int i = 0; i < n; i++) {
a[i] = f(Console.ReadLine().Split());
}
return a;
}
public T[] Arr<T>(int n, Func<int, string[], T> f) {
var a = new T[n];
for (int i = 0; i < n; i++) {
a[i] = f(i, Console.ReadLine().Split());
}
return a;
}
}
|
[["+", 64, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35]]
| 8
| 1,467
| 25
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
var S = cin.ReadLine;
var T = cin.ReadLine;
var a = T + S;
WriteLine(a);
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
var line = cin.ReadLine;
string[] a = line.Split(" ");
var w = a[1] + a[0];
WriteLine(w);
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 0, 197, 0, 198, 39, 224, 225, 226, 0, 70], ["+", 0, 197, 0, 198, 39, 224, 225, 226, 0, 73], ["-", 0, 198, 0, 200, 0, 212, 0, 214, 205, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["-", 0, 198, 0, 200, 0, 212, 0, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["+", 0, 200, 0, 212, 0, 16, 31, 204, 205, 22], ["+", 0, 212, 0, 16, 31, 204, 206, 207, 0, 70], ["+", 0, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 212, 0, 16, 31, 204, 206, 207, 0, 73], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["+", 0, 200, 0, 212, 0, 16, 12, 204, 205, 22], ["+", 0, 212, 0, 16, 12, 204, 206, 207, 0, 70], ["+", 0, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 212, 0, 16, 12, 204, 206, 207, 0, 73], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 450
| 31
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program {
static void Main(string[] args) {
List<string> input = Console.ReadLine().Split(' ').ToList();
StringBuilder s = new StringBuilder();
s.Append(input[0]);
s.Append(input[1]);
Console.WriteLine(s);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
StringBuilder s = new StringBuilder();
s.Append(input[1]);
s.Append(input[0]);
Console.WriteLine(s);
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 39, 236, 141, 22], ["-", 0, 197, 0, 198, 39, 236, 237, 238, 0, 18], ["-", 0, 197, 0, 198, 39, 236, 237, 238, 0, 47], ["+", 0, 197, 0, 198, 39, 224, 225, 226, 0, 70], ["+", 0, 197, 0, 198, 39, 224, 225, 226, 0, 73], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["-", 0, 28, 0, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 28, 0, 204, 206, 207, 0, 28, 0, 203]]
| 8
| 93
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program {
static void Main(string[] args) {
List<string> input = Console.ReadLine().Split(' ').ToList();
StringBuilder s = new StringBuilder();
s.Append(input[0]);
s.Append(input[1]);
Console.WriteLine(s);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program {
static void Main(string[] args) {
List<string> input = Console.ReadLine().Split(' ').ToList();
StringBuilder s = new StringBuilder();
s.Append(input[1]);
s.Append(input[0]);
Console.WriteLine(s);
}
}
|
[["-", 0, 28, 0, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 28, 0, 204, 206, 207, 0, 28, 0, 203]]
| 8
| 93
| 4
|
using System;
namespace Otoshidama {
class Program {
static void Main(string[] args) {
// var exStdIn = new System.IO.StreamReader("stdin.txt");
// System.Console.SetIn(exStdIn);
var input = Console.ReadLine();
var S = int.Parse(input.Split(' ')[0]);
var T = int.Parse(input.Split(' ')[1]);
Console.WriteLine(T + S);
// bool found = false;
// for (int num10000 = 0; num10000 <= N; num10000++)
// {
// for(int num5000 = 0; num5000 <= (N-num10000); num5000++)
// {
// int num1000 = N - num10000 - num5000;
// if (num10000 * 10000 + num5000 * 5000 + num1000 * 1000 == Y)
// {
// Console.WriteLine(num10000 + " " + num5000 + " " +
// num1000); found = true; goto FOR_LOOP;
// }
// }
// }
// FOR_LOOP:;
// if (!found) Console.WriteLine("-1 -1 -1");
}
}
}
|
using System;
namespace Otoshidama {
class Program {
static void Main(string[] args) {
// var exStdIn = new System.IO.StreamReader("stdin.txt");
// System.Console.SetIn(exStdIn);
var input = Console.ReadLine();
var S = input.Split(' ')[0];
var T = input.Split(' ')[1];
Console.WriteLine(T + S);
// bool found = false;
// for (int num10000 = 0; num10000 <= N; num10000++)
// {
// for(int num5000 = 0; num5000 <= (N-num10000); num5000++)
// {
// int num1000 = N - num10000 - num5000;
// if (num10000 * 10000 + num5000 * 5000 + num1000 * 1000 == Y)
// {
// Console.WriteLine(num10000 + " " + num5000 + " " +
// num1000); found = true; goto FOR_LOOP;
// }
// }
// }
// FOR_LOOP:;
// if (!found) Console.WriteLine("-1 -1 -1");
}
}
}
|
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25]]
| 8
| 97
| 10
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC149 {
class Program {
static void Main(string[] args) { a(); }
public static void a() {
string[] st = Console.ReadLine().Split(' ');
string ans = "";
ans += st[0];
ans += st[1];
Console.WriteLine(ans);
}
public static void b() {
long[] abk =
Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
long a = abk[0], b = abk[1], k = abk[2];
long a1 = a;
a -= k;
if (a < 0) {
a = 0;
}
k -= a1;
if (k < 0) {
k = 0;
}
b -= k;
if (b < 0) {
b = 0;
}
Console.WriteLine("{0} {1}", a, b);
}
public static void c() {
long x = long.Parse(Console.ReadLine());
long ans = x;
while (true) {
if (x != ans) {
break;
} else {
x++;
}
}
Console.WriteLine(ans);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC149 {
class Program {
static void Main(string[] args) { a(); }
public static void a() {
string[] st = Console.ReadLine().Split(' ');
string ans = "";
ans += st[1];
ans += st[0];
Console.WriteLine(ans);
}
public static void b() {
long[] abk =
Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
long a = abk[0], b = abk[1], k = abk[2];
long a1 = a;
a -= k;
if (a < 0) {
a = 0;
}
k -= a1;
if (k < 0) {
k = 0;
}
b -= k;
if (b < 0) {
b = 0;
}
Console.WriteLine("{0} {1}", a, b);
}
public static void c() {
long x = long.Parse(Console.ReadLine());
long ans = x;
while (true) {
if (x % 2 == 0) {
x++;
continue;
}
if (x != ans) {
break;
} else {
x++;
}
}
Console.WriteLine(ans);
}
}
}
|
[["-", 0, 11, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 11, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 25], ["+", 0, 52, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 29], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 116, 0, 117], ["+", 8, 196, 0, 57, 64, 196, 0, 116, 0, 35], ["+", 0, 52, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 289
| 19
|
using System;
namespace Kyopuro {
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
int H = int.Parse(str[0]);
int W = int.Parse(str[1]);
string[] map = new string[H];
bool[][] isRoad = new bool [H + 2][]; //ใใใในใฏ้ใ
int[][] count = new int [H + 2][]; //ใใใในใฏในใฟใผใใใไฝใในๅฟ
่ฆใ
int countMax = 0; //ๆๅคงๅฟ
่ฆใชใใน
int finalMax = 0; //ๆ็ต็ใชๆๅคงใใน
int x, y; //ๅๆใใน
int loop; //่ฟท่ทฏใ่งฃใ็พๅจใฎๆๆฐ
bool isSomewhereExist = false; //ๆฎใฃใใในใใใใใฉใใ
int i, j;
for (i = 0; i < H; i++) {
map[i] = Console.ReadLine();
}
//ๅๆๅ
for (i = 0; i < H + 2; i++) {
isRoad[i] = new bool[W + 2];
count[i] = new int[W + 2];
for (j = 0; j < W + 2; j++) {
isRoad[i][j] = false;
count[i][j] = -1;
}
}
for (i = 1; i < H + 1; i++) {
//้ใฎๅ ดๆใ็นๅฎใใ
for (j = 0; j < W; j++) {
if (map[i - 1].Substring(j, 1) == ".") {
isRoad[i][j + 1] = true;
}
}
// isRoad[y][x]ใฏ๏ผๅบงๆจx,yใซๅฃใใใใใชใใใ็คบใใฆใใใ
}
for (y = 1; y < H + 1; y++) {
for (x = 1; x < W + 1; x++) //ๅๆๅบงๆจๆฑบๅฎใซใผใ
{
if (!isRoad[y][x]) {
continue; //ในใฟใผใใ้ใงใชใใชใๆฌกใฎใซใผใใธ
}
//ใในใฎ็ถๆ
ใ-1ใซ
for (i = 0; i < H + 2; i++) {
for (j = 0; j < W + 2; j++) {
count[i][j] = -1;
}
}
count[y][x] = 0; //ๅๆใในใฏ0
isSomewhereExist = true;
for (loop = 0; loop < 300; loop++) //ใซใผใๅๆฐ
{
if (isSomewhereExist) {
for (i = 1; i < H + 1; i++) {
for (j = 1; j < W + 1; j++) {
if (count[i][j] == loop) {
isSomewhereExist = false;
//้ฃๆฅใในใ้ใใคไปใพใง้ใฃใใใจใใชใใชใ
if (isRoad[i][j + 1] && count[i][j + 1] == -1) {
count[i][j + 1] = loop + 1;
countMax = loop + 1;
isSomewhereExist = true;
}
if (isRoad[i][j - 1] && count[i][j - 1] == -1) {
count[i][j - 1] = loop + 1;
countMax = loop + 1;
isSomewhereExist = true;
}
if (isRoad[i + 1][j] && count[i + 1][j] == -1) {
count[i + 1][j] = loop + 1;
countMax = loop + 1;
isSomewhereExist = true;
}
if (isRoad[i - 1][j] && count[i - 1][j] == -1) {
count[i - 1][j] = loop + 1;
countMax = loop + 1;
isSomewhereExist = true;
}
}
}
}
}
}
if (countMax > finalMax) {
finalMax = countMax;
}
}
}
Console.WriteLine(finalMax);
}
}
}
|
using System;
namespace Kyopuro {
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
int H = int.Parse(str[0]);
int W = int.Parse(str[1]);
string[] map = new string[H];
bool[][] isRoad = new bool [H + 2][]; //ใใใในใฏ้ใ
int[][] count = new int [H + 2][]; //ใใใในใฏในใฟใผใใใไฝใในๅฟ
่ฆใ
int countMax = 0; //ๆๅคงๅฟ
่ฆใชใใน
int finalMax = 0; //ๆ็ต็ใชๆๅคงใใน
int x, y; //ๅๆใใน
int loop; //่ฟท่ทฏใ่งฃใ็พๅจใฎๆๆฐ
bool isSomewhereExist = false; //ๆฎใฃใใในใใใใใฉใใ
int i, j;
for (i = 0; i < H; i++) {
map[i] = Console.ReadLine();
}
//ๅๆๅ
for (i = 0; i < H + 2; i++) {
isRoad[i] = new bool[W + 2];
count[i] = new int[W + 2];
for (j = 0; j < W + 2; j++) {
isRoad[i][j] = false;
count[i][j] = -1;
}
}
for (i = 1; i < H + 1; i++) {
//้ใฎๅ ดๆใ็นๅฎใใ
for (j = 0; j < W; j++) {
if (map[i - 1].Substring(j, 1) == ".") {
isRoad[i][j + 1] = true;
}
}
// isRoad[y][x]ใฏ๏ผๅบงๆจx,yใซๅฃใใใใใชใใใ็คบใใฆใใใ
}
for (y = 1; y < H + 1; y++) {
for (x = 1; x < W + 1; x++) //ๅๆๅบงๆจๆฑบๅฎใซใผใ
{
if (!isRoad[y][x]) {
continue; //ในใฟใผใใ้ใงใชใใชใๆฌกใฎใซใผใใธ
}
//ใในใฎ็ถๆ
ใ-1ใซ
for (i = 0; i < H + 2; i++) {
for (j = 0; j < W + 2; j++) {
count[i][j] = -1;
}
}
count[y][x] = 0; //ๅๆใในใฏ0
for (loop = 0; loop < 300; loop++) //ใซใผใๅๆฐ
{
for (i = 1; i < H + 1; i++) {
for (j = 1; j < W + 1; j++) {
if (count[i][j] == loop) {
//้ฃๆฅใในใ้ใใคไปใพใง้ใฃใใใจใใชใใชใ
if (isRoad[i][j + 1] && count[i][j + 1] == -1) {
count[i][j + 1] = loop + 1;
countMax = loop + 1;
}
if (isRoad[i][j - 1] && count[i][j - 1] == -1) {
count[i][j - 1] = loop + 1;
countMax = loop + 1;
}
if (isRoad[i + 1][j] && count[i + 1][j] == -1) {
count[i + 1][j] = loop + 1;
countMax = loop + 1;
}
if (isRoad[i - 1][j] && count[i - 1][j] == -1) {
count[i - 1][j] = loop + 1;
countMax = loop + 1;
}
}
}
}
}
if (countMax > finalMax) {
finalMax = countMax;
}
}
}
Console.WriteLine(finalMax);
}
}
}
|
[["-", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 8, 196, 0, 1, 0, 11, 12, 211, 0, 146], ["-", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 15, 22], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 64, 196, 0, 1, 0, 11, 12, 211, 0, 147], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 64, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 64, 196, 0, 1, 0, 11, 12, 211, 0, 146], ["-", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 732
| 30
|
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atcoder {
public class Program {
private static long mod = 1000000007;
static void Main(string[] args) {
var com = new ModCombination();
var r1 = ReadSplit();
var n = r1[0].Int();
var k = r1[1].Int();
var l = new long[n];
var r2 = ReadSplit();
for (int i = 0; i < n; i++) {
l[i] = r2[i].Long();
}
Array.Sort(l);
var min = 0L;
for (int i = 0; i < n; i++) {
min += com.Combination(n - i - 1, k - 1) * l[i];
min %= mod;
}
var max = 0L;
Array.Reverse(l);
for (int i = 0; i < n; i++) {
max += com.Combination(n - i - 1, k - 1) * l[i];
max %= mod;
}
WriteRead((max - min) % mod);
}
class ModCombination {
public long _mod = 1000000007;
public int _max = 1000000;
long[] fac;
long[] finv;
long[] inv;
public ModCombination() : this(1000000007, 1000000) {}
public ModCombination(long mod, int max) {
_mod = mod;
_max = max;
fac = new long[max];
finv = new long[max];
inv = new long[max];
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < max; i++) {
fac[i] = fac[i - 1] * i % mod;
inv[i] = mod - inv[mod % i] * (mod / i) % mod;
finv[i] = finv[i - 1] * inv[i] % mod;
}
}
public long Combination(int n, int m) {
if (n < m)
return 0;
if (n < 0 || m < 0)
return 0;
return fac[n] * (finv[m] * finv[n - m] % _mod) % _mod;
}
}
public static string Read() { return Console.ReadLine(); }
public static string[] ReadSplit() { return Console.ReadLine().Split(' '); }
public static void WriteRead(object str) {
Console.WriteLine(str);
Read();
}
public static void Write(object str) { Console.WriteLine(str); }
private static bool ChangeMin<T>(ref T a, T b)
where T : IComparable {
if (a.CompareTo(b) > 0) {
a = b;
return true;
}
return false;
}
private static bool ChangekMax<T>(ref T a, T b)
where T : IComparable {
if (b.CompareTo(a) > 0) {
a = b;
return true;
}
return false;
}
}
}
public static class Extentions {
public static int Int(this object obj) { return int.Parse(obj.ToString()); }
public static long Long(this object obj) {
return long.Parse(obj.ToString());
}
public static decimal Decimal(this object obj) {
return decimal.Parse(obj.ToString());
}
public static double Double(this object obj) {
return double.Parse(obj.ToString());
}
public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key)
where T2 : struct {
T2 value;
if (d.TryGetValue(key, out value)) {
return value;
}
return new T2();
}
}
|
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atcoder {
public class Program {
private static long mod = 1000000007;
static void Main(string[] args) {
var com = new ModCombination();
var r1 = ReadSplit();
var n = r1[0].Int();
var k = r1[1].Int();
var l = new long[n];
var r2 = ReadSplit();
for (int i = 0; i < n; i++) {
l[i] = r2[i].Long();
}
Array.Sort(l);
var ans = 0L;
for (int i = 0; i < n; i++) {
ans -= (com.Combination(n - i - 1, k - 1) * l[i]) % mod;
ans %= mod;
}
Array.Reverse(l);
for (int i = 0; i < n; i++) {
ans += (com.Combination(n - i - 1, k - 1) * l[i]) % mod;
ans %= mod;
}
WriteRead((ans + mod) % mod);
}
class ModCombination {
public long _mod = 1000000007;
public int _max = 1000000;
long[] fac;
long[] finv;
long[] inv;
public ModCombination() : this(1000000007, 1000000) {}
public ModCombination(long mod, int max) {
_mod = mod;
_max = max;
fac = new long[max];
finv = new long[max];
inv = new long[max];
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < max; i++) {
fac[i] = fac[i - 1] * i % mod;
inv[i] = mod - inv[mod % i] * (mod / i) % mod;
finv[i] = finv[i - 1] * inv[i] % mod;
}
}
public long Combination(int n, int m) {
if (n < m)
return 0;
if (n < 0 || m < 0)
return 0;
return fac[n] * (finv[m] * finv[n - m] % _mod) % _mod;
}
}
public static string Read() { return Console.ReadLine(); }
public static string[] ReadSplit() { return Console.ReadLine().Split(' '); }
public static void WriteRead(object str) {
Console.WriteLine(str);
Read();
}
public static void Write(object str) { Console.WriteLine(str); }
private static bool ChangeMin<T>(ref T a, T b)
where T : IComparable {
if (a.CompareTo(b) > 0) {
a = b;
return true;
}
return false;
}
private static bool ChangekMax<T>(ref T a, T b)
where T : IComparable {
if (b.CompareTo(a) > 0) {
a = b;
return true;
}
return false;
}
}
}
public static class Extentions {
public static int Int(this object obj) { return int.Parse(obj.ToString()); }
public static long Long(this object obj) {
return long.Parse(obj.ToString());
}
public static decimal Decimal(this object obj) {
return decimal.Parse(obj.ToString());
}
public static double Double(this object obj) {
return double.Parse(obj.ToString());
}
public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key)
where T2 : struct {
T2 value;
if (d.TryGetValue(key, out value)) {
return value;
}
return new T2();
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 110], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 28, 0, 16, 31, 23, 0, 16, 31, 22], ["-", 0, 28, 0, 16, 31, 23, 0, 16, 17, 33], ["-", 0, 28, 0, 16, 31, 23, 0, 16, 12, 22], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 31, 22], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 12, 22]]
| 8
| 829
| 31
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int n = int.Parse(input[0]);
int k = int.Parse(input[1]);
List<int> A =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
A.Sort(); //ๆ้ ใซใฝใผใ
Modular sum = 0;
// long comb = CombinationL(n-1,k-1);
for (int i = 0; i < n; i++) {
if (i > k)
break;
// Console.WriteLine("n:"+(n-1)+" k:"+(k-1));
Modular comb = Modular.Ncr(n - 1 - i, k - 1);
// Max
Modular aMax = new Modular(A[n - 1 - i]) * comb;
sum = sum + aMax;
// Console.WriteLine("Max:"+A[n-1-i]+" nCr:"+(int)comb+"
// aMax:"+(int)aMax);
// Min
Modular aMin = new Modular(A[i]) * comb;
// Console.WriteLine("Min:"+A[i]+" nCr:"+(int)comb+" aMin:"+(int)aMin);
sum = sum - aMin;
}
Console.WriteLine((int)sum);
}
}
class Modular {
private const int M = 1000000007;
private long value;
public Modular(long value) { this.value = value; }
public static implicit operator Modular(long a) {
var m = a % M;
return new Modular((m < 0) ? m + M : m);
}
public static Modular operator +(Modular a, Modular b) {
return a.value + b.value;
}
public static Modular operator -(Modular a, Modular b) {
return a.value - b.value;
}
public static Modular operator *(Modular a, Modular b) {
return a.value * b.value;
}
private static Modular Pow(Modular a, int n) {
switch (n) {
case 0:
return 1;
case 1:
return a;
default:
var p = Pow(a, n / 2);
return p * p * Pow(a, n % 2);
}
}
public static Modular operator /(Modular a, Modular b) {
return a * Pow(b, M - 2);
}
private static readonly List<int> facs = new List<int> { 1 };
private static Modular Fac(int n) {
for (int i = facs.Count; i <= n; ++i) {
facs.Add((int)(Math.BigMul(facs.Last(), i) % M));
}
return facs[n];
}
public static Modular Ncr(int n, int r) {
return (n < r) ? 0 : (n == r) ? 1 : Fac(n) / (Fac(r) * Fac(n - r));
}
public static explicit operator int(Modular a) { return (int)a.value; }
}
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int n = int.Parse(input[0]);
int k = int.Parse(input[1]);
List<int> A =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
A.Sort(); //ๆ้ ใซใฝใผใ
Modular sum = 0;
// long comb = CombinationL(n-1,k-1);
for (int i = 0; i < n; i++) {
// if(i>k)break;
// Console.WriteLine("n:"+(n-1)+" k:"+(k-1));
Modular comb = Modular.Ncr(n - 1 - i, k - 1);
// Max
Modular aMax = new Modular(A[n - 1 - i]) * comb;
sum = sum + aMax;
// Console.WriteLine("Max:"+A[n-1-i]+" nCr:"+(int)comb+"
// aMax:"+(int)aMax);
// Min
Modular aMin = new Modular(A[i]) * comb;
// Console.WriteLine("Min:"+A[i]+" nCr:"+(int)comb+" aMin:"+(int)aMin);
sum = sum - aMin;
}
Console.WriteLine((int)sum);
}
}
class Modular {
private const int M = 1000000007;
private long value;
public Modular(long value) { this.value = value; }
public static implicit operator Modular(long a) {
var m = a % M;
return new Modular((m < 0) ? m + M : m);
}
public static Modular operator +(Modular a, Modular b) {
return a.value + b.value;
}
public static Modular operator -(Modular a, Modular b) {
return a.value - b.value;
}
public static Modular operator *(Modular a, Modular b) {
return a.value * b.value;
}
private static Modular Pow(Modular a, int n) {
switch (n) {
case 0:
return 1;
case 1:
return a;
default:
var p = Pow(a, n / 2);
return p * p * Pow(a, n % 2);
}
}
public static Modular operator /(Modular a, Modular b) {
return a * Pow(b, M - 2);
}
private static readonly List<int> facs = new List<int> { 1 };
private static Modular Fac(int n) {
for (int i = facs.Count; i <= n; ++i) {
facs.Add((int)(Math.BigMul(facs.Last(), i) % M));
}
return facs[n];
}
public static Modular Ncr(int n, int r) {
return (n < r) ? 0 : (n == r) ? 1 : Fac(n) / (Fac(r) * Fac(n - r));
}
public static explicit operator int(Modular a) { return (int)a.value; }
}
|
[["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["-", 0, 7, 8, 196, 0, 57, 64, 93, 0, 94], ["-", 0, 7, 8, 196, 0, 57, 64, 93, 0, 35]]
| 8
| 587
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC150 {
class Program {
static void Main(string[] args) {
int K, N;
var word = Console.ReadLine().Split(' ');
K = int.Parse(word[0]);
N = int.Parse(word[1]);
if (500 * K > N)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC150 {
class Program {
static void Main(string[] args) {
int K, N;
var word = Console.ReadLine().Split(' ');
K = int.Parse(word[0]);
N = int.Parse(word[1]);
if (500 * K >= N)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
Console.ReadKey();
}
}
}
|
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 20], ["+", 0, 57, 75, 1, 0, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 75, 1, 0, 35], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24]]
| 8
| 118
| 8
|
using System;
namespace vscode {
class Program {
static void Main(string[] args) {
int length = int.Parse(Console.ReadLine());
string testee = Console.ReadLine();
int cntAbc = matchWords(testee.ToCharArray(), "ABC".ToCharArray(), length);
Console.WriteLine(cntAbc);
}
static int matchWords(char[] testee, char[] matcher, int length) {
if (length < 3 || length > 50)
return 0;
int found = 0;
int pos = 0;
int vurpos = 0;
while (pos <= length - 1) {
if (testee[pos] == matcher[vurpos]) {
vurpos++;
if (vurpos == 3) {
found++;
vurpos = 0;
}
} else {
vurpos = 0;
}
pos++;
}
return found;
}
}
}
|
using System;
namespace vscode {
class Program {
static void Main(string[] args) {
int length = int.Parse(Console.ReadLine());
string testee = Console.ReadLine();
int cntAbc = matchWords(testee.ToCharArray(), "ABC".ToCharArray(), length);
Console.WriteLine(cntAbc);
}
static int matchWords(char[] testee, char[] matcher, int length) {
if (length < 3 || length > 50)
return 0;
int found = 0;
int pos = 0;
int vurpos = 0;
while (pos <= length - 1) {
if (testee[pos] == matcher[vurpos]) {
vurpos++;
if (vurpos == 3) {
found++;
vurpos = 0;
}
} else {
if (testee[pos] == matcher[0]) {
vurpos = 1;
} else {
vurpos = 0;
}
}
// matcher
pos++;
}
return found;
}
}
}
|
[["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 24], ["+", 75, 196, 0, 57, 15, 16, 31, 204, 205, 22], ["+", 0, 57, 15, 16, 31, 204, 206, 207, 0, 70], ["+", 15, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 57, 15, 16, 31, 204, 206, 207, 0, 73], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 17, 60], ["+", 75, 196, 0, 57, 15, 16, 12, 204, 205, 22], ["+", 0, 57, 15, 16, 12, 204, 206, 207, 0, 70], ["+", 15, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 57, 15, 16, 12, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 25], ["+", 0, 57, 75, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 75, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 57, 75, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 95], ["+", 0, 57, 75, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 57, 75, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 176
| 21
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
namespace atcoder {
class Program {
static void Main(string[] args) {
var n = int.Parse(Console.ReadLine());
var str = Console.ReadLine();
var cnt = 0;
for (var i = 0; i < n; i++) {
if (i + 2 < n && str[i] == 'A' && str[i + 1] == 'B' &&
str[i + 2] == 'C') {
cnt++;
i += 3;
}
}
Console.WriteLine(cnt);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
namespace atcoder {
class Program {
static void Main(string[] args) {
var n = int.Parse(Console.ReadLine());
var str = Console.ReadLine();
var cnt = 0;
for (var i = 0; i < n - 2; i++) {
if (str[i] == 'A' && str[i + 1] == 'B' && str[i + 2] == 'C') {
cnt++;
i += 2;
}
}
Console.WriteLine(cnt);
}
}
}
|
[["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["-", 31, 16, 31, 16, 31, 16, 31, 16, 31, 22], ["-", 31, 16, 31, 16, 31, 16, 31, 16, 17, 72], ["-", 31, 16, 31, 16, 31, 16, 31, 16, 12, 203], ["-", 15, 16, 31, 16, 31, 16, 31, 16, 17, 18], ["-", 15, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["-", 0, 57, 15, 16, 31, 16, 31, 16, 17, 98], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203]]
| 8
| 138
| 10
|
using System;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
var num = int.Parse(Console.ReadLine());
var text = Console.ReadLine();
var ans = 0;
for (var i = 0; num > i; i++) {
if ((num - i) > 3) {
if ((text[i] == 'A') && (text[i + 1] == 'B') && (text[i + 2] == 'C'))
ans++;
}
}
Console.WriteLine(ans);
}
}
}
|
using System;
using System.Collections.Generic;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
var num = int.Parse(Console.ReadLine());
var text = Console.ReadLine();
var ans = 0;
for (var i = 0; num > i; i++) {
if ((num - i) > 2) {
if ((text[i] == 'A') && (text[i + 1] == 'B') && (text[i + 2] == 'C'))
ans++;
}
}
Console.WriteLine(ans);
}
}
}
|
[["+", 36, 36, 36, 36, 0, 208, 0, 231, 0, 233], ["+", 0, 208, 0, 231, 141, 232, 234, 232, 234, 22], ["+", 0, 208, 0, 231, 141, 232, 234, 232, 0, 131], ["+", 0, 208, 0, 231, 141, 232, 234, 232, 141, 22], ["+", 36, 36, 0, 208, 0, 231, 141, 232, 0, 131], ["+", 36, 36, 0, 208, 0, 231, 141, 232, 141, 22], ["+", 36, 36, 36, 36, 0, 208, 0, 231, 0, 35], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203]]
| 8
| 127
| 9
|
using System;
using System.IO;
class Solve {
static void Main(string[] args) {
var N = int.Parse(Console.ReadLine());
var robos = new(int right, int left)[N];
for (int i = 0; i < N; i++) {
var arr = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
robos[i] = (arr[0] + arr[1], arr[0] - arr[1]);
}
Array.Sort(robos);
var answer = N;
var x = robos[0].right;
for (int i = 1; i < N - 1; i++) {
if (x > robos[i].left)
continue;
answer++;
x = robos[i].right;
}
var writer =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(writer);
Console.WriteLine(answer);
Console.Out.Flush();
}
}
|
using System;
using System.IO;
class Solve {
static void Main(string[] args) {
var N = int.Parse(Console.ReadLine());
var robos = new(int right, int left)[N];
for (int i = 0; i < N; i++) {
var arr = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
robos[i] = (arr[0] + arr[1], arr[0] - arr[1]);
}
Array.Sort(robos);
var answer = 0;
var x = int.MinValue;
for (int i = 0; i < N; i++) {
if (x > robos[i].left)
continue;
answer++;
x = robos[i].right;
}
var writer =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(writer);
Console.WriteLine(answer);
Console.Out.Flush();
}
}
|
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 200, 0, 212, 0, 214, 205, 204, 205, 22], ["-", 0, 212, 0, 214, 205, 204, 206, 207, 0, 70], ["-", 0, 214, 205, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 212, 0, 214, 205, 204, 206, 207, 0, 73], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 205, 199], ["-", 0, 198, 0, 200, 0, 212, 0, 214, 141, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 141, 22], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203]]
| 8
| 222
| 13
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;
namespace ConsoleApp2 {
class Program {
static void Main(string[] args) {
var N = long.Parse(Console.ReadLine());
// var NKMR = Console.ReadLine().Split(' ').Select(x =>
// long.Parse(x)).ToArray(); var S = Console.ReadLine();
var robot = new Tuple<long, long>[N];
for (int i = 0; i < N; i++) {
var XL =
Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
robot[i] = new Tuple<long, long>(XL[0], XL[1]);
}
Sort(robot);
var now = 0;
var ext = 0;
for (int i = 1; i < N; i++) {
if (robot[now].Item1 + robot[now].Item2 >
robot[i].Item1 - robot[i].Item2) {
ext++;
} else {
now = i;
}
}
Console.WriteLine(N - ext);
}
}
}
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;
namespace ConsoleApp2 {
class Program {
static void Main(string[] args) {
var N = long.Parse(Console.ReadLine());
// var NKMR = Console.ReadLine().Split(' ').Select(x =>
// long.Parse(x)).ToArray(); var S = Console.ReadLine();
var robot = new Tuple<long, long>[N];
for (int i = 0; i < N; i++) {
var XL =
Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
robot[i] = new Tuple<long, long>(XL[0], XL[1]);
}
Sort(robot);
var now = 0L;
var ext = 0L;
for (int i = 1; i < N; i++) {
if (robot[now].Item1 + robot[now].Item2 >
robot[i].Item1 - robot[i].Item2) {
ext++;
if (robot[now].Item1 + robot[now].Item2 >
robot[i].Item1 + robot[i].Item2) {
now = i;
}
} else {
now = i;
}
}
Console.WriteLine(N - ext);
}
}
}
|
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 15, 16, 31, 16, 31, 214, 205, 204, 205, 22], ["+", 31, 16, 31, 214, 205, 204, 206, 207, 0, 70], ["+", 31, 214, 205, 204, 206, 207, 0, 28, 0, 22], ["+", 31, 16, 31, 214, 205, 204, 206, 207, 0, 73], ["+", 0, 57, 15, 16, 31, 16, 31, 214, 0, 131], ["+", 0, 57, 15, 16, 31, 16, 31, 214, 141, 22], ["+", 64, 196, 0, 57, 15, 16, 31, 16, 17, 72], ["+", 15, 16, 31, 16, 12, 214, 205, 204, 205, 22], ["+", 31, 16, 12, 214, 205, 204, 206, 207, 0, 70], ["+", 12, 214, 205, 204, 206, 207, 0, 28, 0, 22], ["+", 31, 16, 12, 214, 205, 204, 206, 207, 0, 73], ["+", 0, 57, 15, 16, 31, 16, 12, 214, 0, 131], ["+", 0, 57, 15, 16, 31, 16, 12, 214, 141, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 47], ["+", 15, 16, 12, 16, 31, 214, 205, 204, 205, 22], ["+", 12, 16, 31, 214, 205, 204, 206, 207, 0, 70], ["+", 12, 16, 31, 214, 205, 204, 206, 207, 0, 73], ["+", 0, 57, 15, 16, 12, 16, 31, 214, 0, 131], ["+", 0, 57, 15, 16, 12, 16, 31, 214, 141, 22], ["+", 64, 196, 0, 57, 15, 16, 12, 16, 17, 72], ["+", 15, 16, 12, 16, 12, 214, 205, 204, 205, 22], ["+", 12, 16, 12, 214, 205, 204, 206, 207, 0, 70], ["+", 12, 16, 12, 214, 205, 204, 206, 207, 0, 73], ["+", 0, 57, 15, 16, 12, 16, 12, 214, 0, 131], ["+", 0, 57, 15, 16, 12, 16, 12, 214, 141, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 240
| 40
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder.Abc {
class QuestionD {
public static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
// ๆดๆฐใฎๅ
ฅๅ
int n = int.Parse(Console.ReadLine());
var leftRights = new List<int[]>();
for (int i = 0; i < n; i++) {
var intArray =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
var lr =
new int[2] { intArray[0] - intArray[1], intArray[0] + intArray[1] };
leftRights.Add(lr);
}
var robots = new List<int[]>();
leftRights.Sort((l, r) => l[0] - r[0]);
var robotsNum = 1;
var lastRobotIndex = 0;
robots.Add(leftRights[0]);
for (int i = 1; i < n; i++) {
if (leftRights[lastRobotIndex][1] > leftRights[i][0]) {
continue;
}
robotsNum++;
lastRobotIndex = i;
}
Console.WriteLine(robotsNum);
Console.Out.Flush();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder.Abc {
class QuestionD {
public static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
// ๆดๆฐใฎๅ
ฅๅ
int n = int.Parse(Console.ReadLine());
var leftRights = new List<int[]>();
for (int i = 0; i < n; i++) {
var intArray =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
var lr =
new int[2] { intArray[0] - intArray[1], intArray[0] + intArray[1] };
leftRights.Add(lr);
}
var robots = new List<int[]>();
leftRights.Sort((l, r) => l[0] - r[0]);
var robotsNum = 0;
var lastRobotIndex = 0;
robots.Add(leftRights[0]);
for (int i = 1; i < n; i++) {
if (leftRights[lastRobotIndex][1] <= leftRights[i][0]) {
lastRobotIndex = i;
} else if (leftRights[lastRobotIndex][1] < leftRights[i][1]) {
robotsNum++;
} else {
robotsNum++;
lastRobotIndex = i;
}
}
Console.WriteLine(n - robotsNum);
Console.Out.Flush();
}
}
}
|
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 19], ["-", 8, 196, 0, 57, 64, 196, 0, 116, 0, 117], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["+", 0, 7, 8, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 7, 8, 196, 0, 57, 75, 57, 0, 24], ["+", 75, 57, 15, 16, 31, 204, 205, 204, 205, 22], ["+", 15, 16, 31, 204, 205, 204, 206, 207, 0, 70], ["+", 31, 204, 205, 204, 206, 207, 0, 28, 0, 22], ["+", 15, 16, 31, 204, 205, 204, 206, 207, 0, 73], ["+", 75, 57, 15, 16, 31, 204, 206, 207, 0, 70], ["+", 15, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 75, 57, 15, 16, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 18], ["+", 75, 57, 15, 16, 12, 204, 205, 204, 205, 22], ["+", 15, 16, 12, 204, 205, 204, 206, 207, 0, 70], ["+", 12, 204, 205, 204, 206, 207, 0, 28, 0, 22], ["+", 15, 16, 12, 204, 205, 204, 206, 207, 0, 73], ["+", 75, 57, 15, 16, 12, 204, 206, 207, 0, 70], ["+", 15, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 75, 57, 15, 16, 12, 204, 206, 207, 0, 73], ["+", 0, 7, 8, 196, 0, 57, 75, 57, 0, 25], ["+", 8, 196, 0, 57, 75, 57, 64, 196, 0, 45], ["+", 75, 57, 64, 196, 0, 1, 0, 223, 0, 22], ["+", 75, 57, 64, 196, 0, 1, 0, 223, 0, 29], ["+", 0, 57, 75, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 75, 57, 64, 196, 0, 46], ["+", 0, 7, 8, 196, 0, 57, 75, 57, 0, 95], ["+", 8, 196, 0, 57, 75, 57, 75, 196, 0, 45], ["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33]]
| 8
| 305
| 37
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace AtCoder {
class Program {
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);
}
static int Solve(int N, long[][] robots) {
Array.Sort(robots, (a, b) => a[0].CompareTo(b[0]));
long R = robots[0][0] + robots[0][1];
for (int i = 1; i < N; ++i) {
if (robots[i][0] - robots[i][1] < R) {
--N;
R = Math.Min(robots[i][0] + robots[i][1], R);
} else {
R = robots[i][0] + robots[i][1];
}
}
return N;
}
static void Main(string[] args) {
int N = ReadInt();
var robots = new long [N][];
for (int i = 0; i < N; ++i) {
robots[i] = ReadLongs();
}
Console.WriteLine(Solve(N, robots));
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace AtCoder {
class Program {
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);
}
static int Solve(int N, long[][] robots) {
Array.Sort(robots, (a, b) => a[0].CompareTo(b[0]));
long R = robots[0][0] + robots[0][1];
int count = 0;
for (int i = 1; i < N; ++i) {
if (robots[i][0] - robots[i][1] < R) {
++count;
R = Math.Min(robots[i][0] + robots[i][1], R);
} else {
R = robots[i][0] + robots[i][1];
}
}
return N - count;
}
static void Main(string[] args) {
int N = ReadInt();
var robots = new long [N][];
for (int i = 0; i < N; ++i) {
robots[i] = ReadLongs();
}
Console.WriteLine(Solve(N, robots));
}
}
}
|
[["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 57, 64, 196, 0, 1, 0, 241, 0, 68], ["-", 0, 57, 64, 196, 0, 1, 0, 241, 0, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 241, 0, 29], ["+", 0, 57, 64, 196, 0, 1, 0, 241, 0, 22], ["+", 0, 195, 8, 196, 0, 37, 0, 16, 17, 33], ["+", 0, 195, 8, 196, 0, 37, 0, 16, 12, 22]]
| 8
| 403
| 11
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class MainClass {
public const long Giri = 1000000007;
public class Robot {
public long Pos { get; set; }
public long Arm { get; set; }
}
public static void Main(string[] args) {
var n = Console.ReadLine().ToInt();
var robots = new Robot[n];
for (int i = 0; i < n; i++) {
var p = Input();
var robot = new Robot() { Pos = p[0].ToLong(), Arm = p[1].ToLong() };
robots[i] = robot;
}
Array.Sort(robots, (s, t) => (int)(s.Pos - t.Pos));
long cur = 0;
long wa = 0;
for (int i = 0; i < n; i++) {
long k = robots[i].Pos - robots[i].Arm;
if (i != 0 && k < cur)
continue;
cur = robots[i].Pos + robots[i].Arm;
wa++;
}
Console.WriteLine(wa);
}
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 int Clamp(int val, int max, int min = 0) {
return Math.Min(max, Math.Max(min, val));
}
}
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) {
var r = new int[str.Length];
for (int i = 0; i < str.Length; i++)
r[i] = str[i].ToInt();
return r;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class MainClass {
public const long Giri = 1000000007;
public class Robot {
public long Pos { get; set; }
public long Arm { get; set; }
}
public static void Main(string[] args) {
var n = Console.ReadLine().ToInt();
var robots = new Robot[n];
for (int i = 0; i < n; i++) {
var p = Input();
var robot = new Robot() { Pos = p[0].ToLong(), Arm = p[1].ToLong() };
robots[i] = robot;
}
Array.Sort(robots, (s, t) => (int)(s.Pos + s.Arm - t.Pos - t.Arm));
long cur = 0;
long wa = 0;
for (int i = 0; i < n; i++) {
long k = robots[i].Pos - robots[i].Arm;
if (i != 0 && k < cur)
continue;
cur = robots[i].Pos + robots[i].Arm;
wa++;
}
Console.WriteLine(wa);
}
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 int Clamp(int val, int max, int min = 0) {
return Math.Min(max, Math.Max(min, val));
}
}
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) {
var r = new int[str.Length];
for (int i = 0; i < str.Length; i++)
r[i] = str[i].ToInt();
return r;
}
}
|
[["+", 51, 23, 0, 16, 31, 16, 31, 16, 17, 72], ["+", 0, 16, 31, 16, 31, 16, 12, 214, 205, 22], ["+", 0, 16, 31, 16, 31, 16, 12, 214, 0, 131], ["+", 0, 16, 31, 16, 31, 16, 12, 214, 141, 22], ["+", 0, 218, 8, 74, 51, 23, 0, 16, 17, 33], ["+", 8, 74, 51, 23, 0, 16, 12, 214, 205, 22], ["+", 8, 74, 51, 23, 0, 16, 12, 214, 0, 131], ["+", 8, 74, 51, 23, 0, 16, 12, 214, 141, 22]]
| 8
| 482
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;
public class B {
public static void Main() => (new Solver()).Solve();
}
public class Solver {
public void Solve() {
long N = GetLong();
long[] X = new long[N];
long[] L = new long[N];
for (long i = 0; i < N; i++) {
X[i] = GetLong();
L[i] = GetLong();
}
var range = new List<Tuple<long, long>>();
for (long i = 0; i < N; i++)
range.Add(Tuple.Create(X[i] - L[i], X[i] + L[i]));
range.Sort((a, b) => b.Item2 != a.Item2 ? b.Item2.CompareTo(a.Item2)
: b.Item1.CompareTo(a.Item1));
long ans = 1;
long head = range[0].Item1;
for (long i = 1; i < N; i++) {
if (range[(int)i].Item2 > head)
continue;
head = range[(int)i].Item1;
ans++;
}
WriteLine(ans);
}
}
public static class MyIO {
private static string[] args = null;
private static int num = -1;
private static int used = -1;
private static string getArg() {
if (used == num) {
args = Console.ReadLine().Split(' ');
num = args.Length;
used = 0;
}
return args[used++];
}
public static int GetInt() => int.Parse(getArg());
public static long GetLong() => long.Parse(getArg());
public static double GetDouble() => double.Parse(getArg());
public static decimal GetDecimal() => decimal.Parse(getArg());
public static string GetString() => getArg();
public static char GetChar() => getArg()[0];
public static int[] GetInts(long N) =>
Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
public static long[] GetLongs(long N) =>
Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
public static double[] GetDoubles(long N) =>
Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
public static decimal[] GetDecimals(long N) =>
Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
public static string[] GetStrings(long N) =>
Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}
public static class MyUtil {
public static void chmax<T>(ref T x, T y)
where T : IComparable<T> {
if (x.CompareTo(y) < 0)
x = y;
}
public static void chmin<T>(ref T x, T y)
where T : IComparable<T> {
if (x.CompareTo(y) > 0)
x = y;
}
public static void swap<T>(ref T x, ref T y) {
T tmp = x;
x = y;
y = tmp;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;
public class B {
public static void Main() => (new Solver()).Solve();
}
public class Solver {
public void Solve() {
long N = GetLong();
long[] X = new long[N];
long[] L = new long[N];
for (long i = 0; i < N; i++) {
X[i] = GetLong();
L[i] = GetLong();
}
var range = new List<Tuple<long, long>>();
for (long i = 0; i < N; i++)
range.Add(Tuple.Create(X[i] - L[i], X[i] + L[i]));
range.Sort((a, b) => a.Item2 != b.Item2 ? a.Item2.CompareTo(b.Item2)
: a.Item1.CompareTo(b.Item1));
long ans = 1;
long tail = range[0].Item2;
for (long i = 1; i < N; i++) {
if (range[(int)i].Item1 < tail)
continue;
tail = range[(int)i].Item2;
ans++;
}
WriteLine(ans);
}
}
public static class MyIO {
private static string[] args = null;
private static int num = -1;
private static int used = -1;
private static string getArg() {
if (used == num) {
args = Console.ReadLine().Split(' ');
num = args.Length;
used = 0;
}
return args[used++];
}
public static int GetInt() => int.Parse(getArg());
public static long GetLong() => long.Parse(getArg());
public static double GetDouble() => double.Parse(getArg());
public static decimal GetDecimal() => decimal.Parse(getArg());
public static string GetString() => getArg();
public static char GetChar() => getArg()[0];
public static int[] GetInts(long N) =>
Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
public static long[] GetLongs(long N) =>
Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
public static double[] GetDoubles(long N) =>
Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
public static decimal[] GetDecimals(long N) =>
Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
public static string[] GetStrings(long N) =>
Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}
public static class MyUtil {
public static void chmax<T>(ref T x, T y)
where T : IComparable<T> {
if (x.CompareTo(y) < 0)
x = y;
}
public static void chmin<T>(ref T x, T y)
where T : IComparable<T> {
if (x.CompareTo(y) > 0)
x = y;
}
public static void swap<T>(ref T x, ref T y) {
T tmp = x;
x = y;
y = tmp;
}
}
|
[["-", 0, 218, 8, 41, 15, 16, 31, 214, 205, 22], ["+", 0, 218, 8, 41, 15, 16, 31, 214, 205, 22], ["-", 0, 218, 8, 41, 15, 16, 12, 214, 205, 22], ["+", 0, 218, 8, 41, 15, 16, 12, 214, 205, 22], ["-", 8, 41, 64, 213, 63, 214, 205, 214, 205, 22], ["+", 8, 41, 64, 213, 63, 214, 205, 214, 205, 22], ["-", 64, 213, 3, 4, 0, 28, 0, 214, 205, 22], ["+", 64, 213, 3, 4, 0, 28, 0, 214, 205, 22], ["-", 8, 41, 75, 213, 63, 214, 205, 214, 205, 22], ["+", 8, 41, 75, 213, 63, 214, 205, 214, 205, 22], ["-", 75, 213, 3, 4, 0, 28, 0, 214, 205, 22], ["+", 75, 213, 3, 4, 0, 28, 0, 214, 205, 22], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 198, 0, 200, 0, 212, 0, 214, 141, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 141, 22], ["-", 8, 196, 0, 57, 15, 16, 31, 214, 141, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 141, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22], ["-", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 12, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 214, 141, 22]]
| 8
| 776
| 26
|
using System;
namespace abc151A {
class MainClass {
public static void Main(string[] args) {
string A = Console.ReadLine();
switch (A) {
case "a":
Console.WriteLine("b");
break;
case "b":
Console.WriteLine("c");
break;
case "c":
Console.WriteLine("d");
break;
case "e":
Console.WriteLine("f");
break;
case "f":
Console.WriteLine("g");
break;
case "g":
Console.WriteLine("h");
break;
case "h":
Console.WriteLine("i");
break;
case "i":
Console.WriteLine("j");
break;
case "j":
Console.WriteLine("k");
break;
case "k":
Console.WriteLine("l");
break;
case "l":
Console.WriteLine("m");
break;
case "m":
Console.WriteLine("n");
break;
case "n":
Console.WriteLine("o");
break;
case "o":
Console.WriteLine("p");
break;
case "p":
Console.WriteLine("q");
break;
case "q":
Console.WriteLine("r");
break;
case "r":
Console.WriteLine("s");
break;
case "s":
Console.WriteLine("t");
break;
case "t":
Console.WriteLine("u");
break;
case "u":
Console.WriteLine("v");
break;
case "v":
Console.WriteLine("w");
break;
case "w":
Console.WriteLine("x");
break;
case "x":
Console.WriteLine("y");
break;
case "y":
Console.WriteLine("z");
break;
}
}
}
}
|
using System;
namespace abc151A {
class MainClass {
public static void Main(string[] args) {
string A = Console.ReadLine();
switch (A) {
case "a":
Console.WriteLine("b");
break;
case "b":
Console.WriteLine("c");
break;
case "c":
Console.WriteLine("d");
break;
case "d":
Console.WriteLine("e");
break;
case "e":
Console.WriteLine("f");
break;
case "f":
Console.WriteLine("g");
break;
case "g":
Console.WriteLine("h");
break;
case "h":
Console.WriteLine("i");
break;
case "i":
Console.WriteLine("j");
break;
case "j":
Console.WriteLine("k");
break;
case "k":
Console.WriteLine("l");
break;
case "l":
Console.WriteLine("m");
break;
case "m":
Console.WriteLine("n");
break;
case "n":
Console.WriteLine("o");
break;
case "o":
Console.WriteLine("p");
break;
case "p":
Console.WriteLine("q");
break;
case "q":
Console.WriteLine("r");
break;
case "r":
Console.WriteLine("s");
break;
case "s":
Console.WriteLine("t");
break;
case "t":
Console.WriteLine("u");
break;
case "u":
Console.WriteLine("v");
break;
case "v":
Console.WriteLine("w");
break;
case "w":
Console.WriteLine("x");
break;
case "x":
Console.WriteLine("y");
break;
case "y":
Console.WriteLine("z");
break;
}
}
}
}
|
[["+", 8, 254, 0, 239, 0, 264, 0, 5, 0, 222], ["+", 8, 254, 0, 239, 0, 264, 0, 5, 0, 62], ["+", 0, 99, 8, 254, 0, 239, 0, 264, 0, 102], ["+", 0, 239, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 0, 239, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 0, 239, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 0, 239, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 239, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 0, 99, 8, 254, 0, 239, 0, 1, 0, 35], ["+", 0, 99, 8, 254, 0, 239, 0, 93, 0, 94], ["+", 0, 99, 8, 254, 0, 239, 0, 93, 0, 35], ["+", 0, 99, 8, 254, 0, 239, 0, 264, 0, 173]]
| 8
| 422
| 16
|
using System;
namespace ConsoleApp6 {
class Program {
static void Main(string[] args) {
string n;
n = Console.ReadLine();
if (n == "a")
Console.WriteLine("b");
if (n == "b")
Console.WriteLine("c");
if (n == "c")
Console.WriteLine("d");
if (n == "d")
Console.WriteLine("e");
if (n == "f")
Console.WriteLine("f");
if (n == "g")
Console.WriteLine("g");
if (n == "h")
Console.WriteLine("h");
if (n == "i")
Console.WriteLine("i");
if (n == "j")
Console.WriteLine("j");
if (n == "k")
Console.WriteLine("k");
if (n == "l")
Console.WriteLine("l");
if (n == "m")
Console.WriteLine("m");
if (n == "n")
Console.WriteLine("n");
if (n == "o")
Console.WriteLine("o");
if (n == "p")
Console.WriteLine("p");
if (n == "q")
Console.WriteLine("q");
if (n == "r")
Console.WriteLine("r");
if (n == "s")
Console.WriteLine("s");
if (n == "t")
Console.WriteLine("t");
if (n == "u")
Console.WriteLine("u");
if (n == "v")
Console.WriteLine("v");
if (n == "w")
Console.WriteLine("w");
if (n == "x")
Console.WriteLine("x");
if (n == "y")
Console.WriteLine("y");
if (n == "e")
Console.WriteLine("f");
}
}
}
|
using System;
namespace ConsoleApp6 {
class Program {
static void Main(string[] args) {
string n;
n = Console.ReadLine();
if (n == "a")
Console.WriteLine("b");
if (n == "b")
Console.WriteLine("c");
if (n == "c")
Console.WriteLine("d");
if (n == "d")
Console.WriteLine("e");
if (n == "f")
Console.WriteLine("g");
if (n == "g")
Console.WriteLine("h");
if (n == "h")
Console.WriteLine("i");
if (n == "i")
Console.WriteLine("j");
if (n == "j")
Console.WriteLine("k");
if (n == "k")
Console.WriteLine("l");
if (n == "l")
Console.WriteLine("m");
if (n == "m")
Console.WriteLine("n");
if (n == "n")
Console.WriteLine("o");
if (n == "o")
Console.WriteLine("p");
if (n == "p")
Console.WriteLine("q");
if (n == "q")
Console.WriteLine("r");
if (n == "r")
Console.WriteLine("s");
if (n == "s")
Console.WriteLine("t");
if (n == "t")
Console.WriteLine("u");
if (n == "u")
Console.WriteLine("v");
if (n == "v")
Console.WriteLine("w");
if (n == "w")
Console.WriteLine("x");
if (n == "x")
Console.WriteLine("y");
if (n == "y")
Console.WriteLine("z");
if (n == "e")
Console.WriteLine("f");
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 458
| 40
|
/*********************************************
* c# template
*20.06.13 AtCoder Beginner Contest 151. C, D (c#)
*********************************************/
namespace TempName {
using System;
using System.Linq;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using static System.Console;
using static IOmacro._CSharpInput;
using static IOmacro._CppInput;
public class _CRun {
public readonly int PROBLEM_NUM = 1;
/*********************************************
20.06.13 AtCoder Beginner Contest 151. C - Welcome to AtCoder
Nๅใฎๅ้กใใใ
Mๅใฎๆๅบใงใๆญฃ่งฃๆฐใจใใใซใใฃใฏ๏ผ
test input :
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
*********************************************/
public void solve1() {
int numProb = cin;
int numQry = cin;
var arrCntWA = new int[numProb + 1];
int cntAC = 0;
int cntWA = 0;
while (numQry-- > 0) {
int inNum = cin;
string inStr = cin;
if (arrCntWA[inNum] < -1) {
continue;
} else if (inStr == "AC") {
cntAC += 1;
cntWA += arrCntWA[inNum];
} else {
arrCntWA[inNum] += 1;
}
}
WriteLine($"{cntAC} {cntWA}");
}
/*********************************************
20.06.13 AtCoder Beginner Contest 151. D - Maze Master
ๅฃใจ้่ทฏใๅญๅจใใ๏ผๆฌกๅ
ใฎ่ฟท่ทฏใใใใ
ๅบ็บ็นใจๅฐ็็นใไปปๆ่จญๅฎใงใใใจใใ
ๆๅคง็งปๅ่ท้ขใฏ๏ผ
*********************************************/
public void solve2() {}
/*********************************************
*********************************************/
public void solve3() {}
/*********************************************
*********************************************/
public void solve4() {}
/*********************************************
*********************************************/
public void solve5() {}
/*********************************************
*********************************************/
public void solve6() {}
}
class Program {
static void Main() {
var run = new _CRun();
switch (run.PROBLEM_NUM) {
case 1:
run.solve1();
break;
case 2:
run.solve2();
break;
case 3:
run.solve3();
break;
case 4:
run.solve4();
break;
case 5:
run.solve5();
break;
case 6:
run.solve6();
break;
}
}
}
}
namespace IOmacro {
// 20.05.10. ์์
using System;
using System.Linq;
using System.IO;
using System.Collections.Generic;
public class _CSharpInput {
public static StreamWriter _writer =
new StreamWriter(Console.OpenStandardOutput());
public const char separator = ' ';
public static string _string {
get { return Console.ReadLine(); }
}
public static string[] _stringa {
get { return (Console.ReadLine().Split(separator)); }
}
public static int _int {
get { return int.Parse(Console.ReadLine()); }
}
public static int[] _inta {
get {
return Console.ReadLine().Split(separator).Select(int.Parse).ToArray();
}
}
public static long _long {
get { return long.Parse(Console.ReadLine()); }
}
public static long[] _longa {
get {
return Console.ReadLine().Split(separator).Select(long.Parse).ToArray();
}
}
public static double _double {
get { return double.Parse(Console.ReadLine()); }
}
public static double[] _doublea {
get {
return Console.ReadLine().Split(separator).Select(double.Parse).ToArray();
}
}
}
public class _CppInput {
public static _CppInput cin => new _CppInput();
public const char separator = ' ';
private static readonly Queue<string> _input = new Queue<string>();
private _CppInput() {}
public static implicit operator string(_CppInput _) {
if (_input.Count == 0)
Console.ReadLine().Split(separator).foreachExtension(
x => _input.Enqueue(x));
return _input.Dequeue();
}
public static implicit operator int(_CppInput _) {
if (_input.Count == 0)
Console.ReadLine().Split(separator).foreachExtension(
x => _input.Enqueue(x));
return int.Parse(_input.Dequeue());
}
public static implicit operator long(_CppInput _) {
if (_input.Count == 0)
Console.ReadLine().Split(separator).foreachExtension(
x => _input.Enqueue(x));
return long.Parse(_input.Dequeue());
}
public static implicit operator double(_CppInput _) {
if (_input.Count == 0)
Console.ReadLine().Split(separator).foreachExtension(
x => _input.Enqueue(x));
return double.Parse(_input.Dequeue());
}
}
public static class _CEnumerableExtension {
public delegate void Function<in T>(T val);
public static void foreachExtension<T>(this IEnumerable<T> enumerable,
Function<T> function) {
foreach (var x in enumerable)
function(x);
}
}
}
|
/*********************************************
* c# template
*20.06.13 AtCoder Beginner Contest 151. C, D (c#)
*********************************************/
namespace TempName {
using System;
using System.Linq;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using static System.Console;
using static IOmacro._CSharpInput;
using static IOmacro._CppInput;
public class _CRun {
public readonly int PROBLEM_NUM = 1;
/*********************************************
20.06.13 AtCoder Beginner Contest 151. C - Welcome to AtCoder
Nๅใฎๅ้กใใใ
Mๅใฎๆๅบใงใๆญฃ่งฃๆฐใจใใใซใใฃใฏ๏ผ
test input :
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
*********************************************/
public void solve1() {
int numProb = cin;
int numQry = cin;
var arrCntWA = new int[numProb + 1];
int cntAC = 0;
int cntWA = 0;
while (numQry-- > 0) {
int inNum = cin;
string inStr = cin;
if (arrCntWA[inNum] == -1) {
continue;
} else if (inStr == "AC") {
cntAC += 1;
cntWA += arrCntWA[inNum];
arrCntWA[inNum] = -1;
} else {
arrCntWA[inNum] += 1;
}
}
WriteLine($"{cntAC} {cntWA}");
}
/*********************************************
20.06.13 AtCoder Beginner Contest 151. D - Maze Master
ๅฃใจ้่ทฏใๅญๅจใใ๏ผๆฌกๅ
ใฎ่ฟท่ทฏใใใใ
ๅบ็บ็นใจๅฐ็็นใไปปๆ่จญๅฎใงใใใจใใ
ๆๅคง็งปๅ่ท้ขใฏ๏ผ
*********************************************/
public void solve2() {}
/*********************************************
*********************************************/
public void solve3() {}
/*********************************************
*********************************************/
public void solve4() {}
/*********************************************
*********************************************/
public void solve5() {}
/*********************************************
*********************************************/
public void solve6() {}
}
class Program {
static void Main() {
var run = new _CRun();
switch (run.PROBLEM_NUM) {
case 1:
run.solve1();
break;
case 2:
run.solve2();
break;
case 3:
run.solve3();
break;
case 4:
run.solve4();
break;
case 5:
run.solve5();
break;
case 6:
run.solve6();
break;
}
}
}
}
namespace IOmacro {
// 20.05.10. ์์
using System;
using System.Linq;
using System.IO;
using System.Collections.Generic;
public class _CSharpInput {
public static StreamWriter _writer =
new StreamWriter(Console.OpenStandardOutput());
public const char separator = ' ';
public static string _string {
get { return Console.ReadLine(); }
}
public static string[] _stringa {
get { return (Console.ReadLine().Split(separator)); }
}
public static int _int {
get { return int.Parse(Console.ReadLine()); }
}
public static int[] _inta {
get {
return Console.ReadLine().Split(separator).Select(int.Parse).ToArray();
}
}
public static long _long {
get { return long.Parse(Console.ReadLine()); }
}
public static long[] _longa {
get {
return Console.ReadLine().Split(separator).Select(long.Parse).ToArray();
}
}
public static double _double {
get { return double.Parse(Console.ReadLine()); }
}
public static double[] _doublea {
get {
return Console.ReadLine().Split(separator).Select(double.Parse).ToArray();
}
}
}
public class _CppInput {
public static _CppInput cin => new _CppInput();
public const char separator = ' ';
private static readonly Queue<string> _input = new Queue<string>();
private _CppInput() {}
public static implicit operator string(_CppInput _) {
if (_input.Count == 0)
Console.ReadLine().Split(separator).foreachExtension(
x => _input.Enqueue(x));
return _input.Dequeue();
}
public static implicit operator int(_CppInput _) {
if (_input.Count == 0)
Console.ReadLine().Split(separator).foreachExtension(
x => _input.Enqueue(x));
return int.Parse(_input.Dequeue());
}
public static implicit operator long(_CppInput _) {
if (_input.Count == 0)
Console.ReadLine().Split(separator).foreachExtension(
x => _input.Enqueue(x));
return long.Parse(_input.Dequeue());
}
public static implicit operator double(_CppInput _) {
if (_input.Count == 0)
Console.ReadLine().Split(separator).foreachExtension(
x => _input.Enqueue(x));
return double.Parse(_input.Dequeue());
}
}
public static class _CEnumerableExtension {
public delegate void Function<in T>(T val);
public static void foreachExtension<T>(this IEnumerable<T> enumerable,
Function<T> function) {
foreach (var x in enumerable)
function(x);
}
}
}
|
[["-", 0, 52, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 64, 196, 0, 1, 0, 11, 12, 204, 205, 22], ["+", 0, 1, 0, 11, 12, 204, 206, 207, 0, 70], ["+", 0, 11, 12, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 1, 0, 11, 12, 204, 206, 207, 0, 73], ["+", 0, 57, 75, 57, 64, 196, 0, 1, 0, 35], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 64, 196, 0, 1, 0, 11, 12, 241, 0, 33], ["+", 64, 196, 0, 1, 0, 11, 12, 241, 0, 203]]
| 8
| 882
| 10
|
using System;
using System.Collections.Generic;
public class AchieveTheGoal {
public static void Main() {
string[] line = Console.ReadLine().Split(' ');
int N = int.Parse(line[0]);
int M = int.Parse(line[1]);
int correctNum = 0;
int totalPenalty = 0;
Dictionary<int, bool> isCorrect = new Dictionary<int, bool>();
Dictionary<int, int> penaltyNum = new Dictionary<int, int>();
for (int i = 0; i < M; i++) {
line = Console.ReadLine().Split(' ');
int p = int.Parse(line[0]);
if (!isCorrect.ContainsKey(p)) {
if (line[1] == "WA") {
if (!penaltyNum.ContainsKey(p))
penaltyNum[p] = 1;
else
penaltyNum[p]++;
} else if (line[1] == "AC") {
correctNum++;
totalPenalty += penaltyNum[p];
isCorrect[p] = true;
}
}
}
Console.WriteLine(correctNum + " " + totalPenalty);
}
}
|
using System;
using System.Collections.Generic;
public class AchieveTheGoal {
public static void Main() {
string[] line = Console.ReadLine().Split(' ');
int N = int.Parse(line[0]);
int M = int.Parse(line[1]);
int correctNum = 0;
int totalPenalty = 0;
Dictionary<int, bool> isCorrect = new Dictionary<int, bool>();
Dictionary<int, int> penaltyNum = new Dictionary<int, int>();
for (int i = 0; i < M; i++) {
line = Console.ReadLine().Split(' ');
int p = int.Parse(line[0]);
if (!isCorrect.ContainsKey(p)) {
if (line[1] == "WA") {
if (!penaltyNum.ContainsKey(p))
penaltyNum[p] = 1;
else
penaltyNum[p]++;
} else if (line[1] == "AC") {
correctNum++;
if (penaltyNum.ContainsKey(p))
totalPenalty += penaltyNum[p];
isCorrect[p] = true;
}
}
}
Console.WriteLine(correctNum + " " + totalPenalty);
}
}
|
[["+", 0, 57, 75, 57, 64, 196, 0, 57, 0, 121], ["+", 0, 57, 75, 57, 64, 196, 0, 57, 0, 24], ["+", 64, 196, 0, 57, 15, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 57, 15, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 57, 15, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 57, 15, 213, 3, 4, 0, 24], ["+", 0, 57, 15, 213, 3, 4, 0, 28, 0, 22], ["+", 64, 196, 0, 57, 15, 213, 3, 4, 0, 25], ["+", 0, 57, 75, 57, 64, 196, 0, 57, 0, 25]]
| 8
| 250
| 9
|
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() {
long N;
long A;
long B;
Multi(out N, out A, out B);
var ans = (B - A) % 2 == 0 ? (B - A) / 2 : Math.Min(B - 1, N - A);
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() {
long N;
long A;
long B;
Multi(out N, out A, out B);
var ans =
(B - A) % 2 == 0
? (B - A) / 2
: Math.Min(Math.Min(B - 1, N - A),
Math.Min(A + (B - A) / 2, (N - B + 1) + (B - 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]);
}
}
}
|
[["+", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 21], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25], ["+", 0, 212, 0, 41, 75, 213, 3, 4, 0, 21], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 0, 28, 0, 16, 12, 16, 31, 23, 0, 24], ["+", 0, 16, 12, 16, 31, 23, 0, 16, 31, 22], ["+", 0, 16, 12, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 16, 12, 16, 31, 23, 0, 16, 12, 22], ["+", 0, 28, 0, 16, 12, 16, 31, 23, 0, 25], ["+", 3, 4, 0, 28, 0, 16, 12, 16, 17, 85], ["+", 3, 4, 0, 28, 0, 16, 12, 16, 12, 203], ["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 24], ["+", 0, 16, 31, 23, 0, 16, 31, 16, 12, 22], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 12, 203], ["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 25]]
| 8
| 1,547
| 36
|
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() {
long[] read = longa();
long num = read[0];
long a = read[1];
long b = read[2];
if ((a + b) % 2 == 0) {
WriteLine(b - ((a + b) / 2));
} else {
long temp1 = b - a;
long temp2 = num - b;
long l = temp1 + ((temp1 + 1) / 2);
long j = temp2 + ((num - temp2 + a) / 2);
WriteLine(Min(l, j));
}
}
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() {
long[] read = longa();
long num = read[0];
long a = read[1];
long b = read[2];
if ((a + b) % 2 == 0) {
WriteLine(b - ((a + b) / 2));
} else {
long temp1 = b - a;
long tempa = num - a + 1;
long tempb = num - b + 1;
long temp2 = tempa - tempb;
long l = a - 1 + ((temp1 + 1) / 2);
long j = tempb - 1 + ((temp2 + 1) / 2);
/*
WriteLine(l);
WriteLine(j);
*/
WriteLine(Min(l, j));
}
}
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ใงใใชใ
|
[["-", 75, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 75, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 200, 0, 212, 0, 16, 31, 16, 31, 22], ["+", 0, 200, 0, 212, 0, 16, 31, 16, 17, 33], ["+", 0, 200, 0, 212, 0, 16, 31, 16, 12, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["+", 8, 196, 0, 57, 75, 196, 0, 197, 0, 35], ["+", 0, 57, 75, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 33], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["+", 0, 200, 0, 212, 0, 16, 31, 16, 12, 203], ["-", 0, 16, 31, 23, 0, 16, 31, 16, 31, 22], ["-", 0, 16, 31, 23, 0, 16, 31, 16, 17, 33], ["-", 12, 23, 0, 16, 31, 23, 0, 16, 12, 22], ["+", 12, 23, 0, 16, 31, 23, 0, 16, 12, 203]]
| 8
| 909
| 32
|
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 N = l[0], A = l[1], B = l[2];
var left = B - 1;
var right = N - A;
var add = 0L;
if ((B - A) % 2 == 1) {
if (A - 1 <= N - B) {
add = (A - 1) + 1;
A = 1;
B -= (add);
} else {
add = (N - B);
B = N;
A += (add);
}
}
var ans = (B - A) / 2 + add;
Console.WriteLine(ans);
}
}
}
|
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 N = l[0], A = l[1], B = l[2];
var add = 0L;
if ((B - A) % 2 == 1) {
if (A - 1 <= N - B) {
add = (A - 1) + 1;
A = 1;
B -= (add);
} else {
add = (N - B) + 1;
B = N;
A += (add);
}
}
var ans = (B - A) / 2 + add;
Console.WriteLine(ans);
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 33], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 12, 203]]
| 8
| 186
| 16
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
// using System.Numerics;
using System.Runtime.CompilerServices;
using ll = System.Int64;
using static MyIO;
public class Contest {
static void Swap1<T>(ref T a, ref T b) {
T t = a;
a = b;
b = t;
}
static void Swap2<T>(ref T a, ref T b)
where T : IComparable {
if (a.CompareTo(b) == 1)
Swap1(ref a, ref b);
} // b ใฎๆนใๅฐใใใใฐไบคๆ
static bool Chmin<T>(ref T a, T b)
where T : IComparable {
if (a.CompareTo(b) == 1) {
a = b;
return true;
}
return false;
} // b ใฎๆนใๅฐใใใใฐ a ใๆดๆฐ
static bool Chmax<T>(ref T a, T b)
where T : IComparable {
if (a.CompareTo(b) == -1) {
a = b;
return true;
}
return false;
} // b ใฎๆนใๅคงใใใใฐ a ใๆดๆฐ
static T[][] InitMat<T>(long len1, long len2, T val)
where T : struct {
T[][] m = new T[len1][];
for (int i = 0; i < m.Length; i++)
m[i] = Enumerable.Repeat(val, (int)len2).ToArray();
return m;
}
static T[][][] InitMat<T>(long len1, long len2, long len3, T val)
where T : struct {
T[][][] m = new T[len1][][];
for (int i = 0; i < m.Length; i++)
m[i] = InitMat(len2, len3, val);
return m;
}
public const long MOD1 = 1000000007; // 10^9+7
public const double EPS1 = 1e-8;
public static void Main() { Solve_A(); }
public static void Solve_A() {
long n, a, b;
MyIO.ReadMulti(out n, out a, out b);
Swap2(ref a, ref b);
long ans = 0;
if ((b - a) % 2 == 0) {
ans = (b - a) / 2;
} else {
ans = Math.Min(b - 1, n - a);
}
MyIO.WriteMulti(ans);
}
public static void Solve_B() {
long n, m;
MyIO.ReadMulti(out n, out m);
long ans = 0;
MyIO.WriteMulti(ans);
}
public static void Solve_C() {
long n, m;
MyIO.ReadMulti(out n, out m);
long ans = 0;
MyIO.WriteMulti(ans);
}
public static void Solve_D() {
long n, m;
MyIO.ReadMulti(out n, out m);
long ans = 0;
MyIO.WriteMulti(ans);
}
public static void Solve_E() {
long n, m;
MyIO.ReadMulti(out n, out m);
long ans = 0;
MyIO.WriteMulti(ans);
}
public static void Solve_F() {
long n, m;
MyIO.ReadMulti(out n, out m);
long ans = 0;
MyIO.WriteMulti(ans);
}
public static long BS<T>(Func<long, T> seq, T value)
where T : IComparable {
long left = long.MinValue / 4;
long right = long.MaxValue / 4;
while (right - left > 1) {
long mid = left + (right - left) / 2;
if (0 <= seq(mid).CompareTo(value))
right = mid;
else
left = mid;
}
return right;
}
}
#region MyIO
public struct VT<T, U> {
public T Item1;
public U Item2;
public VT(T a, U b) {
Item1 = a;
Item2 = b;
}
}
public struct VT<T, U, V> {
public T Item1;
public U Item2;
public V Item3;
public VT(T a, U b, V c) {
Item1 = a;
Item2 = b;
Item3 = c;
}
}
public struct VT<T, U, V, W> {
public T Item1;
public U Item2;
public V Item3;
public W Item4;
public VT(T a, U b, V c, W d) {
Item1 = a;
Item2 = b;
Item3 = c;
Item4 = d;
}
}
public static class MyIO {
public class Printer : System.IO.StreamWriter {
public override IFormatProvider FormatProvider {
get { return System.Globalization.CultureInfo.InvariantCulture; }
}
public Printer(System.IO.Stream stream)
: base(stream, new UTF8Encoding(false, true)) {}
public Printer(System.IO.Stream stream, Encoding encoding)
: base(stream, encoding) {}
}
private static char[] splitter = new char[] { ' ' };
private static bool eq<T, U>() => typeof(T).Equals(typeof(U));
private static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
private 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, System.Globalization.CultureInfo.InvariantCulture))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
public static string[] ReadMulti<T>(out T a) {
var ar = Console.ReadLine().Split(splitter,
StringSplitOptions.RemoveEmptyEntries);
a = cv<T>(ar[0]);
return ar;
}
public static string[] ReadMulti<T, U>(out T a, out U b) {
var ar = ReadMulti<T>(out a);
b = cv<U>(ar[1]);
return ar;
}
public static string[] ReadMulti<T, U, V>(out T a, out U b, out V c) {
var ar = ReadMulti<T, U>(out a, out b);
c = cv<V>(ar[2]);
return ar;
}
public static string[] ReadMulti<T, U, V, W>(out T a, out U b, out V c,
out W d) {
var ar = ReadMulti<T, U, V>(out a, out b, out c);
d = cv<W>(ar[3]);
return ar;
}
public static string[] ReadMulti<T, U, V, W, X>(out T a, out U b, out V c,
out W d, out X e) {
var ar = ReadMulti<T, U, V, W>(out a, out b, out c, out d);
e = cv<X>(ar[4]);
return ar;
}
public static string[] ReadMulti<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 = ReadMulti<T, U, V, W, X>(out a, out b, out c, out d, out e);
f = cv<Y>(ar[5]);
return ar;
}
public static string[] ReadArray<T>(out T[] a) {
var ar = Console.ReadLine().Split(splitter,
StringSplitOptions.RemoveEmptyEntries);
a = ar.Select(cv<T>).ToArray();
return ar;
}
public static string[][] ReadLines<T>(long n, out T[] a) {
a = new T[n];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++)
arr[i] = ReadMulti(out a[i]);
return arr;
}
public static string[][] ReadLines<T, U>(long n, out VT<T, U>[] a) {
a = new VT<T, U>[n];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++) {
T o;
U p;
arr[i] = ReadMulti(out o, out p);
a[i] = new VT<T, U>(o, p);
}
return arr;
}
public static string[][] ReadLines<T, U, V>(long n, out VT<T, U, V>[] a) {
a = new VT<T, U, V>[n];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++) {
T o;
U p;
V q;
arr[i] = ReadMulti(out o, out p, out q);
a[i] = new VT<T, U, V>(o, p, q);
}
return arr;
}
public static string[][] ReadLines<T, U, V, W>(long n,
out VT<T, U, V, W>[] a) {
a = new VT<T, U, V, W>[n];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++) {
T o;
U p;
V q;
W r;
arr[i] = ReadMulti(out o, out p, out q, out r);
a[i] = new VT<T, U, V, W>(o, p, q, r);
}
return arr;
}
public static string[][] ReadMatrix<T>(long n, out T[][] a) {
a = new T[n][];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++)
arr[i] = ReadArray(out a[i]);
return arr;
}
private static void wwp(Action act) {
var sw = new Printer(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
act();
Console.Out.Flush();
sw.AutoFlush = true;
Console.SetOut(sw);
}
private static string wfm(Type t) => t.Equals(typeof(double)) ? "{0:F10}"
: "{0}";
public static void WriteMulti(params object[] a) {
wwp(() => {
for (int i = 0; i < a.Length; i++) {
string fs = wfm(a[i].GetType()) +
((i < a.Length - 1) ? " " : Environment.NewLine);
Console.Write(fs, a[i]);
}
});
}
public static void WriteArray<T>(T[] a) {
wwp(() => {
string fs = wfm(typeof(T));
string fs1 = fs + " ";
string fs2 = fs + Environment.NewLine;
for (int i = 0; i < a.Length; i++)
Console.Write(((i < a.Length - 1) ? fs1 : fs2), a[i]);
});
}
public static void WriteLines<T>(T[] a) {
wwp(() => {
string fs = wfm(typeof(T)) + Environment.NewLine;
foreach (T x in a)
Console.Write(fs, x);
});
}
}
#endregion
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
// using System.Numerics;
using System.Runtime.CompilerServices;
using ll = System.Int64;
using static MyIO;
public class Contest {
static void Swap1<T>(ref T a, ref T b) {
T t = a;
a = b;
b = t;
}
static void Swap2<T>(ref T a, ref T b)
where T : IComparable {
if (a.CompareTo(b) == 1)
Swap1(ref a, ref b);
} // b ใฎๆนใๅฐใใใใฐไบคๆ
static bool Chmin<T>(ref T a, T b)
where T : IComparable {
if (a.CompareTo(b) == 1) {
a = b;
return true;
}
return false;
} // b ใฎๆนใๅฐใใใใฐ a ใๆดๆฐ
static bool Chmax<T>(ref T a, T b)
where T : IComparable {
if (a.CompareTo(b) == -1) {
a = b;
return true;
}
return false;
} // b ใฎๆนใๅคงใใใใฐ a ใๆดๆฐ
static T[][] InitMat<T>(long len1, long len2, T val)
where T : struct {
T[][] m = new T[len1][];
for (int i = 0; i < m.Length; i++)
m[i] = Enumerable.Repeat(val, (int)len2).ToArray();
return m;
}
static T[][][] InitMat<T>(long len1, long len2, long len3, T val)
where T : struct {
T[][][] m = new T[len1][][];
for (int i = 0; i < m.Length; i++)
m[i] = InitMat(len2, len3, val);
return m;
}
public const long MOD1 = 1000000007; // 10^9+7
public const double EPS1 = 1e-8;
public static void Main() { Solve_A(); }
public static void Solve_A() {
long n, a, b;
MyIO.ReadMulti(out n, out a, out b);
Swap2(ref a, ref b);
long ans = 0;
if ((b - a) % 2 == 0) {
ans = (b - a) / 2;
} else {
ans = Math.Min(a - 1, n - b) + (b - a + 1) / 2;
}
MyIO.WriteMulti(ans);
}
public static void Solve_B() {
long n, m;
MyIO.ReadMulti(out n, out m);
long ans = 0;
MyIO.WriteMulti(ans);
}
public static void Solve_C() {
long n, m;
MyIO.ReadMulti(out n, out m);
long ans = 0;
MyIO.WriteMulti(ans);
}
public static void Solve_D() {
long n, m;
MyIO.ReadMulti(out n, out m);
long ans = 0;
MyIO.WriteMulti(ans);
}
public static void Solve_E() {
long n, m;
MyIO.ReadMulti(out n, out m);
long ans = 0;
MyIO.WriteMulti(ans);
}
public static void Solve_F() {
long n, m;
MyIO.ReadMulti(out n, out m);
long ans = 0;
MyIO.WriteMulti(ans);
}
public static long BS<T>(Func<long, T> seq, T value)
where T : IComparable {
long left = long.MinValue / 4;
long right = long.MaxValue / 4;
while (right - left > 1) {
long mid = left + (right - left) / 2;
if (0 <= seq(mid).CompareTo(value))
right = mid;
else
left = mid;
}
return right;
}
}
#region MyIO
public struct VT<T, U> {
public T Item1;
public U Item2;
public VT(T a, U b) {
Item1 = a;
Item2 = b;
}
}
public struct VT<T, U, V> {
public T Item1;
public U Item2;
public V Item3;
public VT(T a, U b, V c) {
Item1 = a;
Item2 = b;
Item3 = c;
}
}
public struct VT<T, U, V, W> {
public T Item1;
public U Item2;
public V Item3;
public W Item4;
public VT(T a, U b, V c, W d) {
Item1 = a;
Item2 = b;
Item3 = c;
Item4 = d;
}
}
public static class MyIO {
public class Printer : System.IO.StreamWriter {
public override IFormatProvider FormatProvider {
get { return System.Globalization.CultureInfo.InvariantCulture; }
}
public Printer(System.IO.Stream stream)
: base(stream, new UTF8Encoding(false, true)) {}
public Printer(System.IO.Stream stream, Encoding encoding)
: base(stream, encoding) {}
}
private static char[] splitter = new char[] { ' ' };
private static bool eq<T, U>() => typeof(T).Equals(typeof(U));
private static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
private 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, System.Globalization.CultureInfo.InvariantCulture))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
public static string[] ReadMulti<T>(out T a) {
var ar = Console.ReadLine().Split(splitter,
StringSplitOptions.RemoveEmptyEntries);
a = cv<T>(ar[0]);
return ar;
}
public static string[] ReadMulti<T, U>(out T a, out U b) {
var ar = ReadMulti<T>(out a);
b = cv<U>(ar[1]);
return ar;
}
public static string[] ReadMulti<T, U, V>(out T a, out U b, out V c) {
var ar = ReadMulti<T, U>(out a, out b);
c = cv<V>(ar[2]);
return ar;
}
public static string[] ReadMulti<T, U, V, W>(out T a, out U b, out V c,
out W d) {
var ar = ReadMulti<T, U, V>(out a, out b, out c);
d = cv<W>(ar[3]);
return ar;
}
public static string[] ReadMulti<T, U, V, W, X>(out T a, out U b, out V c,
out W d, out X e) {
var ar = ReadMulti<T, U, V, W>(out a, out b, out c, out d);
e = cv<X>(ar[4]);
return ar;
}
public static string[] ReadMulti<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 = ReadMulti<T, U, V, W, X>(out a, out b, out c, out d, out e);
f = cv<Y>(ar[5]);
return ar;
}
public static string[] ReadArray<T>(out T[] a) {
var ar = Console.ReadLine().Split(splitter,
StringSplitOptions.RemoveEmptyEntries);
a = ar.Select(cv<T>).ToArray();
return ar;
}
public static string[][] ReadLines<T>(long n, out T[] a) {
a = new T[n];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++)
arr[i] = ReadMulti(out a[i]);
return arr;
}
public static string[][] ReadLines<T, U>(long n, out VT<T, U>[] a) {
a = new VT<T, U>[n];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++) {
T o;
U p;
arr[i] = ReadMulti(out o, out p);
a[i] = new VT<T, U>(o, p);
}
return arr;
}
public static string[][] ReadLines<T, U, V>(long n, out VT<T, U, V>[] a) {
a = new VT<T, U, V>[n];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++) {
T o;
U p;
V q;
arr[i] = ReadMulti(out o, out p, out q);
a[i] = new VT<T, U, V>(o, p, q);
}
return arr;
}
public static string[][] ReadLines<T, U, V, W>(long n,
out VT<T, U, V, W>[] a) {
a = new VT<T, U, V, W>[n];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++) {
T o;
U p;
V q;
W r;
arr[i] = ReadMulti(out o, out p, out q, out r);
a[i] = new VT<T, U, V, W>(o, p, q, r);
}
return arr;
}
public static string[][] ReadMatrix<T>(long n, out T[][] a) {
a = new T[n][];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++)
arr[i] = ReadArray(out a[i]);
return arr;
}
private static void wwp(Action act) {
var sw = new Printer(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
act();
Console.Out.Flush();
sw.AutoFlush = true;
Console.SetOut(sw);
}
private static string wfm(Type t) => t.Equals(typeof(double)) ? "{0:F10}"
: "{0}";
public static void WriteMulti(params object[] a) {
wwp(() => {
for (int i = 0; i < a.Length; i++) {
string fs = wfm(a[i].GetType()) +
((i < a.Length - 1) ? " " : Environment.NewLine);
Console.Write(fs, a[i]);
}
});
}
public static void WriteArray<T>(T[] a) {
wwp(() => {
string fs = wfm(typeof(T));
string fs1 = fs + " ";
string fs2 = fs + Environment.NewLine;
for (int i = 0; i < a.Length; i++)
Console.Write(((i < a.Length - 1) ? fs1 : fs2), a[i]);
});
}
public static void WriteLines<T>(T[] a) {
wwp(() => {
string fs = wfm(typeof(T)) + Environment.NewLine;
foreach (T x in a)
Console.Write(fs, x);
});
}
}
#endregion
|
[["-", 12, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 31, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 31, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 31, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["+", 0, 11, 12, 16, 31, 213, 3, 4, 0, 25], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 0, 11, 12, 16, 12, 16, 31, 23, 0, 24], ["+", 12, 16, 31, 23, 0, 16, 31, 16, 31, 22], ["+", 12, 16, 12, 16, 31, 23, 0, 16, 17, 72], ["+", 12, 16, 12, 16, 31, 23, 0, 16, 12, 203], ["+", 0, 1, 0, 11, 12, 16, 12, 16, 17, 85], ["+", 0, 1, 0, 11, 12, 16, 12, 16, 12, 203]]
| 8
| 2,532
| 12
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace AC {
class Program {
static void Main(string[] args) {
var input = ReadArrayLong();
var N = input[0];
var A = input[1];
var B = input[2];
var dif = B - A;
var ans = 0L;
if (dif % 2 == 0)
ans = dif / 2;
else {
if (A - 1 < N - B) {
dif = B - (A + 1);
ans += A;
} else {
dif = N - A - (B + 1);
ans += N - B + 1;
}
ans += dif / 2;
}
Console.WriteLine(ans);
}
static string Read() { return Console.ReadLine(); }
static int ReadInt() { return int.Parse(Read()); }
static long ReadLong() { return long.Parse(Read()); }
static int[] ReadArrayInt() {
return Read().Split(' ').Select(s => int.Parse(s)).ToArray();
}
static long[] ReadArrayLong() {
return Read().Split(' ').Select(s => long.Parse(s)).ToArray();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace AC {
class Program {
static void Main(string[] args) {
var input = ReadArrayLong();
var N = input[0];
var A = input[1];
var B = input[2];
var dif = B - A;
var ans = 0L;
if (dif % 2 == 0)
ans = dif / 2;
else {
if (A - 1 < N - B)
ans += A;
else
ans += N - B + 1;
ans += (dif - 1) / 2;
}
Console.WriteLine(ans);
}
static string Read() { return Console.ReadLine(); }
static int ReadInt() { return int.Parse(Read()); }
static long ReadLong() { return long.Parse(Read()); }
static int[] ReadArrayInt() {
return Read().Split(' ').Select(s => int.Parse(s)).ToArray();
}
static long[] ReadArrayLong() {
return Read().Split(' ').Select(s => long.Parse(s)).ToArray();
}
}
}
|
[["-", 0, 57, 75, 196, 0, 57, 64, 196, 0, 45], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 64, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["-", 64, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["-", 0, 1, 0, 11, 12, 16, 12, 23, 0, 24], ["-", 0, 11, 12, 16, 12, 23, 0, 16, 31, 22], ["-", 0, 11, 12, 16, 12, 23, 0, 16, 17, 72], ["-", 0, 11, 12, 16, 12, 23, 0, 16, 12, 203], ["-", 0, 1, 0, 11, 12, 16, 12, 23, 0, 25], ["-", 75, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 0, 57, 75, 196, 0, 57, 64, 196, 0, 46], ["-", 0, 57, 75, 196, 0, 57, 75, 196, 0, 45], ["-", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["-", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 0, 1, 0, 11, 12, 16, 31, 16, 31, 22], ["-", 0, 1, 0, 11, 12, 16, 31, 16, 17, 33], ["-", 0, 1, 0, 11, 12, 16, 31, 16, 12, 22], ["-", 75, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["-", 75, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["-", 0, 57, 75, 196, 0, 57, 75, 196, 0, 46], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 12, 203], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25]]
| 8
| 278
| 30
|
using System;
class A {
static void Main(string[] args) {
string[] s = Console.ReadLine().Split(' ');
int N = int.Parse(s[0]);
int A = int.Parse(s[1]);
int B = int.Parse(s[2]);
int a = A - 1;
int b = N - B;
int c = ((a - b) > 0) ? b : a;
if ((B - A) % 2 == 0) {
Console.WriteLine((B - A) / 2);
}
if ((B - A) % 2 == 1) {
Console.WriteLine((c + 1 + (B - A) / 2));
}
}
}
|
using System;
class A {
static void Main(string[] args) {
string[] s = Console.ReadLine().Split(' ');
long N = long.Parse(s[0]);
long A = long.Parse(s[1]);
long B = long.Parse(s[2]);
long a = A - 1;
long b = N - B;
long c = ((a - b) > 0) ? b : a;
if ((B - A) % 2 == 0) {
Console.WriteLine((B - A) / 2);
}
if ((B - A) % 2 == 1) {
Console.WriteLine((c + 1 + (B - A) / 2));
}
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199]]
| 8
| 166
| 18
|
using System;
using System.Linq;
namespace AGC041 {
class A {
static void Main(string[] args) {
long[] input = Console.ReadLine().Split().Select(long.Parse).ToArray();
long N = input[0];
long A = input[1];
long B = input[2];
if ((B - A) % 2 == 0) {
Console.WriteLine((B - A) / 2);
return;
}
long l = B - 1;
long r = N - A;
long res = 0;
if (l < r) {
res = A + (B - A) / 2;
} else if (r < l) {
res = (N - B + 1) + (N - A + B + 1);
} else {
res = A + (B - A) / 2;
}
Console.WriteLine(res);
}
}
}
|
using System;
using System.Linq;
namespace AGC041 {
class A {
static void Main(string[] args) {
long[] input = Console.ReadLine().Split().Select(long.Parse).ToArray();
long N = input[0];
long A = input[1];
long B = input[2];
if ((B - A) % 2 == 0) {
Console.WriteLine((B - A) / 2);
return;
}
long l = B - 1;
long r = N - A;
long res = 0;
if (l < r) {
res = A + (B - A) / 2;
} else if (r < l) {
res = (N - B + 1) + (N - (A + (N - B + 1))) / 2;
} else {
res = A + (B - A) / 2;
}
Console.WriteLine(res);
}
}
}
|
[["+", 12, 16, 31, 23, 0, 16, 12, 23, 0, 24], ["+", 0, 16, 12, 23, 0, 16, 12, 23, 0, 24], ["+", 0, 16, 12, 23, 0, 16, 31, 16, 31, 22], ["+", 0, 16, 12, 23, 0, 16, 31, 16, 17, 33], ["+", 0, 16, 12, 23, 0, 16, 12, 23, 0, 25], ["+", 0, 11, 12, 16, 12, 16, 31, 23, 0, 25], ["+", 0, 1, 0, 11, 12, 16, 12, 16, 17, 85], ["+", 0, 1, 0, 11, 12, 16, 12, 16, 12, 203]]
| 8
| 196
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp5 {
class Program {
static void Main(string[] args) {
String S = Console.ReadLine();
String[] line = S.Split(' ');
long N = long.Parse(line[0]);
long A = long.Parse(line[1]);
long B = long.Parse(line[2]);
if ((B - A) % 2 == 0) {
Console.WriteLine((B - A) / 2);
} else {
if (N - B > A) {
Console.WriteLine(B - 1);
} else {
Console.WriteLine(N - A);
}
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp5 {
class Program {
static void Main(string[] args) {
String S = Console.ReadLine();
String[] line = S.Split(' ');
long N = long.Parse(line[0]);
long A = long.Parse(line[1]);
long B = long.Parse(line[2]);
if ((B - A) % 2 == 0) {
Console.WriteLine((B - A) / 2);
} else {
if (A - 1 > N - B) {
Console.WriteLine((N - B) + 1 + (B - A - 1) / 2);
} else {
Console.WriteLine(A + (B - A - 1) / 2);
}
}
}
}
}
|
[["+", 75, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 75, 196, 0, 57, 15, 16, 31, 16, 17, 33], ["+", 75, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 17, 47], ["-", 0, 57, 75, 196, 0, 57, 15, 16, 17, 47], ["-", 0, 57, 75, 196, 0, 57, 15, 16, 12, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 28, 0, 16, 31, 16, 31, 23, 0, 24], ["+", 0, 16, 31, 16, 31, 23, 0, 16, 31, 22], ["+", 0, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 16, 31, 16, 31, 23, 0, 16, 12, 22], ["+", 0, 28, 0, 16, 31, 16, 31, 23, 0, 25], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 17, 72], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 12, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 12, 16, 31, 23, 0, 16, 31, 16, 17, 33], ["+", 12, 16, 31, 23, 0, 16, 31, 16, 12, 22], ["+", 3, 4, 0, 28, 0, 16, 12, 16, 17, 85], ["+", 3, 4, 0, 28, 0, 16, 12, 16, 12, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 0, 28, 0, 16, 12, 16, 31, 23, 0, 24], ["+", 12, 16, 31, 23, 0, 16, 31, 16, 31, 22], ["+", 0, 16, 12, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 16, 12, 16, 31, 23, 0, 16, 12, 203], ["+", 0, 28, 0, 16, 12, 16, 31, 23, 0, 25]]
| 8
| 169
| 30
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
checked {
var N = sc.ReadLong();
var A = sc.ReadLong();
var B = sc.ReadLong();
var d = B - A;
if (d % 2 == 0) {
Console.WriteLine(d / 2);
} else {
var res1 = Math.Max(A - 1, B - 1);
var res2 = Math.Max(N - A, N - B);
var ans = Math.Min(res1, res2);
if (A - 1 < N - B) {
var resa = A;
resa += (B - A) / 2;
ans = Math.Min(ans, resa);
} else {
var resb = N - B + 1;
resb += (N - A) / 2;
ans = Math.Min(ans, resb);
}
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) {
checked {
var N = sc.ReadLong();
var A = sc.ReadLong();
var B = sc.ReadLong();
var d = B - A;
if (d % 2 == 0) {
Console.WriteLine(d / 2);
} else {
var res1 = Math.Max(A - 1, B - 1);
var res2 = Math.Max(N - A, N - B);
var ans = Math.Min(res1, res2);
if (A - 1 < N - B) {
var resa = A;
resa += (B - A) / 2;
ans = Math.Min(ans, resa);
} else {
var resb = N - B + 1;
var nexta = A + (N - B + 1);
resb += (N - nexta) / 2;
ans = Math.Min(ans, resb);
}
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;
}
}
|
[["+", 75, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 75, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["+", 0, 200, 0, 212, 0, 16, 12, 23, 0, 24], ["+", 0, 16, 12, 23, 0, 16, 31, 16, 31, 22], ["+", 0, 16, 12, 23, 0, 16, 31, 16, 17, 33], ["+", 0, 16, 12, 23, 0, 16, 31, 16, 12, 22], ["+", 0, 212, 0, 16, 12, 23, 0, 16, 17, 72], ["+", 0, 212, 0, 16, 12, 23, 0, 16, 12, 203], ["+", 0, 200, 0, 212, 0, 16, 12, 23, 0, 25], ["+", 75, 196, 0, 57, 75, 196, 0, 197, 0, 35], ["-", 0, 11, 12, 16, 31, 23, 0, 16, 12, 22], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 12, 22]]
| 8
| 1,182
| 15
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main() {
string[] a = Console.ReadLine().Split(' ');
long N = long.Parse(a[0]);
long A = long.Parse(a[1]);
long B = long.Parse(a[2]);
long min = long.MaxValue;
if (Math.Abs(A - B) % 2 == 0) {
min = Math.Abs(A - B) / 2;
} else {
min = Math.Min(min, N - Math.Min(A, B));
min = Math.Min(min, Math.Max(A, B) - 1);
if (N - Math.Min(A, B) < Math.Max(A, B) - 1) {
min = Math.Min(min, Math.Min(A, B) - 1 + (Math.Abs(B - A) + 1) / 2);
} else {
min = Math.Min(min, N - Math.Max(A, B) + (Math.Abs(B - A) + 1) / 2);
}
}
Console.WriteLine(min);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main() {
string[] a = Console.ReadLine().Split(' ');
long N = long.Parse(a[0]);
long A = long.Parse(a[1]);
long B = long.Parse(a[2]);
long min = long.MaxValue;
if (Math.Abs(A - B) % 2 == 0) {
min = Math.Abs(A - B) / 2;
} else {
min = Math.Min(min, N - Math.Min(A, B));
min = Math.Min(min, Math.Max(A, B) - 1);
if (Math.Max(A, B) - 1 < N - Math.Min(A, B)) {
min = Math.Min(min, Math.Min(A, B) - 1 + (Math.Abs(B - A) + 1) / 2);
} else {
min = Math.Min(min, N - Math.Max(A, B) + (Math.Abs(B - A) + 1) / 2);
}
}
Console.WriteLine(min);
}
}
|
[["-", 75, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["-", 75, 196, 0, 57, 15, 16, 31, 16, 17, 33], ["-", 15, 16, 31, 16, 12, 213, 63, 214, 141, 22], ["+", 15, 16, 31, 16, 31, 213, 63, 214, 141, 22], ["+", 75, 196, 0, 57, 15, 16, 31, 16, 17, 33], ["+", 75, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 75, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 75, 196, 0, 57, 15, 16, 12, 16, 17, 33], ["-", 15, 16, 12, 16, 31, 213, 63, 214, 141, 22], ["+", 15, 16, 12, 16, 12, 213, 63, 214, 141, 22], ["-", 75, 196, 0, 57, 15, 16, 12, 16, 17, 33], ["-", 75, 196, 0, 57, 15, 16, 12, 16, 12, 203]]
| 8
| 269
| 12
|
using System;
using System.Collections.Generic;
using System.Linq;
// namespaceใฎๅคใใณใณใในใๅใซใใฆ้็จ
namespace AGC041A {
class Input {
/// <summary>
/// 1่กใฎๅ
ฅๅใๅๅพใใ
/// </summary>
/// <returns>ๆๅญๅ</returns>
public string String() { return Console.ReadLine(); }
/// <summary>
/// ่คๆฐ่กใฎๅ
ฅๅใๅๅพ
/// </summary>
/// <returns>ๆๅญๅใฎ้
ๅ</returns>
public string[] ArrayString(int rowNumber) {
string[] s = new string[rowNumber];
for (int i = 0; i < rowNumber; i++) {
s[i] = String();
}
return s;
}
/// <summary>
/// 1่กใฎๅ
ฅๅใๅๅพ
/// </summary>
/// <returns>intๅใฎๅค</returns>
public int Int() { return int.Parse(String()); }
/// <summary>
/// 1่กใฎๅ
ฅๅใๅๅพ
/// </summary>
/// <returns>intๅใฎ้
ๅ</returns>
public int[] ArrayInt() { return Split().Select(int.Parse).ToArray(); }
/// <summary>
/// ่คๆฐ่กใฎๅ
ฅๅใๅๅพ
/// </summary>
/// <param name="rowNumber">่กๆฐ</param>
/// <returns>intๅใฎ้
ๅ</returns>
public int[] ArrayInt(int rowNumber) {
int[] ints = new int[rowNumber];
for (int i = 0; i < rowNumber; i++) {
ints[i] = Int();
}
return ints;
}
/// <summary>
/// 1่กใฎๅ
ฅๅใๅๅพ
/// </summary>
/// <returns>longๅใฎๅค</returns>
public long Long() { return long.Parse(String()); }
/// <summary>
/// 2ใคใฎๆดๆฐใ1่กใซๆธใใใฆใใๅ
ฅๅใใ2ใคใฎlongใงๅใๅใ
/// </summary>
/// <param name="A"></param>
/// <param name="B"></param>
public void Longs(ref long A, ref long B) {
var longs = ArrayLong();
A = longs[0];
B = longs[1];
}
/// <summary>
/// 3ใคใฎๆดๆฐใ1่กใซๆธใใใฆใใๅ
ฅๅใใ3ใคใฎlongใงๅใๅใ
/// </summary>
/// <param name="A"></param>
/// <param name="B"></param>
/// <param name="C"></param>
public void Longs(ref long A, ref long B, ref long C) {
var longs = ArrayLong();
A = longs[0];
B = longs[1];
C = longs[2];
}
/// <summary>
/// 4ใคใฎๆดๆฐใ1่กใซๆธใใใฆใใๅ
ฅๅใใ4ใคใฎlongใงๅใๅใ
/// </summary>
/// <param name="A"></param>
/// <param name="B"></param>
/// <param name="C"></param>
/// <param name="D"></param>
public void Longs(ref long A, ref long B, ref long C, ref long D) {
var longs = ArrayLong();
A = longs[0];
B = longs[1];
C = longs[2];
D = longs[3];
}
/// <summary>
/// 2ใคใฎๆดๆฐใ่คๆฐ่กใซๆธใใใฆใใๅ
ฅๅใใ2ใคใฎlong[]ใงๅใๅใ
/// </summary>
/// <param name="rowNumber"></param>
/// <param name="A"></param>
/// <param name="B"></param>
public void LongsArray(long rowNumber, ref long[] A, ref long[] B) {
A = new long[rowNumber];
B = new long[rowNumber];
for (int i = 0; i < rowNumber; i++) {
var l = ArrayLong();
A[i] = l[0];
B[i] = l[1];
}
}
/// <summary>
/// 3ใคใฎๆดๆฐใ่คๆฐ่กใซๆธใใใฆใใๅ
ฅๅใใ2ใคใฎlong[]ใงๅใๅใ
/// </summary>
/// <param name="rowNumber"></param>
/// <param name="A"></param>
/// <param name="B"></param>
/// <param name="C"></param>
public void LongsArray(long rowNumber, ref long[] A, ref long[] B,
ref long[] C) {
A = new long[rowNumber];
B = new long[rowNumber];
C = new long[rowNumber];
for (int i = 0; i < rowNumber; i++) {
var l = ArrayLong();
A[i] = l[0];
B[i] = l[1];
C[i] = l[2];
}
}
/// <summary>
/// 1่กใฎๅ
ฅๅใๅๅพ
/// </summary>
/// <returns>longๅใฎ้
ๅ</returns>
public long[] ArrayLong() { return Split().Select(long.Parse).ToArray(); }
public long[] ArrayLong(int rowNumber) {
long[] longs = new long[rowNumber];
for (int i = 0; i < rowNumber; i++) {
longs[i] = Long();
}
return longs;
}
/// <summary>
/// 1่กใฎๅ
ฅๅใๅๅพ
/// </summary>
/// <returns>doubleๅใฎๅค</returns>
public double Double() { return double.Parse(String()); }
/// <summary>
/// 1่กใฎๅ
ฅๅใๅๅพ
/// </summary>
/// <returns>doubleๅใฎ้
ๅ</returns>
public double[] ArrayDouble() {
return Split().Select(double.Parse).ToArray();
}
private IEnumerable<string> Split() { return String().Split(' '); }
}
class Program {
static void Main(string[] args) {
Solver solver = new Solver();
solver.Solve();
}
}
class Solver {
public Solver() {
Input input = new Input();
input.Longs(ref N, ref A, ref B);
}
private long N;
private long A;
private long B;
public void Solve() {
if ((B - A) % 2 == 1) {
Console.WriteLine(Math.Min(N - A, B - 1));
} else {
Console.WriteLine(Math.Abs((A - B) / 2));
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
// namespaceใฎๅคใใณใณใในใๅใซใใฆ้็จ
namespace AGC041A {
class Input {
/// <summary>
/// 1่กใฎๅ
ฅๅใๅๅพใใ
/// </summary>
/// <returns>ๆๅญๅ</returns>
public string String() { return Console.ReadLine(); }
/// <summary>
/// ่คๆฐ่กใฎๅ
ฅๅใๅๅพ
/// </summary>
/// <returns>ๆๅญๅใฎ้
ๅ</returns>
public string[] ArrayString(int rowNumber) {
string[] s = new string[rowNumber];
for (int i = 0; i < rowNumber; i++) {
s[i] = String();
}
return s;
}
/// <summary>
/// 1่กใฎๅ
ฅๅใๅๅพ
/// </summary>
/// <returns>intๅใฎๅค</returns>
public int Int() { return int.Parse(String()); }
/// <summary>
/// 1่กใฎๅ
ฅๅใๅๅพ
/// </summary>
/// <returns>intๅใฎ้
ๅ</returns>
public int[] ArrayInt() { return Split().Select(int.Parse).ToArray(); }
/// <summary>
/// ่คๆฐ่กใฎๅ
ฅๅใๅๅพ
/// </summary>
/// <param name="rowNumber">่กๆฐ</param>
/// <returns>intๅใฎ้
ๅ</returns>
public int[] ArrayInt(int rowNumber) {
int[] ints = new int[rowNumber];
for (int i = 0; i < rowNumber; i++) {
ints[i] = Int();
}
return ints;
}
/// <summary>
/// 1่กใฎๅ
ฅๅใๅๅพ
/// </summary>
/// <returns>longๅใฎๅค</returns>
public long Long() { return long.Parse(String()); }
/// <summary>
/// 2ใคใฎๆดๆฐใ1่กใซๆธใใใฆใใๅ
ฅๅใใ2ใคใฎlongใงๅใๅใ
/// </summary>
/// <param name="A"></param>
/// <param name="B"></param>
public void Longs(ref long A, ref long B) {
var longs = ArrayLong();
A = longs[0];
B = longs[1];
}
/// <summary>
/// 3ใคใฎๆดๆฐใ1่กใซๆธใใใฆใใๅ
ฅๅใใ3ใคใฎlongใงๅใๅใ
/// </summary>
/// <param name="A"></param>
/// <param name="B"></param>
/// <param name="C"></param>
public void Longs(ref long A, ref long B, ref long C) {
var longs = ArrayLong();
A = longs[0];
B = longs[1];
C = longs[2];
}
/// <summary>
/// 4ใคใฎๆดๆฐใ1่กใซๆธใใใฆใใๅ
ฅๅใใ4ใคใฎlongใงๅใๅใ
/// </summary>
/// <param name="A"></param>
/// <param name="B"></param>
/// <param name="C"></param>
/// <param name="D"></param>
public void Longs(ref long A, ref long B, ref long C, ref long D) {
var longs = ArrayLong();
A = longs[0];
B = longs[1];
C = longs[2];
D = longs[3];
}
/// <summary>
/// 2ใคใฎๆดๆฐใ่คๆฐ่กใซๆธใใใฆใใๅ
ฅๅใใ2ใคใฎlong[]ใงๅใๅใ
/// </summary>
/// <param name="rowNumber"></param>
/// <param name="A"></param>
/// <param name="B"></param>
public void LongsArray(long rowNumber, ref long[] A, ref long[] B) {
A = new long[rowNumber];
B = new long[rowNumber];
for (int i = 0; i < rowNumber; i++) {
var l = ArrayLong();
A[i] = l[0];
B[i] = l[1];
}
}
/// <summary>
/// 3ใคใฎๆดๆฐใ่คๆฐ่กใซๆธใใใฆใใๅ
ฅๅใใ2ใคใฎlong[]ใงๅใๅใ
/// </summary>
/// <param name="rowNumber"></param>
/// <param name="A"></param>
/// <param name="B"></param>
/// <param name="C"></param>
public void LongsArray(long rowNumber, ref long[] A, ref long[] B,
ref long[] C) {
A = new long[rowNumber];
B = new long[rowNumber];
C = new long[rowNumber];
for (int i = 0; i < rowNumber; i++) {
var l = ArrayLong();
A[i] = l[0];
B[i] = l[1];
C[i] = l[2];
}
}
/// <summary>
/// 1่กใฎๅ
ฅๅใๅๅพ
/// </summary>
/// <returns>longๅใฎ้
ๅ</returns>
public long[] ArrayLong() { return Split().Select(long.Parse).ToArray(); }
public long[] ArrayLong(int rowNumber) {
long[] longs = new long[rowNumber];
for (int i = 0; i < rowNumber; i++) {
longs[i] = Long();
}
return longs;
}
/// <summary>
/// 1่กใฎๅ
ฅๅใๅๅพ
/// </summary>
/// <returns>doubleๅใฎๅค</returns>
public double Double() { return double.Parse(String()); }
/// <summary>
/// 1่กใฎๅ
ฅๅใๅๅพ
/// </summary>
/// <returns>doubleๅใฎ้
ๅ</returns>
public double[] ArrayDouble() {
return Split().Select(double.Parse).ToArray();
}
private IEnumerable<string> Split() { return String().Split(' '); }
}
class Program {
static void Main(string[] args) {
Solver solver = new Solver();
solver.Solve();
}
}
class Solver {
public Solver() {
Input input = new Input();
input.Longs(ref N, ref A, ref B);
}
private long N;
private long A;
private long B;
public void Solve() {
if ((B - A) % 2 == 1) {
Console.WriteLine(Math.Min((2 * N - A - B + 1) / 2, (A + B - 1) / 2));
} else {
Console.WriteLine((B - A) / 2);
}
}
}
}
|
[["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 24], ["+", 0, 16, 31, 16, 31, 16, 31, 16, 31, 203], ["+", 0, 16, 31, 16, 31, 16, 31, 16, 17, 48], ["+", 0, 16, 31, 23, 0, 16, 31, 16, 17, 33], ["+", 0, 16, 31, 23, 0, 16, 31, 16, 12, 22], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 12, 203], ["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 25], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 85], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 0, 16, 31, 23, 0, 16, 31, 16, 31, 22], ["+", 0, 16, 31, 23, 0, 16, 31, 16, 17, 72], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25], ["-", 75, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["-", 0, 28, 0, 16, 31, 23, 0, 16, 31, 22], ["-", 0, 28, 0, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 12, 22], ["-", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25]]
| 8
| 859
| 25
|
// ReSharper disable ArrangeTypeMemberModifiers
// ReSharper disable ConvertIfStatementToSwitchStatement
// ReSharper disable FunctionRecursiveOnAllPaths
// ReSharper disable InconsistentNaming
// ReSharper disable InlineOutVariableDeclaration
// ReSharper disable InvertIf
// ReSharper disable JoinDeclarationAndInitializer
// ReSharper disable MemberCanBeMadeStatic.Global
// ReSharper disable MemberCanBeMadeStatic.Local
// ReSharper disable NonReadonlyMemberInGetHashCode
// ReSharper disable PossibleNullReferenceException
// ReSharper disable RedundantUsingDirective
// ReSharper disable SuggestVarOrType_BuiltInTypes
// ReSharper disable SuggestVarOrType_Elsewhere
// ReSharper disable TailRecursiveCall
// ReSharper disable UnusedMember.Global
// ReSharper disable UnusedMember.Local
// ReSharper disable UseObjectOrCollectionInitializert
#if true && UTAKA_LOCAL
//#if false
#define UTAKA_DEBUG
#endif
//#define TOPCODER
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Numerics;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using static UtakaApp.Util;
namespace UtakaApp {
public partial class Program {
public const string SiteName = "AtCoder";
public const string ContestName = "agc041";
public const string ProblemName = "A";
public void Solve() {
long N = cin.ReadLong;
long A = cin.ReadLong - 1;
long B = cin.ReadLong - 1;
long diff = B - A;
if (diff % 2 == 0) {
cou.WriteLine(diff / 2);
return;
}
long diffA = A;
long diffB = N - 1 - B;
long v;
if (diffA < diffB) {
v = diff + diffA;
} else {
v = diff + diffB;
}
long ans = v / 2 + 1;
cou.WriteLine(ans);
}
public void Swap<T>(ref T a, ref T b) {
T c = a;
a = b;
b = c;
}
}
//=========================================================================================
// Debug IO
//=========================================================================================
public partial class Program {
//=========================================================================================
// Main
//=========================================================================================
private readonly ConsoleInput cin;
private readonly IConsole cou;
public Program(ConsoleInput cin, IConsole cou) {
this.cin = cin;
this.cou = cou;
}
#if !TOPCODER
public static void Main(string[] args) {
#if UTAKA_LOCAL
//#if false
new TestCaseCheckerForAtCoder().TestProblems();
#else
var cin = new ConsoleInput(System.Console.In);
var console = new MyConsole();
new Program(cin, console).Solve();
console.Flush();
#endif
}
#endif
public void WriteEnumerable<T>(IEnumerable<T> A, string delimiter = " ") {
if (!A.Any()) {
return;
}
var sb = new StringBuilder();
foreach (T v in A) {
sb.Append(v);
sb.Append(delimiter);
}
if (sb.Length > 0) {
sb.Length--;
}
cou.WriteLine(sb.ToString());
}
}
public static class Util {
public static int LowerBound<T>(T[] arr, int start, int end, T value,
IComparer<T> comparer) {
int low = start;
int high = end;
while (low < high) {
var mid = ((high - low) >> 1) + low;
if (comparer.Compare(arr[mid], value) < 0)
low = mid + 1;
else
high = mid;
}
return low;
}
public static int LowerBound<T>(T[] arr, T value)
where T : IComparable {
return LowerBound(arr, 0, arr.Length, value, Comparer<T>.Default);
}
public static int UpperBound<T>(T[] arr, int start, int end, T value,
IComparer<T> comparer) {
int low = start;
int high = end;
while (low < high) {
var mid = ((high - low) >> 1) + low;
if (comparer.Compare(arr[mid], value) <= 0)
low = mid + 1;
else
high = mid;
}
return low;
}
public static int UpperBound<T>(T[] arr, T value) {
return UpperBound(arr, 0, arr.Length, value, Comparer<T>.Default);
}
public static int UpperBound<T>(List<T> list, int start, int end, T value,
IComparer<T> comparer) {
int low = start;
int high = end;
while (low < high) {
var mid = ((high - low) >> 1) + low;
if (comparer.Compare(list[mid], value) <= 0)
low = mid + 1;
else
high = mid;
}
return low;
}
public static int UpperBound<T>(List<T> list, T value) {
return UpperBound(list, 0, list.Count, value, Comparer<T>.Default);
}
public static T[] Array1D<T>(int a, T defaultValue)
where T : struct {
var ret = new T[a];
for (int i = 0; i < a; i++) {
ret[i] = defaultValue;
}
return ret;
}
public static T[] Array1D<T>(int a)
where T : struct {
var ret = new T[a];
return ret;
}
/// <summary>
/// ่ฆ็ด ๆฐ (a, b) ใฎใdefaultValue ใงๆบใใใใ้
ๅใไฝๆใใพใใ
/// </summary>
/// <typeparam name="T">้
ๅใฎๅ</typeparam>
/// <param name="a">1ๆฌกๅ
ใฎ่ฆ็ด ๆฐ</param>
/// <param name="b">2ๆฌกๅ
ใฎ่ฆ็ด ๆฐ</param>
/// <param name="defaultValue">ใใใฉใซใๅค</param>
/// <returns>ๆๅฎใใๆกไปถใงๅๆๅใใใ้
ๅ</returns>
public static T[,] Array2D<T>(int a, int b, T defaultValue)
where T : struct {
var ret = new T[a, b];
for (int i = 0; i < a; i++) {
for (int j = 0; j < b; j++) {
ret[i, j] = defaultValue;
}
}
return ret;
}
public static T[,,] Array3D<T>(int a, int b, int c, T defaultValue)
where T : struct {
T[,,] ret = new T[a, b, c];
for (int i = 0; i < a; i++) {
for (int j = 0; j < b; j++) {
for (int k = 0; k < c; k++) {
ret[i, j, k] = defaultValue;
}
}
}
return ret;
}
/// <summary>
/// ่ฆ็ด ๆฐ (a, b) ใฎใdefaultValue ใงๆบใใใใJag้
ๅใไฝๆใใพใใ
/// </summary>
/// <typeparam name="T">้
ๅใฎๅ</typeparam>
/// <param name="a">1ๆฌกๅ
ใฎ่ฆ็ด ๆฐ</param>
/// <param name="b">2ๆฌกๅ
ใฎ่ฆ็ด ๆฐ</param>
/// <param name="defaultValue">ใใใฉใซใๅค</param>
/// <returns>ๆๅฎใใๆกไปถใงๅๆๅใใใ้
ๅ</returns>
public static T[][] JagArray2D<T>(int a, int b, T defaultValue)
where T : struct {
var ret = new T[a][];
for (int i = 0; i < a; i++) {
var row = new T[b];
ret[i] = row;
for (int j = 0; j < b; j++) {
row[j] = defaultValue;
}
}
return ret;
}
/// <summary>
/// ่ฆ็ด ๆฐ (a, b) ใฎdefaultๅคใงๆบใใใใJag้
ๅใไฝๆใใพใใ
/// </summary>
/// <typeparam name="T">้
ๅใฎๅ</typeparam>
/// <param name="a">1ๆฌกๅ
ใฎ่ฆ็ด ๆฐ</param>
/// <param name="b">2ๆฌกๅ
ใฎ่ฆ็ด ๆฐ</param>
/// <returns>ๅๆๅใใใ้
ๅ</returns>
public static T[][] JagArray2D<T>(int a, int b)
where T : struct {
var ret = new T[a][];
for (int i = 0; i < a; i++) {
ret[i] = new T[b];
}
return ret;
}
public static T[][][] JagArray3D<T>(int a, int b, int c, T defaultValue)
where T : struct {
var ret = new T[a][][];
for (int i = 0; i < a; i++) {
T[][] aRow = new T[b][];
ret[i] = aRow;
for (int j = 0; j < b; j++) {
T[] bRow = new T[c];
aRow[j] = bRow;
for (int k = 0; k < c; k++) {
bRow[k] = defaultValue;
}
}
}
return ret;
}
public static T[][][] JagArray3D<T>(int a, int b, int c)
where T : struct {
var ret = new T[a][][];
for (int i = 0; i < a; i++) {
T[][] aRow = new T[b][];
ret[i] = aRow;
for (int j = 0; j < b; j++) {
T[] bRow = new T[c];
aRow[j] = bRow;
}
}
return ret;
}
public static T[][][][] JagArray4D<T>(int a, int b, int c, int d,
T defaultValue)
where T : struct {
var ret = new T[a][][][];
for (int i = 0; i < a; i++) {
T[][][] aRow = new T[b][][];
ret[i] = aRow;
for (int j = 0; j < b; j++) {
T[][] bRow = new T[c][];
aRow[j] = bRow;
for (int k = 0; k < c; k++) {
T[] cRow = new T[d];
bRow[k] = cRow;
for (int l = 0; l < d; l++) {
cRow[l] = defaultValue;
}
}
}
}
return ret;
}
public static T[][][][] JagArray4D<T>(int a, int b, int c, int d)
where T : struct {
var ret = new T[a][][][];
for (int i = 0; i < a; i++) {
T[][][] aRow = new T[b][][];
ret[i] = aRow;
for (int j = 0; j < b; j++) {
T[][] bRow = new T[c][];
aRow[j] = bRow;
for (int k = 0; k < c; k++) {
T[] cRow = new T[d];
bRow[k] = cRow;
}
}
}
return ret;
}
public static T[][][][][] JagArray5D<T>(int a, int b, int c, int d, int e,
T defaultValue)
where T : struct {
var ret = new T[a][][][][];
for (int i = 0; i < a; i++) {
T[][][][] aRow = new T[b][][][];
ret[i] = aRow;
for (int j = 0; j < b; j++) {
T[][][] bRow = new T[c][][];
aRow[j] = bRow;
for (int k = 0; k < c; k++) {
T[][] cRow = new T[d][];
bRow[k] = cRow;
for (int l = 0; l < d; l++) {
T[] dRow = new T[e];
cRow[l] = dRow;
for (int m = 0; m < e; m++) {
dRow[m] = defaultValue;
}
}
}
}
}
return ret;
}
public static T[][][][][] JagArray5D<T>(int a, int b, int c, int d, int e)
where T : struct {
var ret = new T[a][][][][];
for (int i = 0; i < a; i++) {
T[][][][] aRow = new T[b][][][];
ret[i] = aRow;
for (int j = 0; j < b; j++) {
T[][][] bRow = new T[c][][];
aRow[j] = bRow;
for (int k = 0; k < c; k++) {
T[][] cRow = new T[d][];
bRow[k] = cRow;
for (int l = 0; l < d; l++) {
T[] dRow = new T[e];
cRow[l] = dRow;
}
}
}
}
return ret;
}
/// <summary>
/// ใธใฃใฐ้
ๅใใณใใผใใฆ่ฟใใ
/// </summary>
public static T[][] CopyJagArray2D<T>(T[][] source)
where T : struct {
int len = source.Length;
T[][] dest = new T[len][];
for (int i = 0; i < len; i++) {
T[] inner = source[i];
int innerLength = inner.Length;
T[] newer = new T[innerLength];
Array.Copy(inner, newer, innerLength);
dest[i] = newer;
}
return dest;
}
}
public static class UtakaExtentions {
/// <summary>
/// IList<T>ใใณใใผใใพใ
/// </summary>
public static T[] Copy<T>(this IList<T> a) {
T[] ret = new T[a.Count];
for (int i = 0; i < a.Count; i++)
ret[i] = a[i];
return ret;
}
/// <summary>
/// 2ๆฌกๅ
ใธใฃใฐ้
ๅใใณใใผใใฆ่ฟใใ
/// </summary>
public static T[][] Copy<T>(this T[][] source)
where T : struct {
int len = source.Length;
T[][] dest = new T[len][];
for (int i = 0; i < len; i++) {
T[] inner = source[i];
int innerLength = inner.Length;
T[] newer = new T[innerLength];
Array.Copy(inner, newer, innerLength);
dest[i] = newer;
}
return dest;
}
}
public class IntLargeComparer : IComparer<int> {
public static IntLargeComparer Instance = new IntLargeComparer();
public int Compare(int x, int y) { return y - x; }
}
public class LongLargeComparer : IComparer<long> {
public static LongLargeComparer Instance = new LongLargeComparer();
public int Compare(long x, long y) {
if (x > y)
return -1;
if (x < y)
return 1;
return 0;
}
}
public class ConsoleInput {
private readonly char _separator = ' ';
private readonly TextReader _stream;
private readonly Queue<string> inputStream;
public ConsoleInput(TextReader stream, char separator = ' ') {
_separator = separator;
_stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0) {
return inputStream.Dequeue();
}
var tmp = _stream.ReadLine().Split(_separator);
for (var i = 0; i < tmp.Length; ++i) {
inputStream.Enqueue(tmp[i]);
}
return inputStream.Dequeue();
}
}
public string ReadLine => _stream.ReadLine();
public int ReadInt => int.Parse(Read);
public long ReadLong => long.Parse(Read);
public double ReadDouble => double.Parse(Read);
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i) {
ret[i] = Read;
}
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i) {
ret[i] = ReadInt;
}
return ret;
}
public int[] ReadIntArrayMinus1(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i) {
ret[i] = ReadInt - 1;
}
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i) {
ret[i] = ReadLong;
}
return ret;
}
}
public interface IConsole {
void Flush();
void Write(object obj);
void Write(string str);
void WriteLine(object obj);
void WriteLine(string str);
void WriteLine();
}
public class MyConsole : IConsole {
public MyConsole() {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
}
public void Flush() { Console.Out.Flush(); }
public void Write(object obj) { Write(obj.ToString()); }
public void Write(string str) { Console.Write(str); }
public void WriteLine(object obj) { WriteLine(obj.ToString()); }
public void WriteLine(string str) { Console.WriteLine(str); }
public void WriteLine() { Console.WriteLine(); }
}
#if UTAKA_LOCAL
public class DebugConsole : IConsole {
private readonly StringBuilder mSb;
public DebugConsole() { mSb = new StringBuilder(); }
public void Flush() {
// ไฝใใใชใ
}
public void Write(object obj) { Write(obj.ToString()); }
public void Write(string str) { mSb.Append(str); }
public void WriteLine(object obj) { WriteLine(obj.ToString()); }
public void WriteLine(string str) { mSb.AppendLine(str); }
public void WriteLine() { mSb.AppendLine(); }
public string GetAllOutput() { return mSb.ToString(); }
}
#endif
#if UTAKA_LOCAL
public class TestCaseCheckerForAtCoder {
private string GetDirectoryPath() {
var problemPart = string.IsNullOrEmpty(Program.ProblemName)
? ""
: $"/{Program.ProblemName}";
return $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}/AlgorithmPrac/{Program.SiteName}/{Program.ContestName}{problemPart}";
}
private string GetInputFilePath(int testCaseNumber) {
return $"{GetDirectoryPath()}/sample-{testCaseNumber}.in";
}
private string GetOutputFilePath(int testCaseNumber) {
return $"{GetDirectoryPath()}/sample-{testCaseNumber}.out";
}
public bool TestProblem(int testCaseNumber) {
var inputFilePath = GetInputFilePath(testCaseNumber);
var outputFilePath = GetOutputFilePath(testCaseNumber);
TextReader inputStream = new StreamReader(inputFilePath);
var cin = new ConsoleInput(inputStream);
var debugConsoleWriter = new DebugConsole();
new Program(cin, debugConsoleWriter).Solve();
var output = debugConsoleWriter.GetAllOutput();
TextReader outputStream = new StreamReader(outputFilePath);
var outputAnswer = outputStream.ReadToEnd();
Dbg.WriteLine(output);
Dbg.WriteLine(outputAnswer);
var isCorrect = output == outputAnswer;
return isCorrect;
}
public void TestProblems(int targetTestCaseNumber = -1) {
if (targetTestCaseNumber >= 0) {
Console.WriteLine(
$"!!!!!!!!!!!! Check TestCase {targetTestCaseNumber} !!!!!!!!!!");
}
bool isSuccessAll = true;
int testCaseNumber = 0;
while (true) {
testCaseNumber++;
bool foundTargetTest = targetTestCaseNumber == testCaseNumber;
if (targetTestCaseNumber >= 0 && !foundTargetTest) {
continue;
}
var inputFileName = GetInputFilePath(testCaseNumber);
if (!File.Exists(inputFileName)) {
break;
}
Console.WriteLine(
$"TestCase {testCaseNumber} =====================================================");
var result = TestProblem(testCaseNumber);
if (result) {
Console.WriteLine("Success");
} else {
isSuccessAll = false;
Console.WriteLine("Failure *****");
}
if (foundTargetTest) {
break;
}
}
if (isSuccessAll) {
Console.WriteLine("!!!!!!!!! All Success !!!!!!!!!");
}
}
}
#endif
public static class Dbg {
[Conditional("UTAKA_DEBUG")]
public static void WriteLine(string str) { Console.WriteLine(str); }
[Conditional("UTAKA_DEBUG")]
public static void WriteLine() { Console.WriteLine(); }
[Conditional("UTAKA_DEBUG")]
public static void Write(string str) { Console.Write(str); }
}
}
|
// ReSharper disable ArrangeTypeMemberModifiers
// ReSharper disable ConvertIfStatementToSwitchStatement
// ReSharper disable FunctionRecursiveOnAllPaths
// ReSharper disable InconsistentNaming
// ReSharper disable InlineOutVariableDeclaration
// ReSharper disable InvertIf
// ReSharper disable JoinDeclarationAndInitializer
// ReSharper disable MemberCanBeMadeStatic.Global
// ReSharper disable MemberCanBeMadeStatic.Local
// ReSharper disable NonReadonlyMemberInGetHashCode
// ReSharper disable PossibleNullReferenceException
// ReSharper disable RedundantUsingDirective
// ReSharper disable SuggestVarOrType_BuiltInTypes
// ReSharper disable SuggestVarOrType_Elsewhere
// ReSharper disable TailRecursiveCall
// ReSharper disable UnusedMember.Global
// ReSharper disable UnusedMember.Local
// ReSharper disable UseObjectOrCollectionInitializert
#if true && UTAKA_LOCAL
//#if false
#define UTAKA_DEBUG
#endif
//#define TOPCODER
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Numerics;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using static UtakaApp.Util;
namespace UtakaApp {
public partial class Program {
public const string SiteName = "AtCoder";
public const string ContestName = "agc041";
public const string ProblemName = "A";
public void Solve() {
long N = cin.ReadLong;
long A = cin.ReadLong - 1;
long B = cin.ReadLong - 1;
long diff = B - A;
if (diff % 2 == 0) {
cou.WriteLine(diff / 2);
return;
}
long diffA = A;
long diffB = N - 1 - B;
long v;
if (diffA < diffB) {
v = B + diffA + 1;
} else {
v = (N - 1 - A) + diffB + 1;
}
long ans = v / 2;
cou.WriteLine(ans);
}
public void Swap<T>(ref T a, ref T b) {
T c = a;
a = b;
b = c;
}
}
//=========================================================================================
// Debug IO
//=========================================================================================
public partial class Program {
//=========================================================================================
// Main
//=========================================================================================
private readonly ConsoleInput cin;
private readonly IConsole cou;
public Program(ConsoleInput cin, IConsole cou) {
this.cin = cin;
this.cou = cou;
}
#if !TOPCODER
public static void Main(string[] args) {
#if UTAKA_LOCAL
//#if false
new TestCaseCheckerForAtCoder().TestProblems();
#else
var cin = new ConsoleInput(System.Console.In);
var console = new MyConsole();
new Program(cin, console).Solve();
console.Flush();
#endif
}
#endif
public void WriteEnumerable<T>(IEnumerable<T> A, string delimiter = " ") {
if (!A.Any()) {
return;
}
var sb = new StringBuilder();
foreach (T v in A) {
sb.Append(v);
sb.Append(delimiter);
}
if (sb.Length > 0) {
sb.Length--;
}
cou.WriteLine(sb.ToString());
}
}
public static class Util {
public static int LowerBound<T>(T[] arr, int start, int end, T value,
IComparer<T> comparer) {
int low = start;
int high = end;
while (low < high) {
var mid = ((high - low) >> 1) + low;
if (comparer.Compare(arr[mid], value) < 0)
low = mid + 1;
else
high = mid;
}
return low;
}
public static int LowerBound<T>(T[] arr, T value)
where T : IComparable {
return LowerBound(arr, 0, arr.Length, value, Comparer<T>.Default);
}
public static int UpperBound<T>(T[] arr, int start, int end, T value,
IComparer<T> comparer) {
int low = start;
int high = end;
while (low < high) {
var mid = ((high - low) >> 1) + low;
if (comparer.Compare(arr[mid], value) <= 0)
low = mid + 1;
else
high = mid;
}
return low;
}
public static int UpperBound<T>(T[] arr, T value) {
return UpperBound(arr, 0, arr.Length, value, Comparer<T>.Default);
}
public static int UpperBound<T>(List<T> list, int start, int end, T value,
IComparer<T> comparer) {
int low = start;
int high = end;
while (low < high) {
var mid = ((high - low) >> 1) + low;
if (comparer.Compare(list[mid], value) <= 0)
low = mid + 1;
else
high = mid;
}
return low;
}
public static int UpperBound<T>(List<T> list, T value) {
return UpperBound(list, 0, list.Count, value, Comparer<T>.Default);
}
public static T[] Array1D<T>(int a, T defaultValue)
where T : struct {
var ret = new T[a];
for (int i = 0; i < a; i++) {
ret[i] = defaultValue;
}
return ret;
}
public static T[] Array1D<T>(int a)
where T : struct {
var ret = new T[a];
return ret;
}
/// <summary>
/// ่ฆ็ด ๆฐ (a, b) ใฎใdefaultValue ใงๆบใใใใ้
ๅใไฝๆใใพใใ
/// </summary>
/// <typeparam name="T">้
ๅใฎๅ</typeparam>
/// <param name="a">1ๆฌกๅ
ใฎ่ฆ็ด ๆฐ</param>
/// <param name="b">2ๆฌกๅ
ใฎ่ฆ็ด ๆฐ</param>
/// <param name="defaultValue">ใใใฉใซใๅค</param>
/// <returns>ๆๅฎใใๆกไปถใงๅๆๅใใใ้
ๅ</returns>
public static T[,] Array2D<T>(int a, int b, T defaultValue)
where T : struct {
var ret = new T[a, b];
for (int i = 0; i < a; i++) {
for (int j = 0; j < b; j++) {
ret[i, j] = defaultValue;
}
}
return ret;
}
public static T[,,] Array3D<T>(int a, int b, int c, T defaultValue)
where T : struct {
T[,,] ret = new T[a, b, c];
for (int i = 0; i < a; i++) {
for (int j = 0; j < b; j++) {
for (int k = 0; k < c; k++) {
ret[i, j, k] = defaultValue;
}
}
}
return ret;
}
/// <summary>
/// ่ฆ็ด ๆฐ (a, b) ใฎใdefaultValue ใงๆบใใใใJag้
ๅใไฝๆใใพใใ
/// </summary>
/// <typeparam name="T">้
ๅใฎๅ</typeparam>
/// <param name="a">1ๆฌกๅ
ใฎ่ฆ็ด ๆฐ</param>
/// <param name="b">2ๆฌกๅ
ใฎ่ฆ็ด ๆฐ</param>
/// <param name="defaultValue">ใใใฉใซใๅค</param>
/// <returns>ๆๅฎใใๆกไปถใงๅๆๅใใใ้
ๅ</returns>
public static T[][] JagArray2D<T>(int a, int b, T defaultValue)
where T : struct {
var ret = new T[a][];
for (int i = 0; i < a; i++) {
var row = new T[b];
ret[i] = row;
for (int j = 0; j < b; j++) {
row[j] = defaultValue;
}
}
return ret;
}
/// <summary>
/// ่ฆ็ด ๆฐ (a, b) ใฎdefaultๅคใงๆบใใใใJag้
ๅใไฝๆใใพใใ
/// </summary>
/// <typeparam name="T">้
ๅใฎๅ</typeparam>
/// <param name="a">1ๆฌกๅ
ใฎ่ฆ็ด ๆฐ</param>
/// <param name="b">2ๆฌกๅ
ใฎ่ฆ็ด ๆฐ</param>
/// <returns>ๅๆๅใใใ้
ๅ</returns>
public static T[][] JagArray2D<T>(int a, int b)
where T : struct {
var ret = new T[a][];
for (int i = 0; i < a; i++) {
ret[i] = new T[b];
}
return ret;
}
public static T[][][] JagArray3D<T>(int a, int b, int c, T defaultValue)
where T : struct {
var ret = new T[a][][];
for (int i = 0; i < a; i++) {
T[][] aRow = new T[b][];
ret[i] = aRow;
for (int j = 0; j < b; j++) {
T[] bRow = new T[c];
aRow[j] = bRow;
for (int k = 0; k < c; k++) {
bRow[k] = defaultValue;
}
}
}
return ret;
}
public static T[][][] JagArray3D<T>(int a, int b, int c)
where T : struct {
var ret = new T[a][][];
for (int i = 0; i < a; i++) {
T[][] aRow = new T[b][];
ret[i] = aRow;
for (int j = 0; j < b; j++) {
T[] bRow = new T[c];
aRow[j] = bRow;
}
}
return ret;
}
public static T[][][][] JagArray4D<T>(int a, int b, int c, int d,
T defaultValue)
where T : struct {
var ret = new T[a][][][];
for (int i = 0; i < a; i++) {
T[][][] aRow = new T[b][][];
ret[i] = aRow;
for (int j = 0; j < b; j++) {
T[][] bRow = new T[c][];
aRow[j] = bRow;
for (int k = 0; k < c; k++) {
T[] cRow = new T[d];
bRow[k] = cRow;
for (int l = 0; l < d; l++) {
cRow[l] = defaultValue;
}
}
}
}
return ret;
}
public static T[][][][] JagArray4D<T>(int a, int b, int c, int d)
where T : struct {
var ret = new T[a][][][];
for (int i = 0; i < a; i++) {
T[][][] aRow = new T[b][][];
ret[i] = aRow;
for (int j = 0; j < b; j++) {
T[][] bRow = new T[c][];
aRow[j] = bRow;
for (int k = 0; k < c; k++) {
T[] cRow = new T[d];
bRow[k] = cRow;
}
}
}
return ret;
}
public static T[][][][][] JagArray5D<T>(int a, int b, int c, int d, int e,
T defaultValue)
where T : struct {
var ret = new T[a][][][][];
for (int i = 0; i < a; i++) {
T[][][][] aRow = new T[b][][][];
ret[i] = aRow;
for (int j = 0; j < b; j++) {
T[][][] bRow = new T[c][][];
aRow[j] = bRow;
for (int k = 0; k < c; k++) {
T[][] cRow = new T[d][];
bRow[k] = cRow;
for (int l = 0; l < d; l++) {
T[] dRow = new T[e];
cRow[l] = dRow;
for (int m = 0; m < e; m++) {
dRow[m] = defaultValue;
}
}
}
}
}
return ret;
}
public static T[][][][][] JagArray5D<T>(int a, int b, int c, int d, int e)
where T : struct {
var ret = new T[a][][][][];
for (int i = 0; i < a; i++) {
T[][][][] aRow = new T[b][][][];
ret[i] = aRow;
for (int j = 0; j < b; j++) {
T[][][] bRow = new T[c][][];
aRow[j] = bRow;
for (int k = 0; k < c; k++) {
T[][] cRow = new T[d][];
bRow[k] = cRow;
for (int l = 0; l < d; l++) {
T[] dRow = new T[e];
cRow[l] = dRow;
}
}
}
}
return ret;
}
/// <summary>
/// ใธใฃใฐ้
ๅใใณใใผใใฆ่ฟใใ
/// </summary>
public static T[][] CopyJagArray2D<T>(T[][] source)
where T : struct {
int len = source.Length;
T[][] dest = new T[len][];
for (int i = 0; i < len; i++) {
T[] inner = source[i];
int innerLength = inner.Length;
T[] newer = new T[innerLength];
Array.Copy(inner, newer, innerLength);
dest[i] = newer;
}
return dest;
}
}
public static class UtakaExtentions {
/// <summary>
/// IList<T>ใใณใใผใใพใ
/// </summary>
public static T[] Copy<T>(this IList<T> a) {
T[] ret = new T[a.Count];
for (int i = 0; i < a.Count; i++)
ret[i] = a[i];
return ret;
}
/// <summary>
/// 2ๆฌกๅ
ใธใฃใฐ้
ๅใใณใใผใใฆ่ฟใใ
/// </summary>
public static T[][] Copy<T>(this T[][] source)
where T : struct {
int len = source.Length;
T[][] dest = new T[len][];
for (int i = 0; i < len; i++) {
T[] inner = source[i];
int innerLength = inner.Length;
T[] newer = new T[innerLength];
Array.Copy(inner, newer, innerLength);
dest[i] = newer;
}
return dest;
}
}
public class IntLargeComparer : IComparer<int> {
public static IntLargeComparer Instance = new IntLargeComparer();
public int Compare(int x, int y) { return y - x; }
}
public class LongLargeComparer : IComparer<long> {
public static LongLargeComparer Instance = new LongLargeComparer();
public int Compare(long x, long y) {
if (x > y)
return -1;
if (x < y)
return 1;
return 0;
}
}
public class ConsoleInput {
private readonly char _separator = ' ';
private readonly TextReader _stream;
private readonly Queue<string> inputStream;
public ConsoleInput(TextReader stream, char separator = ' ') {
_separator = separator;
_stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0) {
return inputStream.Dequeue();
}
var tmp = _stream.ReadLine().Split(_separator);
for (var i = 0; i < tmp.Length; ++i) {
inputStream.Enqueue(tmp[i]);
}
return inputStream.Dequeue();
}
}
public string ReadLine => _stream.ReadLine();
public int ReadInt => int.Parse(Read);
public long ReadLong => long.Parse(Read);
public double ReadDouble => double.Parse(Read);
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i) {
ret[i] = Read;
}
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i) {
ret[i] = ReadInt;
}
return ret;
}
public int[] ReadIntArrayMinus1(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i) {
ret[i] = ReadInt - 1;
}
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i) {
ret[i] = ReadLong;
}
return ret;
}
}
public interface IConsole {
void Flush();
void Write(object obj);
void Write(string str);
void WriteLine(object obj);
void WriteLine(string str);
void WriteLine();
}
public class MyConsole : IConsole {
public MyConsole() {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
}
public void Flush() { Console.Out.Flush(); }
public void Write(object obj) { Write(obj.ToString()); }
public void Write(string str) { Console.Write(str); }
public void WriteLine(object obj) { WriteLine(obj.ToString()); }
public void WriteLine(string str) { Console.WriteLine(str); }
public void WriteLine() { Console.WriteLine(); }
}
#if UTAKA_LOCAL
public class DebugConsole : IConsole {
private readonly StringBuilder mSb;
public DebugConsole() { mSb = new StringBuilder(); }
public void Flush() {
// ไฝใใใชใ
}
public void Write(object obj) { Write(obj.ToString()); }
public void Write(string str) { mSb.Append(str); }
public void WriteLine(object obj) { WriteLine(obj.ToString()); }
public void WriteLine(string str) { mSb.AppendLine(str); }
public void WriteLine() { mSb.AppendLine(); }
public string GetAllOutput() { return mSb.ToString(); }
}
#endif
#if UTAKA_LOCAL
public class TestCaseCheckerForAtCoder {
private string GetDirectoryPath() {
var problemPart = string.IsNullOrEmpty(Program.ProblemName)
? ""
: $"/{Program.ProblemName}";
return $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}/AlgorithmPrac/{Program.SiteName}/{Program.ContestName}{problemPart}";
}
private string GetInputFilePath(int testCaseNumber) {
return $"{GetDirectoryPath()}/sample-{testCaseNumber}.in";
}
private string GetOutputFilePath(int testCaseNumber) {
return $"{GetDirectoryPath()}/sample-{testCaseNumber}.out";
}
public bool TestProblem(int testCaseNumber) {
var inputFilePath = GetInputFilePath(testCaseNumber);
var outputFilePath = GetOutputFilePath(testCaseNumber);
TextReader inputStream = new StreamReader(inputFilePath);
var cin = new ConsoleInput(inputStream);
var debugConsoleWriter = new DebugConsole();
new Program(cin, debugConsoleWriter).Solve();
var output = debugConsoleWriter.GetAllOutput();
TextReader outputStream = new StreamReader(outputFilePath);
var outputAnswer = outputStream.ReadToEnd();
Dbg.WriteLine(output);
Dbg.WriteLine(outputAnswer);
var isCorrect = output == outputAnswer;
return isCorrect;
}
public void TestProblems(int targetTestCaseNumber = -1) {
if (targetTestCaseNumber >= 0) {
Console.WriteLine(
$"!!!!!!!!!!!! Check TestCase {targetTestCaseNumber} !!!!!!!!!!");
}
bool isSuccessAll = true;
int testCaseNumber = 0;
while (true) {
testCaseNumber++;
bool foundTargetTest = targetTestCaseNumber == testCaseNumber;
if (targetTestCaseNumber >= 0 && !foundTargetTest) {
continue;
}
var inputFileName = GetInputFilePath(testCaseNumber);
if (!File.Exists(inputFileName)) {
break;
}
Console.WriteLine(
$"TestCase {testCaseNumber} =====================================================");
var result = TestProblem(testCaseNumber);
if (result) {
Console.WriteLine("Success");
} else {
isSuccessAll = false;
Console.WriteLine("Failure *****");
}
if (foundTargetTest) {
break;
}
}
if (isSuccessAll) {
Console.WriteLine("!!!!!!!!! All Success !!!!!!!!!");
}
}
}
#endif
public static class Dbg {
[Conditional("UTAKA_DEBUG")]
public static void WriteLine(string str) { Console.WriteLine(str); }
[Conditional("UTAKA_DEBUG")]
public static void WriteLine() { Console.WriteLine(); }
[Conditional("UTAKA_DEBUG")]
public static void Write(string str) { Console.Write(str); }
}
}
|
[["-", 64, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["-", 75, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 0, 11, 12, 16, 31, 16, 31, 23, 0, 24], ["+", 31, 16, 31, 23, 0, 16, 31, 16, 31, 22], ["+", 31, 16, 31, 23, 0, 16, 31, 16, 17, 33], ["+", 31, 16, 31, 23, 0, 16, 31, 16, 12, 203], ["+", 12, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["+", 12, 16, 31, 16, 31, 23, 0, 16, 12, 22], ["+", 0, 11, 12, 16, 31, 16, 31, 23, 0, 25], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203]]
| 8
| 3,994
| 16
|
using System;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.IO;
using System.Text;
using N = System.Int64;
public class Solver {
public void Solve() {
N n = rl;
N a = rl;
N b = rl;
if ((a - b) % 2 == 0) {
Write(Math.Abs(a - b) / 2);
} else {
Write((a + b - 1) / 2);
}
}
int ri {
get { return sc.Integer(); }
}
long rl {
get { return sc.Long(); }
}
double rd {
get { return sc.Double(); }
}
string rs {
get { return sc.Scan(); }
}
public StreamScanner sc = new StreamScanner(Console.OpenStandardInput());
/*
private const N mod = 1000000007;
N Reverse(N n) { return Pow(n, mod - 2); }
N Mul(params N[] n) { N p = n[0]; for (N i = 1; i < n.Length; i++) { p = (p *
n[i]) % mod; } return p; } N Pow(N n, N p) { N t = n, q = 1; while (p > 0) {
if (p % 2 == 1) { q = (q * t) % mod; } t = (t * t) % mod; p >>= 1; } return q;
} N PowUpper(N n, N b) { N p = 1; while (p <= n) { p *= b; } return p; } N
Sign(N n) { return n == 0 ? 0 : n > 0 ? 1 : -1; } N Abs(N n) { return (n > 0)
? n : -n; } N Gcd(params N[] n) { N p = n[0]; for (N i = 1; i < n.Length; i++)
{ p = Gcd(p, n[i]); } return p; } N Gcd(N a, N b) { return (a == 0) ? b :
Gcd(b % a, a); } N Lcm(params N[] n) { N p = n[0]; for (N i = 1; i < n.Length;
i++) { p = Lcm(p, n[i]); } return p; } N Lcm(N a, N b) { return (a / Gcd(a, b)
* b) % mod; }
*/
void Write<T>(T t) { Console.WriteLine(t.ToString()); }
void YN(bool t) { Console.WriteLine(t ? "YES" : "NO"); }
void Yn(bool t) { Console.WriteLine(t ? "Yes" : "No"); }
void yn(bool t) { Console.WriteLine(t ? "yes" : "no"); }
}
static class Program {
static public void Main(string[] args) {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
var solver = new Solver();
solver.Solve();
Console.Out.Flush();
}
}
public class StreamScanner {
public StreamScanner(Stream stream) { str = stream; }
private readonly Stream str;
private readonly byte[] buf = new byte[1024];
private int len, ptr;
public bool isEof = false;
public bool IsEndOfStream {
get { return isEof; }
}
private byte read() {
if (isEof)
throw new EndOfStreamException();
if (ptr >= len) {
ptr = 0;
if ((len = str.Read(buf, 0, 1024)) <= 0) {
isEof = true;
return 0;
}
}
return buf[ptr++];
}
public char Char() {
byte b = 0;
do
b = read();
while (b < 33 || 126 < b);
return (char)b;
}
public string Scan() {
var sb = new StringBuilder();
for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
sb.Append(b);
return sb.ToString();
}
public long Long() {
long ret = 0;
byte b = 0;
var ng = false;
do
b = read();
while (b != '-' && (b < '0' || '9' < b));
if (b == '-') {
ng = true;
b = read();
}
for (; true; b = read()) {
if (b < '0' || '9' < b)
return ng ? -ret : ret;
else
ret = ret * 10 + b - '0';
}
}
public int Integer() { return (int)Long(); }
public double Double() { return double.Parse(Scan()); }
}
|
using System;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.IO;
using System.Text;
using N = System.Int64;
public class Solver {
public void Solve() {
N n = rl;
N a = rl;
N b = rl;
if ((a - b) % 2 == 0) {
Write(Math.Abs(a - b) / 2);
} else {
Write(Math.Min((a + b - 1) / 2, (2 * n - a - b + 1) / 2));
}
}
int ri {
get { return sc.Integer(); }
}
long rl {
get { return sc.Long(); }
}
double rd {
get { return sc.Double(); }
}
string rs {
get { return sc.Scan(); }
}
public StreamScanner sc = new StreamScanner(Console.OpenStandardInput());
/*
private const N mod = 1000000007;
N Reverse(N n) { return Pow(n, mod - 2); }
N Mul(params N[] n) { N p = n[0]; for (N i = 1; i < n.Length; i++) { p = (p *
n[i]) % mod; } return p; } N Pow(N n, N p) { N t = n, q = 1; while (p > 0) {
if (p % 2 == 1) { q = (q * t) % mod; } t = (t * t) % mod; p >>= 1; } return q;
} N PowUpper(N n, N b) { N p = 1; while (p <= n) { p *= b; } return p; } N
Sign(N n) { return n == 0 ? 0 : n > 0 ? 1 : -1; } N Abs(N n) { return (n > 0)
? n : -n; } N Gcd(params N[] n) { N p = n[0]; for (N i = 1; i < n.Length; i++)
{ p = Gcd(p, n[i]); } return p; } N Gcd(N a, N b) { return (a == 0) ? b :
Gcd(b % a, a); } N Lcm(params N[] n) { N p = n[0]; for (N i = 1; i < n.Length;
i++) { p = Lcm(p, n[i]); } return p; } N Lcm(N a, N b) { return (a / Gcd(a, b)
* b) % mod; }
*/
void Write<T>(T t) { Console.WriteLine(t.ToString()); }
void YN(bool t) { Console.WriteLine(t ? "YES" : "NO"); }
void Yn(bool t) { Console.WriteLine(t ? "Yes" : "No"); }
void yn(bool t) { Console.WriteLine(t ? "yes" : "no"); }
}
static class Program {
static public void Main(string[] args) {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
var solver = new Solver();
solver.Solve();
Console.Out.Flush();
}
}
public class StreamScanner {
public StreamScanner(Stream stream) { str = stream; }
private readonly Stream str;
private readonly byte[] buf = new byte[1024];
private int len, ptr;
public bool isEof = false;
public bool IsEndOfStream {
get { return isEof; }
}
private byte read() {
if (isEof)
throw new EndOfStreamException();
if (ptr >= len) {
ptr = 0;
if ((len = str.Read(buf, 0, 1024)) <= 0) {
isEof = true;
return 0;
}
}
return buf[ptr++];
}
public char Char() {
byte b = 0;
do
b = read();
while (b < 33 || 126 < b);
return (char)b;
}
public string Scan() {
var sb = new StringBuilder();
for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
sb.Append(b);
return sb.ToString();
}
public long Long() {
long ret = 0;
byte b = 0;
var ng = false;
do
b = read();
while (b != '-' && (b < '0' || '9' < b));
if (b == '-') {
ng = true;
b = read();
}
for (; true; b = read()) {
if (b < '0' || '9' < b)
return ng ? -ret : ret;
else
ret = ret * 10 + b - '0';
}
}
public int Integer() { return (int)Long(); }
public double Double() { return double.Parse(Scan()); }
}
|
[["+", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 21], ["+", 0, 16, 31, 16, 31, 16, 31, 16, 31, 203], ["+", 0, 16, 31, 16, 31, 16, 31, 16, 17, 48], ["+", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["+", 31, 23, 0, 16, 31, 16, 31, 16, 17, 33], ["+", 31, 23, 0, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 16, 31, 23, 0, 16, 31, 16, 17, 33], ["+", 0, 16, 31, 23, 0, 16, 31, 16, 12, 22], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 12, 203], ["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 25], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 85], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25]]
| 8
| 694
| 19
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;
namespace Program {
public static class AGC041A {
static public int numberOfRandomCases = 0;
static public void MakeTestCase(List<string> _input, List<string> _output,
ref Func<string[], bool> _outputChecker) {}
static public void Solve() {
var N = NN;
var B = NN;
var A = NN;
if ((A - B) % 2 == 0) {
Console.WriteLine((A - B) / 2);
} else {
var min = Min(A - 1, N - B);
Console.WriteLine((A - B - 1) / 2 + min);
}
}
static class Console_ {
static Queue<string> param = new Queue<string>();
public static string NextString() {
if (param.Count == 0)
foreach (var item in Console.ReadLine().Split(' '))
param.Enqueue(item);
return param.Dequeue();
}
}
class Printer : StreamWriter {
public override IFormatProvider FormatProvider {
get { return CultureInfo.InvariantCulture; }
}
public Printer(Stream stream)
: base(stream, new UTF8Encoding(false, true)) {
base.AutoFlush = false;
}
public Printer(Stream stream, Encoding encoding) : base(stream, encoding) {
base.AutoFlush = false;
}
}
static public void Main(string[] args) {
if (args.Length == 0) {
Console.SetOut(new Printer(Console.OpenStandardOutput()));
}
var t = new Thread(Solve, 134217728);
t.Start();
t.Join();
Console.Out.Flush();
}
static long NN => long.Parse(Console_.NextString());
static double ND => double.Parse(Console_.NextString());
static string NS => Console_.NextString();
static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
static IEnumerable<T>
OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => xorshift);
static long Count<T>(this IEnumerable<T> x,
Func<T, bool> pred) => Enumerable.Count(x, pred);
static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v,
(int)n);
static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s,
(int)c);
static uint xorshift {
get {
_xsi.MoveNext();
return _xsi.Current;
}
}
static IEnumerator<uint> _xsi = _xsc();
static IEnumerator<uint> _xsc() {
uint x = 123456789, y = 362436069, z = 521288629,
w = (uint)(DateTime.Now.Ticks & 0xffffffff);
while (true) {
var t = x ^ (x << 11);
x = y;
y = z;
z = w;
w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
yield return w;
}
}
}
}
namespace Library {}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;
namespace Program {
public static class AGC041A {
static public int numberOfRandomCases = 0;
static public void MakeTestCase(List<string> _input, List<string> _output,
ref Func<string[], bool> _outputChecker) {}
static public void Solve() {
var N = NN;
var A = NN;
var B = NN;
if ((B - A) % 2 == 0) {
Console.WriteLine((B - A) / 2);
} else {
var min = Min(A - 1, N - B);
Console.WriteLine((B - A - 1) / 2 + min + 1);
}
}
static class Console_ {
static Queue<string> param = new Queue<string>();
public static string NextString() {
if (param.Count == 0)
foreach (var item in Console.ReadLine().Split(' '))
param.Enqueue(item);
return param.Dequeue();
}
}
class Printer : StreamWriter {
public override IFormatProvider FormatProvider {
get { return CultureInfo.InvariantCulture; }
}
public Printer(Stream stream)
: base(stream, new UTF8Encoding(false, true)) {
base.AutoFlush = false;
}
public Printer(Stream stream, Encoding encoding) : base(stream, encoding) {
base.AutoFlush = false;
}
}
static public void Main(string[] args) {
if (args.Length == 0) {
Console.SetOut(new Printer(Console.OpenStandardOutput()));
}
var t = new Thread(Solve, 134217728);
t.Start();
t.Join();
Console.Out.Flush();
}
static long NN => long.Parse(Console_.NextString());
static double ND => double.Parse(Console_.NextString());
static string NS => Console_.NextString();
static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
static IEnumerable<T>
OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => xorshift);
static long Count<T>(this IEnumerable<T> x,
Func<T, bool> pred) => Enumerable.Count(x, pred);
static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v,
(int)n);
static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s,
(int)c);
static uint xorshift {
get {
_xsi.MoveNext();
return _xsi.Current;
}
}
static IEnumerator<uint> _xsi = _xsc();
static IEnumerator<uint> _xsc() {
uint x = 123456789, y = 362436069, z = 521288629,
w = (uint)(DateTime.Now.Ticks & 0xffffffff);
while (true) {
var t = x ^ (x << 11);
x = y;
y = z;
z = w;
w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
yield return w;
}
}
}
}
namespace Library {}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 15, 16, 31, 16, 31, 23, 0, 16, 31, 22], ["-", 15, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["+", 15, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["+", 15, 16, 31, 16, 31, 23, 0, 16, 12, 22], ["-", 0, 28, 0, 16, 31, 23, 0, 16, 31, 22], ["-", 0, 28, 0, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 12, 22], ["-", 31, 16, 31, 23, 0, 16, 31, 16, 31, 22], ["-", 31, 16, 31, 23, 0, 16, 31, 16, 17, 33], ["+", 31, 16, 31, 23, 0, 16, 31, 16, 17, 33], ["+", 31, 16, 31, 23, 0, 16, 31, 16, 12, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
| 8
| 760
| 18
|
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;
namespace AGC041B {
class Program {
static void Main(string[] args) {
var N = RInt;
var M = RInt;
var V = RInt;
var P = RInt;
var A = RInts.OrderByDescending(x => x).ToArray();
int l = 0;
int r = N;
while (r - l > 1) {
int mid = (r + l) / 2;
long point = A[mid] + M;
int biggerCount = 0;
long yoyuu = 0;
for (int i = 0; i < mid - 1; i++) {
if (i == mid)
continue;
if (A[i] > point)
biggerCount++;
else {
yoyuu += point - A[i];
}
}
bool ok = true;
if (biggerCount >= P)
ok = false;
if (V - 1 - (N - mid) > yoyuu)
ok = false;
if (ok)
l = mid;
else
r = mid;
}
Console.WriteLine(l + 1);
}
}
}
namespace Assistant {
static class Input {
static List<string> line = new List<string>();
static int index = 0;
static String RNext() {
if (line.Count <= index)
line.AddRange(Console.ReadLine().Split());
return line[index++];
}
public static int RInt => int.Parse(RNext());
public static long RLong => long.Parse(RNext());
public static int[] RInts =>
Console.ReadLine().Split().Select(int.Parse).ToArray();
public static long[] RLongs =>
Console.ReadLine().Split().Select(long.Parse).ToArray();
public static string RString => RNext();
//ไปฅไธๆชใในใ
public static int[] RIntsC(int c) =>
Enumerable.Repeat(0, c).Select(x => int.Parse(RNext())).ToArray();
public static long[] RLongsC(int c) =>
Enumerable.Repeat(0, c).Select(x => long.Parse(RNext())).ToArray();
public static char[][] RMap(int h) =>
Enumerable.Repeat(0, h)
.Select(x => Console.ReadLine().ToCharArray())
.ToArray();
}
public struct Mlong {
long _v;
const long mod = 1000000007;
public Mlong(long n = 0) : this() { _v = n >= mod ? n % mod : n; }
public static implicit operator Mlong(long _x) => new Mlong(_x);
public static implicit operator long(Mlong _x) => _x._v;
public static Mlong operator +(Mlong m1, Mlong m2) {
long m = m1._v + m2._v;
return m >= mod ? m - mod : m;
}
public static Mlong operator -(Mlong m1, Mlong m2) {
long m = m1._v - m2._v;
return m >= 0 ? m : m + mod;
}
public static Mlong operator *(Mlong m1, Mlong m2) => m1._v * m2._v % mod;
public static Mlong
operator /(Mlong m1, Mlong m2) => m1._v * ModPow(m2._v, mod - 2) % mod;
public static long ModPow(long a, long n) {
if (n == 0)
return 1;
else if (n % 2 == 1)
return a * ModPow(a, n - 1) % mod;
else
return ModPow(a * a % mod, n / 2);
}
static Mlong[] fac, finv, inv;
public static void nCkInit(int max) {
fac = new Mlong[max];
finv = new Mlong[max];
inv = new Mlong[max];
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < max; i++) {
fac[i] = fac[i - 1] * i;
inv[i] = mod - inv[mod % i] * (mod / i);
finv[i] = finv[i - 1] * inv[i];
}
}
public static Mlong nCk(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * finv[k] * finv[n - k];
}
}
static class Debug {
static public void Draw2D<T>(T[,] map, int mode = 1) {
#if DEBUG
int W = map.GetLength(0);
int H = map.GetLength(1);
string[,] map2 = new string[W + 1, H + 1];
for (int i = 0; i < W + 1; i++) {
for (int j = 0; j < H + 1; j++) {
if (i == 0 && j == 0)
map2[i, j] = 0.ToString();
else if (i == 0)
map2[i, j] = (j - 1).ToString();
else if (j == 0)
map2[i, j] = (i - 1).ToString();
else
map2[i, j] = map[i - 1, j - 1].ToString();
}
}
for (int i = 0; i < W + 1; i++) {
for (int j = 0; j < H + 1; j++) {
if (mode == 0)
Console.Write(map2[i, j].Last());
if (mode == 1)
Console.Write(map2[i, j] + " ");
}
Console.WriteLine();
}
Console.WriteLine();
#endif
}
public static void Draw1D<T>(T[] array, int mode = 0) {
#if DEBUG
Console.WriteLine(string.Join(" ", array));
#endif
}
}
}
|
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;
namespace AGC041B {
class Program {
static void Main(string[] args) {
var N = RInt;
var M = RLong;
var V = RInt;
var P = RInt;
var A = RLongs.OrderByDescending(x => x).ToArray();
int l = 0;
int r = N;
while (r - l > 1) {
int mid = (r + l) / 2;
long point = A[mid] + M;
int biggerCount = 0;
long yoyuu = 0;
for (int i = 0; i < mid; i++) {
if (A[i] > point)
biggerCount++;
else if (i >= P - 1) {
yoyuu += point - A[i];
}
}
bool ok = true;
if (biggerCount >= P)
ok = false;
if (M * (V - (N - mid) - (P - 1)) > yoyuu)
ok = false;
if (ok)
l = mid;
else
r = mid;
}
Console.WriteLine(l + 1);
}
}
}
namespace Assistant {
static class Input {
static List<string> line = new List<string>();
static int index = 0;
static String RNext() {
if (line.Count <= index)
line.AddRange(Console.ReadLine().Split());
return line[index++];
}
public static int RInt => int.Parse(RNext());
public static long RLong => long.Parse(RNext());
public static int[] RInts =>
Console.ReadLine().Split().Select(int.Parse).ToArray();
public static long[] RLongs =>
Console.ReadLine().Split().Select(long.Parse).ToArray();
public static string RString => RNext();
//ไปฅไธๆชใในใ
public static int[] RIntsC(int c) =>
Enumerable.Repeat(0, c).Select(x => int.Parse(RNext())).ToArray();
public static long[] RLongsC(int c) =>
Enumerable.Repeat(0, c).Select(x => long.Parse(RNext())).ToArray();
public static char[][] RMap(int h) =>
Enumerable.Repeat(0, h)
.Select(x => Console.ReadLine().ToCharArray())
.ToArray();
}
public struct Mlong {
long _v;
const long mod = 1000000007;
public Mlong(long n = 0) : this() { _v = n >= mod ? n % mod : n; }
public static implicit operator Mlong(long _x) => new Mlong(_x);
public static implicit operator long(Mlong _x) => _x._v;
public static Mlong operator +(Mlong m1, Mlong m2) {
long m = m1._v + m2._v;
return m >= mod ? m - mod : m;
}
public static Mlong operator -(Mlong m1, Mlong m2) {
long m = m1._v - m2._v;
return m >= 0 ? m : m + mod;
}
public static Mlong operator *(Mlong m1, Mlong m2) => m1._v * m2._v % mod;
public static Mlong
operator /(Mlong m1, Mlong m2) => m1._v * ModPow(m2._v, mod - 2) % mod;
public static long ModPow(long a, long n) {
if (n == 0)
return 1;
else if (n % 2 == 1)
return a * ModPow(a, n - 1) % mod;
else
return ModPow(a * a % mod, n / 2);
}
static Mlong[] fac, finv, inv;
public static void nCkInit(int max) {
fac = new Mlong[max];
finv = new Mlong[max];
inv = new Mlong[max];
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < max; i++) {
fac[i] = fac[i - 1] * i;
inv[i] = mod - inv[mod % i] * (mod / i);
finv[i] = finv[i - 1] * inv[i];
}
}
public static Mlong nCk(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * finv[k] * finv[n - k];
}
}
static class Debug {
static public void Draw2D<T>(T[,] map, int mode = 1) {
#if DEBUG
int W = map.GetLength(0);
int H = map.GetLength(1);
string[,] map2 = new string[W + 1, H + 1];
for (int i = 0; i < W + 1; i++) {
for (int j = 0; j < H + 1; j++) {
if (i == 0 && j == 0)
map2[i, j] = 0.ToString();
else if (i == 0)
map2[i, j] = (j - 1).ToString();
else if (j == 0)
map2[i, j] = (i - 1).ToString();
else
map2[i, j] = map[i - 1, j - 1].ToString();
}
}
for (int i = 0; i < W + 1; i++) {
for (int j = 0; j < H + 1; j++) {
if (mode == 0)
Console.Write(map2[i, j].Last());
if (mode == 1)
Console.Write(map2[i, j] + " ");
}
Console.WriteLine();
}
Console.WriteLine();
#endif
}
public static void Draw1D<T>(T[] array, int mode = 0) {
#if DEBUG
Console.WriteLine(string.Join(" ", array));
#endif
}
}
}
|
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 205, 22], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["-", 0, 7, 8, 196, 0, 57, 64, 116, 0, 117], ["-", 0, 7, 8, 196, 0, 57, 64, 116, 0, 35], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 0, 7, 8, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 7, 8, 196, 0, 57, 75, 57, 0, 24], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 31, 22], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 20], ["+", 0, 57, 75, 57, 15, 16, 12, 16, 31, 22], ["+", 0, 57, 75, 57, 15, 16, 12, 16, 17, 33], ["+", 0, 57, 75, 57, 15, 16, 12, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 57, 75, 57, 0, 25], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 48], ["-", 0, 57, 15, 16, 31, 16, 31, 16, 17, 33], ["-", 0, 57, 15, 16, 31, 16, 31, 16, 12, 203], ["+", 12, 23, 0, 16, 31, 16, 12, 23, 0, 25], ["+", 15, 16, 31, 16, 12, 23, 0, 16, 17, 33], ["+", 31, 16, 12, 23, 0, 16, 12, 23, 0, 24], ["+", 12, 23, 0, 16, 12, 23, 0, 16, 31, 22], ["+", 12, 23, 0, 16, 12, 23, 0, 16, 17, 33], ["+", 12, 23, 0, 16, 12, 23, 0, 16, 12, 203], ["+", 31, 16, 12, 23, 0, 16, 12, 23, 0, 25]]
| 8
| 1,301
| 34
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
// using System.Numerics;
using System.Runtime.CompilerServices;
using ll = System.Int64;
using static MyIO;
public class Contest {
static void Swap1<T>(ref T a, ref T b) {
T t = a;
a = b;
b = t;
}
static void Swap2<T>(ref T a, ref T b)
where T : IComparable {
if (a.CompareTo(b) == 1)
Swap1(ref a, ref b);
} // b ใฎๆนใๅฐใใใใฐไบคๆ
static bool Chmin<T>(ref T a, T b)
where T : IComparable {
if (a.CompareTo(b) == 1) {
a = b;
return true;
}
return false;
} // b ใฎๆนใๅฐใใใใฐ a ใๆดๆฐ
static bool Chmax<T>(ref T a, T b)
where T : IComparable {
if (a.CompareTo(b) == -1) {
a = b;
return true;
}
return false;
} // b ใฎๆนใๅคงใใใใฐ a ใๆดๆฐ
static T[][] InitMat<T>(long len1, long len2, T val)
where T : struct {
T[][] m = new T[len1][];
for (int i = 0; i < m.Length; i++)
m[i] = Enumerable.Repeat(val, (int)len2).ToArray();
return m;
}
static T[][][] InitMat<T>(long len1, long len2, long len3, T val)
where T : struct {
T[][][] m = new T[len1][][];
for (int i = 0; i < m.Length; i++)
m[i] = InitMat(len2, len3, val);
return m;
}
public const long MOD1 = 1000000007; // 10^9+7
public const double EPS1 = 1e-8;
public static void Main() { Solve_B(); }
public static void Solve_A() {
long n, m;
MyIO.ReadMulti(out n, out m);
long ans = 0;
MyIO.WriteMulti(ans);
}
public static void Solve_B() {
long n, m, v, p;
MyIO.ReadMulti(out n, out m, out v, out p);
ll[] a;
ReadArray(out a);
Array.Sort(a);
Func<ll, ll> f = (k) => {
if (k < 0)
return int.MinValue;
if (n - p < k)
return int.MaxValue;
ll s = (p + k) * m;
for (ll i = k + 1; i < n - p + 1; i++) {
s += a[k] + m - a[i];
}
return s;
};
ll t = BS(f, m * v);
MyIO.WriteMulti(n - t);
}
public static void Solve_C() {
long n, m;
MyIO.ReadMulti(out n, out m);
long ans = 0;
MyIO.WriteMulti(ans);
}
public static void Solve_D() {
long n, m;
MyIO.ReadMulti(out n, out m);
long ans = 0;
MyIO.WriteMulti(ans);
}
public static void Solve_E() {
long n, m;
MyIO.ReadMulti(out n, out m);
long ans = 0;
MyIO.WriteMulti(ans);
}
public static void Solve_F() {
long n, m;
MyIO.ReadMulti(out n, out m);
long ans = 0;
MyIO.WriteMulti(ans);
}
public static long BS<T>(Func<long, T> seq, T value)
where T : IComparable {
long left = long.MinValue / 4;
long right = long.MaxValue / 4;
while (right - left > 1) {
long mid = left + (right - left) / 2;
if (0 <= seq(mid).CompareTo(value))
right = mid;
else
left = mid;
}
return right;
}
}
#region MyIO
public struct VT<T, U> {
public T Item1;
public U Item2;
public VT(T a, U b) {
Item1 = a;
Item2 = b;
}
}
public struct VT<T, U, V> {
public T Item1;
public U Item2;
public V Item3;
public VT(T a, U b, V c) {
Item1 = a;
Item2 = b;
Item3 = c;
}
}
public struct VT<T, U, V, W> {
public T Item1;
public U Item2;
public V Item3;
public W Item4;
public VT(T a, U b, V c, W d) {
Item1 = a;
Item2 = b;
Item3 = c;
Item4 = d;
}
}
public static class MyIO {
public class Printer : System.IO.StreamWriter {
public override IFormatProvider FormatProvider {
get { return System.Globalization.CultureInfo.InvariantCulture; }
}
public Printer(System.IO.Stream stream)
: base(stream, new UTF8Encoding(false, true)) {}
public Printer(System.IO.Stream stream, Encoding encoding)
: base(stream, encoding) {}
}
private static char[] splitter = new char[] { ' ' };
private static bool eq<T, U>() => typeof(T).Equals(typeof(U));
private static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
private 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, System.Globalization.CultureInfo.InvariantCulture))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
public static string[] ReadMulti<T>(out T a) {
var ar = Console.ReadLine().Split(splitter,
StringSplitOptions.RemoveEmptyEntries);
a = cv<T>(ar[0]);
return ar;
}
public static string[] ReadMulti<T, U>(out T a, out U b) {
var ar = ReadMulti<T>(out a);
b = cv<U>(ar[1]);
return ar;
}
public static string[] ReadMulti<T, U, V>(out T a, out U b, out V c) {
var ar = ReadMulti<T, U>(out a, out b);
c = cv<V>(ar[2]);
return ar;
}
public static string[] ReadMulti<T, U, V, W>(out T a, out U b, out V c,
out W d) {
var ar = ReadMulti<T, U, V>(out a, out b, out c);
d = cv<W>(ar[3]);
return ar;
}
public static string[] ReadMulti<T, U, V, W, X>(out T a, out U b, out V c,
out W d, out X e) {
var ar = ReadMulti<T, U, V, W>(out a, out b, out c, out d);
e = cv<X>(ar[4]);
return ar;
}
public static string[] ReadMulti<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 = ReadMulti<T, U, V, W, X>(out a, out b, out c, out d, out e);
f = cv<Y>(ar[5]);
return ar;
}
public static string[] ReadArray<T>(out T[] a) {
var ar = Console.ReadLine().Split(splitter,
StringSplitOptions.RemoveEmptyEntries);
a = ar.Select(cv<T>).ToArray();
return ar;
}
public static string[][] ReadLines<T>(long n, out T[] a) {
a = new T[n];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++)
arr[i] = ReadMulti(out a[i]);
return arr;
}
public static string[][] ReadLines<T, U>(long n, out VT<T, U>[] a) {
a = new VT<T, U>[n];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++) {
T o;
U p;
arr[i] = ReadMulti(out o, out p);
a[i] = new VT<T, U>(o, p);
}
return arr;
}
public static string[][] ReadLines<T, U, V>(long n, out VT<T, U, V>[] a) {
a = new VT<T, U, V>[n];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++) {
T o;
U p;
V q;
arr[i] = ReadMulti(out o, out p, out q);
a[i] = new VT<T, U, V>(o, p, q);
}
return arr;
}
public static string[][] ReadLines<T, U, V, W>(long n,
out VT<T, U, V, W>[] a) {
a = new VT<T, U, V, W>[n];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++) {
T o;
U p;
V q;
W r;
arr[i] = ReadMulti(out o, out p, out q, out r);
a[i] = new VT<T, U, V, W>(o, p, q, r);
}
return arr;
}
public static string[][] ReadMatrix<T>(long n, out T[][] a) {
a = new T[n][];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++)
arr[i] = ReadArray(out a[i]);
return arr;
}
private static void wwp(Action act) {
var sw = new Printer(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
act();
Console.Out.Flush();
sw.AutoFlush = true;
Console.SetOut(sw);
}
private static string wfm(Type t) => t.Equals(typeof(double)) ? "{0:F10}"
: "{0}";
public static void WriteMulti(params object[] a) {
wwp(() => {
for (int i = 0; i < a.Length; i++) {
string fs = wfm(a[i].GetType()) +
((i < a.Length - 1) ? " " : Environment.NewLine);
Console.Write(fs, a[i]);
}
});
}
public static void WriteArray<T>(T[] a) {
wwp(() => {
string fs = wfm(typeof(T));
string fs1 = fs + " ";
string fs2 = fs + Environment.NewLine;
for (int i = 0; i < a.Length; i++)
Console.Write(((i < a.Length - 1) ? fs1 : fs2), a[i]);
});
}
public static void WriteLines<T>(T[] a) {
wwp(() => {
string fs = wfm(typeof(T)) + Environment.NewLine;
foreach (T x in a)
Console.Write(fs, x);
});
}
}
#endregion
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
// using System.Numerics;
using System.Runtime.CompilerServices;
using ll = System.Int64;
using static MyIO;
public class Contest {
static void Swap1<T>(ref T a, ref T b) {
T t = a;
a = b;
b = t;
}
static void Swap2<T>(ref T a, ref T b)
where T : IComparable {
if (a.CompareTo(b) == 1)
Swap1(ref a, ref b);
} // b ใฎๆนใๅฐใใใใฐไบคๆ
static bool Chmin<T>(ref T a, T b)
where T : IComparable {
if (a.CompareTo(b) == 1) {
a = b;
return true;
}
return false;
} // b ใฎๆนใๅฐใใใใฐ a ใๆดๆฐ
static bool Chmax<T>(ref T a, T b)
where T : IComparable {
if (a.CompareTo(b) == -1) {
a = b;
return true;
}
return false;
} // b ใฎๆนใๅคงใใใใฐ a ใๆดๆฐ
static T[][] InitMat<T>(long len1, long len2, T val)
where T : struct {
T[][] m = new T[len1][];
for (int i = 0; i < m.Length; i++)
m[i] = Enumerable.Repeat(val, (int)len2).ToArray();
return m;
}
static T[][][] InitMat<T>(long len1, long len2, long len3, T val)
where T : struct {
T[][][] m = new T[len1][][];
for (int i = 0; i < m.Length; i++)
m[i] = InitMat(len2, len3, val);
return m;
}
public const long MOD1 = 1000000007; // 10^9+7
public const double EPS1 = 1e-8;
public static void Main() { Solve_B(); }
public static void Solve_A() {
long n, m;
MyIO.ReadMulti(out n, out m);
long ans = 0;
MyIO.WriteMulti(ans);
}
public static void Solve_B() {
long n, m, v, p;
MyIO.ReadMulti(out n, out m, out v, out p);
ll[] a;
ReadArray(out a);
Array.Sort(a);
Func<ll, ll> f = (k) => {
if (k < 0)
return ll.MinValue;
if (n < k + p)
return ll.MaxValue;
if (a[k] + m < a[n - p])
return ll.MinValue;
ll s = (p + k) * m;
for (ll i = k + 1; i <= n - p; i++) {
s += a[k] + m - a[i];
}
return s;
};
ll t = BS(f, m * v);
MyIO.WriteMulti(n - t);
}
public static void Solve_C() {
long n, m;
MyIO.ReadMulti(out n, out m);
long ans = 0;
MyIO.WriteMulti(ans);
}
public static void Solve_D() {
long n, m;
MyIO.ReadMulti(out n, out m);
long ans = 0;
MyIO.WriteMulti(ans);
}
public static void Solve_E() {
long n, m;
MyIO.ReadMulti(out n, out m);
long ans = 0;
MyIO.WriteMulti(ans);
}
public static void Solve_F() {
long n, m;
MyIO.ReadMulti(out n, out m);
long ans = 0;
MyIO.WriteMulti(ans);
}
public static long BS<T>(Func<long, T> seq, T value)
where T : IComparable {
long left = long.MinValue / 4;
long right = long.MaxValue / 4;
while (right - left > 1) {
long mid = left + (right - left) / 2;
if (0 <= seq(mid).CompareTo(value))
right = mid;
else
left = mid;
}
return right;
}
}
#region MyIO
public struct VT<T, U> {
public T Item1;
public U Item2;
public VT(T a, U b) {
Item1 = a;
Item2 = b;
}
}
public struct VT<T, U, V> {
public T Item1;
public U Item2;
public V Item3;
public VT(T a, U b, V c) {
Item1 = a;
Item2 = b;
Item3 = c;
}
}
public struct VT<T, U, V, W> {
public T Item1;
public U Item2;
public V Item3;
public W Item4;
public VT(T a, U b, V c, W d) {
Item1 = a;
Item2 = b;
Item3 = c;
Item4 = d;
}
}
public static class MyIO {
public class Printer : System.IO.StreamWriter {
public override IFormatProvider FormatProvider {
get { return System.Globalization.CultureInfo.InvariantCulture; }
}
public Printer(System.IO.Stream stream)
: base(stream, new UTF8Encoding(false, true)) {}
public Printer(System.IO.Stream stream, Encoding encoding)
: base(stream, encoding) {}
}
private static char[] splitter = new char[] { ' ' };
private static bool eq<T, U>() => typeof(T).Equals(typeof(U));
private static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
private 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, System.Globalization.CultureInfo.InvariantCulture))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
public static string[] ReadMulti<T>(out T a) {
var ar = Console.ReadLine().Split(splitter,
StringSplitOptions.RemoveEmptyEntries);
a = cv<T>(ar[0]);
return ar;
}
public static string[] ReadMulti<T, U>(out T a, out U b) {
var ar = ReadMulti<T>(out a);
b = cv<U>(ar[1]);
return ar;
}
public static string[] ReadMulti<T, U, V>(out T a, out U b, out V c) {
var ar = ReadMulti<T, U>(out a, out b);
c = cv<V>(ar[2]);
return ar;
}
public static string[] ReadMulti<T, U, V, W>(out T a, out U b, out V c,
out W d) {
var ar = ReadMulti<T, U, V>(out a, out b, out c);
d = cv<W>(ar[3]);
return ar;
}
public static string[] ReadMulti<T, U, V, W, X>(out T a, out U b, out V c,
out W d, out X e) {
var ar = ReadMulti<T, U, V, W>(out a, out b, out c, out d);
e = cv<X>(ar[4]);
return ar;
}
public static string[] ReadMulti<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 = ReadMulti<T, U, V, W, X>(out a, out b, out c, out d, out e);
f = cv<Y>(ar[5]);
return ar;
}
public static string[] ReadArray<T>(out T[] a) {
var ar = Console.ReadLine().Split(splitter,
StringSplitOptions.RemoveEmptyEntries);
a = ar.Select(cv<T>).ToArray();
return ar;
}
public static string[][] ReadLines<T>(long n, out T[] a) {
a = new T[n];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++)
arr[i] = ReadMulti(out a[i]);
return arr;
}
public static string[][] ReadLines<T, U>(long n, out VT<T, U>[] a) {
a = new VT<T, U>[n];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++) {
T o;
U p;
arr[i] = ReadMulti(out o, out p);
a[i] = new VT<T, U>(o, p);
}
return arr;
}
public static string[][] ReadLines<T, U, V>(long n, out VT<T, U, V>[] a) {
a = new VT<T, U, V>[n];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++) {
T o;
U p;
V q;
arr[i] = ReadMulti(out o, out p, out q);
a[i] = new VT<T, U, V>(o, p, q);
}
return arr;
}
public static string[][] ReadLines<T, U, V, W>(long n,
out VT<T, U, V, W>[] a) {
a = new VT<T, U, V, W>[n];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++) {
T o;
U p;
V q;
W r;
arr[i] = ReadMulti(out o, out p, out q, out r);
a[i] = new VT<T, U, V, W>(o, p, q, r);
}
return arr;
}
public static string[][] ReadMatrix<T>(long n, out T[][] a) {
a = new T[n][];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++)
arr[i] = ReadArray(out a[i]);
return arr;
}
private static void wwp(Action act) {
var sw = new Printer(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
act();
Console.Out.Flush();
sw.AutoFlush = true;
Console.SetOut(sw);
}
private static string wfm(Type t) => t.Equals(typeof(double)) ? "{0:F10}"
: "{0}";
public static void WriteMulti(params object[] a) {
wwp(() => {
for (int i = 0; i < a.Length; i++) {
string fs = wfm(a[i].GetType()) +
((i < a.Length - 1) ? " " : Environment.NewLine);
Console.Write(fs, a[i]);
}
});
}
public static void WriteArray<T>(T[] a) {
wwp(() => {
string fs = wfm(typeof(T));
string fs1 = fs + " ";
string fs2 = fs + Environment.NewLine;
for (int i = 0; i < a.Length; i++)
Console.Write(((i < a.Length - 1) ? fs1 : fs2), a[i]);
});
}
public static void WriteLines<T>(T[] a) {
wwp(() => {
string fs = wfm(typeof(T)) + Environment.NewLine;
foreach (T x in a)
Console.Write(fs, x);
});
}
}
#endregion
|
[["-", 8, 196, 0, 57, 64, 37, 0, 214, 205, 199], ["+", 8, 196, 0, 57, 64, 37, 0, 214, 205, 22], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 33], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 72], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 22], ["+", 0, 212, 0, 218, 8, 196, 0, 57, 0, 121], ["+", 0, 212, 0, 218, 8, 196, 0, 57, 0, 24], ["+", 0, 57, 15, 16, 31, 16, 31, 204, 205, 22], ["+", 15, 16, 31, 16, 31, 204, 206, 207, 0, 70], ["+", 31, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 15, 16, 31, 16, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 72], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 0, 218, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 8, 196, 0, 57, 15, 16, 12, 204, 205, 22], ["+", 0, 57, 15, 16, 12, 204, 206, 207, 0, 70], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 12, 22], ["+", 0, 57, 15, 16, 12, 204, 206, 207, 0, 73], ["+", 0, 212, 0, 218, 8, 196, 0, 57, 0, 25], ["+", 0, 218, 8, 196, 0, 57, 64, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 37, 0, 214, 0, 131], ["+", 8, 196, 0, 57, 64, 37, 0, 214, 141, 22], ["+", 0, 218, 8, 196, 0, 57, 64, 37, 0, 35], ["-", 0, 218, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 218, 8, 196, 0, 7, 15, 16, 17, 19], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 72], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203]]
| 8
| 2,602
| 33
|
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program {
const int mod = (int)1e9 + 7;
static void Main() {
Sc sc = new Sc();
var s = sc.La;
var a = sc.La;
Array.Sort(a);
long p = 0;
var ra = new long[s[0]];
for (int i = 0; i <= s[0] - s[3]; i++) {
p += a[i];
ra[i] = a[i];
if (i != 0) {
ra[i] += ra[i - 1];
}
}
int ans = 0, r = (int)(s[0] - s[3]);
long po = (s[2] - s[3]);
if (s[2] < s[3]) {
for (int i = 0; i < s[0]; i++) {
if (a[i] + s[1] < a[s[0] - s[3]]) {
ans--;
}
}
Console.WriteLine("{0}", s[0] + ans);
return;
}
for (int i = 0; i < s[0]; i++) {
long c = a[i] + s[1];
int lb = 0, ub = r, mid = 0;
while (ub - lb > 1) {
mid = (ub + lb) / 2;
if (c - a[mid] < s[1]) {
ub = mid;
} else {
lb = mid;
}
}
if (s[1] * po <= lb * s[1] + c * (r - lb) - (ra[r] - ra[lb])) {
} else {
ans--;
}
}
Console.WriteLine("{0}", s[0] + ans);
}
}
public class Sc {
public int I {
get { return int.Parse(Console.ReadLine()); }
}
public long L {
get { return long.Parse(Console.ReadLine()); }
}
public double D {
get { return double.Parse(Console.ReadLine()); }
}
public string S {
get { return Console.ReadLine(); }
}
public int[] Ia {
get { return Array.ConvertAll(Console.ReadLine().Split(), int.Parse); }
}
public long[] La {
get { return Array.ConvertAll(Console.ReadLine().Split(), long.Parse); }
}
public double[] Da {
get { return Array.ConvertAll(Console.ReadLine().Split(), double.Parse); }
}
public string[] Sa {
get { return Console.ReadLine().Split(); }
}
public object[] Oa {
get { return Console.ReadLine().Split(); }
}
public int[] Ia2 {
get {
return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(),
int.Parse);
}
}
public int[] Ia3(int a) {
return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(),
int.Parse);
}
public int[] Ia3(bool a, int b, bool c, int d) {
return Array.ConvertAll(((a ? b.ToString() + " " : "") +
Console.ReadLine() + (c ? " " + d.ToString() : ""))
.Split(),
int.Parse);
}
public long[] La2 {
get {
return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(),
long.Parse);
}
}
public long[] La3(int a) {
return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(),
long.Parse);
}
public long[] La3(bool a, int b, bool c, int d) {
return Array.ConvertAll(((a ? b.ToString() + " " : "") +
Console.ReadLine() + (c ? " " + d.ToString() : ""))
.Split(),
long.Parse);
}
public T[] Arr<T>(int n, Func<T> f) {
var a = new T[n];
for (int i = 0; i < n; i++) {
a[i] = f();
}
return a;
}
public T[] Arr<T>(int n, Func<int, T> f) {
var a = new T[n];
for (int i = 0; i < n; i++) {
a[i] = f(i);
}
return a;
}
public T[] Arr<T>(int n, Func<string[], T> f) {
var a = new T[n];
for (int i = 0; i < n; i++) {
a[i] = f(Console.ReadLine().Split());
}
return a;
}
public T[] Arr<T>(int n, Func<int, string[], T> f) {
var a = new T[n];
for (int i = 0; i < n; i++) {
a[i] = f(i, Console.ReadLine().Split());
}
return a;
}
}
|
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program {
const int mod = (int)1e9 + 7;
static void Main() {
Sc sc = new Sc();
var s = sc.La;
var a = sc.La;
Array.Sort(a);
long p = 0;
var ra = new long[s[0]];
for (int i = 0; i <= s[0] - s[3]; i++) {
p += a[i];
ra[i] = a[i];
if (i != 0) {
ra[i] += ra[i - 1];
}
}
int ans = 0, r = (int)(s[0] - s[3]);
long po = (s[2] - s[3]);
if (s[2] < s[3]) {
for (int i = 0; i < s[0]; i++) {
if (a[i] + s[1] < a[s[0] - s[3]]) {
ans--;
}
}
Console.WriteLine("{0}", s[0] + ans);
return;
}
for (int i = 0; i < s[0]; i++) {
long c = a[i] + s[1];
if (a[i] + s[1] < a[s[0] - s[3]]) {
ans--;
continue;
}
int lb = 0, ub = r, mid = 0;
while (ub - lb > 1) {
mid = (ub + lb) / 2;
if (c - a[mid] < s[1]) {
ub = mid;
} else {
lb = mid;
}
}
if (s[1] * po <= lb * s[1] + c * (r - lb) - (ra[r] - ra[lb])) {
} else {
ans--;
}
}
Console.WriteLine("{0}", s[0] + ans);
}
}
public class Sc {
public int I {
get { return int.Parse(Console.ReadLine()); }
}
public long L {
get { return long.Parse(Console.ReadLine()); }
}
public double D {
get { return double.Parse(Console.ReadLine()); }
}
public string S {
get { return Console.ReadLine(); }
}
public int[] Ia {
get { return Array.ConvertAll(Console.ReadLine().Split(), int.Parse); }
}
public long[] La {
get { return Array.ConvertAll(Console.ReadLine().Split(), long.Parse); }
}
public double[] Da {
get { return Array.ConvertAll(Console.ReadLine().Split(), double.Parse); }
}
public string[] Sa {
get { return Console.ReadLine().Split(); }
}
public object[] Oa {
get { return Console.ReadLine().Split(); }
}
public int[] Ia2 {
get {
return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(),
int.Parse);
}
}
public int[] Ia3(int a) {
return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(),
int.Parse);
}
public int[] Ia3(bool a, int b, bool c, int d) {
return Array.ConvertAll(((a ? b.ToString() + " " : "") +
Console.ReadLine() + (c ? " " + d.ToString() : ""))
.Split(),
int.Parse);
}
public long[] La2 {
get {
return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(),
long.Parse);
}
}
public long[] La3(int a) {
return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(),
long.Parse);
}
public long[] La3(bool a, int b, bool c, int d) {
return Array.ConvertAll(((a ? b.ToString() + " " : "") +
Console.ReadLine() + (c ? " " + d.ToString() : ""))
.Split(),
long.Parse);
}
public T[] Arr<T>(int n, Func<T> f) {
var a = new T[n];
for (int i = 0; i < n; i++) {
a[i] = f();
}
return a;
}
public T[] Arr<T>(int n, Func<int, T> f) {
var a = new T[n];
for (int i = 0; i < n; i++) {
a[i] = f(i);
}
return a;
}
public T[] Arr<T>(int n, Func<string[], T> f) {
var a = new T[n];
for (int i = 0; i < n; i++) {
a[i] = f(Console.ReadLine().Split());
}
return a;
}
public T[] Arr<T>(int n, Func<int, string[], T> f) {
var a = new T[n];
for (int i = 0; i < n; i++) {
a[i] = f(i, Console.ReadLine().Split());
}
return a;
}
}
|
[["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 0, 57, 15, 16, 31, 16, 31, 204, 205, 22], ["+", 15, 16, 31, 16, 31, 204, 206, 207, 0, 70], ["+", 31, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 15, 16, 31, 16, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 72], ["+", 0, 57, 15, 16, 31, 16, 12, 204, 205, 22], ["+", 15, 16, 31, 16, 12, 204, 206, 207, 0, 70], ["+", 31, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 31, 16, 12, 204, 206, 207, 0, 73], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 8, 196, 0, 57, 15, 16, 12, 204, 205, 22], ["+", 0, 57, 15, 16, 12, 204, 206, 207, 0, 70], ["+", 206, 207, 0, 28, 0, 16, 31, 204, 205, 22], ["+", 0, 28, 0, 16, 31, 204, 206, 207, 0, 70], ["+", 0, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 28, 0, 16, 31, 204, 206, 207, 0, 73], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 206, 207, 0, 28, 0, 16, 12, 204, 205, 22], ["+", 0, 28, 0, 16, 12, 204, 206, 207, 0, 70], ["+", 0, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 28, 0, 16, 12, 204, 206, 207, 0, 73], ["+", 0, 57, 15, 16, 12, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 68], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 116, 0, 117], ["+", 8, 196, 0, 57, 64, 196, 0, 116, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 1,244
| 32
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
namespace AtCoder {
class Program {
public static void Main() {
#if TextInput
using (var reader = new StreamReader(Debug.SampleTextPath)) {
Console.SetIn(reader);
#endif
var intArray = IO.ReadIntArray();
int A = intArray[0], B = intArray[1];
IO.Write(6 - (A + B));
#if TextInput
}
#endif
}
}
public static class IO {
public static string Read() { return Console.ReadLine(); }
public static string[] ReadArray(char iSplitter = ' ') {
return Read().Split(iSplitter);
}
public static int ReadInt() { return int.Parse(Read()); }
public static int[] ReadIntArray(char iSplitter = ' ') {
return ReadArray().Select(iText => int.Parse(iText)).ToArray();
}
public static long ReadLong() { return long.Parse(Read()); }
public static long[] ReadLongArray(char iSplitter = ' ') {
return ReadArray().Select(iText => long.Parse(iText)).ToArray();
}
public static double ReadDouble() { return double.Parse(Read()); }
public static double[] ReadDoubleArray(char iSplitter = ' ') {
return ReadArray().Select(iText => double.Parse(iText)).ToArray();
}
public static char ReadChar() { return Read()[0]; }
public static char[] ReadCharArray() { return Read().ToCharArray(); }
public static void Write(string iValue) { Console.WriteLine(iValue); }
public static void Write(int iValue) { Console.WriteLine(iValue); }
public static void Write(long iValue) { Console.WriteLine(iValue); }
public static void Write(double iValue) { Console.WriteLine(iValue); }
public static void Write(char iValue) { Console.WriteLine(iValue); }
public static void Write(decimal iValue) { Console.WriteLine(iValue); }
public static void Write(bool iValue) {
Console.WriteLine(iValue ? "Yes" : "No");
}
public static void Write<Type>(IEnumerable<Type> iValue,
string iJoinWord = " ") {
Console.WriteLine(string.Join(iJoinWord, iValue));
}
}
public static class Util {
public static long Gcd(long i0, long i1) {
return (i0 > i1) ? _Gcd(i0, i1) : _Gcd(i1, i0);
}
public static long Lcm(long i0, long i1) { return (i0 * i1) / Gcd(i0, i1); }
public static long ModPow(long iBaseNumber, long iPow, long iModNumber) {
var num = 1L;
while (iPow != 0) {
if ((iPow & 0x1) != 0) {
num = (num * iBaseNumber) % iModNumber;
}
iBaseNumber = (iBaseNumber * iBaseNumber) % iModNumber;
iPow >>= 1;
}
return num;
}
public static long CombinationNum(int iLeftNumber, int iRightNumber) {
if (iRightNumber == 0) {
return 1;
}
if (iLeftNumber == 0) {
return 0;
}
return iLeftNumber * CombinationNum(iLeftNumber - 1, iRightNumber - 1) /
iRightNumber;
}
public static long Factorial(long iNumber) {
if (iNumber == 0) {
return 1L;
}
return iNumber * Factorial(iNumber - 1);
}
public static bool IsPrime(long iNumber) {
if (iNumber < 2) {
return false;
} else if (iNumber == 2) {
return true;
} else if (iNumber % 2 == 0) {
return false;
}
var sqrtNum = Math.Sqrt(iNumber);
for (var i = 3; i <= sqrtNum; i += 2) {
if (iNumber % i == 0) {
return false;
}
}
return true;
}
private static long _Gcd(long i0, long i1) {
return (i1 == 0) ? i0 : _Gcd(i1, i0 % i1);
}
}
public class UnionFind {
public int[] Parents;
public int[] RootNums;
public UnionFind(int iRootNum) {
Parents = Enumerable.Range(0, iRootNum).ToArray();
RootNums = new int[iRootNum];
}
public void Normalize() {
for (var iIndex = 0; iIndex < Parents.Length; ++iIndex) {
var rootIndex = _GetRoot(iIndex);
++RootNums[rootIndex];
Parents[iIndex] = rootIndex;
}
}
public void Union(int iNumber0, int iNumber1) {
var rootNumber0 = _GetRoot(iNumber0);
var rootNumber1 = _GetRoot(iNumber1);
if (rootNumber0 < rootNumber1) {
Parents[rootNumber1] = rootNumber0;
} else {
Parents[rootNumber0] = rootNumber1;
}
}
public int _GetRoot(int iNumber) {
return (Parents[iNumber] == iNumber) ? iNumber : _GetRoot(Parents[iNumber]);
}
}
public class CumulativeSum {
public static CumulativeSum Create(IEnumerable<long> iNumbers) {
var numbers = iNumbers.ToArray();
var cumulativeSum =
new CumulativeSum { Numbers = numbers,
SumNumbers = new long[numbers.Length + 1] };
var sumNumber = 0L;
for (var iIndex = 0; iIndex < numbers.Length; ++iIndex) {
sumNumber += numbers[iIndex];
cumulativeSum.SumNumbers[iIndex + 1] = sumNumber;
}
return cumulativeSum;
}
public long[] Numbers { get; private set; }
public long[] SumNumbers { get; private set; }
public int GetMaxTotalIndex(int iAreaNum) {
var maxIndex = -1;
var maxNumber = 0L;
var num = Numbers.Length - iAreaNum + 1;
for (var iIndex = 0; iIndex < num; ++iIndex) {
var checkNumber = SumNumbers[iAreaNum + iIndex] - SumNumbers[iIndex];
if (maxNumber < checkNumber) {
maxIndex = iIndex;
maxNumber = checkNumber;
}
}
return maxIndex;
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
namespace AtCoder {
class Program {
public static void Main() {
#if TextInput
using (var reader = new StreamReader(Debug.SampleTextPath)) {
Console.SetIn(reader);
#endif
var A = IO.ReadInt();
var B = IO.ReadInt();
IO.Write(6 - (A + B));
#if TextInput
}
#endif
}
}
public static class IO {
public static string Read() { return Console.ReadLine(); }
public static string[] ReadArray(char iSplitter = ' ') {
return Read().Split(iSplitter);
}
public static int ReadInt() { return int.Parse(Read()); }
public static int[] ReadIntArray(char iSplitter = ' ') {
return ReadArray().Select(iText => int.Parse(iText)).ToArray();
}
public static long ReadLong() { return long.Parse(Read()); }
public static long[] ReadLongArray(char iSplitter = ' ') {
return ReadArray().Select(iText => long.Parse(iText)).ToArray();
}
public static double ReadDouble() { return double.Parse(Read()); }
public static double[] ReadDoubleArray(char iSplitter = ' ') {
return ReadArray().Select(iText => double.Parse(iText)).ToArray();
}
public static char ReadChar() { return Read()[0]; }
public static char[] ReadCharArray() { return Read().ToCharArray(); }
public static void Write(string iValue) { Console.WriteLine(iValue); }
public static void Write(int iValue) { Console.WriteLine(iValue); }
public static void Write(long iValue) { Console.WriteLine(iValue); }
public static void Write(double iValue) { Console.WriteLine(iValue); }
public static void Write(char iValue) { Console.WriteLine(iValue); }
public static void Write(decimal iValue) { Console.WriteLine(iValue); }
public static void Write(bool iValue) {
Console.WriteLine(iValue ? "Yes" : "No");
}
public static void Write<Type>(IEnumerable<Type> iValue,
string iJoinWord = " ") {
Console.WriteLine(string.Join(iJoinWord, iValue));
}
}
public static class Util {
public static long Gcd(long i0, long i1) {
return (i0 > i1) ? _Gcd(i0, i1) : _Gcd(i1, i0);
}
public static long Lcm(long i0, long i1) { return (i0 * i1) / Gcd(i0, i1); }
public static long ModPow(long iBaseNumber, long iPow, long iModNumber) {
var num = 1L;
while (iPow != 0) {
if ((iPow & 0x1) != 0) {
num = (num * iBaseNumber) % iModNumber;
}
iBaseNumber = (iBaseNumber * iBaseNumber) % iModNumber;
iPow >>= 1;
}
return num;
}
public static long CombinationNum(int iLeftNumber, int iRightNumber) {
if (iRightNumber == 0) {
return 1;
}
if (iLeftNumber == 0) {
return 0;
}
return iLeftNumber * CombinationNum(iLeftNumber - 1, iRightNumber - 1) /
iRightNumber;
}
public static long Factorial(long iNumber) {
if (iNumber == 0) {
return 1L;
}
return iNumber * Factorial(iNumber - 1);
}
public static bool IsPrime(long iNumber) {
if (iNumber < 2) {
return false;
} else if (iNumber == 2) {
return true;
} else if (iNumber % 2 == 0) {
return false;
}
var sqrtNum = Math.Sqrt(iNumber);
for (var i = 3; i <= sqrtNum; i += 2) {
if (iNumber % i == 0) {
return false;
}
}
return true;
}
private static long _Gcd(long i0, long i1) {
return (i1 == 0) ? i0 : _Gcd(i1, i0 % i1);
}
}
public class UnionFind {
public int[] Parents;
public int[] RootNums;
public UnionFind(int iRootNum) {
Parents = Enumerable.Range(0, iRootNum).ToArray();
RootNums = new int[iRootNum];
}
public void Normalize() {
for (var iIndex = 0; iIndex < Parents.Length; ++iIndex) {
var rootIndex = _GetRoot(iIndex);
++RootNums[rootIndex];
Parents[iIndex] = rootIndex;
}
}
public void Union(int iNumber0, int iNumber1) {
var rootNumber0 = _GetRoot(iNumber0);
var rootNumber1 = _GetRoot(iNumber1);
if (rootNumber0 < rootNumber1) {
Parents[rootNumber1] = rootNumber0;
} else {
Parents[rootNumber0] = rootNumber1;
}
}
public int _GetRoot(int iNumber) {
return (Parents[iNumber] == iNumber) ? iNumber : _GetRoot(Parents[iNumber]);
}
}
public class CumulativeSum {
public static CumulativeSum Create(IEnumerable<long> iNumbers) {
var numbers = iNumbers.ToArray();
var cumulativeSum =
new CumulativeSum { Numbers = numbers,
SumNumbers = new long[numbers.Length + 1] };
var sumNumber = 0L;
for (var iIndex = 0; iIndex < numbers.Length; ++iIndex) {
sumNumber += numbers[iIndex];
cumulativeSum.SumNumbers[iIndex + 1] = sumNumber;
}
return cumulativeSum;
}
public long[] Numbers { get; private set; }
public long[] SumNumbers { get; private set; }
public int GetMaxTotalIndex(int iAreaNum) {
var maxIndex = -1;
var maxNumber = 0L;
var num = Numbers.Length - iAreaNum + 1;
for (var iIndex = 0; iIndex < num; ++iIndex) {
var checkNumber = SumNumbers[iAreaNum + iIndex] - SumNumbers[iIndex];
if (maxNumber < checkNumber) {
maxIndex = iIndex;
maxNumber = checkNumber;
}
}
return maxIndex;
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 311, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 198, 0, 200, 0, 212, 0, 204, 205, 22], ["-", 0, 200, 0, 212, 0, 204, 206, 207, 0, 70], ["-", 0, 212, 0, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 200, 0, 212, 0, 204, 206, 207, 0, 73], ["-", 0, 311, 8, 196, 0, 197, 0, 198, 0, 21], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 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, 3, 4, 0, 24], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25]]
| 8
| 1,229
| 22
|
using System;
namespace abca148 {
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
int a = int.Parse(str[0]);
int b = int.Parse(str[1]);
if (a == 1 && b == 2)
Console.WriteLine("3");
if (a == 1 && b == 3)
Console.WriteLine("2");
if (a == 2 && b == 1)
Console.WriteLine("3");
if (a == 2 && b == 3)
Console.WriteLine("1");
if (a == 3 && b == 1)
Console.WriteLine("2");
if (a == 3 && b == 2)
Console.WriteLine("1");
Console.ReadKey();
}
}
}
|
using System;
namespace abca148 {
class Program {
static void Main(string[] args) {
int a = int.Parse(Console.ReadLine());
int b = int.Parse(Console.ReadLine());
if (a == 1 && b == 2)
Console.WriteLine("3");
if (a == 1 && b == 3)
Console.WriteLine("2");
if (a == 2 && b == 1)
Console.WriteLine("3");
if (a == 2 && b == 3)
Console.WriteLine("1");
if (a == 3 && b == 1)
Console.WriteLine("2");
if (a == 3 && b == 2)
Console.WriteLine("1");
Console.ReadKey();
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 0, 197, 0, 198, 39, 224, 225, 226, 0, 70], ["-", 0, 197, 0, 198, 39, 224, 225, 226, 0, 73], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 205, 22], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["-", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["-", 0, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["-", 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, 213, 3, 4, 0, 28, 0, 252, 0, 104], ["-", 0, 213, 3, 4, 0, 28, 0, 252, 0, 253], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["-", 3, 4, 0, 28, 0, 204, 206, 207, 0, 70], ["-", 0, 28, 0, 204, 206, 207, 0, 28, 0, 203], ["-", 3, 4, 0, 28, 0, 204, 206, 207, 0, 73], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25]]
| 8
| 186
| 36
|
using System;
using AtCorder;
namespace AtCorder {
class Program {
static void Main(string[] args) { new Program().Solve(); }
public void Solve() {
var input1 = int.Parse(Console.ReadLine());
var input2 = int.Parse(Console.ReadLine());
}
}
}
|
using System;
using AtCorder;
namespace AtCorder {
class Program {
static void Main(string[] args) { new Program().Solve(); }
public void Solve() {
var input1 = int.Parse(Console.ReadLine());
var input2 = int.Parse(Console.ReadLine());
Console.WriteLine(6 - input1 - input2);
}
}
}
|
[["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 31, 203], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 17, 33], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 12, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 69
| 11
|
using System;
class abc148_a {
public static void Main() {
int a = int.Parse(Console.ReadLine());
int b = int.Parse(Console.ReadLine());
if (a == 1) {
if (b == 2) {
Console.WriteLine(3);
} else {
Console.WriteLine(2);
}
}
if (a == 2) {
if (b == 1) {
Console.WriteLine(3);
} else {
Console.WriteLine(2);
}
}
if (a == 3) {
if (b == 1) {
Console.WriteLine(2);
} else {
Console.WriteLine(1);
}
}
}
}
|
using System;
class abc148_a {
public static void Main() {
int a = int.Parse(Console.ReadLine());
int b = int.Parse(Console.ReadLine());
if (a == 1) {
if (b == 2) {
Console.WriteLine(3);
} else if (b == 3) {
Console.WriteLine(2);
}
}
if (a == 2) {
if (b == 1) {
Console.WriteLine(3);
} else if (b == 3) {
Console.WriteLine(1);
}
}
if (a == 3) {
if (b == 1) {
Console.WriteLine(2);
} else if (b == 2) {
Console.WriteLine(1);
}
}
}
}
|
[["+", 0, 57, 64, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 57, 64, 196, 0, 57, 75, 57, 0, 24], ["+", 64, 196, 0, 57, 75, 57, 15, 16, 31, 22], ["+", 64, 196, 0, 57, 75, 57, 15, 16, 17, 60], ["+", 64, 196, 0, 57, 75, 57, 15, 16, 12, 203], ["+", 0, 57, 64, 196, 0, 57, 75, 57, 0, 25], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203]]
| 8
| 142
| 20
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace StringsLength {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
var st = Console.ReadLine().Split();
char[] S = st[0].ToCharArray();
char[] T = st[1].ToCharArray();
string output = "";
for (int i = 0; i < N; i++) {
output += S[i] + T[i];
}
Console.WriteLine(output);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace StringsLength {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
var st = Console.ReadLine().Split();
char[] S = st[0].ToCharArray();
char[] T = st[1].ToCharArray();
var output = "";
for (int i = 0; i < N; i++) {
output += S[i].ToString() + T[i].ToString();
}
Console.WriteLine(output);
}
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 11, 12, 16, 31, 213, 63, 214, 0, 131], ["+", 0, 11, 12, 16, 31, 213, 63, 214, 141, 22], ["+", 0, 11, 12, 16, 31, 213, 3, 4, 0, 24], ["+", 0, 11, 12, 16, 31, 213, 3, 4, 0, 25], ["+", 0, 11, 12, 16, 12, 213, 63, 214, 0, 131], ["+", 0, 11, 12, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 11, 12, 16, 12, 213, 3, 4, 0, 24], ["+", 0, 11, 12, 16, 12, 213, 3, 4, 0, 25]]
| 8
| 130
| 10
|
using System;
using System.Collections;
using System.Collections.Generic;
using static Exter;
using System.Linq;
using System.Numerics;
#if DEBUG
#else
using console = System.Console;
#endif
public class App {
public static void Main(string[] args) {
int n = (int)readarr[0];
string[] s = console.ReadLine().Split(' ');
for (int i = 0; i < n; i++)
console.Write(s[0][i] + s[1][i]);
console.WriteLine();
}
public static long Gcd(long a, long b) => a > b? GcdRecursive(a, b)
: GcdRecursive(b, a);
private static long GcdRecursive(long a, long b) {
if (b == 0)
return a;
return GcdRecursive(b, a % b);
}
}
public class C : IComparable {
public int a, b;
public C(int x, int y) {
a = x;
b = y;
}
public int CompareTo(object o) { return a.CompareTo(((C)o).a); }
}
public class RollingHash {
long[] h;
long m = 2147483647;
int b = 524287;
Power baser;
public RollingHash(string s) {
baser = new Power(b);
h = new long[s.Length];
h[0] = 0;
for (int i = 1; i < s.Length; i++) {
h[i] = (h[i - 1] * b + s[i]) % m;
}
}
public long Calc(int l, int r) {
cout = h[r];
cout = h[l] * baser.GetEntry(r - l - 1);
return 0;
}
}
public class PriorityQueue<T> : IEnumerable<T>
where T : IComparable {
List<T> buffer = new List<T>();
static void PushHeap(List<T> array, T elem) {
int n = array.Count;
array.Add(elem);
while (n != 0) {
int i = (n - 1) / 2;
if (array[n].CompareTo(array[i]) < 0) {
T tmp = array[n];
array[n] = array[i];
array[i] = tmp;
}
n = i;
}
}
static void PopHeap(List<T> array) {
int n = array.Count - 1;
array[0] = array[n];
array.RemoveAt(array.Count - 1);
for (int i = 0, j; (j = 2 * i + 1) < n;) {
if ((j != n - 1) && (array[j].CompareTo(array[j + 1]) > 0))
j++;
if (array[i].CompareTo(array[j]) > 0) {
T tmp = array[j];
array[j] = array[i];
array[i] = tmp;
}
i = j;
}
}
public int Count {
get { return buffer.Count; }
}
public void Push(T elem) { PushHeap(this.buffer, elem); }
public T Peek() { return buffer[0]; }
public T Pop() {
T a = buffer[0];
PopHeap(this.buffer);
return a;
}
public IEnumerator<T> GetEnumerator() {
var v = new List<T>(buffer);
while (v.Count != 0) {
yield return v[0];
PopHeap(v);
}
}
IEnumerator IEnumerable.GetEnumerator() { return this.GetEnumerator(); }
}
public class Power {
public int Base;
private List<long> Value = new List<long>();
public Power(int v) {
if (v == 1)
new ArgumentOutOfRangeException();
long prev = -1;
long g = v;
Base = v;
while (g > prev) {
Value.Add(g);
prev = g;
g *= g;
}
}
public long GetEntry(int exponent) {
long s = 1;
for (int i = 0; (1 << i) <= exponent; i++) {
if ((exponent & (1 << i)) != 0) {
s *= Value[i];
}
}
return s;
}
}
public static class Exter {
public static IEnumerable<long> PrimeFactors(long n) {
int i = 2;
long tmp = n;
while (i * i <= n) {
if (tmp % i == 0) {
tmp /= i;
yield return i;
} else {
i++;
}
}
if (tmp != 1)
yield return tmp;
}
public class LoopArray<T> {
public readonly int Length;
private T[] arr;
public LoopArray(int Capacity) { Length = Capacity; }
public LoopArray(T[] ar) {
arr = new T[ar.Length];
Array.Copy(ar, arr, ar.Length);
}
}
public class Point {
public Point(int cx, int cy) {
x = cx;
y = cy;
}
public int x;
public int y;
}
public static IEnumerable<Result>
ListAll<T1, T2, Result>(IEnumerable<T1> a, IEnumerable<T2> b,
Func<T1, T2, Result> f) {
foreach (var v in a) {
foreach (var w in b)
yield return f(v, w);
}
}
public static IEnumerable<Result>
ListAll<T1, T2, Result>(IEnumerable<T1> a, IEnumerable<T2> b,
Func<T1, T2, Result> f, Func<T1, T2, bool> s) {
foreach (var v in a) {
foreach (var w in b)
if (s(v, w))
yield return f(v, w);
}
}
public static int ToInt(this long v) => (int)v;
public static int ToInt(this string v) => int.Parse(v);
public static int Max(params int[] p) => p.Max();
public static long Max(params long[] p) => p.Max();
public static int Min(params int[] p) => p.Min();
public static long Min(params long[] p) => p.Min();
public static int Gcd(int a, int b) => a > b? GcdRecursive(a, b)
: GcdRecursive(b, a);
private static int GcdRecursive(int a,
int b) => b == 0 ? a : GcdRecursive(b, a % b);
public static object cout {
set {
console.Write(value.ToString());
console.WriteLine();
}
}
public static void ToCout<t>(this IEnumerable<t> v) {
cout = string.Join(",", v);
}
public static long[] readarr {
get {
preadarr =
console.ReadLine().Split().Select(s => long.Parse(s)).ToArray();
return preadarr;
}
}
public static long[] preadarr;
}
#if DEBUG
public static class console {
static int cursorLine = 0;
static readonly string[] cin = System.IO.File.ReadAllLines("Input.txt");
static public string ReadLine() {
if (cursorLine == cin.Length)
cout = "Out";
return cin[cursorLine++];
}
static public void WriteLine() { Console.WriteLine(); }
static public void WriteLine<T>(T input) { Console.WriteLine(input); }
static public void Write<T>(T input) { Console.Write(input); }
static public void WriteLine(string s, params object[] arr) {
Console.WriteLine(s, arr);
}
}
#endif
|
using System;
using System.Collections;
using System.Collections.Generic;
using static Exter;
using System.Linq;
using System.Numerics;
#if DEBUG
#else
using console = System.Console;
#endif
public class App {
public static void Main(string[] args) {
int n = (int)readarr[0];
string[] s = console.ReadLine().Split(' ');
for (int i = 0; i < n; i++)
console.Write((char)s[0][i] + "" + (char)s[1][i]);
console.WriteLine();
}
public static long Gcd(long a, long b) => a > b? GcdRecursive(a, b)
: GcdRecursive(b, a);
private static long GcdRecursive(long a, long b) {
if (b == 0)
return a;
return GcdRecursive(b, a % b);
}
}
public class C : IComparable {
public int a, b;
public C(int x, int y) {
a = x;
b = y;
}
public int CompareTo(object o) { return a.CompareTo(((C)o).a); }
}
public class RollingHash {
long[] h;
long m = 2147483647;
int b = 524287;
Power baser;
public RollingHash(string s) {
baser = new Power(b);
h = new long[s.Length];
h[0] = 0;
for (int i = 1; i < s.Length; i++) {
h[i] = (h[i - 1] * b + s[i]) % m;
}
}
public long Calc(int l, int r) {
cout = h[r];
cout = h[l] * baser.GetEntry(r - l - 1);
return 0;
}
}
public class PriorityQueue<T> : IEnumerable<T>
where T : IComparable {
List<T> buffer = new List<T>();
static void PushHeap(List<T> array, T elem) {
int n = array.Count;
array.Add(elem);
while (n != 0) {
int i = (n - 1) / 2;
if (array[n].CompareTo(array[i]) < 0) {
T tmp = array[n];
array[n] = array[i];
array[i] = tmp;
}
n = i;
}
}
static void PopHeap(List<T> array) {
int n = array.Count - 1;
array[0] = array[n];
array.RemoveAt(array.Count - 1);
for (int i = 0, j; (j = 2 * i + 1) < n;) {
if ((j != n - 1) && (array[j].CompareTo(array[j + 1]) > 0))
j++;
if (array[i].CompareTo(array[j]) > 0) {
T tmp = array[j];
array[j] = array[i];
array[i] = tmp;
}
i = j;
}
}
public int Count {
get { return buffer.Count; }
}
public void Push(T elem) { PushHeap(this.buffer, elem); }
public T Peek() { return buffer[0]; }
public T Pop() {
T a = buffer[0];
PopHeap(this.buffer);
return a;
}
public IEnumerator<T> GetEnumerator() {
var v = new List<T>(buffer);
while (v.Count != 0) {
yield return v[0];
PopHeap(v);
}
}
IEnumerator IEnumerable.GetEnumerator() { return this.GetEnumerator(); }
}
public class Power {
public int Base;
private List<long> Value = new List<long>();
public Power(int v) {
if (v == 1)
new ArgumentOutOfRangeException();
long prev = -1;
long g = v;
Base = v;
while (g > prev) {
Value.Add(g);
prev = g;
g *= g;
}
}
public long GetEntry(int exponent) {
long s = 1;
for (int i = 0; (1 << i) <= exponent; i++) {
if ((exponent & (1 << i)) != 0) {
s *= Value[i];
}
}
return s;
}
}
public static class Exter {
public static IEnumerable<long> PrimeFactors(long n) {
int i = 2;
long tmp = n;
while (i * i <= n) {
if (tmp % i == 0) {
tmp /= i;
yield return i;
} else {
i++;
}
}
if (tmp != 1)
yield return tmp;
}
public class LoopArray<T> {
public readonly int Length;
private T[] arr;
public LoopArray(int Capacity) { Length = Capacity; }
public LoopArray(T[] ar) {
arr = new T[ar.Length];
Array.Copy(ar, arr, ar.Length);
}
}
public class Point {
public Point(int cx, int cy) {
x = cx;
y = cy;
}
public int x;
public int y;
}
public static IEnumerable<Result>
ListAll<T1, T2, Result>(IEnumerable<T1> a, IEnumerable<T2> b,
Func<T1, T2, Result> f) {
foreach (var v in a) {
foreach (var w in b)
yield return f(v, w);
}
}
public static IEnumerable<Result>
ListAll<T1, T2, Result>(IEnumerable<T1> a, IEnumerable<T2> b,
Func<T1, T2, Result> f, Func<T1, T2, bool> s) {
foreach (var v in a) {
foreach (var w in b)
if (s(v, w))
yield return f(v, w);
}
}
public static int ToInt(this long v) => (int)v;
public static int ToInt(this string v) => int.Parse(v);
public static int Max(params int[] p) => p.Max();
public static long Max(params long[] p) => p.Max();
public static int Min(params int[] p) => p.Min();
public static long Min(params long[] p) => p.Min();
public static int Gcd(int a, int b) => a > b? GcdRecursive(a, b)
: GcdRecursive(b, a);
private static int GcdRecursive(int a,
int b) => b == 0 ? a : GcdRecursive(b, a % b);
public static object cout {
set {
console.Write(value.ToString());
console.WriteLine();
}
}
public static void ToCout<t>(this IEnumerable<t> v) {
cout = string.Join(",", v);
}
public static long[] readarr {
get {
preadarr =
console.ReadLine().Split().Select(s => long.Parse(s)).ToArray();
return preadarr;
}
}
public static long[] preadarr;
}
#if DEBUG
public static class console {
static int cursorLine = 0;
static readonly string[] cin = System.IO.File.ReadAllLines("Input.txt");
static public string ReadLine() {
if (cursorLine == cin.Length)
cout = "Out";
return cin[cursorLine++];
}
static public void WriteLine() { Console.WriteLine(); }
static public void WriteLine<T>(T input) { Console.WriteLine(input); }
static public void Write<T>(T input) { Console.Write(input); }
static public void WriteLine(string s, params object[] arr) {
Console.WriteLine(s, arr);
}
}
#endif
|
[["+", 0, 28, 0, 16, 31, 16, 31, 74, 0, 24], ["+", 0, 28, 0, 16, 31, 16, 31, 74, 39, 199], ["+", 0, 28, 0, 16, 31, 16, 31, 74, 0, 25], ["+", 0, 28, 0, 16, 31, 16, 12, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 3, 4, 0, 28, 0, 16, 12, 74, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 12, 74, 39, 199], ["+", 3, 4, 0, 28, 0, 16, 12, 74, 0, 25]]
| 8
| 1,654
| 9
|
using System;
using System.Text;
namespace abc148_b {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
string[] ss = Console.ReadLine().Split(' ');
string S = ss[0];
string T = ss[1];
StringBuilder sb = new StringBuilder();
for (int i = 0; i < S.Length; i++) {
if (i % 2 == 0)
sb.Append(S[i]);
else
sb.Append(T[i]);
}
Console.WriteLine(sb.ToString());
}
}
}
|
using System;
using System.Text;
namespace abc148_b {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
string[] ss = Console.ReadLine().Split(' ');
string S = ss[0];
string T = ss[1];
StringBuilder sb = new StringBuilder();
for (int i = 0; i < S.Length; i++) {
sb.Append(S[i]);
sb.Append(T[i]);
}
Console.WriteLine(sb.ToString());
}
}
}
|
[["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95]]
| 8
| 141
| 9
|
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ่ชไฝใใญใฐใฉใ ใในใ {
class Program {
static void Main(string[] args) {
int N = int.Parse(ReadLine());
string[] reader_I = ReadLine().Split(' ');
string S = reader_I[0];
string T = reader_I[1];
string NewStr = "";
for (int loop = 0; loop < N; loop++) {
NewStr += S[loop] + T[loop];
}
WriteLine(NewStr);
}
}
}
|
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ่ชไฝใใญใฐใฉใ ใในใ {
class Program {
static void Main(string[] args) {
int N = int.Parse(ReadLine());
string[] reader_I = ReadLine().Split(' ');
string S = reader_I[0];
string T = reader_I[1];
string NewStr = "";
for (int loop = 0; loop < N; loop++) {
NewStr += S.Substring(loop, 1) + T.Substring(loop, 1);
}
WriteLine(NewStr);
}
}
}
|
[["-", 0, 11, 12, 16, 31, 204, 206, 207, 0, 70], ["+", 0, 11, 12, 16, 31, 213, 63, 214, 0, 131], ["+", 0, 11, 12, 16, 31, 213, 63, 214, 141, 22], ["+", 0, 11, 12, 16, 31, 213, 3, 4, 0, 24], ["-", 0, 11, 12, 16, 31, 204, 206, 207, 0, 73], ["+", 0, 11, 12, 16, 31, 213, 3, 4, 0, 21], ["+", 12, 16, 31, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 11, 12, 16, 31, 213, 3, 4, 0, 25], ["-", 0, 11, 12, 16, 12, 204, 206, 207, 0, 70], ["+", 0, 11, 12, 16, 12, 213, 63, 214, 0, 131], ["+", 0, 11, 12, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 11, 12, 16, 12, 213, 3, 4, 0, 24], ["-", 0, 11, 12, 16, 12, 204, 206, 207, 0, 73], ["+", 0, 11, 12, 16, 12, 213, 3, 4, 0, 21], ["+", 12, 16, 12, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 11, 12, 16, 12, 213, 3, 4, 0, 25]]
| 8
| 136
| 16
|
using System;
using System.Linq;
namespace CSharp {
class Program {
static void Main() {
var N = int.Parse(Console.ReadLine());
var input = Console.ReadLine().Split(' ').ToArray();
var S = input[0];
var T = input[1];
var result = string.Empty;
for (int i = 0; i < N; i++) {
result += S[i] + T[i];
}
Console.WriteLine(result);
}
}
}
|
using System;
using System.Linq;
namespace CSharp {
class Program {
static void Main() {
var N = int.Parse(Console.ReadLine());
var input = Console.ReadLine().Split(' ').ToArray();
var S = input[0];
var T = input[1];
var result = string.Empty;
for (int i = 0; i < N; i++) {
result += S[i].ToString() + T[i].ToString();
}
Console.WriteLine(result);
}
}
}
|
[["+", 0, 11, 12, 16, 31, 213, 63, 214, 0, 131], ["+", 0, 11, 12, 16, 31, 213, 63, 214, 141, 22], ["+", 0, 11, 12, 16, 31, 213, 3, 4, 0, 24], ["+", 0, 11, 12, 16, 31, 213, 3, 4, 0, 25], ["+", 0, 11, 12, 16, 12, 213, 63, 214, 0, 131], ["+", 0, 11, 12, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 11, 12, 16, 12, 213, 3, 4, 0, 24], ["+", 0, 11, 12, 16, 12, 213, 3, 4, 0, 25]]
| 8
| 115
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC149B {
class Program {
static void Main(string[] args) {
string[] ABK = Console.ReadLine().Split(' ');
long A = long.Parse(ABK[0]);
long B = long.Parse(ABK[1]);
long K = long.Parse(ABK[2]);
long[] ans = new long[2];
if (A >= K) {
ans[0] = A - K;
ans[1] = B;
} else {
ans[0] = 0;
ans[1] = A + B - K;
}
Console.WriteLine(string.Join(" ", ans));
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC149B {
class Program {
static void Main(string[] args) {
string[] ABK = Console.ReadLine().Split(' ');
long A = long.Parse(ABK[0]);
long B = long.Parse(ABK[1]);
long K = long.Parse(ABK[2]);
long[] ans = new long[2];
if (A >= K) {
ans[0] = A - K;
ans[1] = B;
} else if (A + B >= K) {
ans[0] = 0;
ans[1] = A + B - K;
} else {
ans[0] = 0;
ans[1] = 0;
}
Console.WriteLine(string.Join(" ", ans));
}
}
}
|
[["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 24], ["+", 0, 57, 75, 57, 15, 16, 31, 16, 31, 22], ["+", 0, 57, 75, 57, 15, 16, 31, 16, 17, 72], ["+", 0, 57, 75, 57, 15, 16, 31, 16, 12, 22], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 20], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 25], ["+", 0, 57, 75, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 75, 57, 64, 196, 0, 46], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 95], ["+", 8, 196, 0, 57, 75, 57, 75, 196, 0, 45], ["+", 75, 196, 0, 1, 0, 11, 31, 204, 205, 22], ["+", 0, 1, 0, 11, 31, 204, 206, 207, 0, 70], ["+", 0, 11, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 1, 0, 11, 31, 204, 206, 207, 0, 73], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 75, 57, 75, 196, 0, 1, 0, 11, 12, 203], ["+", 0, 57, 75, 57, 75, 196, 0, 1, 0, 35]]
| 8
| 175
| 25
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;
public class Hello {
public static void Main() {
long[] read = longa();
if (read[2] > read[0]) {
read[0] = 0;
read[2] -= read[0];
} else {
read[0] -= read[2];
read[2] = 0;
}
if (read[2] > 0) {
read[1] = Max(read[1] - read[2], 0);
}
WriteLine($"{read[0]} {read[1]}");
}
//ๅ็จฎ่ชญๅ
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;
}
// A/Bๅฐๆฐ็นไปฅไธๅไธ
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 {
public static void Main() {
long[] read = longa();
if (read[2] > read[0]) {
read[2] -= read[0];
read[0] = 0;
} else {
read[0] -= read[2];
read[2] = 0;
}
if (read[2] > 0) {
read[1] = Max(read[1] - read[2], 0);
}
WriteLine($"{read[0]} {read[1]}");
}
//ๅ็จฎ่ชญๅ
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;
}
// A/Bๅฐๆฐ็นไปฅไธๅไธ
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ใงใใชใ
|
[["-", 0, 11, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 11, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 110], ["+", 0, 11, 12, 204, 206, 207, 0, 28, 0, 203], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 110], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203]]
| 8
| 679
| 12
|
using System;
namespace ConsoleApp11 {
class MainClass {
public static void Main() {
string[] S = Console.ReadLine().Split();
long A = long.Parse(S[0]);
long B = long.Parse(S[1]);
long K = long.Parse(S[2]);
for (long l = 0; l < K; l++) {
if (A > K)
A -= K;
else if (B > K - A) {
K -= A;
A = 0;
B -= K;
} else {
A = 0;
B = 0;
break;
}
}
Console.WriteLine("{0} {1}", A, B);
}
}
}
|
using System;
namespace ConsoleApp11 {
class MainClass {
public static void Main() {
string[] S = Console.ReadLine().Split();
long A = long.Parse(S[0]);
long B = long.Parse(S[1]);
long K = long.Parse(S[2]);
if (A > K)
A -= K;
else if (B > K - A) {
K -= A;
A = 0;
B -= K;
} else {
A = 0;
B = 0;
}
Console.WriteLine("{0} {1}", A, B);
}
}
}
|
[["-", 8, 201, 0, 195, 8, 196, 0, 7, 0, 88], ["-", 8, 201, 0, 195, 8, 196, 0, 7, 0, 24], ["-", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["-", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 7, 0, 35], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["-", 0, 195, 8, 196, 0, 7, 26, 223, 0, 22], ["-", 0, 195, 8, 196, 0, 7, 26, 223, 0, 29], ["-", 8, 201, 0, 195, 8, 196, 0, 7, 0, 25], ["-", 0, 195, 8, 196, 0, 7, 8, 196, 0, 45], ["-", 0, 57, 75, 57, 75, 196, 0, 93, 0, 94], ["-", 0, 57, 75, 57, 75, 196, 0, 93, 0, 35], ["-", 8, 196, 0, 57, 75, 57, 75, 196, 0, 46]]
| 8
| 148
| 18
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace cswork {
class Program {
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
i = 0;
return next();
}
public int nextInt() { return int.Parse(next()); }
public long nextLong() { return long.Parse(next()); }
public double nextDouble() { return double.Parse(next()); }
}
public Program() {}
static void Main(string[] args) { new Program().Omame(); }
Scanner cin;
const int MAXIN = 1024;
bool[] used = new bool[MAXIN];
int[] perm = new int[MAXIN];
List<int[]> permList = new List<int[]>();
public void Permutation(int pos, int n, int length) {
if (pos == n) {
permList.Add((int[])perm.Clone());
}
for (int i = 0; i < n; i++) {
if (!used[i]) {
perm[pos] = i;
used[i] = true;
Permutation(pos + 1, n, length);
used[i] = false;
}
}
}
public static List<long> GeneratePrime(long max) {
long prime;
double sqrtMax = Math.Sqrt(max);
var primeList = new List<long>();
List<long> searchList = new List<long>();
for (long i = 2; i <= max - 1; i++) {
searchList.Add(i);
}
do {
prime = searchList.First();
primeList.Add(prime);
searchList.RemoveAll(n => n % prime == 0);
} while (prime < sqrtMax);
primeList.AddRange(searchList);
return primeList;
}
void Omame() {
cin = new Scanner();
long A = cin.nextLong();
long B = cin.nextLong();
long K = cin.nextLong();
if (A >= K) {
Console.WriteLine((A - K) + " " + B);
} else {
Console.WriteLine(0 + " " + (A + B - K));
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace cswork {
class Program {
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
i = 0;
return next();
}
public int nextInt() { return int.Parse(next()); }
public long nextLong() { return long.Parse(next()); }
public double nextDouble() { return double.Parse(next()); }
}
public Program() {}
static void Main(string[] args) { new Program().Omame(); }
Scanner cin;
const int MAXIN = 1024;
bool[] used = new bool[MAXIN];
int[] perm = new int[MAXIN];
List<int[]> permList = new List<int[]>();
public void Permutation(int pos, int n, int length) {
if (pos == n) {
permList.Add((int[])perm.Clone());
}
for (int i = 0; i < n; i++) {
if (!used[i]) {
perm[pos] = i;
used[i] = true;
Permutation(pos + 1, n, length);
used[i] = false;
}
}
}
public static List<long> GeneratePrime(long max) {
long prime;
double sqrtMax = Math.Sqrt(max);
var primeList = new List<long>();
List<long> searchList = new List<long>();
for (long i = 2; i <= max - 1; i++) {
searchList.Add(i);
}
do {
prime = searchList.First();
primeList.Add(prime);
searchList.RemoveAll(n => n % prime == 0);
} while (prime < sqrtMax);
primeList.AddRange(searchList);
return primeList;
}
void Omame() {
cin = new Scanner();
long A = cin.nextLong();
long B = cin.nextLong();
long K = cin.nextLong();
if (A >= K) {
Console.WriteLine((A - K) + " " + B);
} else {
Console.WriteLine(0 + " " + Math.Max(0, (A + B - K)));
}
}
}
}
|
[["+", 0, 28, 0, 16, 12, 213, 63, 214, 205, 22], ["+", 0, 28, 0, 16, 12, 213, 63, 214, 0, 131], ["+", 0, 28, 0, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 16, 12, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 28, 0, 16, 12, 213, 3, 4, 0, 21], ["+", 12, 213, 3, 4, 0, 28, 0, 23, 0, 24], ["+", 12, 213, 3, 4, 0, 28, 0, 23, 0, 25]]
| 8
| 575
| 7
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ABC149B {
class Program {
static void Main(string[] args) {
var ABK = ReadLong();
long A = ABK[0];
long B = ABK[1];
long K = ABK[2];
long a, b;
if (K <= A) {
a = A - K;
b = B;
} else {
a = 0;
b = A + B - K;
}
Console.WriteLine(a + " " + b);
Console.ReadKey();
}
static int[] ReadInt() {
int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
return ret;
}
static long[] ReadLong() {
long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
return ret;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ABC149B {
class Program {
static void Main(string[] args) {
var ABK = ReadLong();
long A = ABK[0];
long B = ABK[1];
long K = ABK[2];
long a, b;
if (K <= A) {
a = A - K;
b = B;
} else {
a = 0;
b = A + B - K;
}
if (b < 0)
b = 0;
Console.WriteLine(a + " " + b);
Console.ReadKey();
}
static int[] ReadInt() {
int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
return ret;
}
static long[] ReadLong() {
long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
return ret;
}
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35]]
| 8
| 198
| 10
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
class GreedyTakahashi {
static void Main(string[] args) {
var input = Console.ReadLine().Split(' ');
var takahashi = long.Parse(input[0]);
var aoki = long.Parse(input[1]);
var times = long.Parse(input[2]);
var aoki_down = takahashi - times;
if (aoki_down <= 0) {
takahashi = 0;
aoki = aoki + aoki_down;
} else {
takahashi = aoki_down;
}
Console.WriteLine("{0} {1}", takahashi, aoki);
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
class GreedyTakahashi {
static void Main(string[] args) {
var input = Console.ReadLine().Split(' ');
var takahashi = long.Parse(input[0]);
var aoki = long.Parse(input[1]);
var times = long.Parse(input[2]);
var aoki_down = takahashi - times;
if (aoki_down <= 0) {
takahashi = 0;
aoki = aoki + aoki_down;
} else {
takahashi = aoki_down;
}
if (aoki <= 0) {
aoki = 0;
}
Console.WriteLine("{0} {1}", takahashi, aoki);
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 19], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 135
| 12
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;
namespace Atcoder {
class Program {
static void Main(string[] args) {
try {
Solve.Answer();
} catch (Exception ex) {
WriteLine(ex.ToString());
}
}
}
public class Solve {
public static void Answer() {
var abk = IO.ReadSplitLong;
abk[0] -= abk[2];
if (abk[0] < 0) {
abk[1] += abk[0];
abk[0] = 0;
}
var ans = new long[] { abk[0], abk[1] };
IO.OutJoinSpace(ans);
}
public class IO {
#region Input
public static string ReadString => ReadLine();
public static int ReadInt => int.Parse(ReadLine());
public static long ReadLong => long.Parse(ReadLine());
public static double ReadDouble => double.Parse(ReadLine());
public static List<string> ReadSplitString => ReadLine().Split().ToList();
public static List<int> ReadSplitInt =>
ReadLine().Split().Select(s => int.Parse(s)).ToList();
public static List<long> ReadSplitLong =>
ReadLine().Split().Select(s => long.Parse(s)).ToList();
public static List<double> ReadSplitdouble =>
ReadLine().Split().Select(s => double.Parse(s)).ToList();
#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");
#endregion
}
/// <summary>
/// ๆญฃใฎๆฐใฎๅๅๆผ็ฎใฎใฟๅฏพๅฟ
/// </summary>
public class Mod {
// ๅฒใๆฐใฎๅฎ็พฉ
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;
}
public class Scanner {
public string Str => Console.ReadLine().Trim();
public int Int => int.Parse(Str);
public long Long => long.Parse(Str);
public double Double => double.Parse(Str);
public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
// public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
// public int[] ArrInt1D(int n) => Create(n, () => Int);
// public long[] ArrLong1D(int n) => Create(n, () => Long);
// public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
// public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
private Queue<string> q = new Queue<string>();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
// ใคใณใฉใคใณๅใๆจๅฅจใใ
public T Next<T>() {
if (q.Count == 0)
foreach (var item in Str.Split(' '))
q.Enqueue(item);
return (T)Convert.ChangeType(q.Dequeue(), typeof(T));
}
public void Make<T1>(out T1 v1) => v1 = Next<T1>();
public void Make<T1, T2>(out T1 v1, out T2 v2) {
v1 = Next<T1>();
v2 = Next<T2>();
}
public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) {
Make(out v1, out v2);
v3 = Next<T3>();
}
public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4) {
Make(out v1, out v2, out v3);
v4 = Next<T4>();
}
public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5) {
Make(out v1, out v2, out v3, out v4);
v5 = Next<T5>();
}
public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5, out T6 v6) {
Make(out v1, out v2, out v3, out v4, out v5);
v6 = Next<T6>();
}
}
public static long GCD(long x, long y) {
if (x < y) {
var tmp = x;
x = y;
y = tmp;
}
while (true)
{
if (x % y == 0) {
return y;
} else {
var tmp = x;
x = y;
y = tmp % y;
}
}
}
}
public class Combination {
public static long Choice2(long n) {
if (n <= 1)
return 0;
if (n == 2)
return 1;
else
return n * (n - 1) / 2;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;
namespace Atcoder {
class Program {
static void Main(string[] args) {
try {
Solve.Answer();
} catch (Exception ex) {
WriteLine(ex.ToString());
}
}
}
public class Solve {
public static void Answer() {
var abk = IO.ReadSplitLong;
abk[0] -= abk[2];
if (abk[0] < 0) {
abk[1] += abk[0];
if (abk[1] < 0)
abk[1] = 0;
abk[0] = 0;
}
var ans = new long[] { abk[0], abk[1] };
IO.OutJoinSpace(ans);
}
public class IO {
#region Input
public static string ReadString => ReadLine();
public static int ReadInt => int.Parse(ReadLine());
public static long ReadLong => long.Parse(ReadLine());
public static double ReadDouble => double.Parse(ReadLine());
public static List<string> ReadSplitString => ReadLine().Split().ToList();
public static List<int> ReadSplitInt =>
ReadLine().Split().Select(s => int.Parse(s)).ToList();
public static List<long> ReadSplitLong =>
ReadLine().Split().Select(s => long.Parse(s)).ToList();
public static List<double> ReadSplitdouble =>
ReadLine().Split().Select(s => double.Parse(s)).ToList();
#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");
#endregion
}
/// <summary>
/// ๆญฃใฎๆฐใฎๅๅๆผ็ฎใฎใฟๅฏพๅฟ
/// </summary>
public class Mod {
// ๅฒใๆฐใฎๅฎ็พฉ
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;
}
public class Scanner {
public string Str => Console.ReadLine().Trim();
public int Int => int.Parse(Str);
public long Long => long.Parse(Str);
public double Double => double.Parse(Str);
public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
// public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
// public int[] ArrInt1D(int n) => Create(n, () => Int);
// public long[] ArrLong1D(int n) => Create(n, () => Long);
// public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
// public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
private Queue<string> q = new Queue<string>();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
// ใคใณใฉใคใณๅใๆจๅฅจใใ
public T Next<T>() {
if (q.Count == 0)
foreach (var item in Str.Split(' '))
q.Enqueue(item);
return (T)Convert.ChangeType(q.Dequeue(), typeof(T));
}
public void Make<T1>(out T1 v1) => v1 = Next<T1>();
public void Make<T1, T2>(out T1 v1, out T2 v2) {
v1 = Next<T1>();
v2 = Next<T2>();
}
public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) {
Make(out v1, out v2);
v3 = Next<T3>();
}
public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4) {
Make(out v1, out v2, out v3);
v4 = Next<T4>();
}
public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5) {
Make(out v1, out v2, out v3, out v4);
v5 = Next<T5>();
}
public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5, out T6 v6) {
Make(out v1, out v2, out v3, out v4, out v5);
v6 = Next<T6>();
}
}
public static long GCD(long x, long y) {
if (x < y) {
var tmp = x;
x = y;
y = tmp;
}
while (true)
{
if (x % y == 0) {
return y;
} else {
var tmp = x;
x = y;
y = tmp % y;
}
}
}
}
public class Combination {
public static long Choice2(long n) {
if (n <= 1)
return 0;
if (n == 2)
return 1;
else
return n * (n - 1) / 2;
}
}
}
|
[["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 64, 196, 0, 57, 15, 16, 31, 204, 205, 22], ["+", 0, 57, 15, 16, 31, 204, 206, 207, 0, 70], ["+", 15, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 57, 15, 16, 31, 204, 206, 207, 0, 73], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["+", 64, 1, 0, 11, 31, 204, 206, 207, 0, 70], ["+", 0, 11, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 64, 1, 0, 11, 31, 204, 206, 207, 0, 73], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 64, 196, 0, 57, 64, 1, 0, 11, 12, 203], ["+", 0, 57, 64, 196, 0, 57, 64, 1, 0, 35], ["+", 64, 196, 0, 1, 0, 11, 31, 204, 205, 22]]
| 8
| 1,092
| 16
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace B {
public class Program {
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
public static void Solve() {
var abk = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
var diff = abk[0] - abk[2];
var a = diff <= 0 ? 0 : diff;
var b = abk[1] + (diff >= 0 ? 0 : diff);
Console.WriteLine($"{a} {b}");
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace B {
public class Program {
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
public static void Solve() {
var abk = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
var diff = abk[0] - abk[2];
var a = diff <= 0 ? 0 : diff;
var b = abk[1] + (diff >= 0 ? 0 : diff);
b = (b < 0 ? 0 : b);
Console.WriteLine($"{a} {b}");
}
}
}
|
[["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 1, 0, 11, 12, 23, 0, 24], ["+", 0, 11, 12, 23, 0, 41, 15, 16, 31, 22], ["+", 0, 11, 12, 23, 0, 41, 15, 16, 17, 18], ["+", 0, 11, 12, 23, 0, 41, 15, 16, 12, 203], ["+", 0, 1, 0, 11, 12, 23, 0, 41, 0, 101], ["+", 0, 1, 0, 11, 12, 23, 0, 41, 64, 203], ["+", 0, 1, 0, 11, 12, 23, 0, 41, 0, 102], ["+", 0, 1, 0, 11, 12, 23, 0, 41, 75, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 23, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 178
| 12
|
using System;
class ABC149 {
static void Main() {
string input = Console.ReadLine();
string[] inputA = input.Split(' ');
long A = (long)int.Parse(inputA[0]);
long B = (long)int.Parse(inputA[1]);
long K = (long)int.Parse(inputA[2]);
if (A == 0 && B == 0) {
Console.WriteLine(A + " " + B);
return;
}
if (A - K >= 0) {
long AmK = A - K;
Console.WriteLine(AmK + " " + B);
} else {
long AB = A + B;
long ABmK = AB - K;
if (ABmK < 0) {
ABmK = 0;
} else {
}
Console.Write("0 ");
Console.WriteLine(ABmK);
}
Console.ReadKey();
}
}
|
using System;
class ABC149 {
static void Main() {
string input = Console.ReadLine();
string[] inputA = input.Split(' ');
long A = long.Parse(inputA[0]);
long B = long.Parse(inputA[1]);
long K = long.Parse(inputA[2]);
if (A == 0 && B == 0) {
Console.WriteLine(A + " " + B);
return;
}
if (A - K >= 0) {
long AmK = A - K;
Console.WriteLine(AmK + " " + B);
} else {
long AB = A + B;
long ABmK = AB - K;
if (ABmK < 0) {
ABmK = 0;
} else {
}
Console.Write("0 ");
Console.WriteLine(ABmK);
}
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 74, 0, 24], ["-", 0, 198, 0, 200, 0, 212, 0, 74, 0, 25], ["-", 0, 212, 0, 74, 51, 213, 63, 214, 205, 199], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 196
| 15
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace AtCoderCs {
class Program {
static void Main() {
var Arg =
Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
if (Arg[0] < Arg[2]) {
Arg[2] -= Arg[0];
Arg[0] = 0;
if (Arg[1] < Arg[2]) {
Arg[1] = 0;
} else
Arg[1] -= Arg[2];
} else {
Arg[1] -= Arg[0];
}
Console.WriteLine(Arg[0] + " " + Arg[1]);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace AtCoderCs {
class Program {
static void Main() {
var Arg =
Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
if (Arg[0] < Arg[2]) {
Arg[2] -= Arg[0];
Arg[0] = 0;
if (Arg[1] < Arg[2]) {
Arg[1] = 0;
} else
Arg[1] -= Arg[2];
} else {
Arg[0] -= Arg[2];
}
Console.WriteLine(Arg[0] + " " + Arg[1]);
}
}
}
|
[["-", 0, 11, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 11, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 11, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 11, 12, 204, 206, 207, 0, 28, 0, 203]]
| 8
| 157
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace Cookies {
class Program {
static void Main(string[] args) {
var input = Console.ReadLine().Split();
long takahashiCookies = long.Parse(input[0]);
long aokiCookies = long.Parse(input[1]);
long requiredActions = long.Parse(input[2]);
takahashiCookies = takahashiCookies - requiredActions;
if (takahashiCookies < 0) {
aokiCookies = aokiCookies + takahashiCookies;
takahashiCookies = 0;
}
Console.WriteLine(takahashiCookies + " " + aokiCookies);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace Cookies {
class Program {
static void Main(string[] args) {
var input = Console.ReadLine().Split();
long takahashiCookies = long.Parse(input[0]);
long aokiCookies = long.Parse(input[1]);
long requiredActions = long.Parse(input[2]);
takahashiCookies = takahashiCookies - requiredActions;
if (takahashiCookies < 0) {
aokiCookies = aokiCookies + takahashiCookies;
takahashiCookies = 0;
}
if (aokiCookies < 0) {
aokiCookies = 0;
}
Console.WriteLine(takahashiCookies + " " + aokiCookies);
}
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 123
| 12
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
var input = Console.ReadLine().Split();
var A = long.Parse(input[0]);
var B = long.Parse(input[1]);
var K = long.Parse(input[2]);
if (K <= A) {
Console.WriteLine(A - K + " " + B);
} else {
Console.WriteLine("0 " + (B - (K - A)));
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
var input = Console.ReadLine().Split();
var A = long.Parse(input[0]);
var B = long.Parse(input[1]);
var K = long.Parse(input[2]);
if (K <= A) {
Console.WriteLine(A - K + " " + B);
} else {
Console.WriteLine("0 " + Math.Max(0, (B - (K - A))));
}
}
}
|
[["+", 0, 28, 0, 16, 12, 213, 63, 214, 205, 22], ["+", 0, 28, 0, 16, 12, 213, 63, 214, 0, 131], ["+", 0, 28, 0, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 16, 12, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 28, 0, 16, 12, 213, 3, 4, 0, 21], ["+", 12, 213, 3, 4, 0, 28, 0, 23, 0, 24], ["+", 0, 28, 0, 23, 0, 16, 12, 23, 0, 25]]
| 8
| 127
| 7
|
using System;
using System.Collections.Generic;
using System.Linq;
// namespaceใฎๅคใใณใณใในใๅใซใใฆ้็จ
namespace ABC149B {
class Input {
/// <summary>
/// 1่กใฎๅ
ฅๅใๅๅพใใ
/// </summary>
/// <returns>ๆๅญๅ</returns>
public string String() { return Console.ReadLine(); }
/// <summary>
/// ่คๆฐ่กใฎๅ
ฅๅใๅๅพ
/// </summary>
/// <returns>ๆๅญๅใฎ้
ๅ</returns>
public string[] ArrayString(int rowNumber) {
string[] s = new string[rowNumber];
for (int i = 0; i < rowNumber; i++) {
s[i] = String();
}
return s;
}
/// <summary>
/// 1่กใฎๅ
ฅๅใๅๅพ
/// </summary>
/// <returns>intๅใฎๅค</returns>
public int Int() { return int.Parse(String()); }
/// <summary>
/// 1่กใฎๅ
ฅๅใๅๅพ
/// </summary>
/// <returns>intๅใฎ้
ๅ</returns>
public int[] ArrayInt() { return Split().Select(int.Parse).ToArray(); }
/// <summary>
/// ่คๆฐ่กใฎๅ
ฅๅใๅๅพ
/// </summary>
/// <param name="rowNumber">่กๆฐ</param>
/// <returns>intๅใฎ้
ๅ</returns>
public int[] ArrayInt(int rowNumber) {
int[] ints = new int[rowNumber];
for (int i = 0; i < rowNumber; i++) {
ints[i] = Int();
}
return ints;
}
/// <summary>
/// 1่กใฎๅ
ฅๅใๅๅพ
/// </summary>
/// <returns>longๅใฎๅค</returns>
public long Long() { return long.Parse(String()); }
/// <summary>
/// 2ใคใฎๆดๆฐใ1่กใซๆธใใใฆใใๅ
ฅๅใใ2ใคใฎlongใงๅใๅใ
/// </summary>
/// <param name="A"></param>
/// <param name="B"></param>
public void Longs(ref long A, ref long B) {
var longs = ArrayLong();
A = longs[0];
B = longs[1];
}
/// <summary>
/// 3ใคใฎๆดๆฐใ1่กใซๆธใใใฆใใๅ
ฅๅใใ3ใคใฎlongใงๅใๅใ
/// </summary>
/// <param name="A"></param>
/// <param name="B"></param>
/// <param name="C"></param>
public void Longs(ref long A, ref long B, ref long C) {
var longs = ArrayLong();
A = longs[0];
B = longs[1];
C = longs[2];
}
/// <summary>
/// 4ใคใฎๆดๆฐใ1่กใซๆธใใใฆใใๅ
ฅๅใใ4ใคใฎlongใงๅใๅใ
/// </summary>
/// <param name="A"></param>
/// <param name="B"></param>
/// <param name="C"></param>
/// <param name="D"></param>
public void Longs(ref long A, ref long B, ref long C, ref long D) {
var longs = ArrayLong();
A = longs[0];
B = longs[1];
C = longs[2];
D = longs[3];
}
/// <summary>
/// 2ใคใฎๆดๆฐใ่คๆฐ่กใซๆธใใใฆใใๅ
ฅๅใใ2ใคใฎlong[]ใงๅใๅใ
/// </summary>
/// <param name="rowNumber"></param>
/// <param name="A"></param>
/// <param name="B"></param>
public void LongsArray(long rowNumber, ref long[] A, ref long[] B) {
A = new long[rowNumber];
B = new long[rowNumber];
for (int i = 0; i < rowNumber; i++) {
var l = ArrayLong();
A[i] = l[0];
B[i] = l[1];
}
}
/// <summary>
/// 3ใคใฎๆดๆฐใ่คๆฐ่กใซๆธใใใฆใใๅ
ฅๅใใ2ใคใฎlong[]ใงๅใๅใ
/// </summary>
/// <param name="rowNumber"></param>
/// <param name="A"></param>
/// <param name="B"></param>
/// <param name="C"></param>
public void LongsArray(long rowNumber, ref long[] A, ref long[] B,
ref long[] C) {
A = new long[rowNumber];
B = new long[rowNumber];
C = new long[rowNumber];
for (int i = 0; i < rowNumber; i++) {
var l = ArrayLong();
A[i] = l[0];
B[i] = l[1];
C[i] = l[2];
}
}
/// <summary>
/// 1่กใฎๅ
ฅๅใๅๅพ
/// </summary>
/// <returns>longๅใฎ้
ๅ</returns>
public long[] ArrayLong() { return Split().Select(long.Parse).ToArray(); }
public long[] ArrayLong(int rowNumber) {
long[] longs = new long[rowNumber];
for (int i = 0; i < rowNumber; i++) {
longs[i] = Long();
}
return longs;
}
/// <summary>
/// 1่กใฎๅ
ฅๅใๅๅพ
/// </summary>
/// <returns>doubleๅใฎๅค</returns>
public double Double() { return double.Parse(String()); }
/// <summary>
/// 1่กใฎๅ
ฅๅใๅๅพ
/// </summary>
/// <returns>doubleๅใฎ้
ๅ</returns>
public double[] ArrayDouble() {
return Split().Select(double.Parse).ToArray();
}
private IEnumerable<string> Split() { return String().Split(' '); }
}
class Program {
static void Main(string[] args) {
Solver solver = new Solver();
solver.Solve();
}
}
class Solver {
public Solver() {
Input input = new Input();
input.Longs(ref A, ref B, ref K);
}
private long A;
private long B;
private long K;
public void Solve() {
if (K <= A) {
Console.WriteLine("" + ((int)(A - K)) + " " + B);
return;
}
if (K > A + B) {
Console.WriteLine("0 0");
return;
}
Console.WriteLine("0 " + (B - K + A));
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
// namespaceใฎๅคใใณใณใในใๅใซใใฆ้็จ
namespace ABC149B {
class Input {
/// <summary>
/// 1่กใฎๅ
ฅๅใๅๅพใใ
/// </summary>
/// <returns>ๆๅญๅ</returns>
public string String() { return Console.ReadLine(); }
/// <summary>
/// ่คๆฐ่กใฎๅ
ฅๅใๅๅพ
/// </summary>
/// <returns>ๆๅญๅใฎ้
ๅ</returns>
public string[] ArrayString(int rowNumber) {
string[] s = new string[rowNumber];
for (int i = 0; i < rowNumber; i++) {
s[i] = String();
}
return s;
}
/// <summary>
/// 1่กใฎๅ
ฅๅใๅๅพ
/// </summary>
/// <returns>intๅใฎๅค</returns>
public int Int() { return int.Parse(String()); }
/// <summary>
/// 1่กใฎๅ
ฅๅใๅๅพ
/// </summary>
/// <returns>intๅใฎ้
ๅ</returns>
public int[] ArrayInt() { return Split().Select(int.Parse).ToArray(); }
/// <summary>
/// ่คๆฐ่กใฎๅ
ฅๅใๅๅพ
/// </summary>
/// <param name="rowNumber">่กๆฐ</param>
/// <returns>intๅใฎ้
ๅ</returns>
public int[] ArrayInt(int rowNumber) {
int[] ints = new int[rowNumber];
for (int i = 0; i < rowNumber; i++) {
ints[i] = Int();
}
return ints;
}
/// <summary>
/// 1่กใฎๅ
ฅๅใๅๅพ
/// </summary>
/// <returns>longๅใฎๅค</returns>
public long Long() { return long.Parse(String()); }
/// <summary>
/// 2ใคใฎๆดๆฐใ1่กใซๆธใใใฆใใๅ
ฅๅใใ2ใคใฎlongใงๅใๅใ
/// </summary>
/// <param name="A"></param>
/// <param name="B"></param>
public void Longs(ref long A, ref long B) {
var longs = ArrayLong();
A = longs[0];
B = longs[1];
}
/// <summary>
/// 3ใคใฎๆดๆฐใ1่กใซๆธใใใฆใใๅ
ฅๅใใ3ใคใฎlongใงๅใๅใ
/// </summary>
/// <param name="A"></param>
/// <param name="B"></param>
/// <param name="C"></param>
public void Longs(ref long A, ref long B, ref long C) {
var longs = ArrayLong();
A = longs[0];
B = longs[1];
C = longs[2];
}
/// <summary>
/// 4ใคใฎๆดๆฐใ1่กใซๆธใใใฆใใๅ
ฅๅใใ4ใคใฎlongใงๅใๅใ
/// </summary>
/// <param name="A"></param>
/// <param name="B"></param>
/// <param name="C"></param>
/// <param name="D"></param>
public void Longs(ref long A, ref long B, ref long C, ref long D) {
var longs = ArrayLong();
A = longs[0];
B = longs[1];
C = longs[2];
D = longs[3];
}
/// <summary>
/// 2ใคใฎๆดๆฐใ่คๆฐ่กใซๆธใใใฆใใๅ
ฅๅใใ2ใคใฎlong[]ใงๅใๅใ
/// </summary>
/// <param name="rowNumber"></param>
/// <param name="A"></param>
/// <param name="B"></param>
public void LongsArray(long rowNumber, ref long[] A, ref long[] B) {
A = new long[rowNumber];
B = new long[rowNumber];
for (int i = 0; i < rowNumber; i++) {
var l = ArrayLong();
A[i] = l[0];
B[i] = l[1];
}
}
/// <summary>
/// 3ใคใฎๆดๆฐใ่คๆฐ่กใซๆธใใใฆใใๅ
ฅๅใใ2ใคใฎlong[]ใงๅใๅใ
/// </summary>
/// <param name="rowNumber"></param>
/// <param name="A"></param>
/// <param name="B"></param>
/// <param name="C"></param>
public void LongsArray(long rowNumber, ref long[] A, ref long[] B,
ref long[] C) {
A = new long[rowNumber];
B = new long[rowNumber];
C = new long[rowNumber];
for (int i = 0; i < rowNumber; i++) {
var l = ArrayLong();
A[i] = l[0];
B[i] = l[1];
C[i] = l[2];
}
}
/// <summary>
/// 1่กใฎๅ
ฅๅใๅๅพ
/// </summary>
/// <returns>longๅใฎ้
ๅ</returns>
public long[] ArrayLong() { return Split().Select(long.Parse).ToArray(); }
public long[] ArrayLong(int rowNumber) {
long[] longs = new long[rowNumber];
for (int i = 0; i < rowNumber; i++) {
longs[i] = Long();
}
return longs;
}
/// <summary>
/// 1่กใฎๅ
ฅๅใๅๅพ
/// </summary>
/// <returns>doubleๅใฎๅค</returns>
public double Double() { return double.Parse(String()); }
/// <summary>
/// 1่กใฎๅ
ฅๅใๅๅพ
/// </summary>
/// <returns>doubleๅใฎ้
ๅ</returns>
public double[] ArrayDouble() {
return Split().Select(double.Parse).ToArray();
}
private IEnumerable<string> Split() { return String().Split(' '); }
}
class Program {
static void Main(string[] args) {
Solver solver = new Solver();
solver.Solve();
}
}
class Solver {
public Solver() {
Input input = new Input();
input.Longs(ref A, ref B, ref K);
}
private long A;
private long B;
private long K;
public void Solve() {
long rest = 0;
if (K <= A) {
rest = A - K;
Console.WriteLine("" + rest + " " + B);
return;
}
if (K > A + B) {
Console.WriteLine("0 0");
return;
}
rest = B - K + A;
Console.WriteLine("0 " + rest);
}
}
}
|
[["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 0, 16, 31, 16, 31, 16, 12, 23, 0, 24], ["-", 31, 16, 31, 16, 12, 23, 0, 74, 0, 24], ["-", 31, 16, 31, 16, 12, 23, 0, 74, 39, 199], ["-", 31, 16, 31, 16, 12, 23, 0, 74, 0, 25], ["-", 31, 16, 12, 23, 0, 74, 51, 23, 0, 24], ["-", 12, 23, 0, 74, 51, 23, 0, 16, 31, 22], ["-", 12, 23, 0, 74, 51, 23, 0, 16, 17, 33], ["-", 12, 23, 0, 74, 51, 23, 0, 16, 12, 22], ["-", 31, 16, 12, 23, 0, 74, 51, 23, 0, 25], ["-", 0, 16, 31, 16, 31, 16, 12, 23, 0, 25], ["+", 0, 28, 0, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 31, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 17, 33], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 12, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["-", 3, 4, 0, 28, 0, 16, 12, 23, 0, 24], ["-", 0, 16, 12, 23, 0, 16, 31, 16, 31, 22], ["-", 0, 16, 12, 23, 0, 16, 31, 16, 17, 33], ["-", 0, 16, 12, 23, 0, 16, 31, 16, 12, 22], ["-", 0, 28, 0, 16, 12, 23, 0, 16, 12, 22], ["-", 3, 4, 0, 28, 0, 16, 12, 23, 0, 25], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22]]
| 8
| 879
| 38
|
using System;
namespace abcb149 {
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
double a = double.Parse(str[0]);
double b = double.Parse(str[1]);
double k = double.Parse(str[2]);
double u = b - (k - a);
if (u < 0)
b = 0;
if (k > a)
Console.WriteLine("{0} {1}", 0, b - (k - a));
else
Console.WriteLine("{0} {1}", a - k, b);
Console.ReadKey();
}
}
}
|
using System;
namespace abcb149 {
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
double a = double.Parse(str[0]);
double b = double.Parse(str[1]);
double k = double.Parse(str[2]);
double u = b - (k - a);
if (a + b < k)
Console.WriteLine("0" + " " + "0");
if (u < 0)
b = 0;
else if (k > a)
Console.WriteLine("{0} {1}", 0, b - (k - a));
else
Console.WriteLine("{0} {1}", a - k, b);
Console.ReadKey();
}
}
}
|
[["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 72], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 205, 22], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 0, 131], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 141, 22], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 28, 0, 16, 31, 16, 31, 5, 0, 62], ["+", 0, 28, 0, 16, 31, 16, 31, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 17, 72], ["+", 0, 28, 0, 16, 31, 16, 12, 5, 0, 62], ["+", 0, 28, 0, 16, 31, 16, 12, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 3, 4, 0, 28, 0, 16, 12, 5, 0, 62], ["+", 3, 4, 0, 28, 0, 16, 12, 5, 0, 222], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95]]
| 8
| 147
| 26
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;
class Program {
static void Main(string[] args) {
var wrong_answer = new wrong_answer();
wrong_answer.Solve();
}
}
public class wrong_answer {
const int INF = 1 << 30;
const long INFL = 1L << 60;
const int MOD = 1000000007;
const int MOD2 = 998244353;
myinout IO = new myinout();
Math2 mmath = new Math2();
// functions
public void Solve() {
//ใใใใ
var o = IO.longm;
var a = o[0];
var b = o[1];
var k = o[2];
var aaa = Math.Max(0, a - k);
b = Math.Max(0, b - (k - a));
IO.wri(aaa + " " + b);
}
}
// b-aใง้้
public class Math2 {
public long[] fact;
public long[] invfact;
public void factoricalmodset(long N, long MOD = 1000000007) {
fact = new long[N + 1];
invfact = new long[N + 1];
fact[0] = 1;
for (long i = 1; i <= N; ++i) {
fact[i] = fact[i - 1] * i % MOD;
}
invfact[N] = pow(fact[N], MOD - 2);
for (long i = N; i > 0; --i) {
invfact[i - 1] = invfact[i] * i % MOD;
}
}
public long nCr(long n, long r, long MOD = 1000000007) {
return (fact[n] * invfact[r] % MOD * invfact[n - r] % MOD);
}
public long pow(long i, long n, long MOD = 1000000007) {
long res = 1;
while (n > 0) {
if ((n & 1) != 0)
res = res * i % MOD;
i = i * i % MOD;
n >>= 1;
}
return res;
}
public long gcd(long i, long y) {
while (y != 0) {
var r = i % y;
i = y;
y = r;
}
return i;
}
public long lcm(long i, long y) { return i * y / gcd(i, y); }
public Dictionary<long, int> primefactorization(long N) {
var ret = new Dictionary<long, int>();
for (long i = 2; i * i <= N; ++i) {
int cnt = 0;
while (N % i == 0) {
cnt++;
N /= i;
}
if (cnt != 0)
ret[i] = cnt;
}
if (N >= 2)
ret[N] = 1;
return ret;
}
public List<long> divisorenumrate(long N) {
var ret = new List<long>();
for (long i = 1; i * i <= N; ++i) {
if (N % i == 0) {
ret.Add(i);
ret.Add(N / i);
}
}
return ret;
}
public void swap<T>(ref T a, ref T b) {
var i = a;
a = b;
b = i;
}
}
class myinout {
// in
public string str => Console.ReadLine();
public string[] strm => str.Split(' ');
public long[] longm => strm.Select(long.Parse).ToArray();
public int[] intm => strm.Select(int.Parse).ToArray();
public char[] charm => str.ToArray();
public double[] doublem => strm.Select(double.Parse).ToArray();
public long long1 => longm[0];
public int int1 => intm[0];
public char char1 => charm[0];
public double double1 => doublem[0];
// out
public void wri<T>(T i) { Console.WriteLine(i); }
public void wri<T>(T[] i) { Console.WriteLine(string.Join(" ", i)); }
public void yn(bool i) {
if (i)
wri("Yes");
else
wri("No");
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;
class Program {
static void Main(string[] args) {
var wrong_answer = new wrong_answer();
wrong_answer.Solve();
}
}
public class wrong_answer {
const int INF = 1 << 30;
const long INFL = 1L << 60;
const int MOD = 1000000007;
const int MOD2 = 998244353;
myinout IO = new myinout();
Math2 mmath = new Math2();
// functions
public void Solve() {
//ใใใใ
var o = IO.longm;
var a = o[0];
var b = o[1];
var k = o[2];
var aaa = Math.Max(0, a - k);
b = Math.Max(0, b - (k - Math.Min(k, a)));
IO.wri(aaa + " " + b);
}
}
// b-aใง้้
public class Math2 {
public long[] fact;
public long[] invfact;
public void factoricalmodset(long N, long MOD = 1000000007) {
fact = new long[N + 1];
invfact = new long[N + 1];
fact[0] = 1;
for (long i = 1; i <= N; ++i) {
fact[i] = fact[i - 1] * i % MOD;
}
invfact[N] = pow(fact[N], MOD - 2);
for (long i = N; i > 0; --i) {
invfact[i - 1] = invfact[i] * i % MOD;
}
}
public long nCr(long n, long r, long MOD = 1000000007) {
return (fact[n] * invfact[r] % MOD * invfact[n - r] % MOD);
}
public long pow(long i, long n, long MOD = 1000000007) {
long res = 1;
while (n > 0) {
if ((n & 1) != 0)
res = res * i % MOD;
i = i * i % MOD;
n >>= 1;
}
return res;
}
public long gcd(long i, long y) {
while (y != 0) {
var r = i % y;
i = y;
y = r;
}
return i;
}
public long lcm(long i, long y) { return i * y / gcd(i, y); }
public Dictionary<long, int> primefactorization(long N) {
var ret = new Dictionary<long, int>();
for (long i = 2; i * i <= N; ++i) {
int cnt = 0;
while (N % i == 0) {
cnt++;
N /= i;
}
if (cnt != 0)
ret[i] = cnt;
}
if (N >= 2)
ret[N] = 1;
return ret;
}
public List<long> divisorenumrate(long N) {
var ret = new List<long>();
for (long i = 1; i * i <= N; ++i) {
if (N % i == 0) {
ret.Add(i);
ret.Add(N / i);
}
}
return ret;
}
public void swap<T>(ref T a, ref T b) {
var i = a;
a = b;
b = i;
}
}
class myinout {
// in
public string str => Console.ReadLine();
public string[] strm => str.Split(' ');
public long[] longm => strm.Select(long.Parse).ToArray();
public int[] intm => strm.Select(int.Parse).ToArray();
public char[] charm => str.ToArray();
public double[] doublem => strm.Select(double.Parse).ToArray();
public long long1 => longm[0];
public int int1 => intm[0];
public char char1 => charm[0];
public double double1 => doublem[0];
// out
public void wri<T>(T i) { Console.WriteLine(i); }
public void wri<T>(T[] i) { Console.WriteLine(string.Join(" ", i)); }
public void yn(bool i) {
if (i)
wri("Yes");
else
wri("No");
}
}
|
[["+", 12, 23, 0, 16, 12, 213, 63, 214, 205, 22], ["+", 12, 23, 0, 16, 12, 213, 63, 214, 0, 131], ["+", 12, 23, 0, 16, 12, 213, 63, 214, 141, 22], ["+", 12, 23, 0, 16, 12, 213, 3, 4, 0, 24], ["+", 0, 16, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 12, 23, 0, 16, 12, 213, 3, 4, 0, 21], ["+", 12, 23, 0, 16, 12, 213, 3, 4, 0, 25]]
| 8
| 909
| 7
|
using System;
public class AtCoderB {
static void Main() {
long a;
long b;
long k;
{
var line = Console.ReadLine();
var words = line.Split(' ');
a = long.Parse(words[0]);
b = long.Parse(words[1]);
k = long.Parse(words[2]);
}
if (a >= k) {
a = a - k;
} else if (a < k) {
a = 0;
b = b - (k - a);
if (b < 0) {
b = 0;
}
}
Console.WriteLine(a + " " + b);
}
}
|
using System;
public class AtCoderB {
static void Main() {
long a;
long b;
long k;
{
var line = Console.ReadLine();
var words = line.Split(' ');
a = long.Parse(words[0]);
b = long.Parse(words[1]);
k = long.Parse(words[2]);
}
if (a >= k) {
a = a - k;
} else if (a < k) {
b = b - (k - a);
a = 0;
if (b < 0) {
b = 0;
}
}
Console.WriteLine(a + " " + b);
}
}
|
[["-", 75, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 75, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["-", 0, 57, 75, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 57, 75, 57, 64, 196, 0, 1, 0, 35], ["+", 75, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 75, 57, 64, 196, 0, 1, 0, 11, 12, 203]]
| 8
| 145
| 8
|
using System;
namespace MyProgram {
class AtCoder {
public static void Main(string[] args) {
long[] input = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
long A = input[0];
long B = input[1];
long K = input[2];
if (A >= K) {
A -= K;
} else {
B -= K - A;
A = 0;
}
Console.WriteLine("{0} {1}", A, B);
}
}
}
|
using System;
namespace MyProgram {
class AtCoder {
public static void Main(string[] args) {
long[] input = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
long A = input[0];
long B = input[1];
long K = input[2];
if (A >= K) {
A -= K;
} else {
B -= K - A;
if (B < 0) {
B = 0;
}
A = 0;
}
Console.WriteLine("{0} {1}", A, B);
}
}
}
|
[["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 24], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 25], ["+", 0, 57, 75, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 75, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 57, 75, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 112
| 12
|
using System.Linq;
using System;
using System.IO;
using System.Collections.Generic;
using static System.Console;
class Program {
static void Main(string[] args) => new Program().solve();
private void solve() {
var pram = ReadLine().Split(' ').Select(long.Parse).ToArray();
var a = pram[0];
var b = pram[1];
var k = pram[2];
var ans = new long[2];
ans[0] = (a < k) ? 0 : a - k;
ans[1] = (a < k) ? b - (k - a) : b;
WriteLine(String.Join(" ", ans));
}
}
|
using System.Linq;
using System;
using System.IO;
using System.Collections.Generic;
using static System.Console;
class Program {
static void Main(string[] args) => new Program().solve();
private void solve() {
var pram = ReadLine().Split(' ').Select(long.Parse).ToArray();
var a = pram[0];
var b = pram[1];
var k = pram[2];
var ans = new long[2];
ans[0] = (a < k) ? 0 : a - k;
var k2 = Math.Max(k - a, 0);
ans[1] = (b < k2) ? 0 : b - k2;
WriteLine(String.Join(" ", ans));
}
}
|
[["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 200, 0, 212, 0, 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, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 21], ["+", 0, 212, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 11, 12, 41, 15, 23, 0, 16, 31, 22], ["+", 0, 11, 12, 41, 15, 23, 0, 16, 31, 22], ["-", 0, 11, 12, 41, 15, 23, 0, 16, 12, 22], ["+", 0, 11, 12, 41, 15, 23, 0, 16, 12, 22], ["-", 0, 1, 0, 11, 12, 41, 64, 16, 31, 22], ["-", 0, 1, 0, 11, 12, 41, 64, 16, 17, 33], ["-", 0, 11, 12, 41, 64, 16, 12, 23, 0, 24], ["-", 12, 41, 64, 16, 12, 23, 0, 16, 31, 22], ["-", 12, 41, 64, 16, 12, 23, 0, 16, 17, 33], ["-", 12, 41, 64, 16, 12, 23, 0, 16, 12, 22], ["-", 0, 11, 12, 41, 64, 16, 12, 23, 0, 25], ["+", 8, 196, 0, 1, 0, 11, 12, 41, 64, 203], ["+", 0, 1, 0, 11, 12, 41, 75, 16, 17, 33], ["+", 0, 1, 0, 11, 12, 41, 75, 16, 12, 22]]
| 8
| 166
| 28
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
public class MainClass {
public static void Main() {
string line = System.Console.ReadLine();
string[] strs = line.Split(' ');
long A = long.Parse(strs[0]);
long B = long.Parse(strs[1]);
long K = long.Parse(strs[2]);
if (A >= K) {
A -= K;
} else {
B -= K - A;
A = 0;
}
/*
for(long i =0; i < K; i++)
{
if(A > 0)
{
A--;
}
else if (B > 0)
{
B--;
}
else
{
break;
}
}*/
System.Console.WriteLine(A + " " + B);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
public class MainClass {
public static void Main() {
string line = System.Console.ReadLine();
string[] strs = line.Split(' ');
long A = long.Parse(strs[0]);
long B = long.Parse(strs[1]);
long K = long.Parse(strs[2]);
if (A >= K) {
A -= K;
} else {
B -= K - A;
if (B < 0) {
B = 0;
}
A = 0;
}
/*
for(long i =0; i < K; i++)
{
if(A > 0)
{
A--;
}
else if (B > 0)
{
B--;
}
else
{
break;
}
}*/
System.Console.WriteLine(A + " " + B);
}
}
|
[["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 24], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 25], ["+", 0, 57, 75, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 75, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 57, 75, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 138
| 12
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public sealed class Begineer149 {
public static void Main() {
long[] ABK = Console.ReadLine()
.Split(new char[] { ' ' })
.Select(x => Convert.ToInt64(x))
.ToArray();
long A = ABK[0], B = ABK[1], k = ABK[2];
long min = Math.Min(A, k);
A = A - min;
k = min;
B = Math.Max(0, B - k);
Console.WriteLine($"{A} {B}");
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public sealed class Begineer149 {
public static void Main() {
long[] ABK = Console.ReadLine()
.Split(new char[] { ' ' })
.Select(x => Convert.ToInt64(x))
.ToArray();
long A = ABK[0], B = ABK[1], k = ABK[2];
if (k < A) {
A = A - k;
k = 0;
} else {
B = Math.Max(0, B - (k - A));
A = 0;
}
Console.WriteLine($"{A} {B}");
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["-", 0, 212, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 21], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["-", 0, 195, 8, 196, 0, 1, 0, 11, 12, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 3, 4, 0, 28, 0, 16, 12, 23, 0, 24], ["+", 0, 28, 0, 16, 12, 23, 0, 16, 17, 33], ["+", 0, 28, 0, 16, 12, 23, 0, 16, 12, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 146
| 29
|
using System;
class ProgramB {
static void Main(string[] args) {
//ๅ
ฅๅ
string[] input = Console.ReadLine().Split(' ');
int a = int.Parse(input[0]);
int b = int.Parse(input[1]);
int k = int.Parse(input[2]);
if (a >= k) {
Console.Write(a - k);
Console.Write(' ');
Console.Write(b);
} else {
Console.Write('0');
Console.Write(' ');
if (a + b >= k)
Console.Write(a + b - k);
else {
Console.Write('0');
}
}
}
}
|
using System;
using System;
class ProgramB {
static void Main(string[] args) {
//ๅ
ฅๅ
string[] input = Console.ReadLine().Split(' ');
long a = long.Parse(input[0]);
long b = long.Parse(input[1]);
long k = long.Parse(input[2]);
if (a >= k) {
Console.Write(a - k);
Console.Write(' ');
Console.Write(b);
} else {
Console.Write('0');
Console.Write(' ');
if (a + b >= k)
Console.Write(a + b - k);
else {
Console.Write('0');
}
}
}
}
|
[["+", 36, 36, 36, 36, 0, 208, 0, 231, 0, 233], ["+", 36, 36, 36, 36, 0, 208, 0, 231, 141, 22], ["+", 36, 36, 36, 36, 0, 208, 0, 231, 0, 35], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199]]
| 8
| 161
| 15
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace atcorder {
class Program {
static void Main(string[] args) {
string[] strArray = Console.ReadLine().Split(' ');
double A = Int64.Parse(strArray[0]);
double B = Int64.Parse(strArray[1]);
double K = Int64.Parse(strArray[2]);
if (K < A) {
Console.WriteLine((K - A).ToString() + " " + B.ToString());
return;
} else if (K < A + B) {
Console.WriteLine("0 " + (B - (K - A)).ToString());
return;
} else {
Console.WriteLine("0 0");
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace atcorder {
class Program {
static void Main(string[] args) {
string[] strArray = Console.ReadLine().Split(' ');
double A = Int64.Parse(strArray[0]);
double B = Int64.Parse(strArray[1]);
double K = Int64.Parse(strArray[2]);
if (K < A) {
double result = A - K;
Console.WriteLine(result.ToString() + " " + B.ToString());
return;
} else if (K < A + B) {
Console.WriteLine("0 " + (B - (K - A)).ToString());
return;
} else {
Console.WriteLine("0 0");
}
}
}
}
|
[["+", 0, 57, 64, 196, 0, 197, 0, 198, 39, 199], ["+", 64, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 33], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 197, 0, 35], ["-", 31, 16, 31, 213, 63, 214, 205, 23, 0, 24], ["-", 31, 213, 63, 214, 205, 23, 0, 16, 31, 22], ["-", 31, 213, 63, 214, 205, 23, 0, 16, 17, 33], ["-", 31, 213, 63, 214, 205, 23, 0, 16, 12, 22], ["-", 31, 16, 31, 213, 63, 214, 205, 23, 0, 25], ["+", 0, 16, 31, 16, 31, 213, 63, 214, 205, 22]]
| 8
| 186
| 13
|
using System;
namespace GreedyTakahashi {
class Program {
static void Main(string[] args) {
var input = Console.ReadLine();
var A = long.Parse(input.Split(' ')[0]);
var B = long.Parse(input.Split(' ')[1]);
var K = long.Parse(input.Split(' ')[2]);
if (A == 0 && B == 0) {
Console.WriteLine("0 0");
return;
}
var takahasi = A - K;
if (takahasi >= 0) {
Console.WriteLine(takahasi + " " + B);
} else {
var aoki = B + takahasi;
Console.WriteLine("0 " + aoki);
}
}
}
}
|
using System;
namespace GreedyTakahashi {
class Program {
static void Main(string[] args) {
var input = Console.ReadLine();
var A = long.Parse(input.Split(' ')[0]);
var B = long.Parse(input.Split(' ')[1]);
var K = long.Parse(input.Split(' ')[2]);
if (A == 0 && B == 0) {
Console.WriteLine("0 0");
return;
}
var takahasi = A - K;
if (takahasi >= 0) {
Console.WriteLine(takahasi + " " + B);
} else {
var aoki = B + takahasi;
if (aoki < 0)
aoki = 0;
Console.WriteLine("0 " + aoki);
}
}
}
}
|
[["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 24], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 25], ["+", 75, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 75, 196, 0, 57, 64, 1, 0, 11, 12, 203], ["+", 0, 57, 75, 196, 0, 57, 64, 1, 0, 35]]
| 8
| 163
| 10
|
using System;
namespace AtCoder_Begginer_Contest1 {
class Program {
static void Main(string[] args) {
string[] ABK = Console.ReadLine().Split();
long A = long.Parse(ABK[0]);
long B = long.Parse(ABK[1]);
long K = long.Parse(ABK[2]);
if (A >= K)
A = A - K;
else if (B + A > K) {
A = 0;
B = B - K + A;
} else
A = 0;
B = 0;
// for (int i = 0; i < K; i++)
// {
// if (A >= 1) A--;
// else if (B >= 1) B--;
// }
Console.WriteLine(A + " " + B);
}
}
}
|
using System;
using System.Linq;
namespace AtCoder_Begginer_Contest1 {
class Program {
static void Main(string[] args) {
string[] ABK = Console.ReadLine().Split();
long A = long.Parse(ABK[0]);
long B = long.Parse(ABK[1]);
long K = long.Parse(ABK[2]);
if (A >= K) {
A = A - K;
} else if (B + A >= K) {
B = B - K + A;
A = 0;
} else {
A = 0;
B = 0;
}
Console.WriteLine(A + " " + B);
}
}
}
|
[["+", 36, 36, 36, 36, 0, 208, 0, 231, 0, 233], ["+", 36, 36, 0, 208, 0, 231, 141, 232, 234, 22], ["+", 36, 36, 0, 208, 0, 231, 141, 232, 0, 131], ["+", 36, 36, 0, 208, 0, 231, 141, 232, 141, 22], ["+", 36, 36, 36, 36, 0, 208, 0, 231, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 8, 196, 0, 57, 75, 57, 15, 16, 17, 47], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 20], ["-", 75, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 75, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["-", 0, 57, 75, 57, 64, 196, 0, 1, 0, 35], ["+", 75, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 75, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 0, 57, 75, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 75, 57, 75, 196, 0, 45], ["+", 8, 196, 0, 57, 75, 57, 75, 196, 0, 46]]
| 8
| 138
| 19
|
using System;
class B {
static void Main(string[] args) {
string[] s = Console.ReadLine().Split(' ');
long A = long.Parse(s[0]);
long B = long.Parse(s[1]);
long K = long.Parse(s[2]);
long a = ((A - K) >= 0) ? (A - K) : 0;
long b = (a == 0) ? ((A + B) - K) : B;
Console.WriteLine(a + " " + b);
}
}
|
using System;
class B {
static void Main(string[] args) {
string[] s = Console.ReadLine().Split(' ');
long A = long.Parse(s[0]);
long B = long.Parse(s[1]);
long K = long.Parse(s[2]);
long a = ((A - K) >= 0) ? (A - K) : 0;
long b = (a == 0) ? ((A + B) - K) : B;
if (b < 0) {
b = 0;
}
Console.WriteLine(a + " " + b);
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 130
| 12
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace AtCoder {
class Program {
static void Main(string[] args) {
var ABK = Io.ReadList<long>();
var A = ABK[0];
var B = ABK[1];
var K = ABK[2];
var a = Math.Max(A - K, 0);
var b = B - Math.Max(K - A, 0);
var output = $"{a} {b}";
Io.Write(output);
}
static int NumberOfDigits(long x) {
if (x < 10)
return 1;
var result = 0;
while (x > 0) {
result++;
x /= 10;
}
return result;
}
static int SumOfDigits(int x) {
var sum = 0;
while (x > 0) {
sum += x % 10;
x /= 10;
}
return sum;
}
class Io {
public static string Read() { return Console.ReadLine(); }
public static IEnumerable<string> ReadRepeat(int count) {
return Enumerable.Range(0, count).Select(_ => Read());
}
public static T Read<T>() {
return (T)Convert.ChangeType(Read(), typeof(T));
}
public static IEnumerable<T> ReadRepeat<T>(int count) {
return Enumerable.Range(0, count).Select(_ => Read<T>());
}
public static string[] ReadList(char devide = ' ') {
return Read().Split(devide);
}
public static T[] ReadList<T>(char devide = ' ') {
return ReadList(devide)
.Select(s => (T)Convert.ChangeType(s, typeof(T)))
.ToArray();
}
public static IEnumerable<T[]> ReadListRepeat<T>(int count,
char devide = ' ') {
return Enumerable.Range(0, count).Select(_ => ReadList<T>(devide));
}
public static void Write(string value) { Console.WriteLine(value); }
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace AtCoder {
class Program {
static void Main(string[] args) {
var ABK = Io.ReadList<long>();
var A = ABK[0];
var B = ABK[1];
var K = ABK[2];
var a = Math.Max(A - K, 0);
var b = Math.Max(B - Math.Max(K - A, 0), 0);
var output = $"{a} {b}";
Io.Write(output);
}
static int NumberOfDigits(long x) {
if (x < 10)
return 1;
var result = 0;
while (x > 0) {
result++;
x /= 10;
}
return result;
}
static int SumOfDigits(int x) {
var sum = 0;
while (x > 0) {
sum += x % 10;
x /= 10;
}
return sum;
}
class Io {
public static string Read() { return Console.ReadLine(); }
public static IEnumerable<string> ReadRepeat(int count) {
return Enumerable.Range(0, count).Select(_ => Read());
}
public static T Read<T>() {
return (T)Convert.ChangeType(Read(), typeof(T));
}
public static IEnumerable<T> ReadRepeat<T>(int count) {
return Enumerable.Range(0, count).Select(_ => Read<T>());
}
public static string[] ReadList(char devide = ' ') {
return Read().Split(devide);
}
public static T[] ReadList<T>(char devide = ' ') {
return ReadList(devide)
.Select(s => (T)Convert.ChangeType(s, typeof(T)))
.ToArray();
}
public static IEnumerable<T[]> ReadListRepeat<T>(int count,
char devide = ' ') {
return Enumerable.Range(0, count).Select(_ => ReadList<T>(devide));
}
public static void Write(string value) { Console.WriteLine(value); }
}
}
}
|
[["+", 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, 28, 0, 16, 12, 213, 3, 4, 0, 21], ["+", 0, 16, 12, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 28, 0, 16, 12, 213, 3, 4, 0, 25]]
| 8
| 454
| 7
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;
namespace AtCoder {
class Program {
static void Main(string[] args) {
var abk = ReadLongs();
//้ซๆฉ
var takahashi = abk[0];
//้ๆจ
var aoki = abk[1];
var K = abk[2];
var ansA = Max(takahashi - K, 0);
var nokori = Max(K - takahashi, 0);
var ansB = aoki - nokori;
WriteLine(ansA + " " + ansB);
}
private static string Read() { return ReadLine(); }
private static string[] Reads() { return (Read().Split()); }
private static int ReadInt() { return int.Parse(Read()); }
private static long ReadLong() { return long.Parse(Read()); }
private static double ReadDouble() { return double.Parse(Read()); }
private static int[] ReadInts() {
return Array.ConvertAll(Read().Split(), int.Parse);
}
private static long[] ReadLongs() {
return Array.ConvertAll(Read().Split(), long.Parse);
}
private static double[] ReadDoubles() {
return Array.ConvertAll(Read().Split(), double.Parse);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;
namespace AtCoder {
class Program {
static void Main(string[] args) {
var abk = ReadLongs();
//้ซๆฉ
var takahashi = abk[0];
//้ๆจ
var aoki = abk[1];
var K = abk[2];
var ansA = Max(takahashi - K, 0);
var nokori = Max(K - takahashi, 0);
var ansB = aoki - nokori;
WriteLine(Max(ansA, 0) + " " + Max(ansB, 0));
}
private static string Read() { return ReadLine(); }
private static string[] Reads() { return (Read().Split()); }
private static int ReadInt() { return int.Parse(Read()); }
private static long ReadLong() { return long.Parse(Read()); }
private static double ReadDouble() { return double.Parse(Read()); }
private static int[] ReadInts() {
return Array.ConvertAll(Read().Split(), int.Parse);
}
private static long[] ReadLongs() {
return Array.ConvertAll(Read().Split(), long.Parse);
}
private static double[] ReadDoubles() {
return Array.ConvertAll(Read().Split(), double.Parse);
}
}
}
|
[["+", 0, 28, 0, 16, 31, 16, 31, 213, 63, 22], ["+", 0, 16, 31, 16, 31, 213, 3, 4, 0, 24], ["+", 0, 16, 31, 16, 31, 213, 3, 4, 0, 21], ["+", 31, 16, 31, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 16, 31, 16, 31, 213, 3, 4, 0, 25], ["+", 3, 4, 0, 28, 0, 16, 12, 213, 63, 22], ["+", 0, 28, 0, 16, 12, 213, 3, 4, 0, 24], ["+", 0, 28, 0, 16, 12, 213, 3, 4, 0, 21], ["+", 0, 16, 12, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 28, 0, 16, 12, 213, 3, 4, 0, 25]]
| 8
| 303
| 10
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
class Program {
static void Main(string[] args) {
// var n = long.Parse(Console.ReadLine());
var ABK = Console.ReadLine().Split().Select(long.Parse).ToArray();
var A = ABK[0];
var B = ABK[1];
var K = ABK[2];
if (A >= K) {
A -= K;
} else {
B -= (K - A);
A = 0;
}
Console.WriteLine(A + " " + B);
}
}
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
class Program {
static void Main(string[] args) {
// var n = long.Parse(Console.ReadLine());
var ABK = Console.ReadLine().Split().Select(long.Parse).ToArray();
var A = ABK[0];
var B = ABK[1];
var K = ABK[2];
if (A >= K) {
A -= K;
} else {
if (B < (K - A)) {
B = 0;
} else {
B -= (K - A);
}
A = 0;
}
Console.WriteLine(A + " " + B);
}
}
|
[["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 24], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 17, 18], ["+", 75, 196, 0, 57, 15, 16, 12, 23, 0, 24], ["+", 0, 57, 15, 16, 12, 23, 0, 16, 31, 22], ["+", 0, 57, 15, 16, 12, 23, 0, 16, 17, 33], ["+", 0, 57, 15, 16, 12, 23, 0, 16, 12, 22], ["+", 75, 196, 0, 57, 15, 16, 12, 23, 0, 25], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 25], ["+", 0, 57, 75, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 75, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 57, 75, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 95], ["+", 0, 57, 75, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 75, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 133
| 19
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ClassLibrary1 {
public class ListNode {
public int val;
public ListNode next;
public ListNode(int x) { val = x; }
}
public class Class1 {
static Dictionary<Tuple<long, long>, long> dic =
new Dictionary<Tuple<long, long>, long>();
static void Main(string[] args) {
var aa = ReadLongArr();
var a = aa[0];
var b = aa[1];
var k = aa[2];
var res = 0;
if (k < a) {
a = a - k;
} else {
a = 0;
b = Math.Max(a + b - k, 0);
}
Console.WriteLine(a + " " + b);
}
class BitArr {
public bool[] bitArr = new bool[64];
public BitArr(long l) {
var ll = l;
for (int i = 0; i < 64; i++) {
bitArr[i] = (ll % 2) == 1;
ll = ll / 2;
}
}
}
public static int Digit(long num) {
// Mathf.Log10(0)ใฏNegativeInfinityใ่ฟใใใใๅฅ้ๅฆ็ใใใ
return (num == 0) ? 1 : ((int)Math.Log10(num) + 1);
}
public static long nCm(long n, long m, long mod) {
if (m == 0)
return 1;
if (n == 0)
return 0;
var a = n * nCm(n - 1, m - 1, mod) / m;
return a % mod;
// return a % 1000000007;
}
private static string ReadString() { return Console.ReadLine(); }
private static string[] ReadStringArr() {
return Console.ReadLine().Split(' ');
}
private static long ReadLong() { return long.Parse(Console.ReadLine()); }
private static long[] ReadLongArr() {
string[] s = ReadStringArr();
long[] l = new long[s.Length];
for (int i = 0; i < l.Length; i++) {
l[i] = long.Parse(s[i]);
}
return l;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ClassLibrary1 {
public class ListNode {
public int val;
public ListNode next;
public ListNode(int x) { val = x; }
}
public class Class1 {
static Dictionary<Tuple<long, long>, long> dic =
new Dictionary<Tuple<long, long>, long>();
static void Main(string[] args) {
var aa = ReadLongArr();
var a = aa[0];
var b = aa[1];
var k = aa[2];
var res = 0;
if (k < a) {
a = a - k;
} else {
b = Math.Max(a + b - k, 0);
a = 0;
}
Console.WriteLine(a + " " + b);
}
class BitArr {
public bool[] bitArr = new bool[64];
public BitArr(long l) {
var ll = l;
for (int i = 0; i < 64; i++) {
bitArr[i] = (ll % 2) == 1;
ll = ll / 2;
}
}
}
public static int Digit(long num) {
// Mathf.Log10(0)ใฏNegativeInfinityใ่ฟใใใใๅฅ้ๅฆ็ใใใ
return (num == 0) ? 1 : ((int)Math.Log10(num) + 1);
}
public static long nCm(long n, long m, long mod) {
if (m == 0)
return 1;
if (n == 0)
return 0;
var a = n * nCm(n - 1, m - 1, mod) / m;
return a % mod;
// return a % 1000000007;
}
private static string ReadString() { return Console.ReadLine(); }
private static string[] ReadStringArr() {
return Console.ReadLine().Split(' ');
}
private static long ReadLong() { return long.Parse(Console.ReadLine()); }
private static long[] ReadLongArr() {
string[] s = ReadStringArr();
long[] l = new long[s.Length];
for (int i = 0; i < l.Length; i++) {
l[i] = long.Parse(s[i]);
}
return l;
}
}
}
|
[["-", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["-", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 0, 57, 75, 196, 0, 1, 0, 11, 12, 203], ["-", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 12, 203]]
| 8
| 471
| 8
|
using System;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split();
long A = long.Parse(str[0]);
long B = long.Parse(str[1]);
long K = long.Parse(str[2]);
long a1 = Math.Min(A, K);
long a2 = K - a1;
A -= a1;
B -= a2;
Console.WriteLine(A + " " + B);
}
}
|
using System;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split();
long A = long.Parse(str[0]);
long B = long.Parse(str[1]);
long K = long.Parse(str[2]);
long a1 = Math.Min(A, K);
long a2 = Math.Min(B, K - a1);
A -= a1;
B -= a2;
Console.WriteLine(A + " " + B);
}
}
|
[["+", 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, 212, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 21], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25]]
| 8
| 119
| 7
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Program {
public static readonly int[] Coefs = { 4, 2, 4, 2, 4, 6, 2, 6 };
private static void Main() {
var x = int.Parse(Console.ReadLine());
var primes = Sieve(10 * 10 * 10 * 10 * 10);
var answer = primes.First(prime => prime >= x);
var writer =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(writer);
Console.WriteLine(answer);
Console.Out.Flush();
}
public static List<int> Sieve(int max) {
var isPrimes = Enumerable.Repeat(true, max + 1).ToArray();
for (var i2 = 4; i2 <= max; i2 += 2)
isPrimes[i2] = false;
for (var i3 = 9; i3 <= max; i3 += 6)
isPrimes[i3] = false;
for (int i5 = 25, x = 4; i5 <= max; i5 += 5 * (x = 6 - x))
isPrimes[i5] = false;
var iCoefIndex = 7;
for (var i = 7; i * i <= max; i += Coefs[iCoefIndex]) {
if (!isPrimes[i]) {
iCoefIndex = iCoefIndex == 7 ? 0 : iCoefIndex + 1;
continue;
}
var jCoefIndex = iCoefIndex;
for (var j = i * i; j <= max; j += i * Coefs[jCoefIndex]) {
isPrimes[j] = false;
jCoefIndex = jCoefIndex == 7 ? 0 : jCoefIndex + 1;
}
iCoefIndex = iCoefIndex == 7 ? 0 : iCoefIndex + 1;
}
return Primes(max, isPrimes);
}
public static List<int> Primes(int max, bool[] isPrimes) {
var primes = new List<int>();
if (max < 2)
return primes;
primes.Add(2);
if (max < 3)
return primes;
primes.Add(3);
if (max < 5)
return primes;
primes.Add(5);
if (max < 7)
return primes;
var iCoefIndex = 7;
for (var i = 7; i <= max; i += Coefs[iCoefIndex]) {
if (isPrimes[i])
primes.Add(i);
iCoefIndex = iCoefIndex == 7 ? 0 : iCoefIndex + 1;
}
return primes;
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Program {
public static readonly int[] Coefs = { 4, 2, 4, 2, 4, 6, 2, 6 };
private static void Main() {
var x = int.Parse(Console.ReadLine());
var primes = Sieve(100003);
var answer = primes.First(prime => prime >= x);
var writer =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(writer);
Console.WriteLine(answer);
Console.Out.Flush();
}
public static List<int> Sieve(int max) {
var isPrimes = Enumerable.Repeat(true, max + 1).ToArray();
for (var i2 = 4; i2 <= max; i2 += 2)
isPrimes[i2] = false;
for (var i3 = 9; i3 <= max; i3 += 6)
isPrimes[i3] = false;
for (int i5 = 25, x = 4; i5 <= max; i5 += 5 * (x = 6 - x))
isPrimes[i5] = false;
var iCoefIndex = 7;
for (var i = 7; i * i <= max; i += Coefs[iCoefIndex]) {
if (!isPrimes[i]) {
iCoefIndex = iCoefIndex == 7 ? 0 : iCoefIndex + 1;
continue;
}
var jCoefIndex = iCoefIndex;
for (var j = i * i; j <= max; j += i * Coefs[jCoefIndex]) {
isPrimes[j] = false;
jCoefIndex = jCoefIndex == 7 ? 0 : jCoefIndex + 1;
}
iCoefIndex = iCoefIndex == 7 ? 0 : iCoefIndex + 1;
}
return Primes(max, isPrimes);
}
public static List<int> Primes(int max, bool[] isPrimes) {
var primes = new List<int>();
if (max < 2)
return primes;
primes.Add(2);
if (max < 3)
return primes;
primes.Add(3);
if (max < 5)
return primes;
primes.Add(5);
if (max < 7)
return primes;
var iCoefIndex = 7;
for (var i = 7; i <= max; i += Coefs[iCoefIndex]) {
if (isPrimes[i])
primes.Add(i);
iCoefIndex = iCoefIndex == 7 ? 0 : iCoefIndex + 1;
}
return primes;
}
}
|
[["-", 0, 16, 31, 16, 31, 16, 31, 16, 31, 203], ["-", 0, 16, 31, 16, 31, 16, 31, 16, 17, 48], ["-", 0, 16, 31, 16, 31, 16, 31, 16, 12, 203], ["-", 0, 28, 0, 16, 31, 16, 31, 16, 17, 48], ["-", 0, 28, 0, 16, 31, 16, 31, 16, 12, 203], ["-", 3, 4, 0, 28, 0, 16, 31, 16, 17, 48], ["-", 3, 4, 0, 28, 0, 16, 31, 16, 12, 203], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 48], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 0, 212, 0, 213, 3, 4, 0, 28, 0, 203]]
| 8
| 510
| 10
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace AtCoderCs {
class Program {
static void Main() {
var Num = int.Parse(Console.ReadLine());
var End = (int)Math.Sqrt(Num) + 2;
var Continue = true;
if (Num == 2)
Console.WriteLine(2);
else if (Num % 2 == 0)
Num++;
for (; Continue; Num += 2) {
for (int i = 3; i < End; i += 2) {
if (Num % i == 0) {
Continue = false;
break;
}
}
Continue = !Continue;
if (Continue) {
Num += 2;
if (End * End < Num)
End++;
}
}
Console.WriteLine(Num);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace AtCoderCs {
class Program {
static void Main() {
var Num = int.Parse(Console.ReadLine());
var End = (int)Math.Sqrt(Num) + 2;
var Continue = true;
if (Num == 2)
Console.WriteLine(2);
else if (Num % 2 == 0)
Num++;
if (Num != 2) {
while (Continue) {
for (int i = 3; i < End; i += 2) {
if (Num % i == 0) {
Continue = false;
break;
}
}
Continue = !Continue;
if (Continue) {
Num += 2;
if (End * End < Num)
End++;
}
}
Console.WriteLine(Num);
}
}
}
}
|
[["-", 8, 201, 0, 195, 8, 196, 0, 7, 0, 88], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["-", 8, 201, 0, 195, 8, 196, 0, 7, 0, 35], ["-", 8, 201, 0, 195, 8, 196, 0, 7, 15, 22], ["-", 8, 196, 0, 7, 26, 11, 0, 202, 0, 107], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 79], ["+", 8, 196, 0, 57, 64, 196, 0, 52, 0, 89], ["+", 8, 196, 0, 57, 64, 196, 0, 52, 0, 24], ["+", 8, 196, 0, 57, 64, 196, 0, 52, 15, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 52, 0, 25], ["+", 0, 57, 64, 196, 0, 52, 8, 196, 0, 45], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 166
| 13
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace AtCoder {
static class Program {
static void Main() {
//ใใใใ
var X = IO.ReadLineToInt();
int[] num = new int[X - 2];
int ans = 0;
for (int i = 0; i < X - 2; i++) {
num[i] = X % (i + 2);
}
if (num.All(n => n != 0)) {
ans = X;
} else {
for (int i = 0; i < X - 2; i++) {
num[i] = i + 2 - num[i];
}
num = num.OrderBy(n => n).ToArray();
for (int i = 0; i < num.Length - 1; i++) {
if (num[i + 1] - num[i] > 1) {
ans = X + num[i] + 1;
break;
}
}
}
//ใใใพใง
Console.WriteLine(ans);
Console.ReadKey();
}
}
static class Func {
static public long mod = 1000000007;
static public void Swap<T>(ref T a, ref T b) {
T temp = a;
a = b;
b = temp;
}
static public long GCD(long a, long b) { return b != 0 ? GCD(b, a % b) : a; }
static public long LCM(long a, long b) { return (long)a * b / GCD(a, b); }
static public long Factorial(long a) {
return a == 1 ? a : a * Factorial(a - 1);
}
public static double ToAngle(this double radian) {
return (double)(radian * 180 / Math.PI);
}
public static double ToRadian(this double angle) {
return (double)(angle * Math.PI / 180);
}
static public long Conbination(long n, long m) {
if (m == 0)
return 1;
if (n == 0)
return 0;
return n * Conbination(n - 1, m - 1) / m;
}
static public void Factoring(long num, ref long[] vs) {
if (num == 1) {
vs[1]++;
}
for (long i = 2; i < Math.Sqrt(num); i++) {
if (num % i == 0) {
vs[i]++;
Factoring(num / i, ref vs);
}
}
vs[1]++;
}
}
static class IO {
static public string ReadLineToString() { return Console.ReadLine(); }
static public int ReadLineToInt() { return int.Parse(Console.ReadLine()); }
static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
static public List<string> ReadLineToStringList() {
return Console.ReadLine().Split(' ').ToList();
}
static public List<int> ReadLineToIntList() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToList();
}
static public List<long> ReadLineToLongList() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToList();
}
static public List<double> ReadLineToDoubleList() {
return Console.ReadLine().Split(' ').Select(double.Parse).ToList();
}
static public void WriteStrings(object[] strings) {
foreach (var o in strings) {
Console.Write(o + " ");
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace AtCoder {
static class Program {
static void Main() {
//ใใใใ
var X = IO.ReadLineToInt();
List<int> num = new List<int>();
int ans = 0;
for (int i = 0; i < X - 2; i++) {
num.Add(X % (i + 2));
}
if (num.All(n => n != 0)) {
ans = X;
} else {
for (int i = 0; i < X - 2; i++) {
num[i] = i + 2 - num[i];
}
num.Add(0);
num = num.OrderBy(n => n).Distinct().ToList();
for (int i = 0; i < num.Count - 1; i++) {
if (num[i + 1] - num[i] > 1) {
ans = X + num[i] + 1;
break;
}
}
}
//ใใใพใง
Console.WriteLine(ans);
Console.ReadKey();
}
}
static class Func {
static public long mod = 1000000007;
static public void Swap<T>(ref T a, ref T b) {
T temp = a;
a = b;
b = temp;
}
static public long GCD(long a, long b) { return b != 0 ? GCD(b, a % b) : a; }
static public long LCM(long a, long b) { return (long)a * b / GCD(a, b); }
static public long Factorial(long a) {
return a == 1 ? a : a * Factorial(a - 1);
}
public static double ToAngle(this double radian) {
return (double)(radian * 180 / Math.PI);
}
public static double ToRadian(this double angle) {
return (double)(angle * Math.PI / 180);
}
static public long Conbination(long n, long m) {
if (m == 0)
return 1;
if (n == 0)
return 0;
return n * Conbination(n - 1, m - 1) / m;
}
static public void Factoring(long num, ref long[] vs) {
if (num == 1) {
vs[1]++;
}
for (long i = 2; i < Math.Sqrt(num); i++) {
if (num % i == 0) {
vs[i]++;
Factoring(num / i, ref vs);
}
}
vs[1]++;
}
}
static class IO {
static public string ReadLineToString() { return Console.ReadLine(); }
static public int ReadLineToInt() { return int.Parse(Console.ReadLine()); }
static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
static public List<string> ReadLineToStringList() {
return Console.ReadLine().Split(' ').ToList();
}
static public List<int> ReadLineToIntList() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToList();
}
static public List<long> ReadLineToLongList() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToList();
}
static public List<double> ReadLineToDoubleList() {
return Console.ReadLine().Split(' ').Select(double.Parse).ToList();
}
static public void WriteStrings(object[] strings) {
foreach (var o in strings) {
Console.Write(o + " ");
}
}
}
}
|
[["+", 8, 196, 0, 197, 0, 198, 39, 236, 141, 22], ["+", 0, 197, 0, 198, 39, 236, 237, 238, 0, 18], ["-", 0, 197, 0, 198, 39, 224, 225, 226, 0, 70], ["-", 0, 197, 0, 198, 39, 224, 225, 226, 0, 73], ["+", 0, 197, 0, 198, 39, 236, 237, 238, 0, 47], ["+", 0, 200, 0, 212, 0, 230, 39, 236, 141, 22], ["+", 0, 212, 0, 230, 39, 236, 237, 238, 0, 18], ["-", 0, 212, 0, 227, 39, 224, 225, 226, 0, 70], ["-", 0, 227, 39, 224, 225, 226, 0, 16, 31, 22], ["-", 0, 227, 39, 224, 225, 226, 0, 16, 17, 33], ["-", 0, 227, 39, 224, 225, 226, 0, 16, 12, 203], ["-", 0, 212, 0, 227, 39, 224, 225, 226, 0, 73], ["+", 0, 212, 0, 230, 39, 236, 237, 238, 0, 47], ["+", 0, 200, 0, 212, 0, 230, 3, 4, 0, 24], ["+", 0, 200, 0, 212, 0, 230, 3, 4, 0, 25], ["-", 0, 1, 0, 11, 31, 204, 206, 207, 0, 70], ["-", 0, 11, 31, 204, 206, 207, 0, 28, 0, 22], ["-", 0, 1, 0, 11, 31, 204, 206, 207, 0, 73], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 12, 23, 0, 25], ["+", 75, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 75, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 75, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 75, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 75, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["-", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 12, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 12, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["+", 12, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["-", 0, 7, 15, 16, 12, 16, 31, 214, 141, 22], ["+", 0, 7, 15, 16, 12, 16, 31, 214, 141, 22]]
| 8
| 776
| 38
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static List<int> list = new List<int>();
static void Main(string[] args) {
int x;
Input(out x);
list.Add(2);
int i = 3;
while (true) {
if (IsPrime(i)) {
if (i > x) {
Console.WriteLine(i);
return;
} else {
list.Add(i);
}
}
i++;
}
}
static bool IsPrime(int n) {
foreach (var p in list) {
if (n % p == 0) {
return false;
}
}
return true;
}
static T ChangeT<T>(string s) => (T)Convert.ChangeType(s, typeof(T));
static void Input<A>(out A a) {
var words = Console.ReadLine().Split(
new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
a = ChangeT<A>(words[0]);
}
static void Input<A, B>(out A a, out B b) {
var words = Console.ReadLine().Split(
new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
a = ChangeT<A>(words[0]);
b = ChangeT<B>(words[1]);
}
static void Input<A, B, C>(out A a, out B b, out C c) {
var words = Console.ReadLine().Split(
new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
a = ChangeT<A>(words[0]);
b = ChangeT<B>(words[1]);
c = ChangeT<C>(words[2]);
}
static void Input<A, B, C, D>(out A a, out B b, out C c, out D d) {
var words = Console.ReadLine().Split(
new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
a = ChangeT<A>(words[0]);
b = ChangeT<B>(words[1]);
c = ChangeT<C>(words[2]);
d = ChangeT<D>(words[3]);
}
static void Input<A, B, C, D, E>(out A a, out B b, out C c, out D d,
out E e) {
var words = Console.ReadLine().Split(
new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
a = ChangeT<A>(words[0]);
b = ChangeT<B>(words[1]);
c = ChangeT<C>(words[2]);
d = ChangeT<D>(words[3]);
e = ChangeT<E>(words[4]);
}
static void Input<A, B, C, D, E, F>(out A a, out B b, out C c, out D d,
out E e, out F f) {
var words = Console.ReadLine().Split(
new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
a = ChangeT<A>(words[0]);
b = ChangeT<B>(words[1]);
c = ChangeT<C>(words[2]);
d = ChangeT<D>(words[3]);
e = ChangeT<E>(words[4]);
f = ChangeT<F>(words[5]);
}
static void InputArray<T>(out T[] array) {
array = Console.ReadLine()
.Split(new[] { ' ' },
options: StringSplitOptions.RemoveEmptyEntries)
.Select(s => ChangeT<T>(s))
.ToArray();
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static List<int> list = new List<int>();
static void Main(string[] args) {
int x;
Input(out x);
list.Add(2);
if (x < 3) {
Console.WriteLine(2);
return;
}
int i = 3;
while (true) {
if (IsPrime(i)) {
if (i >= x) {
Console.WriteLine(i);
return;
} else {
list.Add(i);
}
}
i++;
}
}
static bool IsPrime(int n) {
foreach (var p in list) {
if (n % p == 0) {
return false;
}
}
return true;
}
static T ChangeT<T>(string s) => (T)Convert.ChangeType(s, typeof(T));
static void Input<A>(out A a) {
var words = Console.ReadLine().Split(
new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
a = ChangeT<A>(words[0]);
}
static void Input<A, B>(out A a, out B b) {
var words = Console.ReadLine().Split(
new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
a = ChangeT<A>(words[0]);
b = ChangeT<B>(words[1]);
}
static void Input<A, B, C>(out A a, out B b, out C c) {
var words = Console.ReadLine().Split(
new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
a = ChangeT<A>(words[0]);
b = ChangeT<B>(words[1]);
c = ChangeT<C>(words[2]);
}
static void Input<A, B, C, D>(out A a, out B b, out C c, out D d) {
var words = Console.ReadLine().Split(
new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
a = ChangeT<A>(words[0]);
b = ChangeT<B>(words[1]);
c = ChangeT<C>(words[2]);
d = ChangeT<D>(words[3]);
}
static void Input<A, B, C, D, E>(out A a, out B b, out C c, out D d,
out E e) {
var words = Console.ReadLine().Split(
new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
a = ChangeT<A>(words[0]);
b = ChangeT<B>(words[1]);
c = ChangeT<C>(words[2]);
d = ChangeT<D>(words[3]);
e = ChangeT<E>(words[4]);
}
static void Input<A, B, C, D, E, F>(out A a, out B b, out C c, out D d,
out E e, out F f) {
var words = Console.ReadLine().Split(
new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
a = ChangeT<A>(words[0]);
b = ChangeT<B>(words[1]);
c = ChangeT<C>(words[2]);
d = ChangeT<D>(words[3]);
e = ChangeT<E>(words[4]);
f = ChangeT<F>(words[5]);
}
static void InputArray<T>(out T[] array) {
array = Console.ReadLine()
.Split(new[] { ' ' },
options: StringSplitOptions.RemoveEmptyEntries)
.Select(s => ChangeT<T>(s))
.ToArray();
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 0, 57, 64, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 20]]
| 8
| 832
| 19
|
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atcoder {
public class Program {
static void Main(string[] args) {
var r1 = ReadSplit();
var n = r1[0].ToInt();
var k = r1[1].ToInt();
var r2 = ReadSplit();
var r = r2[0].ToInt();
var s = r2[1].ToInt();
var p = r2[2].ToInt();
var t = Read();
var l = new string[n];
var win = new List<string>();
for (int i = 0; i < n; i++) {
var pre = string.Empty;
var cur = string.Empty;
var fut = string.Empty;
if (i - k >= 0) {
pre = l[i - k];
}
if (i + k < n) {
fut = l[i + k];
}
cur = t[i].ToString();
var getWinHand = new Func<string, string>(x => {
if (x == "r") {
return "p";
} else if (x == "s") {
return "r";
} else {
return "s";
}
});
var getEvenHand = new Func<string, string>(x => {
if (x == "r") {
return "r";
} else if (x == "s") {
return "s";
} else {
return "p";
}
});
var getLoseHand = new Func<string, string>(x => {
if (x == "r") {
return "s";
} else if (x == "s") {
return "p";
} else {
return "r";
}
});
var tmp = string.Empty;
if (pre == getWinHand(cur)) {
var even = getEvenHand(cur);
var lose = getLoseHand(cur);
if (even == getWinHand(fut)) {
tmp = even;
}
if (lose == getWinHand(fut)) {
tmp = lose;
}
} else {
tmp = getWinHand(cur);
}
if (getWinHand(cur) == tmp)
win.Add(tmp);
l[i] = tmp;
}
var ans = 0;
foreach (var hand in win) {
if (hand == "r") {
ans += r;
} else if (hand == "s") {
ans += s;
} else {
ans += p;
}
}
WriteRead(ans);
}
public static string Read() { return Console.ReadLine(); }
public static string[] ReadSplit() { return Console.ReadLine().Split(' '); }
public static void WriteRead(object str) {
Console.WriteLine(str);
Read();
}
public static void Write(object str) { Console.WriteLine(str); }
}
}
public static class Extentions {
public static int ToInt(this object obj) { return int.Parse(obj.ToString()); }
public static decimal ToDecimal(this object obj) {
return decimal.Parse(obj.ToString());
}
public static double ToDouble(this object obj) {
return double.Parse(obj.ToString());
}
public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key)
where T2 : struct {
T2 value;
if (d.TryGetValue(key, out value)) {
return value;
}
return new T2();
}
}
|
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atcoder {
public class Program {
static void Main(string[] args) {
var r1 = ReadSplit();
var n = r1[0].ToInt();
var k = r1[1].ToInt();
var r2 = ReadSplit();
var r = r2[0].ToInt();
var s = r2[1].ToInt();
var p = r2[2].ToInt();
var t = Read();
var l = new string[n];
var win = new List<string>();
for (int i = 0; i < n; i++) {
var pre = string.Empty;
var cur = string.Empty;
var fut = string.Empty;
if (i - k >= 0) {
pre = l[i - k];
}
if (i + k < n) {
fut = t[i + k].ToString();
}
cur = t[i].ToString();
var getWinHand = new Func<string, string>(x => {
if (x == "r") {
return "p";
} else if (x == "s") {
return "r";
} else {
return "s";
}
});
var getEvenHand = new Func<string, string>(x => {
if (x == "r") {
return "r";
} else if (x == "s") {
return "s";
} else {
return "p";
}
});
var getLoseHand = new Func<string, string>(x => {
if (x == "r") {
return "s";
} else if (x == "s") {
return "p";
} else {
return "r";
}
});
var tmp = string.Empty;
if (pre == getWinHand(cur)) {
var even = getEvenHand(cur);
var lose = getLoseHand(cur);
if (even == getWinHand(fut)) {
tmp = lose;
}
if (lose == getWinHand(fut)) {
tmp = even;
}
} else {
tmp = getWinHand(cur);
win.Add(tmp);
}
l[i] = tmp;
}
var ans = 0;
foreach (var hand in win) {
if (hand == "r") {
ans += r;
} else if (hand == "s") {
ans += s;
} else {
ans += p;
}
}
WriteRead(ans);
}
public static string Read() { return Console.ReadLine(); }
public static string[] ReadSplit() { return Console.ReadLine().Split(' '); }
public static void WriteRead(object str) {
Console.WriteLine(str);
Read();
}
public static void Write(object str) { Console.WriteLine(str); }
}
}
public static class Extentions {
public static int ToInt(this object obj) { return int.Parse(obj.ToString()); }
public static decimal ToDecimal(this object obj) {
return decimal.Parse(obj.ToString());
}
public static double ToDouble(this object obj) {
return double.Parse(obj.ToString());
}
public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key)
where T2 : struct {
T2 value;
if (d.TryGetValue(key, out value)) {
return value;
}
return new T2();
}
}
|
[["-", 64, 196, 0, 1, 0, 11, 12, 204, 205, 22], ["+", 0, 11, 12, 213, 63, 214, 205, 204, 205, 22], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["-", 0, 7, 8, 196, 0, 57, 75, 196, 0, 46], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["-", 8, 196, 0, 57, 15, 16, 31, 213, 63, 22], ["-", 0, 57, 15, 16, 31, 213, 3, 4, 0, 24], ["-", 15, 16, 31, 213, 3, 4, 0, 28, 0, 22], ["-", 0, 57, 15, 16, 31, 213, 3, 4, 0, 25], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 765
| 21
|
using System;
public class AtCoderD {
static void Main() {
int n;
int k;
{
var line = Console.ReadLine();
var words = line.Split(' ');
n = int.Parse(words[0]);
k = int.Parse(words[1]);
}
int r;
int s;
int p;
{
var line = Console.ReadLine();
var words = line.Split(' ');
r = int.Parse(words[0]);
s = int.Parse(words[1]);
p = int.Parse(words[2]);
}
string[] hands = new string[n];
{
var line = Console.ReadLine();
for (int i = 0; i < n; i++) {
hands[i] = line.Substring(i, 1);
}
}
int score = 0;
for (int i = 0; i < n; i++) {
if (i >= k) {
if (hands[i].Equals(hands[i - k])) {
continue;
}
if ("r".Equals(hands[i])) {
score += p;
}
if ("s".Equals(hands[i])) {
score += r;
}
if ("p".Equals(hands[i])) {
score += s;
}
}
}
Console.WriteLine(score);
}
}
|
using System;
public class AtCoderD {
static void Main() {
int n;
int k;
{
var line = Console.ReadLine();
var words = line.Split(' ');
n = int.Parse(words[0]);
k = int.Parse(words[1]);
}
int r;
int s;
int p;
{
var line = Console.ReadLine();
var words = line.Split(' ');
r = int.Parse(words[0]);
s = int.Parse(words[1]);
p = int.Parse(words[2]);
}
string[] hands = new string[n];
{
var line = Console.ReadLine();
for (int i = 0; i < n; i++) {
hands[i] = line.Substring(i, 1);
}
}
int score = 0;
bool[] wins = new bool[n];
for (int i = 0; i < n; i++) {
if (i >= k) {
if (hands[i].Equals(hands[i - k]) && wins[i - k]) {
continue;
}
}
if ("r".Equals(hands[i])) {
score += p;
}
if ("s".Equals(hands[i])) {
score += r;
}
if ("p".Equals(hands[i])) {
score += s;
}
wins[i] = true;
}
Console.WriteLine(score);
}
}
|
[["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 0, 197, 0, 198, 39, 224, 225, 226, 0, 70], ["+", 0, 197, 0, 198, 39, 224, 225, 226, 0, 73], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 227, 0, 228], ["+", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["+", 0, 212, 0, 227, 39, 224, 225, 226, 0, 70], ["+", 0, 212, 0, 227, 39, 224, 225, 226, 0, 22], ["+", 0, 212, 0, 227, 39, 224, 225, 226, 0, 73], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 98], ["+", 64, 196, 0, 57, 15, 16, 12, 204, 205, 22], ["+", 0, 57, 15, 16, 12, 204, 206, 207, 0, 70], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 12, 22], ["+", 0, 57, 15, 16, 12, 204, 206, 207, 0, 73], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46], ["-", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 1, 0, 11, 31, 204, 205, 22], ["+", 0, 1, 0, 11, 31, 204, 206, 207, 0, 70], ["+", 0, 11, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 1, 0, 11, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 1, 0, 11, 12, 211, 0, 146], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35]]
| 8
| 305
| 27
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace AtCoder {
struct mint : IEquatable<mint> {
// static uint mod = 998244353;
static uint mod = 1000000007;
uint _v;
public mint(long v) : this((uint)(v % mod + mod)) {}
private mint(uint v) { _v = v < mod ? v : (v - mod); }
public static void SetMod(uint p) { mod = p; }
public static mint operator +(mint lhs, mint rhs) {
return new mint(lhs._v + rhs._v);
}
public static mint operator -(mint lhs, mint rhs) {
return new mint(lhs._v + mod - rhs._v);
}
public static mint operator *(mint lhs, mint rhs) {
return new mint((uint)((ulong)lhs._v * rhs._v % mod));
}
public static mint operator /(mint lhs, mint rhs) { return lhs * rhs.Inv(); }
public static mint operator ^(mint x, int n) { return Pow(x, n); }
public static bool operator ==(mint l, mint r) { return l._v == r._v; }
public static bool operator !=(mint l, mint r) { return !(l == r); }
public static bool operator<(mint l, mint r) { return l._v < r._v; }
public static bool operator>(mint l, mint r) { return l._v > r._v; }
public static mint Pow(mint x, int n) {
var r = new mint(1);
while (n > 0) {
if ((n & 1) > 0)
r *= x;
x *= x;
n >>= 1;
}
return r;
}
public mint Pow(int n) { return Pow(this, n); }
public mint Inv() { return Pow((int)mod - 2); }
public bool Equals(mint o) { return this == o; }
public override bool Equals(object obj) {
if (obj is mint)
return this == (mint)obj;
else
return false;
}
public override int GetHashCode() { return _v.GetHashCode(); }
public override string ToString() { return _v.ToString(); }
public static implicit operator mint(int i) { return new mint(i); }
public static implicit operator mint(long i) { return new mint(i); }
private static mint[] _fact;
public static void SetFact(int n) {
_fact = new mint[n + 1];
_fact[0] = 1;
for (int i = 1; i < n + 1; i++) {
_fact[i] = _fact[i - 1] * i;
}
}
public static mint Fact(int n) {
if (_fact == null || _fact.Length < n) {
SetFact(n * 2);
}
return _fact[n];
}
public static mint Combination(int n, int r) {
return Fact(n) / (Fact(n - r) * Fact(r));
}
}
static class Extensions {
public static int LowerBound<T>(this IList<T> list, T value,
IComparer<T> comp = null) {
if (comp == null)
comp = Comparer<T>.Default;
var l = 0;
var r = list.Count;
while (l < r) {
var m = (l + r) / 2;
var c = comp.Compare(value, list[m]);
if (c > 0)
l = m + 1;
else
r = m;
}
return l;
}
public static int UpperBound<T>(this IList<T> list, T value,
IComparer<T> comp = null) {
if (comp == null)
comp = Comparer<T>.Default;
var l = 0;
var r = list.Count;
while (l < r) {
var m = (l + r) / 2;
var c = comp.Compare(value, list[m]);
if (c >= 0)
l = m + 1;
else
r = m;
}
return r;
}
}
class Program {
static int ReadInt() { return int.Parse(Console.ReadLine()); }
static long ReadLong() { return long.Parse(Console.ReadLine()); }
static int[] ReadIntArray() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
static int[] ReadIntArray(int n) {
var a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = ReadInt();
}
return a;
}
static long[] ReadLongArray() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
}
static long[] ReadLongArray(int n) {
var a = new long[n];
for (int i = 0; i < n; i++) {
a[i] = ReadLong();
}
return a;
}
static List<T> ReadObjects<T>(int n, Func<int[], T> creator) {
var l = new List<T>(n);
for (int i = 0; i < n; i++) {
var a = ReadIntArray();
l.Add(creator(a));
}
return l;
}
static int[,] ReadMatrix(int n, int m) {
var r = new int[n, m];
for (int i = 0; i < n; i++) {
var a = ReadIntArray();
for (int j = 0; j < m; j++) {
r[i, j] = a[j];
}
}
return r;
}
public static int[] ZAlgotithm(string s) {
var len = s.Length;
var a = new int[len];
a[0] = len;
var i = 1;
var j = 0;
while (i < len) {
while (i + j < len && s[j] == s[i + j])
j++;
a[i] = j;
if (j == 0) {
i++;
continue;
}
var k = 1;
while (i + k < len && k + a[k] < j) {
a[i + k] = a[k];
k++;
}
i += k;
j -= k;
}
return a;
}
public class MaxHeap<T> : IEnumerable<T> {
private List<T> _list;
private Comparer<T> _comp;
public int Count {
get { return _list.Count; }
}
public MaxHeap() : this(0) {}
public MaxHeap(int capacity, Comparison<T> comp = null) {
_list = new List<T>(capacity);
if (comp == null) {
_comp = Comparer<T>.Default;
} else {
_comp = Comparer<T>.Create(comp);
}
}
public void Push(T elem) { Upheap(elem); }
public T Pop() { return Downheap(); }
public T Peek() { return _list[0]; }
private void Swap(int i, int j) {
var a = _list[j];
_list[j] = _list[i];
_list[i] = a;
}
private void Upheap(T elem) {
_list.Add(elem);
var i = _list.Count - 1;
while (true) {
if (i == 0)
return;
var j = (i - 1) / 2;
var e = _list[i];
var p = _list[j];
var c = _comp.Compare(e, p);
if (c > 0) {
Swap(i, j);
i = j;
continue;
} else {
break;
}
}
}
private T Downheap() {
var result = _list[0];
var last = _list.Count - 1;
Swap(0, last);
_list.RemoveAt(last);
if (_list.Count == 0)
return result;
var i = 0;
while (true) {
if (i == _list.Count - 1)
return result;
var p = _list[i];
var j = i * 2 + 1;
if (j >= _list.Count)
return result;
if (j + 1 < _list.Count && _comp.Compare(_list[j], _list[j + 1]) < 0) {
j++;
}
if (_comp.Compare(_list[i], _list[j]) < 0) {
Swap(i, j);
i = j;
} else {
return result;
}
}
}
public MaxHeap<T> Copy(Comparison<T> comp = null) {
var c = new MaxHeap<T>(0, comp);
c._list = _list.ToList();
return c;
}
public MaxHeap(List<T> list) {
_list = list;
_comp = Comparer<T>.Default;
}
public List<T> GetList() { return _list; }
public IEnumerator<T> GetEnumerator() { return _list.GetEnumerator(); }
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
}
public class MinHeap<T> : IEnumerable<T> {
private List<T> _list;
private Comparer<T> _comp;
public int Count {
get { return _list.Count; }
}
public MinHeap() : this(0) {}
public MinHeap(int capacity, Comparison<T> comp = null) {
_list = new List<T>(capacity);
if (comp == null) {
_comp = Comparer<T>.Default;
} else {
_comp = Comparer<T>.Create(comp);
}
}
public void Push(T elem) { Upheap(elem); }
public T Pop() { return Downheap(); }
public T Peek() { return _list[0]; }
private void Swap(int i, int j) {
var a = _list[j];
_list[j] = _list[i];
_list[i] = a;
}
private void Upheap(T elem) {
_list.Add(elem);
var i = _list.Count - 1;
while (true) {
if (i == 0)
return;
var j = (i - 1) / 2;
var e = _list[i];
var p = _list[j];
var c = _comp.Compare(e, p);
if (c < 0) {
Swap(i, j);
i = j;
continue;
} else {
break;
}
}
}
private T Downheap() {
var result = _list[0];
var last = _list.Count - 1;
Swap(0, last);
_list.RemoveAt(last);
if (_list.Count == 0)
return result;
var i = 0;
while (true) {
if (i == _list.Count - 1)
return result;
var p = _list[i];
var j = i * 2 + 1;
if (j >= _list.Count)
return result;
if (j + 1 < _list.Count && _comp.Compare(_list[j], _list[j + 1]) > 0) {
j++;
}
if (_comp.Compare(_list[i], _list[j]) > 0) {
Swap(i, j);
i = j;
} else {
return result;
}
}
}
public MinHeap<T> Copy(Comparison<T> comp = null) {
var c = new MinHeap<T>(0, comp);
c._list = _list.ToList();
return c;
}
public MinHeap(List<T> list) {
_list = list;
_comp = Comparer<T>.Default;
}
public List<T> GetList() { return _list; }
public IEnumerator<T> GetEnumerator() { return _list.GetEnumerator(); }
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
}
class InputLine {
private string[] _inputs;
private int _index = 0;
InputLine(string input) {
_inputs = input.Split();
_index = 0;
}
public static InputLine Read() { return new InputLine(Console.ReadLine()); }
public int NextInt() { return int.Parse(_inputs[_index++]); }
public long NextLong() { return long.Parse(_inputs[_index++]); }
public double NextDouble() { return double.Parse(_inputs[_index++]); }
}
public static int GCD(int x, int y) {
var a = Math.Max(x, y);
var b = x + y - a;
while (b != 0) {
var c = b;
b = a % b;
a = c;
}
return a;
}
public static long GCD(long x, long y) {
var a = Math.Max(x, y);
var b = x + y - a;
while (b != 0) {
var c = b;
b = a % b;
a = c;
}
return a;
}
static long ModPower(long x, long y, long mod) {
var bytes = BitConverter.GetBytes(y);
var bits = new System.Collections.BitArray(bytes);
var max2 = 0;
for (int i = bits.Length - 1; i >= 0; i--) {
if (bits[i]) {
max2 = i;
break;
}
}
long result = 1;
for (int i = max2; i >= 0; i--) {
result = (result * result) % mod;
if (bits[i]) {
result = (result * x) % mod;
}
}
return result;
}
static long ModFact(long n, long mod) {
long result = 1;
for (int i = 1; i <= n; i++) {
result = result * i % mod;
}
return result;
}
static long ModAdd(long x, long y, long mod) {
return ((x % mod) + (y % mod)) % mod;
}
static long ModMul(long x, long y, long mod) {
return ((x % mod) * (y % mod)) % mod;
}
static long ModDiv(long x, long y, long mod) {
//ใใงใซใใผใฎๅฐๅฎ็ใใใa^(-1) = a^(p-2)
return ModMul(x, ModPower(y, mod - 2, mod), mod);
}
static long ModComb(long n, long r, long mod) {
long numerator = 1;
for (int i = 0; i < r; i++) {
numerator = ModMul(numerator, n - i, mod);
}
long denominator = ModFact(r, mod);
return ModDiv(numerator, denominator, mod);
}
class Graph {
private int _size;
private List<int>[] _edges;
public Graph(int size) {
_size = size;
_edges = new List<int>[size];
}
public List<int> this[int i] {
get {
if (_edges[i] == null)
_edges[i] = new List<int>();
return _edges[i];
}
}
}
class Graph<T> {
private int _size;
private List<T>[] _edges;
public Graph(int size) {
_size = size;
_edges = new List<T>[size];
}
public List<T> this[int i] {
get {
if (_edges[i] == null)
_edges[i] = new List<T>();
return _edges[i];
}
}
}
static Graph<T> NewGraph<T>(int size, T template) {
return new Graph<T>(size);
}
static List<T> NewList<T>(T template) { return new List<T>(); }
static T[] NewArray<T>(int size, T template) { return new T[size]; }
static long p1097 = 1000000007;
static void Main(string[] args) {
//โ
var nk = ReadIntArray();
var n = nk[0];
var k = nk[1];
var rsp = ReadIntArray();
var r = rsp[0];
var s = rsp[1];
var p = rsp[2];
var t = Console.ReadLine();
var sum = 0;
var prev = new char[k];
for (int i = 0; i < n; i++) {
var c = t[i];
var mod = i % k;
if (i >= k && prev[mod] == c) {
prev[mod] = 'x';
continue;
}
if (prev[mod] == c)
switch (c) {
case 's':
sum += r;
break;
case 'p':
sum += s;
break;
case 'r':
sum += p;
break;
default:
break;
}
prev[mod] = c;
}
Console.WriteLine(sum);
//โ
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace AtCoder {
struct mint : IEquatable<mint> {
// static uint mod = 998244353;
static uint mod = 1000000007;
uint _v;
public mint(long v) : this((uint)(v % mod + mod)) {}
private mint(uint v) { _v = v < mod ? v : (v - mod); }
public static void SetMod(uint p) { mod = p; }
public static mint operator +(mint lhs, mint rhs) {
return new mint(lhs._v + rhs._v);
}
public static mint operator -(mint lhs, mint rhs) {
return new mint(lhs._v + mod - rhs._v);
}
public static mint operator *(mint lhs, mint rhs) {
return new mint((uint)((ulong)lhs._v * rhs._v % mod));
}
public static mint operator /(mint lhs, mint rhs) { return lhs * rhs.Inv(); }
public static mint operator ^(mint x, int n) { return Pow(x, n); }
public static bool operator ==(mint l, mint r) { return l._v == r._v; }
public static bool operator !=(mint l, mint r) { return !(l == r); }
public static bool operator<(mint l, mint r) { return l._v < r._v; }
public static bool operator>(mint l, mint r) { return l._v > r._v; }
public static mint Pow(mint x, int n) {
var r = new mint(1);
while (n > 0) {
if ((n & 1) > 0)
r *= x;
x *= x;
n >>= 1;
}
return r;
}
public mint Pow(int n) { return Pow(this, n); }
public mint Inv() { return Pow((int)mod - 2); }
public bool Equals(mint o) { return this == o; }
public override bool Equals(object obj) {
if (obj is mint)
return this == (mint)obj;
else
return false;
}
public override int GetHashCode() { return _v.GetHashCode(); }
public override string ToString() { return _v.ToString(); }
public static implicit operator mint(int i) { return new mint(i); }
public static implicit operator mint(long i) { return new mint(i); }
private static mint[] _fact;
public static void SetFact(int n) {
_fact = new mint[n + 1];
_fact[0] = 1;
for (int i = 1; i < n + 1; i++) {
_fact[i] = _fact[i - 1] * i;
}
}
public static mint Fact(int n) {
if (_fact == null || _fact.Length < n) {
SetFact(n * 2);
}
return _fact[n];
}
public static mint Combination(int n, int r) {
return Fact(n) / (Fact(n - r) * Fact(r));
}
}
static class Extensions {
public static int LowerBound<T>(this IList<T> list, T value,
IComparer<T> comp = null) {
if (comp == null)
comp = Comparer<T>.Default;
var l = 0;
var r = list.Count;
while (l < r) {
var m = (l + r) / 2;
var c = comp.Compare(value, list[m]);
if (c > 0)
l = m + 1;
else
r = m;
}
return l;
}
public static int UpperBound<T>(this IList<T> list, T value,
IComparer<T> comp = null) {
if (comp == null)
comp = Comparer<T>.Default;
var l = 0;
var r = list.Count;
while (l < r) {
var m = (l + r) / 2;
var c = comp.Compare(value, list[m]);
if (c >= 0)
l = m + 1;
else
r = m;
}
return r;
}
}
class Program {
static int ReadInt() { return int.Parse(Console.ReadLine()); }
static long ReadLong() { return long.Parse(Console.ReadLine()); }
static int[] ReadIntArray() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
static int[] ReadIntArray(int n) {
var a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = ReadInt();
}
return a;
}
static long[] ReadLongArray() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
}
static long[] ReadLongArray(int n) {
var a = new long[n];
for (int i = 0; i < n; i++) {
a[i] = ReadLong();
}
return a;
}
static List<T> ReadObjects<T>(int n, Func<int[], T> creator) {
var l = new List<T>(n);
for (int i = 0; i < n; i++) {
var a = ReadIntArray();
l.Add(creator(a));
}
return l;
}
static int[,] ReadMatrix(int n, int m) {
var r = new int[n, m];
for (int i = 0; i < n; i++) {
var a = ReadIntArray();
for (int j = 0; j < m; j++) {
r[i, j] = a[j];
}
}
return r;
}
public static int[] ZAlgotithm(string s) {
var len = s.Length;
var a = new int[len];
a[0] = len;
var i = 1;
var j = 0;
while (i < len) {
while (i + j < len && s[j] == s[i + j])
j++;
a[i] = j;
if (j == 0) {
i++;
continue;
}
var k = 1;
while (i + k < len && k + a[k] < j) {
a[i + k] = a[k];
k++;
}
i += k;
j -= k;
}
return a;
}
public class MaxHeap<T> : IEnumerable<T> {
private List<T> _list;
private Comparer<T> _comp;
public int Count {
get { return _list.Count; }
}
public MaxHeap() : this(0) {}
public MaxHeap(int capacity, Comparison<T> comp = null) {
_list = new List<T>(capacity);
if (comp == null) {
_comp = Comparer<T>.Default;
} else {
_comp = Comparer<T>.Create(comp);
}
}
public void Push(T elem) { Upheap(elem); }
public T Pop() { return Downheap(); }
public T Peek() { return _list[0]; }
private void Swap(int i, int j) {
var a = _list[j];
_list[j] = _list[i];
_list[i] = a;
}
private void Upheap(T elem) {
_list.Add(elem);
var i = _list.Count - 1;
while (true) {
if (i == 0)
return;
var j = (i - 1) / 2;
var e = _list[i];
var p = _list[j];
var c = _comp.Compare(e, p);
if (c > 0) {
Swap(i, j);
i = j;
continue;
} else {
break;
}
}
}
private T Downheap() {
var result = _list[0];
var last = _list.Count - 1;
Swap(0, last);
_list.RemoveAt(last);
if (_list.Count == 0)
return result;
var i = 0;
while (true) {
if (i == _list.Count - 1)
return result;
var p = _list[i];
var j = i * 2 + 1;
if (j >= _list.Count)
return result;
if (j + 1 < _list.Count && _comp.Compare(_list[j], _list[j + 1]) < 0) {
j++;
}
if (_comp.Compare(_list[i], _list[j]) < 0) {
Swap(i, j);
i = j;
} else {
return result;
}
}
}
public MaxHeap<T> Copy(Comparison<T> comp = null) {
var c = new MaxHeap<T>(0, comp);
c._list = _list.ToList();
return c;
}
public MaxHeap(List<T> list) {
_list = list;
_comp = Comparer<T>.Default;
}
public List<T> GetList() { return _list; }
public IEnumerator<T> GetEnumerator() { return _list.GetEnumerator(); }
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
}
public class MinHeap<T> : IEnumerable<T> {
private List<T> _list;
private Comparer<T> _comp;
public int Count {
get { return _list.Count; }
}
public MinHeap() : this(0) {}
public MinHeap(int capacity, Comparison<T> comp = null) {
_list = new List<T>(capacity);
if (comp == null) {
_comp = Comparer<T>.Default;
} else {
_comp = Comparer<T>.Create(comp);
}
}
public void Push(T elem) { Upheap(elem); }
public T Pop() { return Downheap(); }
public T Peek() { return _list[0]; }
private void Swap(int i, int j) {
var a = _list[j];
_list[j] = _list[i];
_list[i] = a;
}
private void Upheap(T elem) {
_list.Add(elem);
var i = _list.Count - 1;
while (true) {
if (i == 0)
return;
var j = (i - 1) / 2;
var e = _list[i];
var p = _list[j];
var c = _comp.Compare(e, p);
if (c < 0) {
Swap(i, j);
i = j;
continue;
} else {
break;
}
}
}
private T Downheap() {
var result = _list[0];
var last = _list.Count - 1;
Swap(0, last);
_list.RemoveAt(last);
if (_list.Count == 0)
return result;
var i = 0;
while (true) {
if (i == _list.Count - 1)
return result;
var p = _list[i];
var j = i * 2 + 1;
if (j >= _list.Count)
return result;
if (j + 1 < _list.Count && _comp.Compare(_list[j], _list[j + 1]) > 0) {
j++;
}
if (_comp.Compare(_list[i], _list[j]) > 0) {
Swap(i, j);
i = j;
} else {
return result;
}
}
}
public MinHeap<T> Copy(Comparison<T> comp = null) {
var c = new MinHeap<T>(0, comp);
c._list = _list.ToList();
return c;
}
public MinHeap(List<T> list) {
_list = list;
_comp = Comparer<T>.Default;
}
public List<T> GetList() { return _list; }
public IEnumerator<T> GetEnumerator() { return _list.GetEnumerator(); }
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
}
class InputLine {
private string[] _inputs;
private int _index = 0;
InputLine(string input) {
_inputs = input.Split();
_index = 0;
}
public static InputLine Read() { return new InputLine(Console.ReadLine()); }
public int NextInt() { return int.Parse(_inputs[_index++]); }
public long NextLong() { return long.Parse(_inputs[_index++]); }
public double NextDouble() { return double.Parse(_inputs[_index++]); }
}
public static int GCD(int x, int y) {
var a = Math.Max(x, y);
var b = x + y - a;
while (b != 0) {
var c = b;
b = a % b;
a = c;
}
return a;
}
public static long GCD(long x, long y) {
var a = Math.Max(x, y);
var b = x + y - a;
while (b != 0) {
var c = b;
b = a % b;
a = c;
}
return a;
}
static long ModPower(long x, long y, long mod) {
var bytes = BitConverter.GetBytes(y);
var bits = new System.Collections.BitArray(bytes);
var max2 = 0;
for (int i = bits.Length - 1; i >= 0; i--) {
if (bits[i]) {
max2 = i;
break;
}
}
long result = 1;
for (int i = max2; i >= 0; i--) {
result = (result * result) % mod;
if (bits[i]) {
result = (result * x) % mod;
}
}
return result;
}
static long ModFact(long n, long mod) {
long result = 1;
for (int i = 1; i <= n; i++) {
result = result * i % mod;
}
return result;
}
static long ModAdd(long x, long y, long mod) {
return ((x % mod) + (y % mod)) % mod;
}
static long ModMul(long x, long y, long mod) {
return ((x % mod) * (y % mod)) % mod;
}
static long ModDiv(long x, long y, long mod) {
//ใใงใซใใผใฎๅฐๅฎ็ใใใa^(-1) = a^(p-2)
return ModMul(x, ModPower(y, mod - 2, mod), mod);
}
static long ModComb(long n, long r, long mod) {
long numerator = 1;
for (int i = 0; i < r; i++) {
numerator = ModMul(numerator, n - i, mod);
}
long denominator = ModFact(r, mod);
return ModDiv(numerator, denominator, mod);
}
class Graph {
private int _size;
private List<int>[] _edges;
public Graph(int size) {
_size = size;
_edges = new List<int>[size];
}
public List<int> this[int i] {
get {
if (_edges[i] == null)
_edges[i] = new List<int>();
return _edges[i];
}
}
}
class Graph<T> {
private int _size;
private List<T>[] _edges;
public Graph(int size) {
_size = size;
_edges = new List<T>[size];
}
public List<T> this[int i] {
get {
if (_edges[i] == null)
_edges[i] = new List<T>();
return _edges[i];
}
}
}
static Graph<T> NewGraph<T>(int size, T template) {
return new Graph<T>(size);
}
static List<T> NewList<T>(T template) { return new List<T>(); }
static T[] NewArray<T>(int size, T template) { return new T[size]; }
static long p1097 = 1000000007;
static void Main(string[] args) {
//โ
var nk = ReadIntArray();
var n = nk[0];
var k = nk[1];
var rsp = ReadIntArray();
var r = rsp[0];
var s = rsp[1];
var p = rsp[2];
var t = Console.ReadLine();
var sum = 0;
var prev = new char[k];
for (int i = 0; i < n; i++) {
var c = t[i];
var mod = i % k;
if (i >= k && prev[mod] == c) {
prev[mod] = 'x';
continue;
}
switch (c) {
case 's':
sum += r;
break;
case 'p':
sum += s;
break;
case 'r':
sum += p;
break;
default:
break;
}
prev[mod] = c;
}
Console.WriteLine(sum);
//โ
}
}
}
|
[["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["-", 8, 196, 0, 57, 15, 16, 31, 204, 205, 22], ["-", 0, 57, 15, 16, 31, 204, 206, 207, 0, 70], ["-", 15, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["-", 0, 57, 15, 16, 31, 204, 206, 207, 0, 73], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25]]
| 8
| 3,578
| 9
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;
class Program {
static void Main(string[] args) {
var wrong_answer = new wrong_answer();
wrong_answer.Solve();
}
}
public class wrong_answer {
const int INF = 1 << 30;
const long INFL = 1L << 60;
const int MOD = 1000000007;
const int MOD2 = 998244353;
myinout IO = new myinout();
Math2 mmath = new Math2();
// functions
public void Solve() {
//ใใใใ
var o = IO.intm;
var n = o[0];
var k = o[1];
var oo = IO.intm;
var r = oo[0];
var s = oo[1];
var p = oo[2];
var point = new int[3, 3]; // me aite
for (int i = 0; i < 3; ++i)
for (int j = 0; j < 3; ++j)
point[i, j] = 0;
point[0, 1] = r;
point[1, 2] = s;
point[2, 0] = p;
var t = IO.str;
int[] other = new int[n];
for (int i = 0; i < n; ++i) {
if (t[i] == 'r')
other[i] = 0;
if (t[i] == 's')
other[i] = 1;
if (t[i] == 'p')
other[i] = 2;
}
var ss = new char[n];
var ans = 0L;
for (int i = 0; i < n; ++i) {
var kati = (other[i] - 1) % 3;
if (kati < 0)
kati += 3;
var make = (other[i] + 1) % 3;
if (i < k) {
ss[i] = (char)(kati + '0');
ans += point[kati, other[i]];
} else {
if (kati == ss[i - k] - '0') {
ss[i] = (char)(other[i] + '0');
} else {
ss[i] = (char)(kati + '0');
ans += point[kati, other[i]];
}
}
}
IO.wri(ans);
}
static IEnumerable<int> Primes(int maxnum) {
// var sieve = new BitArray(maxnum + 1, true);
bool[] sieve = Enumerable.Repeat(true, maxnum + 1).ToArray();
int squareroot = (int)Math.Sqrt(maxnum);
for (int i = 2; i <= squareroot; i++) {
if (sieve[i] == false)
continue;
for (int n = i * 2; n <= maxnum; n += i)
sieve[n] = false;
}
for (int i = 2; i <= maxnum; i++)
if (sieve[i] == true)
yield return i;
}
}
// b-aใง้้
public class Math2 {
public long[] fact;
public long[] invfact;
public void factoricalmodset(long N, long MOD = 1000000007) {
fact = new long[N + 1];
invfact = new long[N + 1];
fact[0] = 1;
for (long i = 1; i <= N; ++i) {
fact[i] = fact[i - 1] * i % MOD;
}
invfact[N] = pow(fact[N], MOD - 2);
for (long i = N; i > 0; --i) {
invfact[i - 1] = invfact[i] * i % MOD;
}
}
public long nCr(long n, long r, long MOD = 1000000007) {
return (fact[n] * invfact[r] % MOD * invfact[n - r] % MOD);
}
public long pow(long i, long n, long MOD = 1000000007) {
long res = 1;
while (n > 0) {
if ((n & 1) != 0)
res = res * i % MOD;
i = i * i % MOD;
n >>= 1;
}
return res;
}
public long gcd(long i, long y) {
while (y != 0) {
var r = i % y;
i = y;
y = r;
}
return i;
}
public long lcm(long i, long y) { return i * y / gcd(i, y); }
public Dictionary<long, int> primefactorization(long N) {
var ret = new Dictionary<long, int>();
for (long i = 2; i * i <= N; ++i) {
int cnt = 0;
while (N % i == 0) {
cnt++;
N /= i;
}
if (cnt != 0)
ret[i] = cnt;
}
if (N >= 2)
ret[N] = 1;
return ret;
}
public List<long> divisorenumrate(long N) {
var ret = new List<long>();
for (long i = 1; i * i <= N; ++i) {
if (N % i == 0) {
ret.Add(i);
ret.Add(N / i);
}
}
return ret;
}
public void swap<T>(ref T a, ref T b) {
var i = a;
a = b;
b = i;
}
}
class myinout {
// in
public string str => Console.ReadLine();
public string[] strm => str.Split(' ');
public long[] longm => strm.Select(long.Parse).ToArray();
public int[] intm => strm.Select(int.Parse).ToArray();
public char[] charm => str.ToArray();
public double[] doublem => strm.Select(double.Parse).ToArray();
public long long1 => longm[0];
public int int1 => intm[0];
public char char1 => charm[0];
public double double1 => doublem[0];
// out
public void wri<T>(T i) { Console.WriteLine(i); }
public void wri<T>(T[] i) { Console.WriteLine(string.Join(" ", i)); }
public void yn(bool i) {
if (i)
wri("Yes");
else
wri("No");
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;
class Program {
static void Main(string[] args) {
var wrong_answer = new wrong_answer();
wrong_answer.Solve();
}
}
public class wrong_answer {
const int INF = 1 << 30;
const long INFL = 1L << 60;
const int MOD = 1000000007;
const int MOD2 = 998244353;
myinout IO = new myinout();
Math2 mmath = new Math2();
// functions
public void Solve() {
//ใใใใ
var o = IO.intm;
var n = o[0];
var k = o[1];
var oo = IO.intm;
var r = oo[0];
var s = oo[1];
var p = oo[2];
var point = new int[3, 3]; // me aite
for (int i = 0; i < 3; ++i)
for (int j = 0; j < 3; ++j)
point[i, j] = 0;
point[0, 1] = r;
point[1, 2] = s;
point[2, 0] = p;
var t = IO.str;
int[] other = new int[n];
for (int i = 0; i < n; ++i) {
if (t[i] == 'r')
other[i] = 0;
if (t[i] == 's')
other[i] = 1;
if (t[i] == 'p')
other[i] = 2;
}
var ss = new char[n];
var ans = 0L;
for (int i = 0; i < n; ++i) {
var kati = (other[i] - 1) % 3;
if (kati < 0)
kati += 3;
var make = (other[i] + 1) % 3;
if (i < k) {
ss[i] = (char)(kati + '0');
ans += point[kati, other[i]];
} else {
if (kati == ss[i - k] - '0') {
if (i + k < n)
other[i] = other[i + k];
ss[i] = (char)(other[i] + '0');
} else {
ss[i] = (char)(kati + '0');
ans += point[kati, other[i]];
}
}
}
IO.wri(ans);
}
static IEnumerable<int> Primes(int maxnum) {
// var sieve = new BitArray(maxnum + 1, true);
bool[] sieve = Enumerable.Repeat(true, maxnum + 1).ToArray();
int squareroot = (int)Math.Sqrt(maxnum);
for (int i = 2; i <= squareroot; i++) {
if (sieve[i] == false)
continue;
for (int n = i * 2; n <= maxnum; n += i)
sieve[n] = false;
}
for (int i = 2; i <= maxnum; i++)
if (sieve[i] == true)
yield return i;
}
}
// b-aใง้้
public class Math2 {
public long[] fact;
public long[] invfact;
public void factoricalmodset(long N, long MOD = 1000000007) {
fact = new long[N + 1];
invfact = new long[N + 1];
fact[0] = 1;
for (long i = 1; i <= N; ++i) {
fact[i] = fact[i - 1] * i % MOD;
}
invfact[N] = pow(fact[N], MOD - 2);
for (long i = N; i > 0; --i) {
invfact[i - 1] = invfact[i] * i % MOD;
}
}
public long nCr(long n, long r, long MOD = 1000000007) {
return (fact[n] * invfact[r] % MOD * invfact[n - r] % MOD);
}
public long pow(long i, long n, long MOD = 1000000007) {
long res = 1;
while (n > 0) {
if ((n & 1) != 0)
res = res * i % MOD;
i = i * i % MOD;
n >>= 1;
}
return res;
}
public long gcd(long i, long y) {
while (y != 0) {
var r = i % y;
i = y;
y = r;
}
return i;
}
public long lcm(long i, long y) { return i * y / gcd(i, y); }
public Dictionary<long, int> primefactorization(long N) {
var ret = new Dictionary<long, int>();
for (long i = 2; i * i <= N; ++i) {
int cnt = 0;
while (N % i == 0) {
cnt++;
N /= i;
}
if (cnt != 0)
ret[i] = cnt;
}
if (N >= 2)
ret[N] = 1;
return ret;
}
public List<long> divisorenumrate(long N) {
var ret = new List<long>();
for (long i = 1; i * i <= N; ++i) {
if (N % i == 0) {
ret.Add(i);
ret.Add(N / i);
}
}
return ret;
}
public void swap<T>(ref T a, ref T b) {
var i = a;
a = b;
b = i;
}
}
class myinout {
// in
public string str => Console.ReadLine();
public string[] strm => str.Split(' ');
public long[] longm => strm.Select(long.Parse).ToArray();
public int[] intm => strm.Select(int.Parse).ToArray();
public char[] charm => str.ToArray();
public double[] doublem => strm.Select(double.Parse).ToArray();
public long long1 => longm[0];
public int int1 => intm[0];
public char char1 => charm[0];
public double double1 => doublem[0];
// out
public void wri<T>(T i) { Console.WriteLine(i); }
public void wri<T>(T[] i) { Console.WriteLine(string.Join(" ", i)); }
public void yn(bool i) {
if (i)
wri("Yes");
else
wri("No");
}
}
|
[["+", 75, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 75, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 64, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 64, 196, 0, 57, 15, 16, 31, 16, 17, 72], ["+", 64, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 22], ["+", 75, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 1, 0, 11, 31, 204, 205, 22], ["+", 64, 1, 0, 11, 31, 204, 206, 207, 0, 70], ["+", 0, 11, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 64, 1, 0, 11, 31, 204, 206, 207, 0, 73], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 1, 0, 11, 12, 204, 205, 22], ["+", 64, 1, 0, 11, 12, 204, 206, 207, 0, 70], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 17, 72], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 12, 22], ["+", 64, 1, 0, 11, 12, 204, 206, 207, 0, 73], ["+", 0, 57, 64, 196, 0, 57, 64, 1, 0, 35]]
| 8
| 1,357
| 20
|
using System;
using System.Collections.Generic;
using System.Linq;
public class Solution {
public static void Main() {
var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var N = vals[0];
var K = vals[1];
vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var R = vals[0];
var S = vals[1];
var P = vals[2];
var T = Console.ReadLine();
var point = new Dictionary<char, int>();
point['s'] = R;
point['p'] = S;
point['r'] = P;
var score = 0;
char prev = '-';
for (int i = 0; i < K; i++) {
for (int j = i; j < N; j += K) {
if (T[j] != prev) {
score += point[T[j]];
prev = T[j];
} else {
prev = '-';
}
}
}
Console.WriteLine(score);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
public class Solution {
public static void Main() {
var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var N = vals[0];
var K = vals[1];
vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var R = vals[0];
var S = vals[1];
var P = vals[2];
var T = Console.ReadLine();
var point = new Dictionary<char, int>();
point['s'] = R;
point['p'] = S;
point['r'] = P;
var score = 0;
for (int i = 0; i < K; i++) {
char prev = '-';
for (int j = i; j < N; j += K) {
if (T[j] != prev) {
score += point[T[j]];
prev = T[j];
} else {
prev = '-';
}
}
}
Console.WriteLine(score);
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 198, 0, 200, 0, 212, 0, 252, 0, 104], ["-", 0, 198, 0, 200, 0, 212, 0, 252, 0, 253], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 252, 0, 104], ["+", 0, 198, 0, 200, 0, 212, 0, 252, 0, 253], ["+", 8, 196, 0, 7, 8, 196, 0, 197, 0, 35]]
| 8
| 259
| 14
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;
public class E {
public static void Main() => (new Solver()).Solve();
}
public class Solver {
public void Solve() {
long N = GetLong();
long M = GetLong();
long[] A = GetLongs(N);
Array.Sort(A);
Array.Reverse(A);
long MAX = 100000;
long[] cnt = new long[MAX + 1];
for (long i = 0; i < N; i++)
cnt[A[i]]++;
for (long i = 0; i < MAX; i++)
cnt[i + 1] += cnt[i];
long ok = 0;
long ng = (long)1e16;
while (Abs(ng - ok) > 1) {
long mid = (ok + ng) / 2;
long sum = 0;
for (long i = 0; i < N; i++) {
long lb = Max(1, mid - A[i]);
if (lb > MAX)
continue;
sum += cnt[MAX] - cnt[lb - 1];
}
if (sum >= M)
ok = mid;
else
ng = mid;
}
long[] B = new long[N + 1];
for (long i = 0; i < N; i++)
B[i + 1] = B[i] + A[i];
long ans = 0;
long rest = M;
for (long i = 0; i < N; i++) {
long lb = Max(1, ok - A[i]);
if (lb > MAX)
continue;
long diff = Min(rest, cnt[MAX] - cnt[lb - 1]);
ans += diff * A[i] + B[diff];
rest -= diff;
if (rest == 0)
break;
}
WriteLine(ans);
}
}
public static class MyIO {
private static string[] args = null;
private static int num = -1;
private static int used = -1;
private static string getArg() {
if (used == num) {
args = Console.ReadLine().Split(' ');
num = args.Length;
used = 0;
}
return args[used++];
}
public static int GetInt() => int.Parse(getArg());
public static long GetLong() => long.Parse(getArg());
public static double GetDouble() => double.Parse(getArg());
public static decimal GetDecimal() => decimal.Parse(getArg());
public static string GetString() => getArg();
public static char GetChar() => getArg()[0];
public static int[] GetInts(long N) =>
Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
public static long[] GetLongs(long N) =>
Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
public static double[] GetDoubles(long N) =>
Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
public static decimal[] GetDecimals(long N) =>
Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
public static string[] GetStrings(long N) =>
Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}
public static class MyUtil {
public static void chmax<T>(ref T x, T y)
where T : IComparable<T> {
if (x.CompareTo(y) < 0)
x = y;
}
public static void chmin<T>(ref T x, T y)
where T : IComparable<T> {
if (x.CompareTo(y) > 0)
x = y;
}
public static void swap<T>(ref T x, ref T y) {
T tmp = x;
x = y;
y = tmp;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;
public class E {
public static void Main() => (new Solver()).Solve();
}
public class Solver {
public void Solve() {
long N = GetLong();
long M = GetLong();
long[] A = GetLongs(N);
Array.Sort(A);
Array.Reverse(A);
long MAX = 100000;
long[] cnt = new long[MAX + 1];
for (long i = 0; i < N; i++)
cnt[A[i]]++;
for (long i = 0; i < MAX; i++)
cnt[i + 1] += cnt[i];
long ok = 0;
long ng = (long)1e16;
while (Abs(ng - ok) > 1) {
long mid = (ok + ng) / 2;
long sum = 0;
for (long i = 0; i < N; i++) {
long lb = Max(1, mid - A[i]);
if (lb > MAX)
continue;
sum += cnt[MAX] - cnt[lb - 1];
}
if (sum >= M)
ok = mid;
else
ng = mid;
}
long[] B = new long[N + 1];
for (long i = 0; i < N; i++)
B[i + 1] = B[i] + A[i];
long ans = 0;
long rest = M;
for (long i = 0; i < N; i++) {
long lb = Max(1, ok + 1 - A[i]);
if (lb > MAX)
continue;
long diff = Min(rest, cnt[MAX] - cnt[lb - 1]);
ans += diff * A[i] + B[diff];
rest -= diff;
if (rest == 0)
break;
}
ans += rest * ok;
WriteLine(ans);
}
}
public static class MyIO {
private static string[] args = null;
private static int num = -1;
private static int used = -1;
private static string getArg() {
if (used == num) {
args = Console.ReadLine().Split(' ');
num = args.Length;
used = 0;
}
return args[used++];
}
public static int GetInt() => int.Parse(getArg());
public static long GetLong() => long.Parse(getArg());
public static double GetDouble() => double.Parse(getArg());
public static decimal GetDecimal() => decimal.Parse(getArg());
public static string GetString() => getArg();
public static char GetChar() => getArg()[0];
public static int[] GetInts(long N) =>
Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
public static long[] GetLongs(long N) =>
Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
public static double[] GetDoubles(long N) =>
Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
public static decimal[] GetDecimals(long N) =>
Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
public static string[] GetStrings(long N) =>
Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}
public static class MyUtil {
public static void chmax<T>(ref T x, T y)
where T : IComparable<T> {
if (x.CompareTo(y) < 0)
x = y;
}
public static void chmin<T>(ref T x, T y)
where T : IComparable<T> {
if (x.CompareTo(y) > 0)
x = y;
}
public static void swap<T>(ref T x, ref T y) {
T tmp = x;
x = y;
y = tmp;
}
}
|
[["+", 3, 4, 0, 28, 0, 16, 31, 16, 17, 72], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 12, 203], ["+", 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, 48], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 904
| 8
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
using System.Linq;
using E = System.Linq.Enumerable;
internal partial class Solver {
struct Data {
public int Index;
public int Sum;
public bool Same;
}
public void Run() {
var n = ni();
var m = nl();
var a = ni(n);
Array.Sort(a);
var sum = a.Select(x => (long)x).ToArray();
for (int i = n - 2; i >= 0; i--) {
sum[i] += sum[i + 1];
}
int lower = 0, upper = 100000 * 3;
long ans = 0;
while (lower <= upper) {
var mid = (lower + upper) >> 1;
long handShake = 0;
long total = 0;
for (int i = 0; i < n; i++) {
var b = LowerBound(a, mid - a[i]);
handShake += n - b;
if (b < n) {
total += sum[b] + 1L * (n - b) * a[i];
}
}
if (handShake <= m) {
// ans
upper = mid - 1;
} else {
ans = total - mid * (handShake - m);
lower = mid + 1;
}
}
cout.WriteLine(ans);
}
public static int LowerBound<T>(IList<T> A, T x) {
return LowerBound(A, 0, A.Count, x);
}
public static int LowerBound<T>(IList<T> A, T x, IComparer<T> comparer) {
return LowerBound(A, 0, A.Count, x, comparer);
}
public static int LowerBound<T>(IList<T> A, T x, Comparison<T> comp) {
return LowerBound(A, 0, A.Count, x, Comparer<T>.Create(comp));
}
public static int LowerBound<T>(IList<T> A, int start, int end, T x) {
return LowerBound(A, start, end, x, Comparer<T>.Default);
}
public static int LowerBound<T>(IList<T> A, int start, int end, T x,
Comparison<T> comp) {
return LowerBound(A, start, end, x, Comparer<T>.Create(comp));
}
public static int LowerBound<T>(IList<T> A, int start, int end, T x,
IComparer<T> comparer) {
int lower = start, upper = end - 1;
int result = end;
while (lower <= upper) {
int pos = (lower + upper) >> 1;
if (comparer.Compare(x, A[pos]) <= 0) {
result = pos;
upper = pos - 1;
} else {
lower = pos + 1;
}
}
return result;
}
}
// PREWRITEN CODE BEGINS FROM HERE
internal partial class Solver : Scanner {
public static void Main(string[] args) {
#if LOCAL
byte[] inputBuffer = new byte[1000000];
var inputStream = Console.OpenStandardInput(inputBuffer.Length);
using (var reader = new StreamReader(inputStream, Console.InputEncoding,
false, inputBuffer.Length)) {
Console.SetIn(reader);
new Solver(Console.In, Console.Out).Run();
}
#else
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
new Solver(Console.In, Console.Out).Run();
Console.Out.Flush();
#endif
}
#pragma warning disable IDE0052
private readonly TextReader cin;
private readonly TextWriter cout;
#pragma warning restore IDE0052
public Solver(TextReader reader, TextWriter writer) : base(reader) {
cin = reader;
cout = writer;
}
public Solver(string input, TextWriter writer)
: this(new StringReader(input), writer) {}
#pragma warning disable IDE1006
#pragma warning disable IDE0051
private int ni() { return NextInt(); }
private int[] ni(int n) { return NextIntArray(n); }
private long nl() { return NextLong(); }
private long[] nl(int n) { return NextLongArray(n); }
private double nd() { return NextDouble(); }
private double[] nd(int n) { return NextDoubleArray(n); }
private string ns() { return Next(); }
private string[] ns(int n) { return NextArray(n); }
#pragma warning restore IDE1006
#pragma warning restore IDE0051
}
internal static class LinqPadExtension {
public static T Dump<T>(this T obj) {
#if LOCAL
return LINQPad.Extensions.Dump(obj);
#else
return obj;
#endif
}
}
public class Scanner {
private readonly TextReader Reader;
private readonly Queue<string> TokenQueue = new Queue<string>();
private readonly CultureInfo ci = CultureInfo.InvariantCulture;
public Scanner() : this(Console.In) {}
public Scanner(TextReader reader) { Reader = reader; }
public int NextInt() { return int.Parse(Next(), ci); }
public long NextLong() { return long.Parse(Next(), ci); }
public double NextDouble() { return double.Parse(Next(), ci); }
public string[] NextArray(int size) {
string[] array = new string[size];
for (int i = 0; i < size; i++) {
array[i] = Next();
}
return array;
}
public int[] NextIntArray(int size) {
int[] array = new int[size];
for (int i = 0; i < size; i++) {
array[i] = NextInt();
}
return array;
}
public long[] NextLongArray(int size) {
long[] array = new long[size];
for (int i = 0; i < size; i++) {
array[i] = NextLong();
}
return array;
}
public double[] NextDoubleArray(int size) {
double[] array = new double[size];
for (int i = 0; i < size; i++) {
array[i] = NextDouble();
}
return array;
}
public string Next() {
if (TokenQueue.Count == 0) {
if (!StockTokens()) {
throw new InvalidOperationException();
}
}
return TokenQueue.Dequeue();
}
public bool HasNext() {
if (TokenQueue.Count > 0) {
return true;
}
return StockTokens();
}
private static readonly char[] _separator = new[] { ' ', '\t' };
private bool StockTokens() {
while (true) {
string line = Reader.ReadLine();
if (line == null) {
return false;
}
string[] tokens =
line.Split(_separator, StringSplitOptions.RemoveEmptyEntries);
if (tokens.Length == 0) {
continue;
}
foreach (string token in tokens) {
TokenQueue.Enqueue(token);
}
return true;
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
using System.Linq;
using E = System.Linq.Enumerable;
internal partial class Solver {
struct Data {
public int Index;
public int Sum;
public bool Same;
}
public void Run() {
var n = ni();
var m = nl();
var a = ni(n);
Array.Sort(a);
var sum = a.Select(x => (long)x).ToArray();
for (int i = n - 2; i >= 0; i--) {
sum[i] += sum[i + 1];
}
int lower = 0, upper = 100000 * 3;
long ans = sum[0] * n * 2;
while (lower <= upper) {
var mid = (lower + upper) >> 1;
long handShake = 0;
long total = 0;
for (int i = 0; i < n; i++) {
var b = LowerBound(a, mid - a[i]);
handShake += n - b;
if (b < n) {
total += sum[b] + 1L * (n - b) * a[i];
}
}
if (handShake <= m) {
// ans
upper = mid - 1;
} else {
ans = total - mid * (handShake - m);
lower = mid + 1;
}
}
cout.WriteLine(ans);
}
public static int LowerBound<T>(IList<T> A, T x) {
return LowerBound(A, 0, A.Count, x);
}
public static int LowerBound<T>(IList<T> A, T x, IComparer<T> comparer) {
return LowerBound(A, 0, A.Count, x, comparer);
}
public static int LowerBound<T>(IList<T> A, T x, Comparison<T> comp) {
return LowerBound(A, 0, A.Count, x, Comparer<T>.Create(comp));
}
public static int LowerBound<T>(IList<T> A, int start, int end, T x) {
return LowerBound(A, start, end, x, Comparer<T>.Default);
}
public static int LowerBound<T>(IList<T> A, int start, int end, T x,
Comparison<T> comp) {
return LowerBound(A, start, end, x, Comparer<T>.Create(comp));
}
public static int LowerBound<T>(IList<T> A, int start, int end, T x,
IComparer<T> comparer) {
int lower = start, upper = end - 1;
int result = end;
while (lower <= upper) {
int pos = (lower + upper) >> 1;
if (comparer.Compare(x, A[pos]) <= 0) {
result = pos;
upper = pos - 1;
} else {
lower = pos + 1;
}
}
return result;
}
}
// PREWRITEN CODE BEGINS FROM HERE
internal partial class Solver : Scanner {
public static void Main(string[] args) {
#if LOCAL
byte[] inputBuffer = new byte[1000000];
var inputStream = Console.OpenStandardInput(inputBuffer.Length);
using (var reader = new StreamReader(inputStream, Console.InputEncoding,
false, inputBuffer.Length)) {
Console.SetIn(reader);
new Solver(Console.In, Console.Out).Run();
}
#else
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
new Solver(Console.In, Console.Out).Run();
Console.Out.Flush();
#endif
}
#pragma warning disable IDE0052
private readonly TextReader cin;
private readonly TextWriter cout;
#pragma warning restore IDE0052
public Solver(TextReader reader, TextWriter writer) : base(reader) {
cin = reader;
cout = writer;
}
public Solver(string input, TextWriter writer)
: this(new StringReader(input), writer) {}
#pragma warning disable IDE1006
#pragma warning disable IDE0051
private int ni() { return NextInt(); }
private int[] ni(int n) { return NextIntArray(n); }
private long nl() { return NextLong(); }
private long[] nl(int n) { return NextLongArray(n); }
private double nd() { return NextDouble(); }
private double[] nd(int n) { return NextDoubleArray(n); }
private string ns() { return Next(); }
private string[] ns(int n) { return NextArray(n); }
#pragma warning restore IDE1006
#pragma warning restore IDE0051
}
internal static class LinqPadExtension {
public static T Dump<T>(this T obj) {
#if LOCAL
return LINQPad.Extensions.Dump(obj);
#else
return obj;
#endif
}
}
public class Scanner {
private readonly TextReader Reader;
private readonly Queue<string> TokenQueue = new Queue<string>();
private readonly CultureInfo ci = CultureInfo.InvariantCulture;
public Scanner() : this(Console.In) {}
public Scanner(TextReader reader) { Reader = reader; }
public int NextInt() { return int.Parse(Next(), ci); }
public long NextLong() { return long.Parse(Next(), ci); }
public double NextDouble() { return double.Parse(Next(), ci); }
public string[] NextArray(int size) {
string[] array = new string[size];
for (int i = 0; i < size; i++) {
array[i] = Next();
}
return array;
}
public int[] NextIntArray(int size) {
int[] array = new int[size];
for (int i = 0; i < size; i++) {
array[i] = NextInt();
}
return array;
}
public long[] NextLongArray(int size) {
long[] array = new long[size];
for (int i = 0; i < size; i++) {
array[i] = NextLong();
}
return array;
}
public double[] NextDoubleArray(int size) {
double[] array = new double[size];
for (int i = 0; i < size; i++) {
array[i] = NextDouble();
}
return array;
}
public string Next() {
if (TokenQueue.Count == 0) {
if (!StockTokens()) {
throw new InvalidOperationException();
}
}
return TokenQueue.Dequeue();
}
public bool HasNext() {
if (TokenQueue.Count > 0) {
return true;
}
return StockTokens();
}
private static readonly char[] _separator = new[] { ' ', '\t' };
private bool StockTokens() {
while (true) {
string line = Reader.ReadLine();
if (line == null) {
return false;
}
string[] tokens =
line.Split(_separator, StringSplitOptions.RemoveEmptyEntries);
if (tokens.Length == 0) {
continue;
}
foreach (string token in tokens) {
TokenQueue.Enqueue(token);
}
return true;
}
}
}
|
[["+", 0, 212, 0, 16, 31, 16, 31, 204, 205, 22], ["+", 0, 16, 31, 16, 31, 204, 206, 207, 0, 70], ["+", 0, 16, 31, 16, 31, 204, 206, 207, 0, 73], ["+", 0, 200, 0, 212, 0, 16, 31, 16, 17, 48], ["+", 0, 200, 0, 212, 0, 16, 31, 16, 12, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 48], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203]]
| 8
| 1,495
| 7
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.