buggy_code
stringlengths 11
625k
| fixed_code
stringlengths 17
625k
| bug_type
stringlengths 2
4.45k
| language
int64 0
8
| token_count
int64 5
200k
| change_count
int64 0
100
|
|---|---|---|---|---|---|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class AtCoderA {
static void Main() {
var sc = new Scanner();
int n = sc.NextInt();
int[] s = new int[n];
for (int i = 0; i < n; i++) {
s[i] = sc.NextInt();
}
List<int> ten = new List<int>();
List<int> notTen = new List<int>();
foreach (var num in s) {
if (num % 10 == 0) {
ten.Add(num);
} else {
notTen.Add(num);
}
}
int answer = 0;
if (notTen.Count() > 0) {
answer = s.Sum() - notTen.Min();
}
Console.WriteLine(answer);
}
class Scanner {
private string[] _line;
private int _index;
private const char Separator = ' ';
public Scanner() {
_line = new string[0];
_index = 0;
}
public string Next() {
while (_index >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_index = 0;
}
return _line[_index++];
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
public decimal NextDecimal() => decimal.Parse(Next());
public char NextChar() => Next()[0];
public char[] NextCharArray() => Next().ToCharArray();
public string[] Array() {
_line = Console.ReadLine().Split(Separator);
_index = _line.Length;
return _line;
}
public int[] IntArray() => Array().Select(int.Parse).ToArray();
public long[] LongArray() => Array().Select(long.Parse).ToArray();
public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class AtCoderA {
static void Main() {
var sc = new Scanner();
int n = sc.NextInt();
int[] s = new int[n];
for (int i = 0; i < n; i++) {
s[i] = sc.NextInt();
}
List<int> ten = new List<int>();
List<int> notTen = new List<int>();
foreach (var num in s) {
if (num % 10 == 0) {
ten.Add(num);
} else {
notTen.Add(num);
}
}
int answer = s.Sum();
if (notTen.Count == 0) {
answer = 0;
}
if (answer % 10 == 0 && notTen.Count() > 0) {
answer = s.Sum() - notTen.Min();
}
Console.WriteLine(answer);
}
class Scanner {
private string[] _line;
private int _index;
private const char Separator = ' ';
public Scanner() {
_line = new string[0];
_index = 0;
}
public string Next() {
while (_index >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_index = 0;
}
return _line[_index++];
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
public decimal NextDecimal() => decimal.Parse(Next());
public char NextChar() => Next()[0];
public char[] NextCharArray() => Next().ToCharArray();
public string[] Array() {
_line = Console.ReadLine().Split(Separator);
_index = _line.Length;
return _line;
}
public int[] IntArray() => Array().Select(int.Parse).ToArray();
public long[] LongArray() => Array().Select(long.Parse).ToArray();
public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
}
}
|
[["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 205, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 0, 131], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 141, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 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, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 17, 109], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 12, 203], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98]]
| 8
| 483
| 24
|
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
class Solve {
const int mod = 1000000007;
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
int[] s = new int[N];
long ans = 0;
for (int i = 0; i < N; i++) {
s[i] = int.Parse(Console.ReadLine());
ans += s[i];
}
if (ans % 10 == 0) {
Array.Sort(s);
for (int i = 0; i < N; i++) {
if (s[i] % 10 != 0) {
ans -= s[i];
break;
}
ans = 0;
}
}
Console.WriteLine(ans);
}
}
|
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
class Solve {
const int mod = 1000000007;
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
int[] s = new int[N];
long ans = 0;
for (int i = 0; i < N; i++) {
s[i] = int.Parse(Console.ReadLine());
ans += s[i];
}
if (ans % 10 == 0) {
long ansc = ans;
Array.Sort(s);
for (int i = 0; i < N; i++) {
if (s[i] % 10 != 0) {
ans -= s[i];
break;
}
}
if (ans == ansc) {
ans = 0;
}
}
Console.WriteLine(ans);
}
}
|
[["+", 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, 197, 0, 198, 0, 200, 0, 212, 0, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 197, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 45]]
| 8
| 188
| 13
|
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
namespace AtCoder.Contest.D {
static class Program {
public static void Solve(Scanner cin) {
var (n, a, b) = cin.ReadValue<int, int, int>();
var h = cin.ReadIntArray(n);
long l = 0;
long r = 1000000001;
while (r - l > 1) {
long mid = l + (r - l) / 2;
if (isOk(h, mid, a, b))
r = mid;
else
l = mid;
}
Console.WriteLine(r);
}
public static bool isOk(int[] h, long k, int a, int b) {
return h.Select(x => (x - k * b + a - b - 1) / (a - b)).Sum() <= k;
}
public static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var cin = new Scanner();
Solve(cin);
Console.Out.Flush();
}
public static void YESNO(bool condition) {
if (condition)
Console.WriteLine("YES");
else
Console.WriteLine("NO");
}
public static void YesNo(bool condition) {
if (condition)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
public static void yesno(bool condition) {
if (condition)
Console.WriteLine("yes");
else
Console.WriteLine("no");
}
}
class Scanner {
string[] s;
int i;
char[] separator = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string Read() => ReadString();
public string ReadString() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(separator, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return ReadString();
i = 0;
return s[i++];
}
public string[] ReadStringArray(int N) {
string[] Array = new string[N];
for (int i = 0; i < N; i++) {
Array[i] = ReadString();
}
return Array;
}
public int ReadInt() { return int.Parse(ReadString()); }
public int[] ReadIntArray(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = ReadInt() + add;
}
return Array;
}
public long ReadLong() { return long.Parse(ReadString()); }
public long[] ReadLongArray(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = ReadLong() + add;
}
return Array;
}
public double ReadDouble() { return double.Parse(ReadString()); }
public double[] ReadDoubleArray(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = ReadDouble() + add;
}
return Array;
}
public T1 ReadValue<T1>() => (T1)Convert.ChangeType(ReadString(),
typeof(T1));
public (T1, T2) ReadValue<T1, T2>() {
var inputs = ReadStringArray(2);
var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
return (v1, v2);
}
public (T1, T2, T3) ReadValue<T1, T2, T3>() {
var inputs = ReadStringArray(3);
var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
return (v1, v2, v3);
}
public (T1, T2, T3, T4) ReadValue<T1, T2, T3, T4>() {
var inputs = ReadStringArray(4);
var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));
return (v1, v2, v3, v4);
}
public (T1, T2, T3, T4, T5) ReadValue<T1, T2, T3, T4, T5>() {
var inputs = ReadStringArray(5);
var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));
var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5));
return (v1, v2, v3, v4, v5);
}
public (T1, T2, T3, T4, T5, T6) ReadValue<T1, T2, T3, T4, T5, T6>() {
var inputs = ReadStringArray(6);
var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));
var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5));
var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6));
return (v1, v2, v3, v4, v5, v6);
}
public (T1, T2, T3, T4, T5, T6,
T7) ReadValue<T1, T2, T3, T4, T5, T6, T7>() {
var inputs = ReadStringArray(7);
var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));
var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5));
var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6));
var v7 = (T7)Convert.ChangeType(inputs[6], typeof(T7));
return (v1, v2, v3, v4, v5, v6, v7);
}
public T1[] ReadValueArray<T1>(int N) {
var v1 = new T1[N];
for (int i = 0; i < N; i++) {
v1[i] = ReadValue<T1>();
}
return v1;
}
public (T1[], T2[]) ReadValueArray<T1, T2>(int N) {
var (v1, v2) = (new T1[N], new T2[N]);
for (int i = 0; i < N; i++) {
var (t1, t2) = ReadValue<T1, T2>();
v1[i] = t1;
v2[i] = t2;
}
return (v1, v2);
}
public (T1[], T2[], T3[]) ReadValueArray<T1, T2, T3>(int N) {
var (v1, v2, v3) = (new T1[N], new T2[N], new T3[N]);
for (int i = 0; i < N; i++) {
var (t1, t2, t3) = ReadValue<T1, T2, T3>();
v1[i] = t1;
v2[i] = t2;
v3[i] = t3;
}
return (v1, v2, v3);
}
public (T1[], T2[], T3[], T4[]) ReadValueArray<T1, T2, T3, T4>(int N) {
var (v1, v2, v3, v4) = (new T1[N], new T2[N], new T3[N], new T4[N]);
for (int i = 0; i < N; i++) {
var (t1, t2, t3, t4) = ReadValue<T1, T2, T3, T4>();
v1[i] = t1;
v2[i] = t2;
v3[i] = t3;
v4[i] = t4;
}
return (v1, v2, v3, v4);
}
public (T1[], T2[], T3[], T4[],
T5[]) ReadValueArray<T1, T2, T3, T4, T5>(int N) {
var (v1, v2, v3, v4, v5) =
(new T1[N], new T2[N], new T3[N], new T4[N], new T5[N]);
for (int i = 0; i < N; i++) {
var (t1, t2, t3, t4, t5) = ReadValue<T1, T2, T3, T4, T5>();
v1[i] = t1;
v2[i] = t2;
v3[i] = t3;
v4[i] = t4;
v5[i] = t5;
}
return (v1, v2, v3, v4, v5);
}
public (T1[], T2[], T3[], T4[], T5[],
T6[]) ReadValueArray<T1, T2, T3, T4, T5, T6>(int N) {
var (v1, v2, v3, v4, v5, v6) =
(new T1[N], new T2[N], new T3[N], new T4[N], new T5[N], new T6[N]);
for (int i = 0; i < N; i++) {
var (t1, t2, t3, t4, t5, t6) = ReadValue<T1, T2, T3, T4, T5, T6>();
v1[i] = t1;
v2[i] = t2;
v3[i] = t3;
v4[i] = t4;
v5[i] = t5;
v6[i] = t6;
}
return (v1, v2, v3, v4, v5, v6);
}
public (T1[], T2[], T3[], T4[], T5[], T6[],
T7[]) ReadValueArray<T1, T2, T3, T4, T5, T6, T7>(int N) {
var (v1, v2, v3, v4, v5, v6, v7) =
(new T1[N], new T2[N], new T3[N], new T4[N], new T5[N], new T6[N],
new T7[N]);
for (int i = 0; i < N; i++) {
var (t1, t2, t3, t4, t5, t6, t7) =
ReadValue<T1, T2, T3, T4, T5, T6, T7>();
v1[i] = t1;
v2[i] = t2;
v3[i] = t3;
v4[i] = t4;
v5[i] = t5;
v6[i] = t6;
v7[i] = t7;
}
return (v1, v2, v3, v4, v5, v6, v7);
}
}
}
|
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
namespace AtCoder.Contest.D {
static class Program {
public static void Solve(Scanner cin) {
var (n, a, b) = cin.ReadValue<int, int, int>();
var h = cin.ReadLongArray(n);
long l = 0;
long r = 1000000010;
while (r - l > 1) {
long mid = l + (r - l) / 2;
if (isOk(h, mid, a, b))
r = mid;
else
l = mid;
}
Console.WriteLine(r);
}
public static bool isOk(long[] h, long k, int a, int b) {
return h.Select(x => Math.Max(0, (x - k * b + a - b - 1) / (a - b)))
.Sum() <= k;
}
public static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var cin = new Scanner();
Solve(cin);
Console.Out.Flush();
}
public static void YESNO(bool condition) {
if (condition)
Console.WriteLine("YES");
else
Console.WriteLine("NO");
}
public static void YesNo(bool condition) {
if (condition)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
public static void yesno(bool condition) {
if (condition)
Console.WriteLine("yes");
else
Console.WriteLine("no");
}
}
class Scanner {
string[] s;
int i;
char[] separator = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string Read() => ReadString();
public string ReadString() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(separator, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return ReadString();
i = 0;
return s[i++];
}
public string[] ReadStringArray(int N) {
string[] Array = new string[N];
for (int i = 0; i < N; i++) {
Array[i] = ReadString();
}
return Array;
}
public int ReadInt() { return int.Parse(ReadString()); }
public int[] ReadIntArray(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = ReadInt() + add;
}
return Array;
}
public long ReadLong() { return long.Parse(ReadString()); }
public long[] ReadLongArray(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = ReadLong() + add;
}
return Array;
}
public double ReadDouble() { return double.Parse(ReadString()); }
public double[] ReadDoubleArray(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = ReadDouble() + add;
}
return Array;
}
public T1 ReadValue<T1>() => (T1)Convert.ChangeType(ReadString(),
typeof(T1));
public (T1, T2) ReadValue<T1, T2>() {
var inputs = ReadStringArray(2);
var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
return (v1, v2);
}
public (T1, T2, T3) ReadValue<T1, T2, T3>() {
var inputs = ReadStringArray(3);
var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
return (v1, v2, v3);
}
public (T1, T2, T3, T4) ReadValue<T1, T2, T3, T4>() {
var inputs = ReadStringArray(4);
var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));
return (v1, v2, v3, v4);
}
public (T1, T2, T3, T4, T5) ReadValue<T1, T2, T3, T4, T5>() {
var inputs = ReadStringArray(5);
var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));
var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5));
return (v1, v2, v3, v4, v5);
}
public (T1, T2, T3, T4, T5, T6) ReadValue<T1, T2, T3, T4, T5, T6>() {
var inputs = ReadStringArray(6);
var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));
var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5));
var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6));
return (v1, v2, v3, v4, v5, v6);
}
public (T1, T2, T3, T4, T5, T6,
T7) ReadValue<T1, T2, T3, T4, T5, T6, T7>() {
var inputs = ReadStringArray(7);
var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));
var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5));
var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6));
var v7 = (T7)Convert.ChangeType(inputs[6], typeof(T7));
return (v1, v2, v3, v4, v5, v6, v7);
}
public T1[] ReadValueArray<T1>(int N) {
var v1 = new T1[N];
for (int i = 0; i < N; i++) {
v1[i] = ReadValue<T1>();
}
return v1;
}
public (T1[], T2[]) ReadValueArray<T1, T2>(int N) {
var (v1, v2) = (new T1[N], new T2[N]);
for (int i = 0; i < N; i++) {
var (t1, t2) = ReadValue<T1, T2>();
v1[i] = t1;
v2[i] = t2;
}
return (v1, v2);
}
public (T1[], T2[], T3[]) ReadValueArray<T1, T2, T3>(int N) {
var (v1, v2, v3) = (new T1[N], new T2[N], new T3[N]);
for (int i = 0; i < N; i++) {
var (t1, t2, t3) = ReadValue<T1, T2, T3>();
v1[i] = t1;
v2[i] = t2;
v3[i] = t3;
}
return (v1, v2, v3);
}
public (T1[], T2[], T3[], T4[]) ReadValueArray<T1, T2, T3, T4>(int N) {
var (v1, v2, v3, v4) = (new T1[N], new T2[N], new T3[N], new T4[N]);
for (int i = 0; i < N; i++) {
var (t1, t2, t3, t4) = ReadValue<T1, T2, T3, T4>();
v1[i] = t1;
v2[i] = t2;
v3[i] = t3;
v4[i] = t4;
}
return (v1, v2, v3, v4);
}
public (T1[], T2[], T3[], T4[],
T5[]) ReadValueArray<T1, T2, T3, T4, T5>(int N) {
var (v1, v2, v3, v4, v5) =
(new T1[N], new T2[N], new T3[N], new T4[N], new T5[N]);
for (int i = 0; i < N; i++) {
var (t1, t2, t3, t4, t5) = ReadValue<T1, T2, T3, T4, T5>();
v1[i] = t1;
v2[i] = t2;
v3[i] = t3;
v4[i] = t4;
v5[i] = t5;
}
return (v1, v2, v3, v4, v5);
}
public (T1[], T2[], T3[], T4[], T5[],
T6[]) ReadValueArray<T1, T2, T3, T4, T5, T6>(int N) {
var (v1, v2, v3, v4, v5, v6) =
(new T1[N], new T2[N], new T3[N], new T4[N], new T5[N], new T6[N]);
for (int i = 0; i < N; i++) {
var (t1, t2, t3, t4, t5, t6) = ReadValue<T1, T2, T3, T4, T5, T6>();
v1[i] = t1;
v2[i] = t2;
v3[i] = t3;
v4[i] = t4;
v5[i] = t5;
v6[i] = t6;
}
return (v1, v2, v3, v4, v5, v6);
}
public (T1[], T2[], T3[], T4[], T5[], T6[],
T7[]) ReadValueArray<T1, T2, T3, T4, T5, T6, T7>(int N) {
var (v1, v2, v3, v4, v5, v6, v7) =
(new T1[N], new T2[N], new T3[N], new T4[N], new T5[N], new T6[N],
new T7[N]);
for (int i = 0; i < N; i++) {
var (t1, t2, t3, t4, t5, t6, t7) =
ReadValue<T1, T2, T3, T4, T5, T6, T7>();
v1[i] = t1;
v2[i] = t2;
v3[i] = t3;
v4[i] = t4;
v5[i] = t5;
v6[i] = t6;
v7[i] = t7;
}
return (v1, v2, v3, v4, v5, v6, v7);
}
}
}
|
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 195, 54, 55, 0, 220, 39, 224, 39, 199], ["+", 0, 195, 54, 55, 0, 220, 39, 224, 39, 199], ["+", 0, 28, 0, 218, 8, 213, 63, 214, 205, 22], ["+", 0, 28, 0, 218, 8, 213, 63, 214, 0, 131], ["+", 0, 28, 0, 218, 8, 213, 63, 214, 141, 22], ["+", 0, 28, 0, 218, 8, 213, 3, 4, 0, 24], ["+", 0, 218, 8, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 28, 0, 218, 8, 213, 3, 4, 0, 21], ["+", 3, 4, 0, 28, 0, 16, 12, 23, 0, 25]]
| 8
| 2,668
| 13
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;
namespace AtCoderTemplate {
class ProgramD {
static void Main() {
int N = NextInt;
long A = NextInt, B = NextInt;
var list = TakeLine(N).Select(l => l[0]).ToList();
int left = 0, right = 1000000000;
long dif = A - B;
while (right - left > 1) {
int mid = (left + right) / 2;
long damage = (long)mid * B;
if (mid >= list.Sum(x => Math.Max((x - damage - 1) / dif + 1, 0))) {
right = mid;
} else {
left = mid;
}
}
System.Console.WriteLine(right);
}
}
}
namespace Library {
class Input {
static IEnumerator<string> enumerator =
new string[] {}.AsEnumerable().GetEnumerator();
public static string Line => Console.ReadLine();
public static string[] StrArr => Line.Split(' ');
public static int NextInt => int.Parse(NextWord());
public static long NextLong => long.Parse(NextWord());
public static List<int> IntList => StrArr.Select(int.Parse).ToList();
public static List<long> LongList => StrArr.Select(long.Parse).ToList();
public static IEnumerable<long[]> TakeLine(int N) {
return Enumerable.Repeat(0, N).Select(
_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
}
public static string NextWord() {
while (!enumerator.MoveNext()) {
enumerator = StrArr.AsEnumerable().GetEnumerator();
}
return enumerator.Current;
}
}
}
namespace Library {
class Modular {
public const int mod = 1000000007;
public readonly long value;
public Modular(long value) { this.value = value; }
public static implicit operator Modular(long a) {
var m = a % mod;
return new Modular((m < 0) ? m + mod : 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;
}
public 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, mod - 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) % mod));
}
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; }
}
}
namespace Library {
class MyMath {
public static long Gcd(long a, long b) { return b == 0 ? a : Gcd(b, a % b); }
public static long Sqrt(long n) {
if (n < 0)
return 0;
long a = 0, tmp = 0, b = 0;
for (int i = 62; i >= 0; i -= 2) {
tmp = (b << 1) + 1 <= (n >> i) ? 1 : 0;
a = a << 1 | tmp;
n -= (((b << 1) + 1) * tmp) << i;
b = (b << 1) + tmp + tmp;
}
return a;
}
public static long Nck(int n, int k) {
if (k == 0)
return 1;
if (n == 0)
return 0;
return n * Nck(n - 1, k - 1) / k;
}
}
}
namespace Library {
public class PriorityQueue<T> {
readonly List<T> _heap = new List<T>();
readonly Comparison<T> _comparison;
public PriorityQueue(Comparison<T> comparison) { _comparison = comparison; }
public PriorityQueue() : this(Comparer<T>.Default.Compare) {}
public PriorityQueue(IComparer<T> comparer) : this(comparer.Compare) {}
public void Enqueue(T item) {
_heap.Add(item);
int childID = _heap.Count - 1;
int parentID = (childID - 1) / 2;
while (childID > 0 && _comparison(_heap[parentID], _heap[childID]) > 0) {
Swap(parentID, childID);
childID = parentID;
parentID = (parentID - 1) / 2;
}
}
public T Dequeue() {
var first = _heap.First();
_heap[0] = _heap.Last();
_heap.RemoveAt(_heap.Count - 1);
int parentID = 0;
int childID = parentID * 2 + 2;
if (childID >= _heap.Count ||
_comparison(_heap[childID], _heap[childID - 1]) > 0)
childID--;
while (childID < _heap.Count &&
_comparison(_heap[parentID], _heap[childID]) > 0) {
Swap(parentID, childID);
parentID = childID;
childID = parentID * 2 + 2;
if (childID >= _heap.Count ||
_comparison(_heap[childID], _heap[childID - 1]) > 0)
childID--;
}
return first;
}
void Swap(int parent, int child) {
var tmp = _heap[parent];
_heap[parent] = _heap[child];
_heap[child] = tmp;
}
public T Peek() { return _heap[0]; }
public int Count => _heap.Count;
public bool Any() { return _heap.Any(); }
public List<T> Data => _heap;
}
}
namespace Library {
public class UnionFind {
public int[] Parents { get; set; }
public UnionFind(int size) {
Parents = Enumerable.Repeat(-1, size).ToArray();
}
public int Find(int num) {
if (Parents[num] < 0)
return num;
Parents[num] = Find(Parents[num]);
return Parents[num];
}
public int Size(int num) { return -Parents[Find(num)]; }
public bool Same(int a, int b) { return Find(a) == Find(b); }
public void Unite(int a, int b) {
int x = Find(a), y = Find(b);
if (Size(x) > Size(y)) {
Parents[x] += Parents[y];
Parents[y] = x;
} else {
Parents[y] += Parents[x];
Parents[x] = y;
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;
namespace AtCoderTemplate {
class ProgramD {
static void Main() {
int N = NextInt;
long A = NextLong, B = NextLong;
var list = TakeLine(N).Select(l => l[0]).ToList();
long left = 0, right = 1000000000, dif = A - B;
while (right - left > 1) {
long mid = (left + right) / 2, damage = mid * B;
if (mid >= list.Sum(x => {
if (x <= damage)
return 0;
return (x - damage - 1) / dif + 1;
})) {
right = mid;
} else {
left = mid;
}
}
System.Console.WriteLine(right);
}
}
}
namespace Library {
class Input {
static IEnumerator<string> enumerator =
new string[] {}.AsEnumerable().GetEnumerator();
public static string Line => Console.ReadLine();
public static string[] StrArr => Line.Split(' ');
public static int NextInt => int.Parse(NextWord());
public static long NextLong => long.Parse(NextWord());
public static List<int> IntList => StrArr.Select(int.Parse).ToList();
public static List<long> LongList => StrArr.Select(long.Parse).ToList();
public static IEnumerable<long[]> TakeLine(int N) {
return Enumerable.Repeat(0, N).Select(
_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
}
public static string NextWord() {
while (!enumerator.MoveNext()) {
enumerator = StrArr.AsEnumerable().GetEnumerator();
}
return enumerator.Current;
}
}
}
namespace Library {
class Modular {
public const int mod = 1000000007;
public readonly long value;
public Modular(long value) { this.value = value; }
public static implicit operator Modular(long a) {
var m = a % mod;
return new Modular((m < 0) ? m + mod : 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;
}
public 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, mod - 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) % mod));
}
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; }
}
}
namespace Library {
class MyMath {
public static long Gcd(long a, long b) { return b == 0 ? a : Gcd(b, a % b); }
public static long Sqrt(long n) {
if (n < 0)
return 0;
long a = 0, tmp = 0, b = 0;
for (int i = 62; i >= 0; i -= 2) {
tmp = (b << 1) + 1 <= (n >> i) ? 1 : 0;
a = a << 1 | tmp;
n -= (((b << 1) + 1) * tmp) << i;
b = (b << 1) + tmp + tmp;
}
return a;
}
public static long Nck(int n, int k) {
if (k == 0)
return 1;
if (n == 0)
return 0;
return n * Nck(n - 1, k - 1) / k;
}
}
}
namespace Library {
public class PriorityQueue<T> {
readonly List<T> _heap = new List<T>();
readonly Comparison<T> _comparison;
public PriorityQueue(Comparison<T> comparison) { _comparison = comparison; }
public PriorityQueue() : this(Comparer<T>.Default.Compare) {}
public PriorityQueue(IComparer<T> comparer) : this(comparer.Compare) {}
public void Enqueue(T item) {
_heap.Add(item);
int childID = _heap.Count - 1;
int parentID = (childID - 1) / 2;
while (childID > 0 && _comparison(_heap[parentID], _heap[childID]) > 0) {
Swap(parentID, childID);
childID = parentID;
parentID = (parentID - 1) / 2;
}
}
public T Dequeue() {
var first = _heap.First();
_heap[0] = _heap.Last();
_heap.RemoveAt(_heap.Count - 1);
int parentID = 0;
int childID = parentID * 2 + 2;
if (childID >= _heap.Count ||
_comparison(_heap[childID], _heap[childID - 1]) > 0)
childID--;
while (childID < _heap.Count &&
_comparison(_heap[parentID], _heap[childID]) > 0) {
Swap(parentID, childID);
parentID = childID;
childID = parentID * 2 + 2;
if (childID >= _heap.Count ||
_comparison(_heap[childID], _heap[childID - 1]) > 0)
childID--;
}
return first;
}
void Swap(int parent, int child) {
var tmp = _heap[parent];
_heap[parent] = _heap[child];
_heap[child] = tmp;
}
public T Peek() { return _heap[0]; }
public int Count => _heap.Count;
public bool Any() { return _heap.Any(); }
public List<T> Data => _heap;
}
}
namespace Library {
public class UnionFind {
public int[] Parents { get; set; }
public UnionFind(int size) {
Parents = Enumerable.Repeat(-1, size).ToArray();
}
public int Find(int num) {
if (Parents[num] < 0)
return num;
Parents[num] = Find(Parents[num]);
return Parents[num];
}
public int Size(int num) { return -Parents[Find(num)]; }
public bool Same(int a, int b) { return Find(a) == Find(b); }
public void Unite(int a, int b) {
int x = Find(a), y = Find(b);
if (Size(x) > Size(y)) {
Parents[x] += Parents[y];
Parents[y] = x;
} else {
Parents[y] += Parents[x];
Parents[x] = y;
}
}
}
}
|
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 0, 21], ["-", 0, 52, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 52, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 52, 8, 196, 0, 197, 0, 35], ["+", 0, 52, 8, 196, 0, 197, 0, 198, 0, 21], ["-", 0, 200, 0, 212, 0, 16, 31, 74, 0, 24], ["-", 0, 200, 0, 212, 0, 16, 31, 74, 39, 199], ["-", 0, 200, 0, 212, 0, 16, 31, 74, 0, 25], ["-", 0, 28, 0, 218, 8, 213, 63, 214, 205, 22], ["-", 0, 28, 0, 218, 8, 213, 63, 214, 0, 131], ["-", 0, 28, 0, 218, 8, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 218, 8, 196, 0, 45], ["+", 0, 28, 0, 218, 8, 196, 0, 57, 0, 121], ["+", 0, 218, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 218, 8, 196, 0, 57, 15, 16, 17, 19], ["+", 0, 218, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 0, 28, 0, 218, 8, 196, 0, 57, 0, 25], ["+", 0, 218, 8, 196, 0, 57, 64, 37, 0, 38], ["+", 0, 218, 8, 196, 0, 57, 64, 37, 0, 203], ["+", 0, 218, 8, 196, 0, 57, 64, 37, 0, 35], ["+", 0, 28, 0, 218, 8, 196, 0, 37, 0, 38], ["-", 0, 28, 0, 218, 8, 213, 3, 4, 0, 21], ["-", 0, 218, 8, 213, 3, 4, 0, 28, 0, 203], ["-", 0, 28, 0, 218, 8, 213, 3, 4, 0, 25], ["+", 0, 28, 0, 218, 8, 196, 0, 37, 0, 35], ["+", 3, 4, 0, 28, 0, 218, 8, 196, 0, 46]]
| 8
| 1,564
| 35
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;
public class D {
public static void Main() { Console.WriteLine((new Solver()).Solve()); }
}
public class Solver {
public int N { get; private set; }
public long A { get; private set; }
public long B { get; private set; }
public long[] h { get; private set; }
public Solver() {
N = GetInt();
A = GetLong();
B = GetLong();
h = new long[N];
for (int i = 0; i < N; i++)
h[i] = GetLong();
}
public long Solve() {
long lb = 0;
long ub = 1000000000000;
while (lb < ub) {
long mid = (lb + ub) >> 1;
if (enough(mid))
ub = mid;
else
lb = mid + 1;
}
return lb;
}
private bool enough(long T) {
long sum = 0;
for (int i = 0; i < N; i++)
sum += (h[i] - B * T + (A - B - 1)) / (A - B);
return (sum <= T);
}
}
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() { return int.Parse(getArg()); }
public static long GetLong() { return long.Parse(getArg()); }
public static double GetDouble() { return double.Parse(getArg()); }
public static string GetString() { return getArg(); }
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;
public class D {
public static void Main() { Console.WriteLine((new Solver()).Solve()); }
}
public class Solver {
public int N { get; private set; }
public long A { get; private set; }
public long B { get; private set; }
public long[] h { get; private set; }
public Solver() {
N = GetInt();
A = GetLong();
B = GetLong();
h = new long[N];
for (int i = 0; i < N; i++)
h[i] = GetLong();
}
public long Solve() {
long lb = 0;
long ub = 1000000000;
while (lb < ub) {
long mid = (lb + ub) >> 1;
if (enough(mid))
ub = mid;
else
lb = mid + 1;
}
return lb;
}
private bool enough(long T) {
long sum = 0;
for (int i = 0; i < N; i++) {
if (h[i] <= B * T)
continue;
sum += (h[i] - B * T + (A - B - 1)) / (A - B);
}
return (sum <= T);
}
}
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() { return int.Parse(getArg()); }
public static long GetLong() { return long.Parse(getArg()); }
public static double GetDouble() { return double.Parse(getArg()); }
public static string GetString() { return getArg(); }
}
|
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 45], ["+", 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, 19], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 48], ["+", 8, 196, 0, 57, 15, 16, 12, 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], ["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46]]
| 8
| 420
| 17
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//解説AC
namespace ABC_D {
class D063 {
static void Main(string[] args) {
int[] a = Console.ReadLine().Split(' ').Select(z => int.Parse(z)).ToArray();
int N = a[0], A = a[1], B = a[2];
int[] h = new int[N];
for (int i = 0; i < N; i++) {
h[i] = int.Parse(Console.ReadLine());
}
int r = BinarySearch(h, A, B);
Console.WriteLine(r);
}
static int BinarySearch(int[] h, int A, int B) {
int s = 0;
int t = int.MaxValue - 1;
while (s + 1 < t) {
int mid = (s + t) / 2;
if (Judge(h, mid, A, B)) {
t = mid;
} else {
s = mid;
}
}
return t;
}
static bool Judge(int[] h, int T, int A, int B) {
//全体ダメージ
long d = (long)T * B;
long sum = 0;
for (int i = 0; i < h.Length; i++) {
sum += (long)Math.Ceiling((double)(h[i] - d) / (A - B));
}
if (sum <= T)
return true;
else
return false;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//解説AC
namespace ABC_D {
class D063 {
static void Main(string[] args) {
// string path = @"C:\Contest\CSharp\TaskSample\ABC_D063_b05";
// System.IO.StreamReader sr = new System.IO.StreamReader(path);
// System.Console.SetIn(sr);
int[] a = Console.ReadLine().Split(' ').Select(z => int.Parse(z)).ToArray();
int N = a[0], A = a[1], B = a[2];
int[] h = new int[N];
for (int i = 0; i < N; i++) {
h[i] = int.Parse(Console.ReadLine());
}
int r = BinarySearch(h, A, B);
Console.WriteLine(r);
}
static int BinarySearch(int[] h, int A, int B) {
int s = 0;
int t = int.MaxValue;
while (s + 1 < t) {
int mid = (s + t) / 2;
if (Judge(h, mid, A, B)) {
t = mid;
} else {
s = mid;
}
}
return t;
}
static bool Judge(int[] h, int T, int A, int B) {
//全体ダメージ
long d = (long)T * B;
long sum = 0;
for (int i = 0; i < h.Length; i++) {
if (h[i] > d) {
sum += (long)Math.Ceiling((double)(h[i] - d) / (A - B));
}
}
if (sum <= T)
return true;
else
return false;
}
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 33], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["+", 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, 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, 196, 0, 45], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 341
| 13
|
using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;
class Program {
private static readonly Scanner sc = new Scanner();
static void Main(string[] args) {
var n = sc.Int;
var a = sc.Long;
var b = sc.Long;
var sn = new long[n];
for (var i = 0; i < n; i++)
sn[i] = sc.Int;
int l = 0;
int r = 1000000010;
while (r - l > 1) {
int mid = (l + r) / 2;
long cnt = 0;
for (var i = 0; i < n; i++) {
cnt += (sn[i] - b * mid + a - b - 1) / (a - b);
}
bool ok = cnt <= mid;
if (ok)
r = mid;
else
l = mid;
}
Console.WriteLine(r);
}
}
class Scanner {
private string[] _str = new string[0];
private int _i;
public string Line {
get { return Console.ReadLine(); }
}
public string Str {
get {
if (_i >= _str.Length) {
_str = Line.Split(' ');
_i = 0;
}
return _str[_i++];
}
}
public string[] StrArr {
get { return Line.Split(' '); }
}
public int Int {
get { return int.Parse(Str); }
}
public int[] IntArr {
get { return Line.Split(' ').Select(int.Parse).ToArray(); }
}
public long Long {
get { return long.Parse(Str); }
}
public long[] LongArr {
get { return Line.Split(' ').Select(long.Parse).ToArray(); }
}
public double Double {
get { return double.Parse(Str); }
}
public double[] DoubleArr {
get { return Line.Split(' ').Select(double.Parse).ToArray(); }
}
}
|
using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;
class Program {
private static readonly Scanner sc = new Scanner();
static void Main(string[] args) {
var n = sc.Int;
var a = sc.Long;
var b = sc.Long;
var sn = new long[n];
for (var i = 0; i < n; i++)
sn[i] = sc.Int;
int l = 0;
int r = 1000000010;
while (r - l > 1) {
int mid = (l + r) / 2;
long cnt = 0;
for (var i = 0; i < n; i++) {
long res = sn[i] - b * mid;
if (res > 0)
cnt += (res + a - b - 1) / (a - b);
}
bool ok = cnt <= mid;
if (ok)
r = mid;
else
l = mid;
}
Console.WriteLine(r);
}
}
class Scanner {
private string[] _str = new string[0];
private int _i;
public string Line {
get { return Console.ReadLine(); }
}
public string Str {
get {
if (_i >= _str.Length) {
_str = Line.Split(' ');
_i = 0;
}
return _str[_i++];
}
}
public string[] StrArr {
get { return Line.Split(' '); }
}
public int Int {
get { return int.Parse(Str); }
}
public int[] IntArr {
get { return Line.Split(' ').Select(int.Parse).ToArray(); }
}
public long Long {
get { return long.Parse(Str); }
}
public long[] LongArr {
get { return Line.Split(' ').Select(long.Parse).ToArray(); }
}
public double Double {
get { return double.Parse(Str); }
}
public double[] DoubleArr {
get { return Line.Split(' ').Select(double.Parse).ToArray(); }
}
}
|
[["-", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["-", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 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], ["+", 8, 196, 0, 7, 8, 196, 0, 197, 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, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 107], ["+", 64, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 31, 23, 0, 16, 31, 16, 31, 16, 31, 22]]
| 8
| 439
| 17
|
using System;
using System.Linq;
class Program {
static void Main() {
int N = int.Parse(Console.ReadLine());
int[] s = new int[N];
for (int i = 0; i < N; i++) {
s[i] = int.Parse(Console.ReadLine());
}
int score = s.Sum();
if (score % 10 == 0 && s.Any(x => x % 10 != 0)) {
score -= s.Where(x => x % 10 != 0).Min();
}
Console.WriteLine(score);
}
}
|
using System;
using System.Linq;
class Program {
static void Main() {
int N = int.Parse(Console.ReadLine());
int[] s = new int[N];
for (int i = 0; i < N; i++) {
s[i] = int.Parse(Console.ReadLine());
}
int score = s.Sum();
if (score % 10 == 0) {
if (s.Any(x => x % 10 != 0)) {
score -= s.Where(x => x % 10 != 0).Min();
} else {
score = 0;
}
}
Console.WriteLine(score);
}
}
|
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 95], ["+", 0, 57, 64, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 12, 203], ["+", 64, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["+", 0, 57, 64, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 134
| 13
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace NotFounds {
public class Program {
public static void Main(string[] args) { new Program().Solve(); }
public void Solve() {
var cin = new MyInputStream();
var N = cin.ri();
var s = new int[N];
for (int i = 0; i < N; ++i)
s[i] = cin.ri();
Array.Sort(s);
var sum = s.Sum();
if (sum % 10 != 0) {
WriteLine(sum);
return;
} else {
for (int i = N - 1; i >= 0; --i) {
if ((sum - s[i]) % 10 != 0) {
WriteLine(sum - s[i]);
return;
}
}
}
WriteLine(0);
}
}
public class MyInputStream {
private char separator = ' ';
private Queue<string> inputStream;
public MyInputStream(char separator = ' ') {
this.separator = separator;
inputStream = new Queue<string>();
}
public string Read() {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = Console.ReadLine().Trim().Split(separator);
for (int i = 0; i < tmp.Length; i++) {
inputStream.Enqueue(tmp[i]);
}
return inputStream.Dequeue();
}
public string ReadLine() => Console.ReadLine();
public int ReadInt() => int.Parse(Read());
public long ReadLong() => long.Parse(Read());
public double ReadDouble() => double.Parse(Read());
public string r() => Read();
public int ri() => ReadInt();
public long rl() => ReadLong();
public double rd() => ReadDouble();
}
}
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace NotFounds {
public class Program {
public static void Main(string[] args) { new Program().Solve(); }
public void Solve() {
var cin = new MyInputStream();
var N = cin.ri();
var s = new int[N];
for (int i = 0; i < N; ++i)
s[i] = cin.ri();
Array.Sort(s);
var sum = s.Sum();
if (sum % 10 != 0) {
WriteLine(sum);
return;
} else {
for (int i = 0; i < N; ++i) {
if ((sum - s[i]) % 10 != 0) {
WriteLine(sum - s[i]);
return;
}
}
}
WriteLine(0);
}
}
public class MyInputStream {
private char separator = ' ';
private Queue<string> inputStream;
public MyInputStream(char separator = ' ') {
this.separator = separator;
inputStream = new Queue<string>();
}
public string Read() {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = Console.ReadLine().Trim().Split(separator);
for (int i = 0; i < tmp.Length; i++) {
inputStream.Enqueue(tmp[i]);
}
return inputStream.Dequeue();
}
public string ReadLine() => Console.ReadLine();
public int ReadInt() => int.Parse(Read());
public long ReadLong() => long.Parse(Read());
public double ReadDouble() => double.Parse(Read());
public string r() => Read();
public int ri() => ReadInt();
public long rl() => ReadLong();
public double rd() => ReadDouble();
}
}
|
[["-", 10, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["-", 10, 198, 0, 200, 0, 212, 0, 16, 17, 33], ["-", 10, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 57, 75, 196, 0, 7, 15, 16, 17, 20], ["-", 0, 57, 75, 196, 0, 7, 15, 16, 12, 203], ["+", 0, 57, 75, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 57, 75, 196, 0, 7, 15, 16, 12, 22], ["-", 0, 57, 75, 196, 0, 7, 26, 241, 0, 68], ["+", 0, 57, 75, 196, 0, 7, 26, 241, 0, 29]]
| 8
| 435
| 10
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;
using static AtCoder.CalcL;
namespace AtCoder {
class AC {
const int MOD = 1000000007;
// const int MOD = 998244353;
const int INF = int.MaxValue / 2;
const long SINF = long.MaxValue / 2;
const double EPS = 1e-8;
static readonly int[] dI = { 0, 1, 0, -1 };
static readonly int[] dJ = { 1, 0, -1, 0 };
// static List<List<int>> G = new List<List<int>>();
// static List<List<Edge>>G = new List<List<Edge>>();
// static List<Edge> E = new List<Edge>();
static void Main(string[] args) {
// var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush =
// false }; Console.SetOut(sw);
var cin = new Scanner();
var input = cin.ReadSplitInt();
int N = input[0];
long K = input[1];
var sum = new List<Tuple<long, int>>();
var ind = new int[N + 1];
for (var i = 0; i < N; i++) {
var a = long.Parse(Console.ReadLine()) - K;
if (i == 0) {
sum.Add(new Tuple<long, int>(a, 1));
} else {
sum.Add(new Tuple<long, int>(sum[i - 1].Item1 + a, i + 1));
}
}
var seg = new SegmentTree<int>(N + 1, (x, y) => x + y, 0);
sum.Add(new Tuple<long, int>(0, 0));
sum.Sort((x, y) => {
long dif = x.Item1 - y.Item1;
long idif = x.Item2 - y.Item2;
return dif == 0 ? (idif == 0 ? 0 : (idif > 0 ? 1 : -1))
: (dif > 0 ? 1 : -1);
});
seg.Assign(0, 1);
for (var i = 1; i <= N; i++) {
ind[sum[i].Item2] = i;
seg.Assign(i, 0);
}
seg.Set_All();
long ans = 0;
for (var i = 1; i <= N; i++) {
ans += seg.Query_Answer(0, ind[i]);
seg.Query_Update(ind[i], 1);
}
Console.WriteLine(ans);
// Console.Out.Flush();
}
struct Edge {
public int from;
public int to;
public long dist;
public Edge(int t, long c) {
from = -1;
to = t;
dist = c;
}
public Edge(int f, int t, long c) {
from = f;
to = t;
dist = c;
}
}
}
public class SegmentTree<T> {
int n;
T[] Tree;
Func<T, T, T> f;
T ex;
public SegmentTree(int size, Func<T, T, T> fun, T exvalue) {
f = fun;
ex = exvalue;
n = 1;
while (n < size)
n <<= 1;
Tree = new T[(n << 1) - 1];
for (var i = 0; i < Tree.Length; i++)
Tree[i] = ex;
}
public SegmentTree(int size, Func<T, T, T> f, T exvalue, T initial)
: this(size, f, exvalue) {
for (var i = 0; i < size; i++)
Tree[i + n - 1] = initial;
Set_All();
}
public void Set_All() {
for (var i = n - 2; i >= 0; i--) {
Tree[i] = f(Tree[(i << 1) + 1], Tree[(i << 1) + 2]);
}
}
public void Assign(int ind, T val) { Tree[ind + n - 1] = val; }
public void Update(int ind) {
int i = ind + n - 1;
while (i > 0) {
i = (i - 1) >> 1;
Tree[i] = f(Tree[(i << 1) + 1], Tree[(i << 1) + 2]);
}
}
public void Query_Update(int ind, T val) {
Assign(ind, val);
Update(ind);
}
public T Query_Answer(int l, int r) //[l,r)
{
return Scanning(l, r, 0, 0, n);
}
private T Scanning(int l, int r, int ind, int ind_l, int ind_r) {
if (ind_r <= l || r <= ind_l) {
return ex;
}
if (l <= ind_l && ind_r <= r) {
return Tree[ind];
}
return f(Scanning(l, r, (ind << 1) + 1, ind_l, (ind_l + ind_r) >> 1),
Scanning(l, r, (ind << 1) + 2, (ind_l + ind_r) >> 1, ind_r));
}
public T Look(int ind) { return Tree[ind + n - 1]; }
public void Debug_Display_All() {
for (var i = 0; i < n; i++)
Console.Write($"{Tree[i + n - 1]} ");
Console.WriteLine();
}
}
public class Scanner {
public int[] ReadSplitInt() {
return ConvertAll(Console.ReadLine().Split(), int.Parse);
}
public long[] ReadSplitLong() {
return ConvertAll(Console.ReadLine().Split(), long.Parse);
}
public double[] ReadSplit_Double() {
return ConvertAll(Console.ReadLine().Split(), double.Parse);
}
}
public static class Tool {
static public void Initialize<T>(ref T[] array, T initialvalue) {
for (var i = 0; i < array.Length; i++) {
array[i] = initialvalue;
}
}
static public void Swap<T>(ref T a, ref T b) {
T keep = a;
a = b;
b = keep;
}
static public void Display<T>(T[,] array2d, int n, int m) {
for (var i = 0; i < n; i++) {
for (var j = 0; j < m; j++) {
Console.Write($"{array2d[i, j]} ");
}
Console.WriteLine();
}
}
static public long LPow(int a, int b) { return (long)Pow(a, b); }
}
static public class CalcI {
public static int Gcd(int a, int b) {
if (a * b == 0) {
return Max(a, b);
}
return a % b == 0 ? b : Gcd(b, a % b);
}
public static int Lcm(int a, int b) {
int g = Gcd(a, b);
return a / g * b;
}
public static int Ceil(int n, int div) { return (n + div - 1) / div; }
}
static public class CalcL {
public static long Gcd(long a, long b) {
if (a * b == 0) {
return Max(a, b);
}
return a % b == 0 ? b : Gcd(b, a % b);
}
public static long Lcm(long a, long b) {
long g = Gcd(a, b);
return a / g * b;
}
public static long Ceil(long n, long div) { return (n + div - 1) / div; }
}
class Modulo {
private const int M = 1000000007;
private readonly int[] m_facs;
public int Mul(int a, int b) { return (int)(Math.BigMul(a, b) % M); }
public Modulo(int n) {
m_facs = new int[n + 1];
m_facs[0] = 1;
for (int i = 1; i <= n; ++i) {
m_facs[i] = Mul(m_facs[i - 1], i);
}
}
public int Fac(int n) { return m_facs[n]; }
public int Pow(int a, int m) {
switch (m) {
case 0:
return 1;
case 1:
return a;
default:
int p1 = Pow(a, m / 2);
int p2 = Mul(p1, p1);
return ((m % 2) == 0) ? p2 : Mul(p2, a);
}
}
public int Div(int a, int b) { return Mul(a, Pow(b, M - 2)); }
public int Ncr(int n, int r) {
if (n < r) {
return 0;
}
if (n == r) {
return 1;
}
int res = Fac(n);
res = Div(res, Fac(r));
res = Div(res, Fac(n - r));
return res;
}
public Modulo() {}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;
using static AtCoder.CalcL;
namespace AtCoder {
class AC {
const int MOD = 1000000007;
// const int MOD = 998244353;
const int INF = int.MaxValue / 2;
const long SINF = long.MaxValue / 2;
const double EPS = 1e-8;
static readonly int[] dI = { 0, 1, 0, -1 };
static readonly int[] dJ = { 1, 0, -1, 0 };
// static List<List<int>> G = new List<List<int>>();
// static List<List<Edge>>G = new List<List<Edge>>();
// static List<Edge> E = new List<Edge>();
static void Main(string[] args) {
// var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush =
// false }; Console.SetOut(sw);
var cin = new Scanner();
var input = cin.ReadSplitInt();
int N = input[0];
long K = input[1];
var sum = new List<Tuple<long, int>>();
var ind = new int[N + 1];
for (var i = 0; i < N; i++) {
var a = long.Parse(Console.ReadLine()) - K;
if (i == 0) {
sum.Add(new Tuple<long, int>(a, 1));
} else {
sum.Add(new Tuple<long, int>(sum[i - 1].Item1 + a, i + 1));
}
}
var seg = new SegmentTree<int>(N + 1, (x, y) => x + y, 0);
sum.Add(new Tuple<long, int>(0, 0));
sum.Sort((x, y) => {
long dif = x.Item1 - y.Item1;
long idif = x.Item2 - y.Item2;
return dif == 0 ? (idif == 0 ? 0 : (idif > 0 ? 1 : -1))
: (dif > 0 ? 1 : -1);
});
for (var i = 0; i <= N; i++) {
ind[sum[i].Item2] = i;
seg.Assign(i, 0);
}
seg.Set_All();
long ans = 0;
for (var i = 0; i <= N; i++) {
ans += seg.Query_Answer(0, ind[i]);
seg.Query_Update(ind[i], 1);
}
Console.WriteLine(ans);
// Console.Out.Flush();
}
struct Edge {
public int from;
public int to;
public long dist;
public Edge(int t, long c) {
from = -1;
to = t;
dist = c;
}
public Edge(int f, int t, long c) {
from = f;
to = t;
dist = c;
}
}
}
public class SegmentTree<T> {
int n;
T[] Tree;
Func<T, T, T> f;
T ex;
public SegmentTree(int size, Func<T, T, T> fun, T exvalue) {
f = fun;
ex = exvalue;
n = 1;
while (n < size)
n <<= 1;
Tree = new T[(n << 1) - 1];
for (var i = 0; i < Tree.Length; i++)
Tree[i] = ex;
}
public SegmentTree(int size, Func<T, T, T> f, T exvalue, T initial)
: this(size, f, exvalue) {
for (var i = 0; i < size; i++)
Tree[i + n - 1] = initial;
Set_All();
}
public void Set_All() {
for (var i = n - 2; i >= 0; i--) {
Tree[i] = f(Tree[(i << 1) + 1], Tree[(i << 1) + 2]);
}
}
public void Assign(int ind, T val) { Tree[ind + n - 1] = val; }
public void Update(int ind) {
int i = ind + n - 1;
while (i > 0) {
i = (i - 1) >> 1;
Tree[i] = f(Tree[(i << 1) + 1], Tree[(i << 1) + 2]);
}
}
public void Query_Update(int ind, T val) {
Assign(ind, val);
Update(ind);
}
public T Query_Answer(int l, int r) //[l,r)
{
return Scanning(l, r, 0, 0, n);
}
private T Scanning(int l, int r, int ind, int ind_l, int ind_r) {
if (ind_r <= l || r <= ind_l) {
return ex;
}
if (l <= ind_l && ind_r <= r) {
return Tree[ind];
}
return f(Scanning(l, r, (ind << 1) + 1, ind_l, (ind_l + ind_r) >> 1),
Scanning(l, r, (ind << 1) + 2, (ind_l + ind_r) >> 1, ind_r));
}
public T Look(int ind) { return Tree[ind + n - 1]; }
public void Debug_Display_All() {
for (var i = 0; i < n; i++)
Console.Write($"{Tree[i + n - 1]} ");
Console.WriteLine();
}
}
public class Scanner {
public int[] ReadSplitInt() {
return ConvertAll(Console.ReadLine().Split(), int.Parse);
}
public long[] ReadSplitLong() {
return ConvertAll(Console.ReadLine().Split(), long.Parse);
}
public double[] ReadSplit_Double() {
return ConvertAll(Console.ReadLine().Split(), double.Parse);
}
}
public static class Tool {
static public void Initialize<T>(ref T[] array, T initialvalue) {
for (var i = 0; i < array.Length; i++) {
array[i] = initialvalue;
}
}
static public void Swap<T>(ref T a, ref T b) {
T keep = a;
a = b;
b = keep;
}
static public void Display<T>(T[,] array2d, int n, int m) {
for (var i = 0; i < n; i++) {
for (var j = 0; j < m; j++) {
Console.Write($"{array2d[i, j]} ");
}
Console.WriteLine();
}
}
static public long LPow(int a, int b) { return (long)Pow(a, b); }
}
static public class CalcI {
public static int Gcd(int a, int b) {
if (a * b == 0) {
return Max(a, b);
}
return a % b == 0 ? b : Gcd(b, a % b);
}
public static int Lcm(int a, int b) {
int g = Gcd(a, b);
return a / g * b;
}
public static int Ceil(int n, int div) { return (n + div - 1) / div; }
}
static public class CalcL {
public static long Gcd(long a, long b) {
if (a * b == 0) {
return Max(a, b);
}
return a % b == 0 ? b : Gcd(b, a % b);
}
public static long Lcm(long a, long b) {
long g = Gcd(a, b);
return a / g * b;
}
public static long Ceil(long n, long div) { return (n + div - 1) / div; }
}
class Modulo {
private const int M = 1000000007;
private readonly int[] m_facs;
public int Mul(int a, int b) { return (int)(Math.BigMul(a, b) % M); }
public Modulo(int n) {
m_facs = new int[n + 1];
m_facs[0] = 1;
for (int i = 1; i <= n; ++i) {
m_facs[i] = Mul(m_facs[i - 1], i);
}
}
public int Fac(int n) { return m_facs[n]; }
public int Pow(int a, int m) {
switch (m) {
case 0:
return 1;
case 1:
return a;
default:
int p1 = Pow(a, m / 2);
int p2 = Mul(p1, p1);
return ((m % 2) == 0) ? p2 : Mul(p2, a);
}
}
public int Div(int a, int b) { return Mul(a, Pow(b, M - 2)); }
public int Ncr(int n, int r) {
if (n < r) {
return 0;
}
if (n == r) {
return 1;
}
int res = Fac(n);
res = Div(res, Fac(r));
res = Div(res, Fac(n - r));
return res;
}
public Modulo() {}
}
}
|
[["-", 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, 203], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 21], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203]]
| 8
| 1,903
| 13
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class AtCoderA {
static void Main() {
var sc = new Scanner();
long n = sc.NextInt();
long a = sc.NextInt();
long b = sc.NextInt();
long answer = (b - a) * (n - 2) + 1;
Console.WriteLine(answer);
}
class Scanner {
private string[] _line;
private int _index;
private const char Separator = ' ';
public Scanner() {
_line = new string[0];
_index = 0;
}
public string Next() {
while (_index >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_index = 0;
}
return _line[_index++];
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
public decimal NextDecimal() => decimal.Parse(Next());
public char NextChar() => Next()[0];
public char[] NextCharArray() => Next().ToCharArray();
public string[] Array() {
_line = Console.ReadLine().Split(Separator);
_index = _line.Length;
return _line;
}
public int[] IntArray() => Array().Select(int.Parse).ToArray();
public long[] LongArray() => Array().Select(long.Parse).ToArray();
public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class AtCoderA {
static void Main() {
var sc = new Scanner();
long n = sc.NextInt();
long a = sc.NextInt();
long b = sc.NextInt();
long answer = (b - a) * (n - 2) + 1;
if (a > b) {
answer = 0;
}
if (n == 1 && a != b) {
answer = 0;
}
Console.WriteLine(answer);
}
class Scanner {
private string[] _line;
private int _index;
private const char Separator = ' ';
public Scanner() {
_line = new string[0];
_index = 0;
}
public string Next() {
while (_index >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_index = 0;
}
return _line[_index++];
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
public decimal NextDecimal() => decimal.Parse(Next());
public char NextChar() => Next()[0];
public char[] NextCharArray() => Next().ToCharArray();
public string[] Array() {
_line = Console.ReadLine().Split(Separator);
_index = _line.Length;
return _line;
}
public int[] IntArray() => Array().Select(int.Parse).ToArray();
public long[] LongArray() => Array().Select(long.Parse).ToArray();
public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 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, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 79], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 22]]
| 8
| 385
| 28
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Numerics;
using System.IO;
using System.Runtime.InteropServices;
using static System.Math;
using static Math2;
using static io;
using static Utils;
public class CompetitiveProgramming {
public void Solve() {
var o = Longs;
var N = o[0];
var A = o[1];
var B = o[2];
if (N == 1) {
Write((A == B) ? 1 : 0);
}
Write((N - 2) * (B - A) + 1);
}
string reading() {
string path = @"..\..\inputgenerator\test\ig.txt";
return File.ReadAllText(path);
}
}
public static class Math2 {
public const int INF = 1 << 29;
public const long INFL = 1L << 60;
public const long MOD = 1000000007;
public const int MOD2 = 998244353;
public static long Power(long i, long N, long MOD = 1000000007) // i^N
{
long res = 1;
while (N > 0) {
if ((N & 1) != 0)
res = res * i % MOD;
i = i * i % MOD;
N >>= 1;
}
return res;
}
public static long Power2(long i, long N) // i^N
{
long res = 1;
while (N > 0) {
if ((N & 1) != 0)
res = res * i;
i = i * i;
N >>= 1;
}
return res;
}
public static long GCD(long i, long N) {
if (i > N)
Swap(ref i, ref N);
if (i == 0)
return N;
while (N != 0) {
var r = i % N;
i = N;
N = r;
}
return i;
}
public static long LCM(long i, long N) => i * N / GCD(i, N);
public static long Comb(long N, long R, int MOD = 1000000007) {
long ret = 1;
long x = 1;
for (long i = N; i >= N - R + 1; --i) {
ret = ret / x * i;
ret %= MOD;
x++;
}
return ret;
}
public static long Comb2(long N, long R) {
long Nume = 1;
long Deno = 1;
if (R > N - R)
Swap(ref N, ref R);
for (long i = 1; i <= R; ++i) {
Deno *= i;
Nume *= N - i + 1;
}
return Deno / Nume;
}
}
public static class Utils {
public static void Swap<T>(ref T A, ref T B) {
T x = A;
A = B;
B = x;
}
public static int DigitSum(int N) {
string s = N.ToString();
int ret = 0;
for (int i = 0; i < s.Length; ++i)
ret += s[i] - '0';
return ret;
}
}
class Program {
static void Main(string[] args) {
var CompetitiveProgramming = new CompetitiveProgramming();
CompetitiveProgramming.Solve();
}
}
public static class io {
public static string Str => Console.ReadLine();
public static string[] Strs => Str.Split(' ');
public static long[] Longs => Strs.Select(long.Parse).ToArray();
public static int[] Ints => Strs.Select(int.Parse).ToArray();
public static char[] Chars => Str.ToArray();
public static double[] Doubles => Strs.Select(double.Parse).ToArray();
public static long Long1 => Longs[0];
public static int Int1 => Ints[0];
public static char Char1 => Chars[0];
public static double Double1 => Doubles[0];
public static long[] VerticalRead(int N) {
long[] A = new long[N];
for (int i = 0; i < N; ++i)
A[i] = Long1;
return A;
}
public static void Write(string a) => Console.WriteLine(a);
public static void Write(params object[] i) => Write(string.Join(" ", i));
public static void Write<T>(IEnumerable<T> a) => Write(string.Join(" ", a));
public static void Verticalwrite<T>(IEnumerable<T> a) {
foreach (var z in a)
Write(z);
}
public static void YN(bool i) {
if (i)
Write("Yes");
else
Write("No");
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Numerics;
using System.IO;
using System.Runtime.InteropServices;
using static System.Math;
using static Math2;
using static io;
using static Utils;
public class CompetitiveProgramming {
public void Solve() {
var o = Longs;
var N = o[0];
var A = o[1];
var B = o[2];
if (A > B)
Write(0);
else if (N == 1) {
Write((A == B) ? 1 : 0);
} else
Write((N - 2) * (B - A) + 1);
}
string reading() {
string path = @"..\..\inputgenerator\test\ig.txt";
return File.ReadAllText(path);
}
}
public static class Math2 {
public const int INF = 1 << 29;
public const long INFL = 1L << 60;
public const long MOD = 1000000007;
public const int MOD2 = 998244353;
public static long Power(long i, long N, long MOD = 1000000007) // i^N
{
long res = 1;
while (N > 0) {
if ((N & 1) != 0)
res = res * i % MOD;
i = i * i % MOD;
N >>= 1;
}
return res;
}
public static long Power2(long i, long N) // i^N
{
long res = 1;
while (N > 0) {
if ((N & 1) != 0)
res = res * i;
i = i * i;
N >>= 1;
}
return res;
}
public static long GCD(long i, long N) {
if (i > N)
Swap(ref i, ref N);
if (i == 0)
return N;
while (N != 0) {
var r = i % N;
i = N;
N = r;
}
return i;
}
public static long LCM(long i, long N) => i * N / GCD(i, N);
public static long Comb(long N, long R, int MOD = 1000000007) {
long ret = 1;
long x = 1;
for (long i = N; i >= N - R + 1; --i) {
ret = ret / x * i;
ret %= MOD;
x++;
}
return ret;
}
public static long Comb2(long N, long R) {
long Nume = 1;
long Deno = 1;
if (R > N - R)
Swap(ref N, ref R);
for (long i = 1; i <= R; ++i) {
Deno *= i;
Nume *= N - i + 1;
}
return Deno / Nume;
}
}
public static class Utils {
public static void Swap<T>(ref T A, ref T B) {
T x = A;
A = B;
B = x;
}
public static int DigitSum(int N) {
string s = N.ToString();
int ret = 0;
for (int i = 0; i < s.Length; ++i)
ret += s[i] - '0';
return ret;
}
}
class Program {
static void Main(string[] args) {
var CompetitiveProgramming = new CompetitiveProgramming();
CompetitiveProgramming.Solve();
}
}
public static class io {
public static string Str => Console.ReadLine();
public static string[] Strs => Str.Split(' ');
public static long[] Longs => Strs.Select(long.Parse).ToArray();
public static int[] Ints => Strs.Select(int.Parse).ToArray();
public static char[] Chars => Str.ToArray();
public static double[] Doubles => Strs.Select(double.Parse).ToArray();
public static long Long1 => Longs[0];
public static int Int1 => Ints[0];
public static char Char1 => Chars[0];
public static double Double1 => Doubles[0];
public static long[] VerticalRead(int N) {
long[] A = new long[N];
for (int i = 0; i < N; ++i)
A[i] = Long1;
return A;
}
public static void Write(string a) => Console.WriteLine(a);
public static void Write(params object[] i) => Write(string.Join(" ", i));
public static void Write<T>(IEnumerable<T> a) => Write(string.Join(" ", a));
public static void Verticalwrite<T>(IEnumerable<T> a) {
foreach (var z in a)
Write(z);
}
public static void YN(bool i) {
if (i)
Write("Yes");
else
Write("No");
}
}
|
[["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 213, 63, 22], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 24], ["+", 64, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 95]]
| 8
| 1,002
| 13
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCorder {
public class Program {
static void Main(string[] args) {
long[] nab = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
long n = nab[0];
long a = nab[1];
long b = nab[2];
if (a > b || (n == 1 & a != b)) {
Console.WriteLine(0);
return;
}
long ans = b * n - a * n + 1;
Console.WriteLine(ans);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCorder {
public class Program {
static void Main(string[] args) {
long[] nab = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
long n = nab[0];
long a = nab[1];
long b = nab[2];
if (a > b || (n == 1 & a != b)) {
Console.WriteLine(0);
return;
}
long ans = (b * (n - 1) + a) - (a * (n - 1) + b) + 1;
Console.WriteLine(ans);
}
}
}
|
[["+", 0, 212, 0, 16, 31, 16, 31, 23, 0, 24], ["+", 31, 23, 0, 16, 31, 16, 12, 23, 0, 24], ["+", 0, 16, 31, 16, 12, 23, 0, 16, 17, 33], ["+", 0, 16, 31, 16, 12, 23, 0, 16, 12, 203], ["+", 31, 23, 0, 16, 31, 16, 12, 23, 0, 25], ["+", 0, 16, 31, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 16, 31, 16, 31, 23, 0, 16, 12, 22], ["+", 0, 212, 0, 16, 31, 16, 31, 23, 0, 25], ["+", 0, 212, 0, 16, 31, 16, 12, 23, 0, 24], ["+", 12, 23, 0, 16, 31, 16, 12, 23, 0, 24], ["+", 12, 23, 0, 16, 31, 16, 12, 23, 0, 25], ["+", 0, 16, 31, 16, 12, 23, 0, 16, 17, 72], ["+", 0, 16, 31, 16, 12, 23, 0, 16, 12, 22], ["+", 0, 212, 0, 16, 31, 16, 12, 23, 0, 25]]
| 8
| 147
| 16
|
using System;
using System.Linq;
public class Hello {
public static void Main() {
var input = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
var n = input[0];
var a = input[1];
var b = input[2];
var max = 0L;
var min = 0L;
if (n >= 1 && a <= b) {
max = a + b * (n - 1);
min = a * (n - 1) + b;
Console.WriteLine(max - min + 1);
} else {
Console.WriteLine(0);
}
}
}
|
using System;
using System.Linq;
public class Hello {
public static void Main() {
var input = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
var n = input[0];
var a = input[1];
var b = input[2];
var max = 0L;
var min = 0L;
if (n >= 2 && a <= b) {
max = a + b * (n - 1);
min = a * (n - 1) + b;
Console.WriteLine(max - min + 1);
} else if (n == 1 && a == b) {
Console.WriteLine(1);
} else {
Console.WriteLine(0);
}
}
}
|
[["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 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, 60], ["+", 0, 57, 75, 57, 15, 16, 31, 16, 12, 203], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 98], ["+", 0, 57, 75, 57, 15, 16, 12, 16, 31, 22], ["+", 0, 57, 75, 57, 15, 16, 12, 16, 17, 60], ["+", 0, 57, 75, 57, 15, 16, 12, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 25], ["+", 8, 196, 0, 57, 75, 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]]
| 8
| 139
| 22
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder {
class Program {
static void Main(string[] args) {
Scanner cin = new Scanner();
var N = cin.Long();
var A = cin.Long();
var B = cin.Long();
long ans;
if (A > B || N == 1)
ans = 0;
else {
ans = A + (N - 1) * B - (N - 1) * A - B + 1;
}
Console.WriteLine(ans);
Console.ReadLine();
}
}
class Scanner //標準入力
{
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int Int() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = Int() + add;
}
return Array;
}
public long Long() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = Long() + add;
}
return Array;
}
public double Double() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = Double() + add;
}
return Array;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder {
class Program {
static void Main(string[] args) {
Scanner cin = new Scanner();
var N = cin.Long();
var A = cin.Long();
var B = cin.Long();
long ans;
if (A > B)
ans = 0;
else if (A == B)
ans = 1;
else {
if (N == 1)
ans = 0;
else
ans = A + (N - 1) * B - (N - 1) * A - B + 1;
}
Console.WriteLine(ans);
Console.ReadLine();
}
}
class Scanner //標準入力
{
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int Int() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = Int() + add;
}
return Array;
}
public long Long() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = Long() + add;
}
return Array;
}
public double Double() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = Double() + add;
}
return Array;
}
}
}
|
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 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, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 195, 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, 60], ["+", 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, 1, 0, 11, 31, 22], ["+", 75, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 75, 57, 64, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 57, 75, 57, 64, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 95], ["+", 8, 196, 0, 57, 75, 57, 75, 196, 0, 45], ["+", 0, 57, 75, 57, 75, 196, 0, 57, 0, 121], ["+", 0, 57, 75, 57, 75, 196, 0, 57, 0, 24], ["-", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45]]
| 8
| 489
| 22
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static string InputPattern = "InputX";
static List<string> GetInputList() {
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("4 4 6");
// 5
} else if (InputPattern == "Input2") {
WillReturn.Add("5 4 3");
// 0
} else if (InputPattern == "Input3") {
WillReturn.Add("1 7 10");
// 0
} else if (InputPattern == "Input4") {
WillReturn.Add("1 3 3");
// 1
} else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null)
WillReturn.Add(wkStr);
}
return WillReturn;
}
static void Main() {
List<string> InputList = GetInputList();
int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();
int N = wkArr[0];
int A = wkArr[1];
int B = wkArr[2];
if (A > B) {
Console.WriteLine(0);
return;
}
if (N == 1) {
if (A == B)
Console.WriteLine(1);
else
Console.WriteLine(0);
} else {
int RestCnt = N - 2;
int MinSum = A + B + RestCnt * A;
int MaxSum = A + B + RestCnt * B;
Console.WriteLine(MaxSum - MinSum + 1);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static string InputPattern = "InputX";
static List<string> GetInputList() {
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("4 4 6");
// 5
} else if (InputPattern == "Input2") {
WillReturn.Add("5 4 3");
// 0
} else if (InputPattern == "Input3") {
WillReturn.Add("1 7 10");
// 0
} else if (InputPattern == "Input4") {
WillReturn.Add("1 3 3");
// 1
} else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null)
WillReturn.Add(wkStr);
}
return WillReturn;
}
static void Main() {
List<string> InputList = GetInputList();
long[] wkArr = InputList[0].Split(' ').Select(X => long.Parse(X)).ToArray();
long N = wkArr[0];
long A = wkArr[1];
long B = wkArr[2];
if (A > B) {
Console.WriteLine(0);
return;
}
if (N == 1) {
if (A == B)
Console.WriteLine(1);
else
Console.WriteLine(0);
} else {
long RestCnt = N - 2;
long MinSum = A + B + RestCnt * A;
long MaxSum = A + B + RestCnt * B;
Console.WriteLine(MaxSum - MinSum + 1);
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["+", 0, 28, 0, 218, 8, 213, 63, 214, 205, 199], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 57, 75, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 57, 75, 196, 0, 197, 0, 198, 39, 199]]
| 8
| 324
| 16
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder {
class Program {
static void Main(string[] args) {
string[] lines = Console.ReadLine().Split(' ');
long n = long.Parse(lines[0]);
long a = long.Parse(lines[1]);
long b = long.Parse(lines[2]);
long ans = 0;
if (a > b) {
ans = 0;
} else if (n <= 2 || a == b) {
ans = 1;
} else {
for (int i = 1; i < n - 2; i++) {
ans += (b - a) * 2 + 1;
}
}
Console.WriteLine(ans);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder {
class Program {
static void Main(string[] args) {
string[] lines = Console.ReadLine().Split(' ');
long n = long.Parse(lines[0]);
long a = long.Parse(lines[1]);
long b = long.Parse(lines[2]);
long ans = 0;
if ((n == 1 && a < b) || a > b) {
ans = 0;
} else if ((n == 2 && a < b) || a == b) {
ans = 1;
} else {
for (int i = 0; i < n - 2; i++) {
ans += (b - a);
}
ans++;
}
Console.WriteLine(ans);
}
}
}
|
[["+", 8, 196, 0, 57, 15, 16, 31, 23, 0, 24], ["+", 15, 16, 31, 23, 0, 16, 31, 16, 31, 22], ["+", 15, 16, 31, 23, 0, 16, 31, 16, 17, 60], ["+", 15, 16, 31, 23, 0, 16, 31, 16, 12, 203], ["+", 0, 57, 15, 16, 31, 23, 0, 16, 17, 98], ["+", 15, 16, 31, 23, 0, 16, 12, 16, 17, 18], ["+", 15, 16, 31, 23, 0, 16, 12, 16, 12, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 23, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 24], ["-", 0, 57, 75, 57, 15, 16, 31, 16, 17, 19], ["+", 75, 57, 15, 16, 31, 23, 0, 16, 17, 98], ["+", 15, 16, 31, 23, 0, 16, 12, 16, 31, 22], ["+", 0, 57, 75, 57, 15, 16, 31, 23, 0, 25], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 1, 0, 11, 12, 16, 31, 16, 17, 48], ["-", 0, 1, 0, 11, 12, 16, 31, 16, 12, 203], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["+", 75, 57, 75, 196, 0, 1, 0, 223, 0, 22], ["+", 75, 57, 75, 196, 0, 1, 0, 223, 0, 29], ["+", 0, 57, 75, 57, 75, 196, 0, 1, 0, 35]]
| 8
| 177
| 27
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
class Program {
private static int Next() {
int c;
int res = 0;
do {
c = reader.Read();
if (c == -1)
return res;
} while (c < '0' || c > '9');
res = c - '0';
while (true) {
c = reader.Read();
if (c < '0' || c > '9')
return res;
res *= 10;
res += c - '0';
}
}
private static readonly StreamReader reader = new StreamReader(
Console.OpenStandardInput(1024 * 10), Encoding.ASCII, false, 1024 * 10);
private static readonly StreamWriter writer = new StreamWriter(
Console.OpenStandardOutput(1024 * 10), Encoding.ASCII, 1024 * 10);
// CultureInfo.InvariantCulture
static void Main(String[] args) {
var data =
Console.ReadLine().TrimEnd().Split(' ').Select(long.Parse).ToList();
var n = data[0];
var a = data[1];
var b = data[2];
if (n == 1) {
Console.WriteLine(a == b ? "1" : "0");
} else {
Console.WriteLine(a + (n - 1) * b - a * (n - 1) - b + 1);
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
class Program {
private static int Next() {
int c;
int res = 0;
do {
c = reader.Read();
if (c == -1)
return res;
} while (c < '0' || c > '9');
res = c - '0';
while (true) {
c = reader.Read();
if (c < '0' || c > '9')
return res;
res *= 10;
res += c - '0';
}
}
private static readonly StreamReader reader = new StreamReader(
Console.OpenStandardInput(1024 * 10), Encoding.ASCII, false, 1024 * 10);
private static readonly StreamWriter writer = new StreamWriter(
Console.OpenStandardOutput(1024 * 10), Encoding.ASCII, 1024 * 10);
// CultureInfo.InvariantCulture
static void Main(String[] args) {
var data =
Console.ReadLine().TrimEnd().Split(' ').Select(long.Parse).ToList();
var n = data[0];
var a = data[1];
var b = data[2];
if (n == 1) {
Console.WriteLine(a == b ? "1" : "0");
} else {
Console.WriteLine(Math.Max(a + (n - 1) * b - a * (n - 1) - b + 1, 0));
}
}
}
|
[["+", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 21], ["+", 0, 28, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25]]
| 8
| 325
| 7
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Collections;
using System.Linq.Expressions;
static class Program {
static void Main() { new Magatro().Solve(); }
}
class Magatro {
private int N, A, B;
private void Scan() {
var line = Console.ReadLine().Split(' ');
N = int.Parse(line[0]);
A = int.Parse(line[1]);
B = int.Parse(line[2]);
}
public void Solve() {
Scan();
if (A > B) {
Console.WriteLine(0);
return;
}
if (A == B) {
Console.WriteLine(1);
return;
}
if (N == 1) {
Console.WriteLine(0);
return;
}
long min = A * (N - 1) + B;
long max = A + B * (N - 1);
Console.WriteLine(max - min + 1);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Collections;
using System.Linq.Expressions;
static class Program {
static void Main() { new Magatro().Solve(); }
}
class Magatro {
private int N, A, B;
private void Scan() {
var line = Console.ReadLine().Split(' ');
N = int.Parse(line[0]);
A = int.Parse(line[1]);
B = int.Parse(line[2]);
}
public void Solve() {
Scan();
if (A > B) {
Console.WriteLine(0);
return;
}
if (A == B) {
Console.WriteLine(1);
return;
}
if (N == 1) {
Console.WriteLine(0);
return;
}
long min = (long)A * (N - 1) + (long)B;
long max = (long)A + (long)B * (N - 1);
Console.WriteLine(max - min + 1);
}
}
|
[["+", 0, 212, 0, 16, 31, 16, 31, 74, 0, 24], ["+", 0, 212, 0, 16, 31, 16, 31, 74, 39, 199], ["+", 0, 212, 0, 16, 31, 16, 31, 74, 0, 25], ["+", 0, 200, 0, 212, 0, 16, 12, 74, 0, 24], ["+", 0, 200, 0, 212, 0, 16, 12, 74, 39, 199], ["+", 0, 200, 0, 212, 0, 16, 12, 74, 0, 25], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 0, 24], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 39, 199], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 0, 25], ["+", 0, 212, 0, 16, 12, 16, 31, 74, 0, 24], ["+", 0, 212, 0, 16, 12, 16, 31, 74, 39, 199], ["+", 0, 212, 0, 16, 12, 16, 31, 74, 0, 25]]
| 8
| 218
| 12
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Globalization;
using System.IO;
#region code challenges entry point
#if !SOLVER_ATWORKSPACE
class Program {
static void Main(string[] args) {
using (
var output = new CC.BP.FormattedStreamWriter(
Console
.OpenStandardOutput())) using (var input =
new CC.BP.BufferedStreamReader(
Console
.OpenStandardInput())) new CC
.ConcreteSolver(input, output)
.Do();
}
}
#endif
#endregion
#region code helpers boilerplate
namespace CC.BP {
class BufferedStreamReader : StreamReader {
const int QUEUE_INITSIZE = 1000;
public BufferedStreamReader(String fileName) : base(fileName) {}
public BufferedStreamReader(Stream stream) : base(stream) {}
private Queue<string> buffer = new Queue<string>(QUEUE_INITSIZE);
public override string ReadLine() {
if (buffer.Count > 0)
throw new InvalidOperationException("must read from buffer first");
return base.ReadLine();
}
public string ReadToken() {
while (buffer.Count == 0) {
base.ReadLine()
.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)
.ToList()
.ForEach((t) => { buffer.Enqueue(t); });
}
return buffer.Dequeue();
}
public void ResetBuffer() { buffer = new Queue<string>(QUEUE_INITSIZE); }
}
class FormattedStreamWriter : StreamWriter {
public FormattedStreamWriter(Stream stream) : base(stream) {}
public FormattedStreamWriter(string filePath) : base(filePath) {}
public override IFormatProvider FormatProvider {
get { return CultureInfo.InvariantCulture; }
}
}
static class IOExtensions {
public static string String(this BufferedStreamReader reader) {
return reader.ReadToken();
}
public static string[] StringArray(this BufferedStreamReader reader,
int n) {
var array = new string[n];
for (int i = 0; i < n; ++i) {
array[i] = reader.ReadToken();
}
return array;
}
public static int Int(this BufferedStreamReader reader) {
return int.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
public static int[] IntArray(this BufferedStreamReader reader, int n) {
var array = new int[n];
for (int i = 0; i < n; ++i) {
array[i] = int.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
return array;
}
public static uint UnsignedInt(this BufferedStreamReader reader) {
return uint.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
public static long Long(this BufferedStreamReader reader) {
return long.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
public static long[] LongArray(this BufferedStreamReader reader, int n) {
var array = new long[n];
for (int i = 0; i < n; ++i) {
array[i] = long.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
return array;
}
public static ulong UnsignedLong(this BufferedStreamReader reader) {
return ulong.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
public static double Double(this BufferedStreamReader reader) {
return double.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
public static double[] DoubleArray(this BufferedStreamReader reader,
int n) {
var array = new double[n];
for (int i = 0; i < n; ++i) {
array[i] =
double.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
return array;
}
public static decimal Decimal(this BufferedStreamReader reader) {
return decimal.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
public static decimal[] DecimalArray(this BufferedStreamReader reader,
int n) {
var array = new decimal[n];
for (int i = 0; i < n; ++i) {
array[i] =
decimal.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
return array;
}
public static void ArrayLine<T>(this FormattedStreamWriter writer,
T[] array, int n, string format = "{0}",
string separator = " ") {
for (int i = 0; i < n; ++i) {
if (i > 0)
writer.Write(separator);
writer.Write(format, array[i]);
}
writer.WriteLine();
}
public static void ArrayLine<T>(this FormattedStreamWriter writer,
T[] array, string format = "{0}",
string separator = " ") {
writer.ArrayLine(array, array.Length, format, separator);
}
}
abstract class BaseSolver {
public static T[][] Create2DArray<T>(int dim1, int dim2) {
var res = new T[dim1][];
for (int i = 0; i < dim1; ++i)
res[i] = new T[dim2];
return res;
}
public static T[][][] Create3DArray<T>(int dim1, int dim2, int dim3) {
var res = new T[dim1][][];
for (int i = 0; i < dim1; ++i)
res[i] = Create2DArray<T>(dim2, dim3);
return res;
}
public static T[][][][] Create4DArray<T>(int dim1, int dim2, int dim3,
int dim4) {
var res = new T[dim1][][][];
for (int i = 0; i < dim1; ++i)
res[i] = Create3DArray<T>(dim2, dim3, dim4);
return res;
}
public abstract void Do();
}
static class Utils {
public static void Swap<T>(ref T one, ref T second) {
T tmp = one;
one = second;
second = tmp;
}
}
}
#endregion
namespace CC {
using CC.BP;
using System.Diagnostics;
class ConcreteSolver : BaseSolver {
private readonly BufferedStreamReader read;
private readonly FormattedStreamWriter write;
public ConcreteSolver(BufferedStreamReader read,
FormattedStreamWriter write) {
this.read = read;
this.write = write;
}
public override void Do() {
var n = read.Int();
var a = read.Int();
var b = read.Int();
if (a > b)
write.WriteLine(0);
else {
var lows = 1L * a * (n - 1) + b;
var lars = 1L * b * (n - 1) + a;
write.WriteLine(lars - lows + 1);
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Globalization;
using System.IO;
#region code challenges entry point
#if !SOLVER_ATWORKSPACE
class Program {
static void Main(string[] args) {
using (
var output = new CC.BP.FormattedStreamWriter(
Console
.OpenStandardOutput())) using (var input =
new CC.BP.BufferedStreamReader(
Console
.OpenStandardInput())) new CC
.ConcreteSolver(input, output)
.Do();
}
}
#endif
#endregion
#region code helpers boilerplate
namespace CC.BP {
class BufferedStreamReader : StreamReader {
const int QUEUE_INITSIZE = 1000;
public BufferedStreamReader(String fileName) : base(fileName) {}
public BufferedStreamReader(Stream stream) : base(stream) {}
private Queue<string> buffer = new Queue<string>(QUEUE_INITSIZE);
public override string ReadLine() {
if (buffer.Count > 0)
throw new InvalidOperationException("must read from buffer first");
return base.ReadLine();
}
public string ReadToken() {
while (buffer.Count == 0) {
base.ReadLine()
.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)
.ToList()
.ForEach((t) => { buffer.Enqueue(t); });
}
return buffer.Dequeue();
}
public void ResetBuffer() { buffer = new Queue<string>(QUEUE_INITSIZE); }
}
class FormattedStreamWriter : StreamWriter {
public FormattedStreamWriter(Stream stream) : base(stream) {}
public FormattedStreamWriter(string filePath) : base(filePath) {}
public override IFormatProvider FormatProvider {
get { return CultureInfo.InvariantCulture; }
}
}
static class IOExtensions {
public static string String(this BufferedStreamReader reader) {
return reader.ReadToken();
}
public static string[] StringArray(this BufferedStreamReader reader,
int n) {
var array = new string[n];
for (int i = 0; i < n; ++i) {
array[i] = reader.ReadToken();
}
return array;
}
public static int Int(this BufferedStreamReader reader) {
return int.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
public static int[] IntArray(this BufferedStreamReader reader, int n) {
var array = new int[n];
for (int i = 0; i < n; ++i) {
array[i] = int.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
return array;
}
public static uint UnsignedInt(this BufferedStreamReader reader) {
return uint.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
public static long Long(this BufferedStreamReader reader) {
return long.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
public static long[] LongArray(this BufferedStreamReader reader, int n) {
var array = new long[n];
for (int i = 0; i < n; ++i) {
array[i] = long.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
return array;
}
public static ulong UnsignedLong(this BufferedStreamReader reader) {
return ulong.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
public static double Double(this BufferedStreamReader reader) {
return double.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
public static double[] DoubleArray(this BufferedStreamReader reader,
int n) {
var array = new double[n];
for (int i = 0; i < n; ++i) {
array[i] =
double.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
return array;
}
public static decimal Decimal(this BufferedStreamReader reader) {
return decimal.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
public static decimal[] DecimalArray(this BufferedStreamReader reader,
int n) {
var array = new decimal[n];
for (int i = 0; i < n; ++i) {
array[i] =
decimal.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
}
return array;
}
public static void ArrayLine<T>(this FormattedStreamWriter writer,
T[] array, int n, string format = "{0}",
string separator = " ") {
for (int i = 0; i < n; ++i) {
if (i > 0)
writer.Write(separator);
writer.Write(format, array[i]);
}
writer.WriteLine();
}
public static void ArrayLine<T>(this FormattedStreamWriter writer,
T[] array, string format = "{0}",
string separator = " ") {
writer.ArrayLine(array, array.Length, format, separator);
}
}
abstract class BaseSolver {
public static T[][] Create2DArray<T>(int dim1, int dim2) {
var res = new T[dim1][];
for (int i = 0; i < dim1; ++i)
res[i] = new T[dim2];
return res;
}
public static T[][][] Create3DArray<T>(int dim1, int dim2, int dim3) {
var res = new T[dim1][][];
for (int i = 0; i < dim1; ++i)
res[i] = Create2DArray<T>(dim2, dim3);
return res;
}
public static T[][][][] Create4DArray<T>(int dim1, int dim2, int dim3,
int dim4) {
var res = new T[dim1][][][];
for (int i = 0; i < dim1; ++i)
res[i] = Create3DArray<T>(dim2, dim3, dim4);
return res;
}
public abstract void Do();
}
static class Utils {
public static void Swap<T>(ref T one, ref T second) {
T tmp = one;
one = second;
second = tmp;
}
}
}
#endregion
namespace CC {
using CC.BP;
using System.Diagnostics;
class ConcreteSolver : BaseSolver {
private readonly BufferedStreamReader read;
private readonly FormattedStreamWriter write;
public ConcreteSolver(BufferedStreamReader read,
FormattedStreamWriter write) {
this.read = read;
this.write = write;
}
public override void Do() {
var n = read.Int();
var a = read.Int();
var b = read.Int();
if (a > b)
write.WriteLine(0);
else {
if (a < b && n == 1)
write.WriteLine(0);
else {
var lows = 1L * a * (n - 1) + b;
var lars = 1L * b * (n - 1) + a;
write.WriteLine(lars - lows + 1);
}
}
}
}
}
|
[["+", 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, 16, 31, 22], ["+", 75, 196, 0, 57, 15, 16, 31, 16, 17, 18], ["+", 75, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 17, 98], ["+", 75, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 75, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 75, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 205, 22], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 0, 131], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 141, 22], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 24], ["+", 64, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 25], ["+", 0, 57, 75, 196, 0, 57, 64, 1, 0, 35], ["+", 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
| 1,363
| 20
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AGC015 {
public class A {
private void Run() {
var input = Console.ReadLine().Trim().Split();
var N = long.Parse(input[0]);
var A = long.Parse(input[1]);
var B = long.Parse(input[2]);
Console.WriteLine((B * (N - 1) + A) - (B + A * (N - 1)) + 1);
}
public static void Main() {
var old = Console.Out;
using (var writer = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false }) {
Console.SetOut(writer);
new A().Run();
Console.Out.Flush();
Console.SetOut(old);
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AGC015 {
public class A {
private void Run() {
var input = Console.ReadLine().Trim().Split();
var N = long.Parse(input[0]);
var A = long.Parse(input[1]);
var B = long.Parse(input[2]);
Console.WriteLine(Math.Max((B * (N - 1) + A) - (B + A * (N - 1)) + 1, 0));
}
public static void Main() {
var old = Console.Out;
using (var writer = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false }) {
Console.SetOut(writer);
new A().Run();
Console.Out.Flush();
Console.SetOut(old);
}
}
}
}
|
[["+", 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, 16, 31, 23, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 21], ["+", 0, 28, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25]]
| 8
| 195
| 7
|
//#pragma warning disable
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
public class Test {
public static int[,] CreatePartialSumTable(byte[][] s) {
var H = s.Length;
var W = s[0].Length;
var sum = new int[H + 1, W + 1];
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
sum[i + 1, j + 1] =
sum[i, j + 1] + sum[i + 1, j] - sum[i, j] + (int)s[i][j];
}
}
return sum;
}
public static void Main() {
var line1 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var N = line1[0];
var M = line1[1];
var Q = line1[2];
var s = new byte[N][];
for (var i = 0; i < N; i++) {
s[i] = new byte[M];
var s0 = Console.ReadLine();
for (int j = 0; j < M; j++) {
s[i][j] = (byte)(s0[j] - '0');
}
}
int[,] face = CreatePartialSumTable(s);
int[,] edgeVert; // 垂直方向の罫線
{
var temp = new byte[N][];
for (int i = 0; i < N; i++) {
temp[i] = new byte[M - 1];
for (int j = 0; j < M - 1; j++) {
temp[i][j] = (byte)(s[i][j] * s[i][j + 1]); // 両方青
}
}
edgeVert = CreatePartialSumTable(temp);
temp = null;
}
int[,] edgeHori; // 水平方向の罫線
{
var temp = new byte[N - 1][];
for (int i = 0; i < N - 1; i++) {
temp[i] = new byte[M];
for (int j = 0; j < M; j++) {
temp[i][j] = (byte)(s[i][j] * s[i + 1][j]); // 両方青
}
}
s = null;
edgeHori = CreatePartialSumTable(temp);
temp = null;
GC.Collect();
}
for (int k = 0; k < Q; k++) {
var line2 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var x1 = line2[0]; // 縦方向の座標をxi、横方向の座標をyiで表すのはNG
var y1 = line2[1];
var x2 = line2[2];
var y2 = line2[3];
var f = face[x2, y2] - face[x2, y1 - 1] - face[x1 - 1, y2] +
face[x1 - 1, y1 - 1];
var v = edgeVert[x2, y2 - 1] - edgeVert[x2, y1 - 1] -
edgeVert[x1 - 1, y2 - 1] + edgeVert[x1 - 1, y1 - 1];
var h = edgeHori[x2 - 1, y2] - edgeHori[x2 - 1, y1 - 1] -
edgeHori[x1 - 1, y2] + edgeHori[x1 - 1, y1 - 1];
Console.WriteLine(f - v - h);
if (k % 30000 == 0) {
GC.Collect();
}
}
}
}
|
//#pragma warning disable
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
public class Test {
public static int[,] CreatePartialSumTable(byte[][] s, int H, int W) {
var sum = new int[H + 1, W + 1];
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
sum[i + 1, j + 1] =
sum[i, j + 1] + sum[i + 1, j] - sum[i, j] + (int)s[i][j];
}
}
return sum;
}
public static void Main() {
var line1 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var N = line1[0];
var M = line1[1];
var Q = line1[2];
var s = new byte[N][];
for (var i = 0; i < N; i++) {
s[i] = new byte[M];
var s0 = Console.ReadLine();
for (int j = 0; j < M; j++) {
s[i][j] = (byte)(s0[j] - '0');
}
}
int[,] face = CreatePartialSumTable(s, N, M);
int[,] edgeVert; // 垂直方向の罫線
{
var temp = new byte[N][];
for (int i = 0; i < N; i++) {
temp[i] = new byte[M - 1];
for (int j = 0; j < M - 1; j++) {
temp[i][j] = (byte)(s[i][j] * s[i][j + 1]); // 両方青
}
}
edgeVert = CreatePartialSumTable(temp, N, M - 1);
temp = null;
}
int[,] edgeHori; // 水平方向の罫線
{
var temp = new byte[N - 1][];
for (int i = 0; i < N - 1; i++) {
temp[i] = new byte[M];
for (int j = 0; j < M; j++) {
temp[i][j] = (byte)(s[i][j] * s[i + 1][j]); // 両方青
}
}
s = null;
edgeHori = CreatePartialSumTable(temp, N - 1, M);
temp = null;
GC.Collect();
}
for (int k = 0; k < Q; k++) {
var line2 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var x1 = line2[0]; // 縦方向の座標をxi、横方向の座標をyiで表すのはNG
var y1 = line2[1];
var x2 = line2[2];
var y2 = line2[3];
var f = face[x2, y2] - face[x2, y1 - 1] - face[x1 - 1, y2] +
face[x1 - 1, y1 - 1];
var v = edgeVert[x2, y2 - 1] - edgeVert[x2, y1 - 1] -
edgeVert[x1 - 1, y2 - 1] + edgeVert[x1 - 1, y1 - 1];
var h = edgeHori[x2 - 1, y2] - edgeHori[x2 - 1, y1 - 1] -
edgeHori[x1 - 1, y2] + edgeHori[x1 - 1, y1 - 1];
Console.WriteLine(f - v - h);
if (k % 30000 == 0) {
GC.Collect();
}
}
}
}
|
[["-", 0, 235, 8, 201, 0, 195, 54, 55, 0, 25], ["-", 0, 235, 8, 201, 0, 195, 8, 196, 0, 45], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 235, 8, 201, 0, 195, 54, 55, 0, 21], ["+", 8, 201, 0, 195, 54, 55, 0, 220, 39, 199], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 198, 0, 200, 0, 212, 0, 214, 205, 22], ["-", 0, 198, 0, 200, 0, 212, 0, 214, 0, 131], ["-", 0, 198, 0, 200, 0, 212, 0, 214, 141, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 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, 235, 8, 201, 0, 195, 54, 55, 0, 25], ["+", 0, 235, 8, 201, 0, 195, 8, 196, 0, 45], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 21], ["+", 0, 212, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["+", 0, 11, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
| 8
| 785
| 39
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve {
public Solve() {}
StringBuilder sb;
public static int Main() {
new Solve().Run();
return 0;
}
void Run() {
sb = new StringBuilder();
Calc();
Console.Write(sb.ToString());
}
void Calc() {
long A = long.Parse(Console.ReadLine());
long B = long.Parse(Console.ReadLine());
int b;
for (b = 63; b >= 0; b--) {
if (((((long)1 << b) & A) == 0) && ((((long)1 << b) & B) != 0)) {
long temp = A;
A = B;
B = temp;
break;
} else if (((((long)1 << b) & A) != 0) && ((((long)1 << b) & B) == 0)) {
break;
} else if (((((long)1 << b) & A) != 0) && ((((long)1 << b) & B) != 0)) {
A -= (long)1 << b;
B -= (long)1 << b;
}
}
long count = ((long)1 << b) - B;
int c;
for (c = b - 1; c >= 0; c--) {
if (((((long)1 << c) & A) != 0)) {
break;
}
}
long C = ((long)1 << (c + 1));
count += Math.Min((long)1 << b, count + C);
sb.Append(count + "\n");
}
}
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve {
public Solve() {}
StringBuilder sb;
public static int Main() {
new Solve().Run();
return 0;
}
void Run() {
sb = new StringBuilder();
Calc();
Console.Write(sb.ToString());
}
void Calc() {
long A = long.Parse(Console.ReadLine());
long B = long.Parse(Console.ReadLine());
if (A == B) {
sb.Append("1\n");
return;
}
int b;
for (b = 63; b >= 0; b--) {
if (((((long)1 << b) & A) == 0) && ((((long)1 << b) & B) != 0)) {
long temp = A;
A = B;
B = temp;
break;
} else if (((((long)1 << b) & A) != 0) && ((((long)1 << b) & B) == 0)) {
break;
} else if (((((long)1 << b) & A) != 0) && ((((long)1 << b) & B) != 0)) {
A -= (long)1 << b;
B -= (long)1 << b;
}
}
long count = ((long)1 << b) - B;
int c;
for (c = b - 1; c >= 0; c--) {
if (((((long)1 << c) & A) != 0)) {
break;
}
}
long C = ((long)1 << (c + 1));
count += Math.Min((long)1 << b, count + C);
sb.Append(count + "\n");
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 44], ["+", 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]]
| 8
| 386
| 20
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program {
static void Main() {
//入力
// int n = 100;
/*
long n = long.Parse(Console.ReadLine());
long[] input = new long[5];
for(int a = 0; a < 5; a++)
{
input[a]=long.Parse(Console.ReadLine());
}
*/
int[] g1 = { 1, 3, 5, 7, 8, 10, 12 };
int[] g2 = { 4, 6, 9, 11 };
int[] g3 = { 2 };
int[] input =
Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
Console.WriteLine(
Array.IndexOf(g1, input[0]) == Array.IndexOf(g1, input[1]) ||
Array.IndexOf(g2, input[0]) == Array.IndexOf(g2, input[1])
? "Yes"
: "No");
/*
//処理速度計測
var sw = new System.Diagnostics.Stopwatch();
sw.Start();
//解法
//処理速度表示
sw.Stop();
TimeSpan ts = sw.Elapsed;
Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms");
*/
Console.ReadLine();
}
}
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program {
static void Main() {
//入力
// int n = 100;
/*
long n = long.Parse(Console.ReadLine());
long[] input = new long[5];
for(int a = 0; a < 5; a++)
{
input[a]=long.Parse(Console.ReadLine());
}
*/
int[] g1 = { 1, 3, 5, 7, 8, 10, 12 };
int[] g2 = { 4, 6, 9, 11 };
int[] g3 = { 2 };
int[] input =
Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
Console.WriteLine((Array.IndexOf(g1, input[0]) > -1 &&
Array.IndexOf(g1, input[1]) > -1) ||
(Array.IndexOf(g2, input[0]) > -1 &&
Array.IndexOf(g2, input[1]) > -1)
? "Yes"
: "No");
/*
//処理速度計測
var sw = new System.Diagnostics.Stopwatch();
sw.Start();
//解法
//処理速度表示
sw.Stop();
TimeSpan ts = sw.Elapsed;
Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms");
*/
Console.ReadLine();
}
}
|
[["+", 0, 28, 0, 41, 15, 16, 31, 23, 0, 24], ["-", 0, 28, 0, 41, 15, 16, 31, 16, 17, 60], ["+", 15, 16, 31, 23, 0, 16, 31, 16, 17, 47], ["+", 31, 23, 0, 16, 31, 16, 12, 241, 0, 33], ["+", 31, 23, 0, 16, 31, 16, 12, 241, 0, 203], ["+", 0, 41, 15, 16, 31, 23, 0, 16, 17, 98], ["+", 0, 16, 12, 16, 31, 213, 3, 4, 0, 25], ["+", 15, 16, 31, 23, 0, 16, 12, 16, 17, 47], ["+", 31, 23, 0, 16, 12, 16, 12, 241, 0, 33], ["+", 31, 23, 0, 16, 12, 16, 12, 241, 0, 203], ["+", 0, 28, 0, 41, 15, 16, 12, 23, 0, 24], ["-", 0, 28, 0, 41, 15, 16, 12, 16, 17, 60], ["+", 15, 16, 12, 23, 0, 16, 31, 16, 17, 47], ["+", 12, 23, 0, 16, 31, 16, 12, 241, 0, 33], ["+", 12, 23, 0, 16, 31, 16, 12, 241, 0, 203], ["+", 0, 41, 15, 16, 12, 23, 0, 16, 17, 98], ["+", 15, 16, 12, 23, 0, 16, 12, 16, 17, 47], ["+", 12, 23, 0, 16, 12, 16, 12, 241, 0, 33], ["+", 12, 23, 0, 16, 12, 16, 12, 241, 0, 203]]
| 8
| 184
| 20
|
using System;
using System.Linq;
using System.IO;
using System.Collections.Generic;
using System.Text;
namespace AtCoder {
public class Program {
static int[] getKeys(char delimiter = ' ') {
var Keys = Console.ReadLine().Split(delimiter);
int N = Keys.Length;
int[] Ns = new int[N];
for (int i = 0; i < N; i++) {
Ns[i] = int.Parse(Keys[i]);
}
return Ns;
}
static long[] getKeys_L(char delimiter = ' ') {
var Keys = Console.ReadLine().Split(delimiter);
int N = Keys.Length;
long[] Ns = new long[N];
for (int i = 0; i < N; i++) {
Ns[i] = long.Parse(Keys[i]);
}
return Ns;
}
static double[] getKeys_D(char delimiter = ' ') {
var Keys = Console.ReadLine().Split(delimiter);
int N = Keys.Length;
var Ns = new double[N];
for (int i = 0; i < N; i++) {
Ns[i] = double.Parse(Keys[i]);
}
return Ns;
}
static int[] getLines(int N, char delimiter = ' ') {
int[] Ns = new int[N];
for (int i = 0; i < N; i++) {
Ns[i] = int.Parse(Console.ReadLine());
}
return Ns;
}
static long[] getLines_L(int N, char delimiter = ' ') {
long[] Ns = new long[N];
for (int i = 0; i < N; i++) {
Ns[i] = long.Parse(Console.ReadLine());
}
return Ns;
}
static double[] getLines_D(int N, char delimiter = ' ') {
double[] Ns = new double[N];
for (int i = 0; i < N; i++) {
Ns[i] = double.Parse(Console.ReadLine());
}
return Ns;
}
public static void Show<T>(T[,] map) {
int H = map.GetLength(0);
int W = map.GetLength(1);
Console.WriteLine("-------------------------");
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
Console.Write(map[i, j] + " ");
}
Console.WriteLine();
}
Console.WriteLine("-------------------------");
}
public static void Show<T>(T[,] map, string delimiter) {
int H = map.GetLength(0);
int W = map.GetLength(1);
Console.WriteLine("-------------------------");
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
Console.Write(map[i, j] + delimiter);
}
Console.WriteLine();
}
Console.WriteLine("-------------------------");
}
public static void Show<T>(IEnumerable<T> ts) {
foreach (var item in ts) {
Console.Write(item + " ");
}
Console.WriteLine();
}
public static void Show<T>(IEnumerable<T> ts, string delimiter) {
foreach (var item in ts) {
Console.Write(item + delimiter);
}
Console.WriteLine();
}
public static void ShowDictionary<T1, T2>(Dictionary<T1, T2> dictionary) {
foreach (var item in dictionary) {
Console.WriteLine(item);
}
}
static T[] getUniform<T>(int length, T value) {
T[] Ts = new T[length];
for (int i = 0; i < length; i++) {
Ts[i] = value;
}
return Ts;
}
static void setUniform<T>(T[] ts, T value) {
int length = ts.Length;
for (int i = 0; i < length; i++) {
ts[i] = value;
}
}
static T[,] getUniform<T>(int row, int col, T value) {
T[,] Ts = new T[row, col];
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
Ts[j, i] = value;
}
}
return Ts;
}
static void setUniform<T>(T[,] ts, T value) {
int N = ts.GetLength(0);
int M = ts.GetLength(1);
for (int i = 0; i < M; i++) {
for (int j = 0; j < N; j++) {
ts[j, i] = value;
}
}
}
static Tuple<int, int> findIndex<T>(T[,] map, T value)
where T : IComparable {
int row = map.GetLength(0);
int col = map.GetLength(1);
for (int i = 0; i < col; i++) {
for (int j = 0; j < row; j++) {
if (value.CompareTo(map[j, i]) == 0)
return new Tuple<int, int>(j, i);
}
}
return new Tuple<int, int>(-1, -1);
}
static void Main() {
var keys = getKeys();
Array.Sort(keys);
Console.WriteLine(keys.First() + keys.Last());
}
}
}
|
using System;
using System.Linq;
using System.IO;
using System.Collections.Generic;
using System.Text;
namespace AtCoder {
public class Program {
static int[] getKeys(char delimiter = ' ') {
var Keys = Console.ReadLine().Split(delimiter);
int N = Keys.Length;
int[] Ns = new int[N];
for (int i = 0; i < N; i++) {
Ns[i] = int.Parse(Keys[i]);
}
return Ns;
}
static long[] getKeys_L(char delimiter = ' ') {
var Keys = Console.ReadLine().Split(delimiter);
int N = Keys.Length;
long[] Ns = new long[N];
for (int i = 0; i < N; i++) {
Ns[i] = long.Parse(Keys[i]);
}
return Ns;
}
static double[] getKeys_D(char delimiter = ' ') {
var Keys = Console.ReadLine().Split(delimiter);
int N = Keys.Length;
var Ns = new double[N];
for (int i = 0; i < N; i++) {
Ns[i] = double.Parse(Keys[i]);
}
return Ns;
}
static int[] getLines(int N, char delimiter = ' ') {
int[] Ns = new int[N];
for (int i = 0; i < N; i++) {
Ns[i] = int.Parse(Console.ReadLine());
}
return Ns;
}
static long[] getLines_L(int N, char delimiter = ' ') {
long[] Ns = new long[N];
for (int i = 0; i < N; i++) {
Ns[i] = long.Parse(Console.ReadLine());
}
return Ns;
}
static double[] getLines_D(int N, char delimiter = ' ') {
double[] Ns = new double[N];
for (int i = 0; i < N; i++) {
Ns[i] = double.Parse(Console.ReadLine());
}
return Ns;
}
public static void Show<T>(T[,] map) {
int H = map.GetLength(0);
int W = map.GetLength(1);
Console.WriteLine("-------------------------");
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
Console.Write(map[i, j] + " ");
}
Console.WriteLine();
}
Console.WriteLine("-------------------------");
}
public static void Show<T>(T[,] map, string delimiter) {
int H = map.GetLength(0);
int W = map.GetLength(1);
Console.WriteLine("-------------------------");
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
Console.Write(map[i, j] + delimiter);
}
Console.WriteLine();
}
Console.WriteLine("-------------------------");
}
public static void Show<T>(IEnumerable<T> ts) {
foreach (var item in ts) {
Console.Write(item + " ");
}
Console.WriteLine();
}
public static void Show<T>(IEnumerable<T> ts, string delimiter) {
foreach (var item in ts) {
Console.Write(item + delimiter);
}
Console.WriteLine();
}
public static void ShowDictionary<T1, T2>(Dictionary<T1, T2> dictionary) {
foreach (var item in dictionary) {
Console.WriteLine(item);
}
}
static T[] getUniform<T>(int length, T value) {
T[] Ts = new T[length];
for (int i = 0; i < length; i++) {
Ts[i] = value;
}
return Ts;
}
static void setUniform<T>(T[] ts, T value) {
int length = ts.Length;
for (int i = 0; i < length; i++) {
ts[i] = value;
}
}
static T[,] getUniform<T>(int row, int col, T value) {
T[,] Ts = new T[row, col];
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
Ts[j, i] = value;
}
}
return Ts;
}
static void setUniform<T>(T[,] ts, T value) {
int N = ts.GetLength(0);
int M = ts.GetLength(1);
for (int i = 0; i < M; i++) {
for (int j = 0; j < N; j++) {
ts[j, i] = value;
}
}
}
static Tuple<int, int> findIndex<T>(T[,] map, T value)
where T : IComparable {
int row = map.GetLength(0);
int col = map.GetLength(1);
for (int i = 0; i < col; i++) {
for (int j = 0; j < row; j++) {
if (value.CompareTo(map[j, i]) == 0)
return new Tuple<int, int>(j, i);
}
}
return new Tuple<int, int>(-1, -1);
}
static void Main() {
Console.ReadLine();
var keys = getKeys();
Console.WriteLine(keys.Max() - keys.Min());
}
}
}
|
[["+", 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, 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, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["-", 0, 28, 0, 16, 31, 213, 63, 214, 141, 22], ["+", 0, 28, 0, 16, 31, 213, 63, 214, 141, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["-", 0, 28, 0, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 28, 0, 16, 12, 213, 63, 214, 141, 22]]
| 8
| 1,227
| 19
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using System.Globalization;
using System.Collections;
namespace CompetitiveProgramming {
public class CPair<T, U> : IComparable
where T : IComparable<T> {
public readonly T Item1;
public readonly U Item2;
public int CompareTo(object obj) {
CPair<T, U> castedObj = (CPair<T, U>)obj;
return this.Item1.CompareTo(castedObj.Item1);
}
public CPair(T t, U u) {
Item1 = t;
Item2 = u;
}
}
class Pair : IComparable {
public long x;
public long a;
public long b;
public long c;
public Pair(long X, long Y, long Z, long D) {
x = X;
a = Y;
b = Z;
c = D;
}
public Pair(long a, long x) {
this.a = a;
this.x = x;
}
public Pair(long a, long b, long c) {
this.a = a;
this.b = b;
this.c = c;
}
public int CompareTo(object obj) {
Pair kore = (Pair)obj;
return x.CompareTo(kore.x);
}
public static bool operator <=(Pair p1, Pair p2) {
if (p1.x != p2.x) {
return p1.x <= p2.x;
} else {
return p1.a <= p2.a;
}
}
public static bool operator >=(Pair p1, Pair p2) {
if (p1.x != p2.x) {
return p1.x >= p2.x;
} else {
return p1.a >= p2.a;
}
}
}
class Zettiti : IComparable {
public long num;
public Zettiti(long num) { this.num = num; }
public int CompareTo(object obj) {
Zettiti kore = (Zettiti)obj;
long knum = Math.Abs(kore.num);
long mynum = Math.Abs(num);
return mynum.CompareTo(knum);
}
}
class Program {
static void Main(string[] args) {
// Utils.BinarySearch.Search
StreamScanner scan = new StreamScanner(System.Console.OpenStandardInput());
bool[] rates = new bool[8];
long free = 0;
long n = scan.Long();
long[] a = scan.Long(n);
for (long i = 0; i < n; i++) {
if (a[i] / 400 >= 8)
free++;
else
rates[a[i] / 400] = true;
}
long ans = 0;
for (long i = 0; i < 8; i++) {
if (rates[i])
ans++;
}
if (ans == 0)
ans = 1;
Console.Write(ans + " ");
Console.Write(ans + free);
}
static bool isOK(long mid, long[] a, long[] f, long k) {
long count = 0;
for (long i = 0; i < a.Length; i++) {
long togo = mid / f[i];
;
count += Math.Max(0, a[i] - togo);
}
return (count <= k);
}
static void Output<T>(List<T> list, string kugiri = "\n") {
for (int i = 0; i < list.Count; i++) {
Console.Write(list[i]);
if (i != list.Count - 1) {
Console.Write(kugiri);
}
}
}
static void Output<T>(T[] list, string kugiri = "\n") {
for (int i = 0; i < list.Length; i++) {
Console.Write(list[i]);
if (i != list.Length - 1) {
Console.Write(kugiri);
}
}
}
static void Output<T>(T[,] list, string kugiri1 = " ",
string kugiri2 = "\n") {
int len1 = list.GetLength(0);
int len2 = list.GetLength(1);
for (int i = 0; i < len1; i++) {
for (int j = 0; j < len2; j++) {
Console.Write(list[i, j]);
if (j != len2 - 1) {
Console.Write(kugiri1);
}
}
if (i != len1 - 1) {
Console.Write(kugiri2);
}
}
}
static int binary_search<T>(T key, T[] moto, Func<int, T, T[], bool> isok) {
int ng = -1;
int ok = moto.Length;
while (Math.Abs(ok - ng) > 1) {
int mid = (ok + ng) / 2;
if (isok(mid, key, moto)) {
ok = mid;
} else {
ng = mid;
}
}
return ok;
}
static int binary_search(int key, int[] moto) {
int ng = -1;
int ok = moto.Length;
while (Math.Abs(ok - ng) > 1) {
int mid = (ok + ng) / 2;
if (isOK(mid, key, moto)) {
ok = mid;
} else {
ng = mid;
}
}
return ok;
}
static int[] Togo;
static bool CheckBipartite(int now, int prev, List<int>[] g,
int c = 0) // 0,-1が想定
{
if (Togo == null)
Togo = Enumerable.Repeat(-1, g.Length).ToArray();
foreach (var next in g[now]) {
if (next == prev)
continue;
var nextc = Togo[next];
if (nextc >= 0 && nextc == c)
return false;
if (nextc >= 0)
continue;
Togo[next] = (c + 1) % 2;
var res = CheckBipartite(next, now, g, (c + 1) % 2);
if (res == false)
return false;
}
return true;
}
static bool isOK(int index, int key, int[] moto) { return moto[index] > key; }
public static int bitCount(int k) {
uint i = (uint)k;
i = i - ((i >> 1) & 0x55555555);
i = (i & 0x33333333) + ((i >> 2) & 0x33333333);
i = (i + (i >> 4)) & 0x0f0f0f0f;
i = i + (i >> 8);
i = i + (i >> 16);
return (int)i & 0x3f;
}
static int check(long moto, long tai) {
if (tai % moto != 0) {
return 0;
}
while (tai > 1) {
if (tai % moto == 0) {
tai /= moto;
} else if (tai > moto) {
tai %= moto;
} else {
tai -= moto;
}
}
if (tai == 1) {
return 1;
} else {
return 0;
}
}
static bool NextPermutation(int[] array) {
var size = array.Length;
var ok = false;
// array[i]<array[i+1]を満たす最大のiを求める
int i = size - 2;
for (; 0 <= i; i--) {
if (array[i] < array[i + 1]) {
ok = true;
break;
}
}
//全ての要素が降順の場合、NextPermutationは存在しない
if (ok == false)
return false;
// array[i]<array[j]を満たす最大のjを求める
int j = size - 1;
for (;; j--) {
if (array[i] < array[j])
break;
}
// iとjの要素をswapする
var tmp = array[i];
array[i] = array[j];
array[j] = tmp;
// i以降の要素を反転させる
Array.Reverse(array, i + 1, size - (i + 1));
return true;
}
static List<int[]> GetAllPermutation(int N) {
var res = new List<int[]>();
var array = Enumerable.Range(0, N).ToArray();
do {
var copy = new int[N];
array.CopyTo(copy, 0);
res.Add(copy);
} while (NextPermutation(array));
return res;
}
static List<int[]> GetAllPermutation(int[] array) {
var size = array.Length;
var res = new List<int[]>();
do {
var copy = new int[size];
array.CopyTo(copy, 0);
res.Add(copy);
} while (NextPermutation(array));
return res;
}
static long Syakutori(
int[] a,
long
k) //しゃくとり法モデル:連続部分列に含まれるすべての要素の値の和がK以上
{
long sum = 0;
int right = 0;
long ans = 0;
for (int left = 0; left < a.Length; left++) {
while (right < a.Length && sum < k) {
sum += a[right];
right++;
}
if (k <= sum) {
ans += a.Length - right + 1;
}
if (left == right) {
right++;
} else {
sum -= a[left];
}
}
return ans;
}
static int[] zalgo(String s) {
int n = s.Length;
int[] ret = new int[n];
ret[0] = n;
int i = 1, j = 0;
while (i < n) {
while (i + j < n && s[j] == s[i + j])
++j;
ret[i] = j;
if (j == 0) {
++i;
continue;
}
int k = 1;
while (i + k < n && k + ret[k] < j) {
ret[i + k] = ret[k];
++k;
}
i += k;
j -= k;
}
return ret;
}
static int gcd(int a, int b) {
if (a % b == 0) {
return b;
}
return gcd(b, a % b);
}
static long gcd(long a, long b) {
if (a % b == 0) {
return b;
}
return gcd(b, a % b);
}
public static List<long> factorialMemo = new List<long>() { 1 };
static long Fact(int x) {
for (int i = factorialMemo.Count; i <= x; i++)
factorialMemo.Add(factorialMemo.Last() * i);
return factorialMemo[x];
}
static int[] yousogotoplus(int[] a, int[] b) {
int[] c = new int[a.Length];
for (int i = 0; i < a.Length; i++) {
c[i] = a[i] + b[i];
}
return c;
}
static int[] yousogotoplus(int[] a, int[,] b, int l) {
int[] c = new int[a.Length];
for (int i = 0; i < a.Length; i++) {
c[i] = a[i] + b[l, i];
}
return c;
}
static int[] yousogotoplus(int[,] a, int l) {
int[] c = new int[a.GetLength(1)];
for (int i = 0; i < a.GetLength(1); i++) {
c[i] = a[l, i];
}
return c;
}
public static long LowerBound(long[] a, long key) {
long l = 0;
long r = a.Length;
long mid;
while (l < r) {
mid = ((r - l) / 2) + l;
if (a[mid] <= key)
l = mid + 1;
else
r = mid;
}
return l;
}
public static long LIS(long[] a) {
var dp = Enumerable.Range(0, a.Length).Select(x => long.MaxValue).ToArray();
for (int i = 0; i < a.Length; i++) {
dp[LowerBound(dp, a[i])] = a[i];
}
return LowerBound(dp, long.MaxValue - 1);
}
static long DivideWith(long m, long n, List<long> primes) {
while (m % n == 0) {
primes.Add(n);
m = m / n;
}
return m;
}
static List<CPair<long, long>> SoinsuBunkai(long num) {
List<CPair<long, long>> primes = new List<CPair<long, long>>();
List<long> yakusu = new List<long>();
List<long> yakusu2 = new List<long>();
for (int i = 2; i * i <= num; i++) {
if (num % i != 0) {
continue;
}
yakusu.Add(i);
if (i * i != num) {
yakusu2.Add(num / i);
}
}
for (int i = 0; i < yakusu.Count; i++) {
if (num % yakusu[i] != 0) {
continue;
}
int j = 0;
for (j = 0; num % yakusu[i] == 0; j++) {
num /= yakusu[i];
}
primes.Add(new CPair<long, long>(yakusu[i], j));
}
for (int i = yakusu2.Count - 1; i > 0; i--) {
if (num % yakusu2[i] != 0) {
continue;
}
int j = 0;
for (j = 0; num % yakusu2[i] == 0; j++) {
num /= yakusu2[i];
}
primes.Add(new CPair<long, long>(yakusu2[i], j));
}
return primes;
}
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;
}
/* static long[] SoinsuBunkai(long num)
{
if (num == 1)
return new long[] { 1 };
List<long> primes = new List<long>();
long n = DivideWith(num, 2, primes);
n = DivideWith(n, 3, primes);
n = DivideWith(n, 5, primes);
long i = 0;
while (n > 1)
{
int[] ps = { 7, 11, 13, 17, 19, 23, 29, 31 };
foreach (var p in ps)
{
// 30m+2, 30m+3, 30m+4, 30m+5, 30m+6、30m+8...
は割る必要はない。 n = DivideWith(n, i + p, primes); if (n == 1) break;
}
i += 30;
}
return primes.ToArray();
}*/
public static int h;
public static int w;
public static int BFS(int height, int width, char[,] map) {
int[] dx = new int[] { -1, 0, 0, 1 };
int[] dy = new int[] { 0, 1, -1, 0 };
bool[,] visited = new bool[h, w];
int[,] len = new int[h, w];
var queue = new Queue<Tuple<int, int>>();
queue.Enqueue(new Tuple<int, int>(height, width));
int max = 0;
visited[height, width] = true;
while (queue.Count > 0) {
var now = queue.Dequeue();
for (int i = 0; i < 4; i++) {
int ny = now.Item1 + dy[i];
int nx = now.Item2 + dx[i];
if (ny >= h || ny < 0 || nx >= w || nx < 0)
continue;
if (visited[ny, nx] || map[ny, nx] == '#')
continue;
visited[ny, nx] = true;
len[ny, nx] = len[now.Item1, now.Item2] + 1;
max = Math.Max(max, len[ny, nx]);
queue.Enqueue(new Tuple<int, int>(ny, nx));
}
}
return max;
}
static public bool Bit(long x, int dig) => ((1L << dig) & x) != 0;
static public void Swap<T>(ref T a, ref T b) {
T keep = a;
a = b;
b = keep;
}
static public void Initialize<T>(ref T[] array, T initialvalue) {
array = Array.ConvertAll(array, x => initialvalue);
}
static int[] Manacher(string S) {
int i = 0, j = 0;
int[] R = new int[S.Length];
while (i < S.Length) {
while (i - j >= 0 && i + j < S.Length && S[i - j] == S[i + j])
++j;
R[i] = j;
int k = 1;
while (i - k >= 0 && k + R[i - k] < j) {
R[i + k] = R[i - k];
++k;
}
i += k;
j -= k;
}
return R;
}
/* static Pair[] a;
static int SaikiZentansaku(List<int>now,int count,int last,int n,int m)
{
List<int> next = new List<int>();
for (int i = 0; i < now.Count; i++)
{
next.Add(now[i]);
}
next.Add(last);
var kore = next.ToArray();
int ans = 0;
if(count==n)
{
for (int i = 0; i < a.Length; i++)
{
int A = a[i].a;
int b = a[i].b;
int c = a[i].c;
int d = a[i].x;
if (kore[b] - kore[A] == c) { ans += d; }
}
return ans;
}
for (int i = last; i <= m; i++)
{
ans = Math.Max(ans, SaikiZentansaku(next, count + 1, i, n, m));
}
return ans;
}*/
}
public class StreamScanner {
public StreamScanner(Stream stream) { str = stream; }
private readonly Stream str;
private readonly byte[] buf = new byte[1024];
private long 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 char[] Char(long n) {
char[] kore = new char[n];
for (long i = 0; i < n; i++) {
kore[i] = Char();
}
return kore;
}
public char[,] Char(long n, long m) {
char[,] kore = new char[n, m];
for (long i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
kore[i, j] = Char();
}
}
return kore;
}
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 long[] Long(long n, bool minus1 = false) {
long[] kore = new long[n];
for (int i = 0; i < n; i++) {
kore[i] = Long();
if (minus1)
kore[i]--;
}
return kore;
}
public Mlong[] MLong(long n) {
Mlong[] kore = new Mlong[n];
for (int i = 0; i < n; i++) {
kore[i] = Long();
}
return kore;
}
public long[,] Long(long h, long w, bool minus1 = false) {
long[,] kore = new long[h, w];
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
kore[i, j] = Long();
if (minus1)
kore[i, j]--;
}
}
return kore;
}
public int Integer() { return (int)Long(); }
public Mint[] MInteger(long n) {
Mint[] kore = new Mint[n];
for (int i = 0; i < n; i++) {
kore[i] = Integer();
}
return kore;
}
public int[] Integer(long n, bool minus1 = false) {
int[] kore = new int[n];
for (int i = 0; i < n; i++) {
kore[i] = (int)Long();
if (minus1)
kore[i]--;
}
return kore;
}
public int[,] Integer(long h, long w, bool minus1 = false) {
int[,] kore = new int[h, w];
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
kore[i, j] = (int)Long();
if (minus1)
kore[i, j]--;
}
}
return kore;
}
public int[] StringToInt(int n) {
char[] s = Scan().ToCharArray();
int[] kore = new int[n];
for (int i = 0; i < n; i++) {
kore[i] = s[i] - '0';
}
return kore;
}
public int[,] StringToInt(int h, int w) {
int[,] kore = new int[h, w];
for (int i = 0; i < h; i++) {
char[] s = Scan().ToCharArray();
for (int j = 0; j < w; j++) {
kore[i, j] = s[j] - '0';
}
}
return kore;
}
public double Double() {
return double.Parse(Scan(), CultureInfo.InvariantCulture);
}
}
public class UnionFind {
public int[] data;
public UnionFind(int size) {
data = new int[size];
for (int i = 0; i < size; i++)
data[i] = -1;
}
public bool Unite(int x, int y) {
x = Root(x);
y = Root(y);
if (x != y) {
if (data[y] < data[x]) {
var tmp = y;
y = x;
x = tmp;
}
data[x] += data[y];
data[y] = x;
}
return x != y;
}
public bool IsSameGroup(int x, int y) { return Root(x) == Root(y); }
public int Root(int x) { return data[x] < 0 ? x : data[x] = Root(data[x]); }
}
public class Mlong : IComparable {
private static long mod = 1000000007;
public long num;
public Mlong(long num) {
if (num < 0) {
num += mod;
}
this.num = num % mod;
}
public override int GetHashCode() { return num.GetHashCode(); }
public override bool Equals(object obj) { return num.Equals(obj); }
public static Mlong operator +(Mlong x, Mlong y) {
return new Mlong((x.num + y.num) % mod);
}
public static Mlong operator -(Mlong x, Mlong y) {
return new Mlong((x.num - y.num + mod) % mod);
}
public static Mlong operator *(Mlong x, Mlong y) {
return new Mlong((long)(((1L * x.num) * y.num) % mod));
}
public Mlong hutujyo(Mlong x) { return new Mlong(num / x.num); }
static long GetInverse(long a) {
long div, p = mod, x1 = 1, y1 = 0, x2 = 0, y2 = 1;
while (true) {
if (p == 1)
return x2 + mod;
div = a / p;
x1 -= x2 * div;
y1 -= y2 * div;
a %= p;
if (a == 1)
return x1 + mod;
div = p / a;
x2 -= x1 * div;
y2 -= y1 * div;
p %= a;
}
}
public Mlong modjyo(Mlong x) { return num * GetInverse(x.num) % mod; }
public static implicit operator Mlong(long x) { return new Mlong(x); }
public static Mlong operator %(Mlong x, Mlong y) {
return new Mlong(x.num % y.num);
}
public static explicit operator long(Mlong x) { return x.num; }
public static bool operator ==(Mlong x, Mlong y) { return x.num == y.num; }
public static bool operator !=(Mlong x, Mlong y) { return x.num != y.num; }
public static bool operator<(Mlong x, Mlong y) { return x.num < y.num; }
public static bool operator>(Mlong x, Mlong y) { return x.num > y.num; }
public static bool operator <=(Mlong x, Mlong y) { return x.num <= y.num; }
public static bool operator >=(Mlong x, Mlong y) { return x.num >= y.num; }
public Mlong Pow(Mlong n) {
Mlong pow = this;
Mlong res = 1;
while (n > 0) {
if (n % 2 == 1) {
res *= pow;
}
pow *= pow;
n = n.hutujyo(2);
}
/* if (n == 1) { return this % mod; }
if (n % 2 == 1) { return (this * Pow(n - 1)) % mod; }
Mint buf = Pow(n.hutujyo(2));
return (buf * buf) % mod;*/
return res;
}
public static Mlong Pow(Mlong a, Mlong n) { return a.Pow(n); }
public static List<Mlong> factorialMemo = new List<Mlong>() { 1 };
static Mlong Factorial(int x) {
for (int i = factorialMemo.Count; i <= x; i++)
factorialMemo.Add(factorialMemo.Last() * i);
return factorialMemo[x];
}
public static Mlong Comb(Mlong n, Mlong a) {
Mlong buf1 = 1;
Mlong buf2 = 1;
for (long i = 0; i < a.num; i++) {
buf1 *= n - i;
buf2 *= (i + 1);
}
return buf1.modjyo(buf2);
}
public static Mlong Comb(int n, int r) {
return Factorial(n).modjyo(Factorial(r)).modjyo(Factorial(n - r));
}
public static void WriteLine(Mlong x) { Console.WriteLine(x.num); }
public int CompareTo(object obj) {
Mlong kore = (Mlong)obj;
return num.CompareTo(kore.num);
}
}
public class Mint : IComparable {
public static int mod = 1000000007;
public int num;
public Mint(int Num) { num = Num; }
public override int GetHashCode() { return num.GetHashCode(); }
public override bool Equals(object obj) { return num.Equals(obj); }
public static Mint operator +(Mint x, Mint y) {
return new Mint((x.num + y.num) % mod);
}
public static Mint operator -(Mint x, Mint y) {
return new Mint((x.num - y.num + mod) % mod);
}
public static Mint operator *(Mint x, Mint y) {
return new Mint((int)(((1L * x.num) * y.num) % mod));
}
public Mint hutujyo(Mint x) { return new Mint(num / x.num); }
static int GetInverse(long a) {
long div, p = mod, x1 = 1, y1 = 0, x2 = 0, y2 = 1;
while (true) {
if (p == 1)
return (int)(x2 + mod);
div = a / p;
x1 -= x2 * div;
y1 -= y2 * div;
a %= p;
if (a == 1)
return (int)(x1 + mod);
div = p / a;
x2 -= x1 * div;
y2 -= y1 * div;
p %= a;
}
}
public Mint modjyo(Mint x) { return num * GetInverse(x.num) % mod; }
/* public Mint modjyo(Mint x)
{
return num * x.Pow(mod - 2);
}*/
public static implicit operator Mint(int x) { return new Mint(x); }
public static Mint[] Toarray(int[] x) {
Mint[] buf = new Mint[x.Length];
for (int i = 0; i < x.Length; i++) {
buf[i] = x[i];
}
return buf;
}
public static explicit operator int(Mint x) { return x.num; }
public static Mint operator %(Mint x, Mint y) {
return new Mint(x.num % y.num);
}
public static bool operator ==(Mint x, Mint y) { return x.num == y.num; }
public static bool operator !=(Mint x, Mint y) { return x.num != y.num; }
public static bool operator<(Mint x, Mint y) { return x.num < y.num; }
public static bool operator>(Mint x, Mint y) { return x.num > y.num; }
public static bool operator <=(Mint x, Mint y) { return x.num <= y.num; }
public static bool operator >=(Mint x, Mint y) { return x.num >= y.num; }
public Mint Pow(Mint n) {
Mint pow = this;
Mint res = 1;
while (n > 0) {
if (n % 2 == 1) {
res *= pow;
}
pow *= pow;
n.hutujyo(2);
}
/* if (n == 1) { return this % mod; }
if (n % 2 == 1) { return (this * Pow(n - 1)) % mod; }
Mint buf = Pow(n.hutujyo(2));
return (buf * buf) % mod;*/
return res;
}
public static Mint Pow(Mint a, Mint n) { return a.Pow(n); }
public static List<Mint> factorialMemo = new List<Mint>() { 1 };
static Mint Factorial(int x) {
for (int i = factorialMemo.Count; i <= x; i++)
factorialMemo.Add(factorialMemo.Last() * i);
return factorialMemo[x];
}
public static Mint Comb(int n, int r) {
return Factorial(n).modjyo(Factorial(r)).modjyo(Factorial(n - r));
}
public static void WriteLine(Mint x) { Console.WriteLine(x.num); }
public int CompareTo(object obj) {
Mint kore = (Mint)obj;
return num.CompareTo(kore.num);
}
}
public class PriorityQueue<T> : IEnumerable<T> {
private readonly List<T> _data = new List<T>();
private readonly IComparer<T> _comparer;
private readonly bool _isDescending;
public PriorityQueue(IComparer<T> comparer, bool isDescending = true) {
_comparer = comparer;
_isDescending = isDescending;
}
public PriorityQueue(Comparison<T> comparison, bool isDescending = true)
: this(Comparer<T>.Create(comparison), isDescending) {}
public PriorityQueue(bool isDescending = true)
: this(Comparer<T>.Default, isDescending) {}
public void Enqueue(T item) {
_data.Add(item);
var childIndex = _data.Count - 1;
while (childIndex > 0) {
var parentIndex = (childIndex - 1) / 2;
if (Compare(_data[childIndex], _data[parentIndex]) >= 0)
break;
Swap(childIndex, parentIndex);
childIndex = parentIndex;
}
}
public T Dequeue() {
var lastIndex = _data.Count - 1;
var firstItem = _data[0];
_data[0] = _data[lastIndex];
_data.RemoveAt(lastIndex--);
var parentIndex = 0;
while (true) {
var childIndex = parentIndex * 2 + 1;
if (childIndex > lastIndex)
break;
var rightChild = childIndex + 1;
if (rightChild <= lastIndex &&
Compare(_data[rightChild], _data[childIndex]) < 0)
childIndex = rightChild;
if (Compare(_data[parentIndex], _data[childIndex]) <= 0)
break;
Swap(parentIndex, childIndex);
parentIndex = childIndex;
}
return firstItem;
}
public T Peek() { return _data[0]; }
private void Swap(int a, int b) {
var tmp = _data[a];
_data[a] = _data[b];
_data[b] = tmp;
}
private int Compare(T a, T b) {
return _isDescending ? _comparer.Compare(b, a) : _comparer.Compare(a, b);
}
public int Count => _data.Count;
public IEnumerator<T> GetEnumerator() { return _data.GetEnumerator(); }
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
public class Tree {
public Node[] Nodes;
public List<int[]> hen;
public class Node {
public int? parent = null;
public List<int[]> children = new List<int[]>();
public int parentcolor = -1;
}
public Tree(int kosu) {
Nodes = new Node[kosu];
for (int i = 0; i < Nodes.Length; i++) {
Nodes[i] = new Node();
}
hen = new List<int[]>();
}
public void Connect(int oya, int ko, int id) {
hen.Add(new int[] { oya, ko, 0 });
Nodes[oya].children.Add(new int[] { ko, id });
Nodes[ko].parent = oya;
}
}
/// <summary>
/// Self-Balancing Binary Search Tree
/// (using Randamized BST)
/// </summary>
public class SB_BinarySearchTree<T>
where T : IComparable {
public class Node {
public T Value;
public Node LChild;
public Node RChild;
public int Count; // size of the sub tree
public Node(T v) {
Value = v;
Count = 1;
}
}
static Random _rnd = new Random();
public static int Count(Node t) { return t == null ? 0 : t.Count; }
static Node Update(Node t) {
t.Count = Count(t.LChild) + Count(t.RChild) + 1;
return t;
}
public static Node Merge(Node l, Node r) {
if (l == null || r == null)
return l == null ? r : l;
if ((double)Count(l) / (double)(Count(l) + Count(r)) > _rnd.NextDouble()) {
l.RChild = Merge(l.RChild, r);
return Update(l);
} else {
r.LChild = Merge(l, r.LChild);
return Update(r);
}
}
/// <summary>
/// split as [0, k), [k, n)
/// </summary>
public static Tuple<Node, Node> Split(Node t, int k) {
if (t == null)
return new Tuple<Node, Node>(null, null);
if (k <= Count(t.LChild)) {
var s = Split(t.LChild, k);
t.LChild = s.Item2;
return new Tuple<Node, Node>(s.Item1, Update(t));
} else {
var s = Split(t.RChild, k - Count(t.LChild) - 1);
t.RChild = s.Item1;
return new Tuple<Node, Node>(Update(t), s.Item2);
}
}
public static Node Remove(Node t, T v) {
if (Find(t, v) == null)
return t;
return RemoveAt(t, LowerBound(t, v));
}
public static Node RemoveAt(Node t, int k) {
var s = Split(t, k);
var s2 = Split(s.Item2, 1);
return Merge(s.Item1, s2.Item2);
}
public static bool Contains(Node t, T v) { return Find(t, v) != null; }
public static Node Find(Node t, T v) {
while (t != null) {
var cmp = t.Value.CompareTo(v);
if (cmp > 0)
t = t.LChild;
else if (cmp < 0)
t = t.RChild;
else
break;
}
return t;
}
public static Node FindByIndex(Node t, int idx) {
if (t == null)
return null;
var currentIdx = Count(t) - Count(t.RChild) - 1;
while (t != null) {
if (currentIdx == idx)
return t;
if (currentIdx > idx) {
t = t.LChild;
currentIdx -= (Count(t == null ? null : t.RChild) + 1);
} else {
t = t.RChild;
currentIdx += (Count(t == null ? null : t.LChild) + 1);
}
}
return null;
}
public static int UpperBound(Node t, T v) {
var torg = t;
if (t == null)
return -1;
var ret = Int32.MaxValue;
var idx = Count(t) - Count(t.RChild) - 1;
while (t != null) {
var cmp = t.Value.CompareTo(v);
if (cmp > 0) {
ret = Math.Min(ret, idx);
t = t.LChild;
idx -= (Count(t == null ? null : t.RChild) + 1);
} else if (cmp <= 0) {
t = t.RChild;
idx += (Count(t == null ? null : t.LChild) + 1);
}
}
return ret == Int32.MaxValue ? Count(torg) : ret;
}
public static int LowerBound(Node t, T v) {
var torg = t;
if (t == null)
return -1;
var idx = Count(t) - Count(t.RChild) - 1;
var ret = Int32.MaxValue;
while (t != null) {
var cmp = t.Value.CompareTo(v);
if (cmp >= 0) {
if (cmp == 0)
ret = Math.Min(ret, idx);
t = t.LChild;
if (t == null)
ret = Math.Min(ret, idx);
idx -= t == null ? 0 : (Count(t.RChild) + 1);
} else if (cmp < 0) {
t = t.RChild;
idx += (Count(t == null ? null : t.LChild) + 1);
if (t == null)
return idx;
}
}
// return ret;
return ret == Int32.MaxValue ? Count(torg) : ret;
}
public static Node Insert(Node t, T v) {
var ub = LowerBound(t, v);
return InsertByIdx(t, ub, v);
}
static Node InsertByIdx(Node t, int k, T v) {
var s = Split(t, k);
return Merge(Merge(s.Item1, new Node(v)), s.Item2);
}
public static IEnumerable<T> Enumerate(Node t) {
var ret = new List<T>();
Enumerate(t, ret);
return ret;
}
static void Enumerate(Node t, List<T> ret) {
if (t == null)
return;
Enumerate(t.LChild, ret);
ret.Add(t.Value);
Enumerate(t.RChild, ret);
}
}
/// <summary>
/// C-like set
/// </summary>
public class Set<T>
where T : IComparable {
protected SB_BinarySearchTree<T>.Node _root;
public T this[int idx] {
get { return ElementAt(idx); }
}
public int Count() { return SB_BinarySearchTree<T>.Count(_root); }
public bool Any() { return _root != null; }
public virtual void Insert(T v) {
if (_root == null)
_root = new SB_BinarySearchTree<T>.Node(v);
else {
if (SB_BinarySearchTree<T>.Find(_root, v) != null)
return;
_root = SB_BinarySearchTree<T>.Insert(_root, v);
}
}
public void Clear() { _root = null; }
public void Remove(T v) { _root = SB_BinarySearchTree<T>.Remove(_root, v); }
public bool Contains(T v) {
return SB_BinarySearchTree<T>.Contains(_root, v);
}
public T ElementAt(int k) {
var node = SB_BinarySearchTree<T>.FindByIndex(_root, k);
if (node == null)
throw new IndexOutOfRangeException();
return node.Value;
}
public int Count(T v) {
return SB_BinarySearchTree<T>.UpperBound(_root, v) -
SB_BinarySearchTree<T>.LowerBound(_root, v);
}
public int LowerBound(T v) {
return SB_BinarySearchTree<T>.LowerBound(_root, v);
}
public int UpperBound(T v) {
return SB_BinarySearchTree<T>.UpperBound(_root, v);
}
public T max() {
SB_BinarySearchTree<T>.Node ima = _root;
while (ima.RChild != null) {
ima = ima.RChild;
}
return ima.Value;
}
public T min() {
SB_BinarySearchTree<T>.Node ima = _root;
while (ima.LChild != null) {
ima = ima.LChild;
}
return ima.Value;
}
public Tuple<int, int> EqualRange(T v) {
if (!Contains(v))
return new Tuple<int, int>(-1, -1);
return new Tuple<int, int>(SB_BinarySearchTree<T>.LowerBound(_root, v),
SB_BinarySearchTree<T>.UpperBound(_root, v) - 1);
}
public List<T> ToList() {
return new List<T>(SB_BinarySearchTree<T>.Enumerate(_root));
}
}
/// <summary>
/// C-like multiset
/// </summary>
public class MultiSet<T> : Set<T>
where T : IComparable {
public override void Insert(T v) {
if (_root == null)
_root = new SB_BinarySearchTree<T>.Node(v);
else
_root = SB_BinarySearchTree<T>.Insert(_root, v);
}
}
public class RollingHashSlow {
public const long B = (long)1e5 + 7;
public const long MOD = (long)1e9 + 7;
public string S { get; set; }
public int N { get; set; }
public long[] Power { get; set; }
public long[] Hash { get; set; }
public RollingHashSlow(string s) {
this.S = s;
this.N = s.Length;
// B^nを計算しておく
this.Power = new long[this.N + 1];
this.Power[0] = 1;
for (int i = 0; i < N; i++) {
this.Power[i + 1] = (this.Power[i] * B) % MOD;
}
// ハッシュを前計算する
this.Hash = new long[this.N + 1];
for (int i = 0; i < N; i++) {
this.Hash[i + 1] = (this.Hash[i] * B + S[i]) % MOD;
}
}
// S[l, r) のハッシュ値を求める
public long Get(int l, int r) {
var hash = this.Hash[r] - (this.Hash[l] * this.Power[r - l] % MOD);
if (hash < 0)
hash += MOD;
return hash;
}
}
class RollingHashFast {
public const ulong B = (ulong)1e9 + 7;
public string S { get; set; }
public int N { get; set; }
public ulong[] Power { get; set; }
public ulong[] Hash { get; set; }
public RollingHashFast(string s) {
this.S = s;
this.N = s.Length;
// B^nを計算しておく
this.Power = new ulong[this.N + 1];
this.Power[0] = 1;
for (int i = 0; i < N; i++) {
this.Power[i + 1] = this.Power[i] * B;
}
// ハッシュを前計算する
this.Hash = new ulong[this.N + 1];
for (int i = 0; i < N; i++) {
this.Hash[i + 1] = this.Hash[i] * B + S[i];
}
}
// [l, r) のハッシュ値を求める
public ulong Get(int l, int r) {
var hash = this.Hash[r] - (this.Hash[l] * this.Power[r - l]);
return hash;
}
}
class Segtree<T> {
int n;
T[] tree;
Func<T, T, T> f;
T exnum;
public Segtree(int m, Func<T, T, T> f, T ex) {
this.f = f;
this.exnum = ex;
n = 1;
while (n < m)
n <<= 1;
tree = new T[(n << 1) - 1];
for (int i = 0; i < tree.Length; i++)
tree[i] = ex;
}
public Segtree(int m, T ini, Func<T, T, T> f, T ex) : this(m, f, ex) {
for (int i = 0; i < m; ++i)
tree[i + n - 1] = ini;
all_update();
}
public void assign_without_update(int j, T x) { tree[j + n - 1] = x; }
public void update(int j, T x) {
int i = j + n - 1;
tree[i] = x;
while (i > 0) {
i = (i - 1) >> 1;
tree[i] = f(tree[(i << 1) + 1], tree[(i << 1) + 2]);
}
}
public void all_update() {
for (int i = n - 2; i >= 0; i--)
tree[i] = f(tree[(i << 1) + 1], tree[(i << 1) + 2]);
}
public T look(int i) { return tree[i + n - 1]; }
// [s, t)
public T run(int s, int t) { return query(s, t, 0, 0, n); }
T query(int s, int t, int k, int l, int r) {
if (r <= s || t <= l)
return exnum;
if (s <= l && r <= t)
return tree[k];
return f(query(s, t, (k << 1) + 1, l, (l + r) >> 1),
query(s, t, (k + 1) << 1, (l + r) >> 1, r));
}
}
public class WarshallFloyd {
public int V { get; set; }
public long[,] DP { get; set; }
public long INF = long.MaxValue;
public bool[] Negative;
public WarshallFloyd(int v) {
this.V = v;
this.DP = new long[V, V];
for (int i = 0; i < V; i++) {
for (int j = 0; j < V; j++) {
this.DP[i, j] = INF;
}
this.DP[i, i] = 0;
}
}
public void SetCost(int a, int b, int c = 1) { this.DP[a, b] = c; }
public long[,] CalcMinCost() {
this.Negative = new bool[V];
for (int k = 0; k < V; k++) {
for (int i = 0; i < V; i++) {
for (int j = 0; j < V; j++) {
if (DP[i, k] == INF || DP[k, j] == INF)
continue;
DP[i, j] = Math.Min(DP[i, j], DP[i, k] + DP[k, j]);
}
}
}
for (int k = 0; k < V; k++) {
for (int i = 0; i < V; i++) {
for (int j = 0; j < V; j++) {
if (DP[i, k] == INF || DP[k, j] == INF)
continue;
if (DP[i, j] > DP[i, k] + DP[k, j]) {
this.Negative[i] = true;
this.Negative[j] = true;
this.Negative[k] = true;
}
}
}
}
return DP;
}
public long GetMinCost(int a, int b) { return DP[a, b]; }
public bool IsINF(int a, int b) { return DP[a, b] >= INF; }
public bool IsNegative(params int[] vs) {
if (vs.Length == 0)
vs = Enumerable.Range(0, V).ToArray();
foreach (var v in vs) {
if (Negative[v])
return true;
}
return false;
}
}
/// <summary>
/// Get min cost between two points
/// </summary>
public class Dijkstra {
private int maxIndex = -1;
private const int INF = Int32.MaxValue;
private int[,] _edgeArray;
/// <summary>
/// Dijkstra, get min cost between two points
/// should not contain negatie cost path
/// </summary>
/// <param name="size">max index of vertices</param>
public Dijkstra(int size) {
maxIndex = size + 1;
_edgeArray = new int[maxIndex, maxIndex];
for (int i = 0; i < _edgeArray.GetLength(0); i++) {
for (int j = 0; j < _edgeArray.GetLength(1); j++) {
_edgeArray[i, j] = INF;
if (i == j)
_edgeArray[i, j] = 0;
}
}
}
// Add a path(no direction) with its cost
public void AddPath(int s, int t, int cost) {
_edgeArray[s, t] = Math.Min(_edgeArray[s, t], cost);
_edgeArray[t, s] = _edgeArray[s, t];
}
// Get the min cost between s and t
// return Int32.MaxValue if no path
public int GetMinCost(int s, int t) {
int[] cost = new int[maxIndex];
for (int i = 0; i < cost.Length; i++)
cost[i] = INF;
cost[s] = 0;
var priorityQueue = new PriorityQueue<CPair<int, int>>();
priorityQueue.Enqueue(new CPair<int, int>(0, s));
while (priorityQueue.Count() > 0) {
var costDestinationPair = priorityQueue.Dequeue();
if (cost[costDestinationPair.Item2] < costDestinationPair.Item1)
continue;
for (int i = 0; i < maxIndex; i++) {
int newCostToi = _edgeArray[costDestinationPair.Item2, i] == INF
? INF
: costDestinationPair.Item1 +
_edgeArray[costDestinationPair.Item2, i];
if (newCostToi < cost[i]) {
cost[i] = newCostToi;
priorityQueue.Enqueue(new CPair<int, int>(newCostToi, i));
}
}
}
return cost[t];
}
}
class Deque<T> : IEnumerable<T> {
public T this[int i] {
get { return this.Buffer[(this.FirstIndex + i) % this.Capacity]; }
set {
if (i < 0)
throw new ArgumentOutOfRangeException();
this.Buffer[(this.FirstIndex + i) % this.Capacity] = value;
}
}
private T[] Buffer;
private int Capacity;
private int FirstIndex;
private int LastIndex {
get { return (this.FirstIndex + this.Length) % this.Capacity; }
}
public int Length;
public Deque(int capacity = 16) {
this.Capacity = capacity;
this.Buffer = new T[this.Capacity];
this.FirstIndex = 0;
}
public void PushBack(T data) {
if (this.Length == this.Capacity)
this.Resize();
this.Buffer[this.LastIndex] = data;
this.Length++;
}
public void PushFront(T data) {
if (this.Length == this.Capacity)
this.Resize();
var index = this.FirstIndex - 1;
if (index < 0)
index = this.Capacity - 1;
this.Buffer[index] = data;
this.Length++;
this.FirstIndex = index;
}
public T PopBack() {
if (this.Length == 0)
throw new InvalidOperationException("データが空です。");
var data = this[this.Length - 1];
this.Length--;
return data;
}
public T PopFront() {
if (this.Length == 0)
throw new InvalidOperationException("データが空です。");
var data = this[0];
this.FirstIndex++;
this.FirstIndex %= this.Capacity;
this.Length--;
return data;
}
private void Resize() {
var newArray = new T[this.Capacity * 2];
for (int i = 0; i < this.Length; i++) {
newArray[i] = this[i];
}
this.FirstIndex = 0;
this.Capacity *= 2;
this.Buffer = newArray;
}
public IEnumerator<T> GetEnumerator() {
for (int i = 0; i < this.Length; i++) {
yield return this[i];
}
}
IEnumerator IEnumerable.GetEnumerator() {
for (int i = 0; i < this.Length; i++) {
yield return this[i];
}
}
}
public struct Edge {
public int from;
public int to;
public long dist;
public Edge(int t, long c) {
from = -1;
to = t;
dist = c;
}
public Edge(int f, int t, long c) {
from = f;
to = t;
dist = c;
}
}
public class PotentializedUnionFind {
int _count;
int[] par, sizes, rank;
long[] weight;
public PotentializedUnionFind(int N) {
_count = N;
par = new int[N];
sizes = new int[N];
rank = new int[N];
weight = new long[N];
for (int i = 0; i < N; ++i) {
par[i] = i;
sizes[i] = 1;
rank[i] = 0;
}
}
int Root(int X) {
if (par[X] == X) {
return X;
} else {
int r = Root(par[X]);
weight[X] += weight[par[X]];
return (par[X] = r);
}
}
public bool Merge(int X, int Y, long W) {
W += GetWeight(X);
W -= GetWeight(Y);
X = Root(X);
Y = Root(Y);
if (X == Y)
return false;
--_count;
if (rank[X] < rank[Y]) {
par[X] = Y;
sizes[Y] += sizes[X];
weight[X] = -W;
} else {
par[Y] = X;
sizes[X] += sizes[Y];
if (rank[X] == rank[Y])
++rank[X];
weight[Y] = W;
}
return true;
}
public bool IsSame(int X, int Y) => Root(X) == Root(Y);
public int Count => _count;
public bool IsParent(int X) => X == Root(X);
public int GetParent(int X) => Root(X);
public int Size(int X) => sizes[Root(X)];
public long GetWeight(int X) {
Root(X);
return weight[X];
}
public long GetDiff(int X, int Y) => GetWeight(Y) - GetWeight(X);
}
public static class BellmanFord {
public class Vertex {
public long Distance { get; set; }
public Vertex() { Distance = long.MaxValue; }
}
public class Edge {
public int From { get; private set; }
public int To { get; private set; }
public long Weight { get; private set; }
public Edge(int from, int to, long weight) {
From = from;
To = to;
Weight = weight;
}
}
private static void GetReachable(int origin, ref HashSet<int> reached,
ref Dictionary<int, int[]> paths) {
if (reached.Contains(origin))
return;
reached.Add(origin);
if (paths.ContainsKey(origin) == false)
return;
foreach (var p in paths[origin])
GetReachable(p, ref reached, ref paths);
}
/// <summary>
/// null: 負の無限大
/// long.MaxValue: たどり着けない
/// その他: 距離
/// </summary>
public static long? RunBellmanFord(int vertexCount, List<Edge> rawEdges,
int source, int dest) {
var forwards =
rawEdges.GroupBy(x => x.From)
.ToDictionary(x => x.Key, x => x.Select(xs => xs.To).ToArray());
var reverses = rawEdges.GroupBy(x => x.To).ToDictionary(
x => x.Key, x => x.Select(xs => xs.From).ToArray());
var fromSource = new HashSet<int>();
var toDest = new HashSet<int>();
GetReachable(source, ref fromSource, ref forwards);
GetReachable(dest, ref toDest, ref reverses);
var edges = rawEdges.Where(e => fromSource.Contains(e.From))
.Where(e => fromSource.Contains(e.To))
.Where(e => toDest.Contains(e.From))
.Where(e => toDest.Contains(e.To))
.ToArray();
// initialize distances
var vertices = new List<Vertex>();
for (int i = 0; i < vertexCount; i++)
vertices.Add(new Vertex());
vertices[source].Distance = 0L;
// update distances
for (int i = 0; i < vertices.Count; i++) {
foreach (var e in edges) {
var from = vertices[e.From];
var to = vertices[e.To];
if (from.Distance == long.MaxValue)
continue;
var newDistance = from.Distance + e.Weight;
if (to.Distance > newDistance) {
to.Distance = newDistance;
}
}
}
// check negative cycle
foreach (var e in edges) {
var from = vertices[e.From];
var to = vertices[e.To];
if (from.Distance + e.Weight < to.Distance)
return null;
}
return vertices[dest].Distance;
}
}
public class SortedMultiSet<T> : IEnumerable<T> {
private SortedDictionary<T, int> _dict;
public SortedMultiSet() { _dict = new SortedDictionary<T, int>(); }
public SortedMultiSet(IEnumerable<T> items) : this() { Add(items); }
public bool Contains(T item) { return _dict.ContainsKey(item); }
public void Add(T item) {
if (_dict.ContainsKey(item))
_dict[item]++;
else
_dict[item] = 1;
}
public void Add(IEnumerable<T> items) {
foreach (var item in items)
Add(item);
}
public void Remove(T item) {
if (!_dict.ContainsKey(item))
throw new ArgumentException();
if (--_dict[item] == 0)
_dict.Remove(item);
}
// Return the last value in the multiset
public T Peek() {
if (!_dict.Any())
throw new NullReferenceException();
return _dict.Last().Key;
}
// Return the last value in the multiset and remove it.
public T Pop() {
T item = Peek();
Remove(item);
return item;
}
public IEnumerator<T> GetEnumerator() {
foreach (var kvp in _dict)
for (int i = 0; i < kvp.Value; i++)
yield return kvp.Key;
}
IEnumerator IEnumerable.GetEnumerator() { return this.GetEnumerator(); }
}
class Treap<T> : IEnumerable<T>
where T : IComparable {
public int Length {
get { return this.Root == null ? 0 : this.NodeCount(this.Root); }
}
public T this[int i] {
get {
if (this.Root.Count < i - 1)
throw new IndexOutOfRangeException();
return this.Root.Get(i);
}
}
public Node Root;
private IComparer<T> Cmp = Comparer<T>.Default;
public Treap(IComparer<T> cmp = null) {
if (cmp != null)
this.Cmp = cmp;
}
public Node Merge(Node l, Node r) {
if (l == null || r == null)
return l == null ? r : l;
if (l.Priority > r.Priority) {
l.R = this.Merge(l.R, r);
return this.Update(l);
} else {
r.L = this.Merge(l, r.L);
return this.Update(r);
}
}
// 左にk個、右に残り(n-k)個に分割する
public (Node, Node) Split(int k) { return this.Split(this.Root, k); }
public (Node, Node) Split(Node t, int k) {
if (t == null)
return (null, null);
if (k <= this.NodeCount(t.L)) {
var s = this.Split(t.L, k);
t.L = s.Item2;
return (s.Item1, this.Update(t));
} else {
var s = this.Split(t.R, k - this.NodeCount(t.L) - 1);
t.R = s.Item1;
return (this.Update(t), s.Item2);
}
}
public int NodeCount(Node node) { return node == null ? 0 : node.Count; }
public int LowerBouond(T value) { return this.LowerBouond(this.Root, value); }
public int LowerBouond(Node node, T value) {
if (node == null)
return 0;
if (this.Cmp.Compare(value, node.Value) <= 0)
return this.LowerBouond(node.L, value);
else
return this.NodeCount(node.L) + 1 + this.LowerBouond(node.R, value);
}
public int UpperBound(T value) { return this.UpperBound(this.Root, value); }
public int UpperBound(Node node, T value) {
if (node == null)
return 0;
if (this.Cmp.Compare(value, node.Value) >= 0)
return this.NodeCount(node.L) + 1 + this.UpperBound(node.R, value);
else
return this.UpperBound(node.L, value);
}
public int ValueCount(T value) {
return this.UpperBound(value) - this.LowerBouond(value);
}
public void Insert(T value) {
var sub = this.Split(this.Root, this.LowerBouond(value));
var newNode = new Node(value);
var merged = this.Merge(sub.Item1, newNode);
this.Root = this.Merge(merged, sub.Item2);
}
public void Erase(T value) {
if (this.ValueCount(value) == 0)
return;
var sub = this.Split(this.Root, this.LowerBouond(value));
this.Root = this.Merge(sub.Item1, this.Split(sub.Item2, 1).Item2);
}
public void InsertAt(Node node, int k) {
var sub = this.Split(this.Root, k);
var merged = this.Merge(sub.Item1, node);
this.Root = this.Merge(merged, sub.Item2);
}
public void InsertAt(T value, int k) {
var node = new Node(value);
var sub = this.Split(this.Root, k);
var merged = this.Merge(sub.Item1, node);
this.Root = this.Merge(merged, sub.Item2);
}
public Node EraseAt(int k) {
var sub = this.Split(this.Root, k);
var sub2 = this.Split(sub.Item2, 1);
var res = sub2.Item1;
this.Root = this.Merge(sub.Item1, sub2.Item2);
return res;
}
public Node Update(Node node) {
node.Count = this.NodeCount(node.L) + this.NodeCount(node.R) + 1;
return node;
}
public class Node {
private static Random Rand = new Random();
public T Value;
public Node L = null;
public Node R = null;
public int Count;
public double Priority;
public Node(T value, double priority) {
this.Value = value;
this.Priority = priority;
this.Count = 1;
}
public Node(T value) : this(value, Rand.NextDouble()) {}
public T Get(int i) { return this.GetNode(i).Value; }
public Node GetNode(int i) {
var lcount = 0;
if (this.L != null)
lcount = this.L.Count;
if (lcount == i)
return this;
else if (lcount < i)
return this.R.GetNode(i - lcount - 1);
else
return this.L.GetNode(i);
}
}
public IEnumerator<T> GetEnumerator() {
for (int i = 0; i < this.Length; i++)
yield return this.Root.Get(i);
}
IEnumerator IEnumerable.GetEnumerator() { return this.GetEnumerator(); }
}
public static class ObjectExtension {
// ディープコピーの複製を作る拡張メソッド
public static T DeepClone<T>(this T src) {
using (var memoryStream = new System.IO.MemoryStream()) {
var binaryFormatter =
new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
binaryFormatter.Serialize(memoryStream, src); // シリアライズ
memoryStream.Seek(0, System.IO.SeekOrigin.Begin);
return (T)binaryFormatter.Deserialize(memoryStream); // デシリアライズ
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using System.Globalization;
using System.Collections;
namespace CompetitiveProgramming {
public class CPair<T, U> : IComparable
where T : IComparable<T> {
public readonly T Item1;
public readonly U Item2;
public int CompareTo(object obj) {
CPair<T, U> castedObj = (CPair<T, U>)obj;
return this.Item1.CompareTo(castedObj.Item1);
}
public CPair(T t, U u) {
Item1 = t;
Item2 = u;
}
}
class Pair : IComparable {
public long x;
public long a;
public long b;
public long c;
public Pair(long X, long Y, long Z, long D) {
x = X;
a = Y;
b = Z;
c = D;
}
public Pair(long a, long x) {
this.a = a;
this.x = x;
}
public Pair(long a, long b, long c) {
this.a = a;
this.b = b;
this.c = c;
}
public int CompareTo(object obj) {
Pair kore = (Pair)obj;
return x.CompareTo(kore.x);
}
public static bool operator <=(Pair p1, Pair p2) {
if (p1.x != p2.x) {
return p1.x <= p2.x;
} else {
return p1.a <= p2.a;
}
}
public static bool operator >=(Pair p1, Pair p2) {
if (p1.x != p2.x) {
return p1.x >= p2.x;
} else {
return p1.a >= p2.a;
}
}
}
class Zettiti : IComparable {
public long num;
public Zettiti(long num) { this.num = num; }
public int CompareTo(object obj) {
Zettiti kore = (Zettiti)obj;
long knum = Math.Abs(kore.num);
long mynum = Math.Abs(num);
return mynum.CompareTo(knum);
}
}
class Program {
static void Main(string[] args) {
// Utils.BinarySearch.Search
StreamScanner scan = new StreamScanner(System.Console.OpenStandardInput());
bool[] rates = new bool[8];
long free = 0;
long n = scan.Long();
long[] a = scan.Long(n);
for (long i = 0; i < n; i++) {
if (a[i] / 400 >= 8)
free++;
else
rates[a[i] / 400] = true;
}
long ans = 0;
for (long i = 0; i < 8; i++) {
if (rates[i])
ans++;
}
if (ans == 0) {
Console.WriteLine(1 + " " + free);
return;
}
Console.Write(ans + " ");
Console.Write(ans + free);
}
static bool isOK(long mid, long[] a, long[] f, long k) {
long count = 0;
for (long i = 0; i < a.Length; i++) {
long togo = mid / f[i];
;
count += Math.Max(0, a[i] - togo);
}
return (count <= k);
}
static void Output<T>(List<T> list, string kugiri = "\n") {
for (int i = 0; i < list.Count; i++) {
Console.Write(list[i]);
if (i != list.Count - 1) {
Console.Write(kugiri);
}
}
}
static void Output<T>(T[] list, string kugiri = "\n") {
for (int i = 0; i < list.Length; i++) {
Console.Write(list[i]);
if (i != list.Length - 1) {
Console.Write(kugiri);
}
}
}
static void Output<T>(T[,] list, string kugiri1 = " ",
string kugiri2 = "\n") {
int len1 = list.GetLength(0);
int len2 = list.GetLength(1);
for (int i = 0; i < len1; i++) {
for (int j = 0; j < len2; j++) {
Console.Write(list[i, j]);
if (j != len2 - 1) {
Console.Write(kugiri1);
}
}
if (i != len1 - 1) {
Console.Write(kugiri2);
}
}
}
static int binary_search<T>(T key, T[] moto, Func<int, T, T[], bool> isok) {
int ng = -1;
int ok = moto.Length;
while (Math.Abs(ok - ng) > 1) {
int mid = (ok + ng) / 2;
if (isok(mid, key, moto)) {
ok = mid;
} else {
ng = mid;
}
}
return ok;
}
static int binary_search(int key, int[] moto) {
int ng = -1;
int ok = moto.Length;
while (Math.Abs(ok - ng) > 1) {
int mid = (ok + ng) / 2;
if (isOK(mid, key, moto)) {
ok = mid;
} else {
ng = mid;
}
}
return ok;
}
static int[] Togo;
static bool CheckBipartite(int now, int prev, List<int>[] g,
int c = 0) // 0,-1が想定
{
if (Togo == null)
Togo = Enumerable.Repeat(-1, g.Length).ToArray();
foreach (var next in g[now]) {
if (next == prev)
continue;
var nextc = Togo[next];
if (nextc >= 0 && nextc == c)
return false;
if (nextc >= 0)
continue;
Togo[next] = (c + 1) % 2;
var res = CheckBipartite(next, now, g, (c + 1) % 2);
if (res == false)
return false;
}
return true;
}
static bool isOK(int index, int key, int[] moto) { return moto[index] > key; }
public static int bitCount(int k) {
uint i = (uint)k;
i = i - ((i >> 1) & 0x55555555);
i = (i & 0x33333333) + ((i >> 2) & 0x33333333);
i = (i + (i >> 4)) & 0x0f0f0f0f;
i = i + (i >> 8);
i = i + (i >> 16);
return (int)i & 0x3f;
}
static int check(long moto, long tai) {
if (tai % moto != 0) {
return 0;
}
while (tai > 1) {
if (tai % moto == 0) {
tai /= moto;
} else if (tai > moto) {
tai %= moto;
} else {
tai -= moto;
}
}
if (tai == 1) {
return 1;
} else {
return 0;
}
}
static bool NextPermutation(int[] array) {
var size = array.Length;
var ok = false;
// array[i]<array[i+1]を満たす最大のiを求める
int i = size - 2;
for (; 0 <= i; i--) {
if (array[i] < array[i + 1]) {
ok = true;
break;
}
}
//全ての要素が降順の場合、NextPermutationは存在しない
if (ok == false)
return false;
// array[i]<array[j]を満たす最大のjを求める
int j = size - 1;
for (;; j--) {
if (array[i] < array[j])
break;
}
// iとjの要素をswapする
var tmp = array[i];
array[i] = array[j];
array[j] = tmp;
// i以降の要素を反転させる
Array.Reverse(array, i + 1, size - (i + 1));
return true;
}
static List<int[]> GetAllPermutation(int N) {
var res = new List<int[]>();
var array = Enumerable.Range(0, N).ToArray();
do {
var copy = new int[N];
array.CopyTo(copy, 0);
res.Add(copy);
} while (NextPermutation(array));
return res;
}
static List<int[]> GetAllPermutation(int[] array) {
var size = array.Length;
var res = new List<int[]>();
do {
var copy = new int[size];
array.CopyTo(copy, 0);
res.Add(copy);
} while (NextPermutation(array));
return res;
}
static long Syakutori(
int[] a,
long
k) //しゃくとり法モデル:連続部分列に含まれるすべての要素の値の和がK以上
{
long sum = 0;
int right = 0;
long ans = 0;
for (int left = 0; left < a.Length; left++) {
while (right < a.Length && sum < k) {
sum += a[right];
right++;
}
if (k <= sum) {
ans += a.Length - right + 1;
}
if (left == right) {
right++;
} else {
sum -= a[left];
}
}
return ans;
}
static int[] zalgo(String s) {
int n = s.Length;
int[] ret = new int[n];
ret[0] = n;
int i = 1, j = 0;
while (i < n) {
while (i + j < n && s[j] == s[i + j])
++j;
ret[i] = j;
if (j == 0) {
++i;
continue;
}
int k = 1;
while (i + k < n && k + ret[k] < j) {
ret[i + k] = ret[k];
++k;
}
i += k;
j -= k;
}
return ret;
}
static int gcd(int a, int b) {
if (a % b == 0) {
return b;
}
return gcd(b, a % b);
}
static long gcd(long a, long b) {
if (a % b == 0) {
return b;
}
return gcd(b, a % b);
}
public static List<long> factorialMemo = new List<long>() { 1 };
static long Fact(int x) {
for (int i = factorialMemo.Count; i <= x; i++)
factorialMemo.Add(factorialMemo.Last() * i);
return factorialMemo[x];
}
static int[] yousogotoplus(int[] a, int[] b) {
int[] c = new int[a.Length];
for (int i = 0; i < a.Length; i++) {
c[i] = a[i] + b[i];
}
return c;
}
static int[] yousogotoplus(int[] a, int[,] b, int l) {
int[] c = new int[a.Length];
for (int i = 0; i < a.Length; i++) {
c[i] = a[i] + b[l, i];
}
return c;
}
static int[] yousogotoplus(int[,] a, int l) {
int[] c = new int[a.GetLength(1)];
for (int i = 0; i < a.GetLength(1); i++) {
c[i] = a[l, i];
}
return c;
}
public static long LowerBound(long[] a, long key) {
long l = 0;
long r = a.Length;
long mid;
while (l < r) {
mid = ((r - l) / 2) + l;
if (a[mid] <= key)
l = mid + 1;
else
r = mid;
}
return l;
}
public static long LIS(long[] a) {
var dp = Enumerable.Range(0, a.Length).Select(x => long.MaxValue).ToArray();
for (int i = 0; i < a.Length; i++) {
dp[LowerBound(dp, a[i])] = a[i];
}
return LowerBound(dp, long.MaxValue - 1);
}
static long DivideWith(long m, long n, List<long> primes) {
while (m % n == 0) {
primes.Add(n);
m = m / n;
}
return m;
}
static List<CPair<long, long>> SoinsuBunkai(long num) {
List<CPair<long, long>> primes = new List<CPair<long, long>>();
List<long> yakusu = new List<long>();
List<long> yakusu2 = new List<long>();
for (int i = 2; i * i <= num; i++) {
if (num % i != 0) {
continue;
}
yakusu.Add(i);
if (i * i != num) {
yakusu2.Add(num / i);
}
}
for (int i = 0; i < yakusu.Count; i++) {
if (num % yakusu[i] != 0) {
continue;
}
int j = 0;
for (j = 0; num % yakusu[i] == 0; j++) {
num /= yakusu[i];
}
primes.Add(new CPair<long, long>(yakusu[i], j));
}
for (int i = yakusu2.Count - 1; i > 0; i--) {
if (num % yakusu2[i] != 0) {
continue;
}
int j = 0;
for (j = 0; num % yakusu2[i] == 0; j++) {
num /= yakusu2[i];
}
primes.Add(new CPair<long, long>(yakusu2[i], j));
}
return primes;
}
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;
}
/* static long[] SoinsuBunkai(long num)
{
if (num == 1)
return new long[] { 1 };
List<long> primes = new List<long>();
long n = DivideWith(num, 2, primes);
n = DivideWith(n, 3, primes);
n = DivideWith(n, 5, primes);
long i = 0;
while (n > 1)
{
int[] ps = { 7, 11, 13, 17, 19, 23, 29, 31 };
foreach (var p in ps)
{
// 30m+2, 30m+3, 30m+4, 30m+5, 30m+6、30m+8...
は割る必要はない。 n = DivideWith(n, i + p, primes); if (n == 1) break;
}
i += 30;
}
return primes.ToArray();
}*/
public static int h;
public static int w;
public static int BFS(int height, int width, char[,] map) {
int[] dx = new int[] { -1, 0, 0, 1 };
int[] dy = new int[] { 0, 1, -1, 0 };
bool[,] visited = new bool[h, w];
int[,] len = new int[h, w];
var queue = new Queue<Tuple<int, int>>();
queue.Enqueue(new Tuple<int, int>(height, width));
int max = 0;
visited[height, width] = true;
while (queue.Count > 0) {
var now = queue.Dequeue();
for (int i = 0; i < 4; i++) {
int ny = now.Item1 + dy[i];
int nx = now.Item2 + dx[i];
if (ny >= h || ny < 0 || nx >= w || nx < 0)
continue;
if (visited[ny, nx] || map[ny, nx] == '#')
continue;
visited[ny, nx] = true;
len[ny, nx] = len[now.Item1, now.Item2] + 1;
max = Math.Max(max, len[ny, nx]);
queue.Enqueue(new Tuple<int, int>(ny, nx));
}
}
return max;
}
static public bool Bit(long x, int dig) => ((1L << dig) & x) != 0;
static public void Swap<T>(ref T a, ref T b) {
T keep = a;
a = b;
b = keep;
}
static public void Initialize<T>(ref T[] array, T initialvalue) {
array = Array.ConvertAll(array, x => initialvalue);
}
static int[] Manacher(string S) {
int i = 0, j = 0;
int[] R = new int[S.Length];
while (i < S.Length) {
while (i - j >= 0 && i + j < S.Length && S[i - j] == S[i + j])
++j;
R[i] = j;
int k = 1;
while (i - k >= 0 && k + R[i - k] < j) {
R[i + k] = R[i - k];
++k;
}
i += k;
j -= k;
}
return R;
}
/* static Pair[] a;
static int SaikiZentansaku(List<int>now,int count,int last,int n,int m)
{
List<int> next = new List<int>();
for (int i = 0; i < now.Count; i++)
{
next.Add(now[i]);
}
next.Add(last);
var kore = next.ToArray();
int ans = 0;
if(count==n)
{
for (int i = 0; i < a.Length; i++)
{
int A = a[i].a;
int b = a[i].b;
int c = a[i].c;
int d = a[i].x;
if (kore[b] - kore[A] == c) { ans += d; }
}
return ans;
}
for (int i = last; i <= m; i++)
{
ans = Math.Max(ans, SaikiZentansaku(next, count + 1, i, n, m));
}
return ans;
}*/
}
public class StreamScanner {
public StreamScanner(Stream stream) { str = stream; }
private readonly Stream str;
private readonly byte[] buf = new byte[1024];
private long 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 char[] Char(long n) {
char[] kore = new char[n];
for (long i = 0; i < n; i++) {
kore[i] = Char();
}
return kore;
}
public char[,] Char(long n, long m) {
char[,] kore = new char[n, m];
for (long i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
kore[i, j] = Char();
}
}
return kore;
}
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 long[] Long(long n, bool minus1 = false) {
long[] kore = new long[n];
for (int i = 0; i < n; i++) {
kore[i] = Long();
if (minus1)
kore[i]--;
}
return kore;
}
public Mlong[] MLong(long n) {
Mlong[] kore = new Mlong[n];
for (int i = 0; i < n; i++) {
kore[i] = Long();
}
return kore;
}
public long[,] Long(long h, long w, bool minus1 = false) {
long[,] kore = new long[h, w];
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
kore[i, j] = Long();
if (minus1)
kore[i, j]--;
}
}
return kore;
}
public int Integer() { return (int)Long(); }
public Mint[] MInteger(long n) {
Mint[] kore = new Mint[n];
for (int i = 0; i < n; i++) {
kore[i] = Integer();
}
return kore;
}
public int[] Integer(long n, bool minus1 = false) {
int[] kore = new int[n];
for (int i = 0; i < n; i++) {
kore[i] = (int)Long();
if (minus1)
kore[i]--;
}
return kore;
}
public int[,] Integer(long h, long w, bool minus1 = false) {
int[,] kore = new int[h, w];
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
kore[i, j] = (int)Long();
if (minus1)
kore[i, j]--;
}
}
return kore;
}
public int[] StringToInt(int n) {
char[] s = Scan().ToCharArray();
int[] kore = new int[n];
for (int i = 0; i < n; i++) {
kore[i] = s[i] - '0';
}
return kore;
}
public int[,] StringToInt(int h, int w) {
int[,] kore = new int[h, w];
for (int i = 0; i < h; i++) {
char[] s = Scan().ToCharArray();
for (int j = 0; j < w; j++) {
kore[i, j] = s[j] - '0';
}
}
return kore;
}
public double Double() {
return double.Parse(Scan(), CultureInfo.InvariantCulture);
}
}
public class UnionFind {
public int[] data;
public UnionFind(int size) {
data = new int[size];
for (int i = 0; i < size; i++)
data[i] = -1;
}
public bool Unite(int x, int y) {
x = Root(x);
y = Root(y);
if (x != y) {
if (data[y] < data[x]) {
var tmp = y;
y = x;
x = tmp;
}
data[x] += data[y];
data[y] = x;
}
return x != y;
}
public bool IsSameGroup(int x, int y) { return Root(x) == Root(y); }
public int Root(int x) { return data[x] < 0 ? x : data[x] = Root(data[x]); }
}
public class Mlong : IComparable {
private static long mod = 1000000007;
public long num;
public Mlong(long num) {
if (num < 0) {
num += mod;
}
this.num = num % mod;
}
public override int GetHashCode() { return num.GetHashCode(); }
public override bool Equals(object obj) { return num.Equals(obj); }
public static Mlong operator +(Mlong x, Mlong y) {
return new Mlong((x.num + y.num) % mod);
}
public static Mlong operator -(Mlong x, Mlong y) {
return new Mlong((x.num - y.num + mod) % mod);
}
public static Mlong operator *(Mlong x, Mlong y) {
return new Mlong((long)(((1L * x.num) * y.num) % mod));
}
public Mlong hutujyo(Mlong x) { return new Mlong(num / x.num); }
static long GetInverse(long a) {
long div, p = mod, x1 = 1, y1 = 0, x2 = 0, y2 = 1;
while (true) {
if (p == 1)
return x2 + mod;
div = a / p;
x1 -= x2 * div;
y1 -= y2 * div;
a %= p;
if (a == 1)
return x1 + mod;
div = p / a;
x2 -= x1 * div;
y2 -= y1 * div;
p %= a;
}
}
public Mlong modjyo(Mlong x) { return num * GetInverse(x.num) % mod; }
public static implicit operator Mlong(long x) { return new Mlong(x); }
public static Mlong operator %(Mlong x, Mlong y) {
return new Mlong(x.num % y.num);
}
public static explicit operator long(Mlong x) { return x.num; }
public static bool operator ==(Mlong x, Mlong y) { return x.num == y.num; }
public static bool operator !=(Mlong x, Mlong y) { return x.num != y.num; }
public static bool operator<(Mlong x, Mlong y) { return x.num < y.num; }
public static bool operator>(Mlong x, Mlong y) { return x.num > y.num; }
public static bool operator <=(Mlong x, Mlong y) { return x.num <= y.num; }
public static bool operator >=(Mlong x, Mlong y) { return x.num >= y.num; }
public Mlong Pow(Mlong n) {
Mlong pow = this;
Mlong res = 1;
while (n > 0) {
if (n % 2 == 1) {
res *= pow;
}
pow *= pow;
n = n.hutujyo(2);
}
/* if (n == 1) { return this % mod; }
if (n % 2 == 1) { return (this * Pow(n - 1)) % mod; }
Mint buf = Pow(n.hutujyo(2));
return (buf * buf) % mod;*/
return res;
}
public static Mlong Pow(Mlong a, Mlong n) { return a.Pow(n); }
public static List<Mlong> factorialMemo = new List<Mlong>() { 1 };
static Mlong Factorial(int x) {
for (int i = factorialMemo.Count; i <= x; i++)
factorialMemo.Add(factorialMemo.Last() * i);
return factorialMemo[x];
}
public static Mlong Comb(Mlong n, Mlong a) {
Mlong buf1 = 1;
Mlong buf2 = 1;
for (long i = 0; i < a.num; i++) {
buf1 *= n - i;
buf2 *= (i + 1);
}
return buf1.modjyo(buf2);
}
public static Mlong Comb(int n, int r) {
return Factorial(n).modjyo(Factorial(r)).modjyo(Factorial(n - r));
}
public static void WriteLine(Mlong x) { Console.WriteLine(x.num); }
public int CompareTo(object obj) {
Mlong kore = (Mlong)obj;
return num.CompareTo(kore.num);
}
}
public class Mint : IComparable {
public static int mod = 1000000007;
public int num;
public Mint(int Num) { num = Num; }
public override int GetHashCode() { return num.GetHashCode(); }
public override bool Equals(object obj) { return num.Equals(obj); }
public static Mint operator +(Mint x, Mint y) {
return new Mint((x.num + y.num) % mod);
}
public static Mint operator -(Mint x, Mint y) {
return new Mint((x.num - y.num + mod) % mod);
}
public static Mint operator *(Mint x, Mint y) {
return new Mint((int)(((1L * x.num) * y.num) % mod));
}
public Mint hutujyo(Mint x) { return new Mint(num / x.num); }
static int GetInverse(long a) {
long div, p = mod, x1 = 1, y1 = 0, x2 = 0, y2 = 1;
while (true) {
if (p == 1)
return (int)(x2 + mod);
div = a / p;
x1 -= x2 * div;
y1 -= y2 * div;
a %= p;
if (a == 1)
return (int)(x1 + mod);
div = p / a;
x2 -= x1 * div;
y2 -= y1 * div;
p %= a;
}
}
public Mint modjyo(Mint x) { return num * GetInverse(x.num) % mod; }
/* public Mint modjyo(Mint x)
{
return num * x.Pow(mod - 2);
}*/
public static implicit operator Mint(int x) { return new Mint(x); }
public static Mint[] Toarray(int[] x) {
Mint[] buf = new Mint[x.Length];
for (int i = 0; i < x.Length; i++) {
buf[i] = x[i];
}
return buf;
}
public static explicit operator int(Mint x) { return x.num; }
public static Mint operator %(Mint x, Mint y) {
return new Mint(x.num % y.num);
}
public static bool operator ==(Mint x, Mint y) { return x.num == y.num; }
public static bool operator !=(Mint x, Mint y) { return x.num != y.num; }
public static bool operator<(Mint x, Mint y) { return x.num < y.num; }
public static bool operator>(Mint x, Mint y) { return x.num > y.num; }
public static bool operator <=(Mint x, Mint y) { return x.num <= y.num; }
public static bool operator >=(Mint x, Mint y) { return x.num >= y.num; }
public Mint Pow(Mint n) {
Mint pow = this;
Mint res = 1;
while (n > 0) {
if (n % 2 == 1) {
res *= pow;
}
pow *= pow;
n.hutujyo(2);
}
/* if (n == 1) { return this % mod; }
if (n % 2 == 1) { return (this * Pow(n - 1)) % mod; }
Mint buf = Pow(n.hutujyo(2));
return (buf * buf) % mod;*/
return res;
}
public static Mint Pow(Mint a, Mint n) { return a.Pow(n); }
public static List<Mint> factorialMemo = new List<Mint>() { 1 };
static Mint Factorial(int x) {
for (int i = factorialMemo.Count; i <= x; i++)
factorialMemo.Add(factorialMemo.Last() * i);
return factorialMemo[x];
}
public static Mint Comb(int n, int r) {
return Factorial(n).modjyo(Factorial(r)).modjyo(Factorial(n - r));
}
public static void WriteLine(Mint x) { Console.WriteLine(x.num); }
public int CompareTo(object obj) {
Mint kore = (Mint)obj;
return num.CompareTo(kore.num);
}
}
public class PriorityQueue<T> : IEnumerable<T> {
private readonly List<T> _data = new List<T>();
private readonly IComparer<T> _comparer;
private readonly bool _isDescending;
public PriorityQueue(IComparer<T> comparer, bool isDescending = true) {
_comparer = comparer;
_isDescending = isDescending;
}
public PriorityQueue(Comparison<T> comparison, bool isDescending = true)
: this(Comparer<T>.Create(comparison), isDescending) {}
public PriorityQueue(bool isDescending = true)
: this(Comparer<T>.Default, isDescending) {}
public void Enqueue(T item) {
_data.Add(item);
var childIndex = _data.Count - 1;
while (childIndex > 0) {
var parentIndex = (childIndex - 1) / 2;
if (Compare(_data[childIndex], _data[parentIndex]) >= 0)
break;
Swap(childIndex, parentIndex);
childIndex = parentIndex;
}
}
public T Dequeue() {
var lastIndex = _data.Count - 1;
var firstItem = _data[0];
_data[0] = _data[lastIndex];
_data.RemoveAt(lastIndex--);
var parentIndex = 0;
while (true) {
var childIndex = parentIndex * 2 + 1;
if (childIndex > lastIndex)
break;
var rightChild = childIndex + 1;
if (rightChild <= lastIndex &&
Compare(_data[rightChild], _data[childIndex]) < 0)
childIndex = rightChild;
if (Compare(_data[parentIndex], _data[childIndex]) <= 0)
break;
Swap(parentIndex, childIndex);
parentIndex = childIndex;
}
return firstItem;
}
public T Peek() { return _data[0]; }
private void Swap(int a, int b) {
var tmp = _data[a];
_data[a] = _data[b];
_data[b] = tmp;
}
private int Compare(T a, T b) {
return _isDescending ? _comparer.Compare(b, a) : _comparer.Compare(a, b);
}
public int Count => _data.Count;
public IEnumerator<T> GetEnumerator() { return _data.GetEnumerator(); }
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
public class Tree {
public Node[] Nodes;
public List<int[]> hen;
public class Node {
public int? parent = null;
public List<int[]> children = new List<int[]>();
public int parentcolor = -1;
}
public Tree(int kosu) {
Nodes = new Node[kosu];
for (int i = 0; i < Nodes.Length; i++) {
Nodes[i] = new Node();
}
hen = new List<int[]>();
}
public void Connect(int oya, int ko, int id) {
hen.Add(new int[] { oya, ko, 0 });
Nodes[oya].children.Add(new int[] { ko, id });
Nodes[ko].parent = oya;
}
}
/// <summary>
/// Self-Balancing Binary Search Tree
/// (using Randamized BST)
/// </summary>
public class SB_BinarySearchTree<T>
where T : IComparable {
public class Node {
public T Value;
public Node LChild;
public Node RChild;
public int Count; // size of the sub tree
public Node(T v) {
Value = v;
Count = 1;
}
}
static Random _rnd = new Random();
public static int Count(Node t) { return t == null ? 0 : t.Count; }
static Node Update(Node t) {
t.Count = Count(t.LChild) + Count(t.RChild) + 1;
return t;
}
public static Node Merge(Node l, Node r) {
if (l == null || r == null)
return l == null ? r : l;
if ((double)Count(l) / (double)(Count(l) + Count(r)) > _rnd.NextDouble()) {
l.RChild = Merge(l.RChild, r);
return Update(l);
} else {
r.LChild = Merge(l, r.LChild);
return Update(r);
}
}
/// <summary>
/// split as [0, k), [k, n)
/// </summary>
public static Tuple<Node, Node> Split(Node t, int k) {
if (t == null)
return new Tuple<Node, Node>(null, null);
if (k <= Count(t.LChild)) {
var s = Split(t.LChild, k);
t.LChild = s.Item2;
return new Tuple<Node, Node>(s.Item1, Update(t));
} else {
var s = Split(t.RChild, k - Count(t.LChild) - 1);
t.RChild = s.Item1;
return new Tuple<Node, Node>(Update(t), s.Item2);
}
}
public static Node Remove(Node t, T v) {
if (Find(t, v) == null)
return t;
return RemoveAt(t, LowerBound(t, v));
}
public static Node RemoveAt(Node t, int k) {
var s = Split(t, k);
var s2 = Split(s.Item2, 1);
return Merge(s.Item1, s2.Item2);
}
public static bool Contains(Node t, T v) { return Find(t, v) != null; }
public static Node Find(Node t, T v) {
while (t != null) {
var cmp = t.Value.CompareTo(v);
if (cmp > 0)
t = t.LChild;
else if (cmp < 0)
t = t.RChild;
else
break;
}
return t;
}
public static Node FindByIndex(Node t, int idx) {
if (t == null)
return null;
var currentIdx = Count(t) - Count(t.RChild) - 1;
while (t != null) {
if (currentIdx == idx)
return t;
if (currentIdx > idx) {
t = t.LChild;
currentIdx -= (Count(t == null ? null : t.RChild) + 1);
} else {
t = t.RChild;
currentIdx += (Count(t == null ? null : t.LChild) + 1);
}
}
return null;
}
public static int UpperBound(Node t, T v) {
var torg = t;
if (t == null)
return -1;
var ret = Int32.MaxValue;
var idx = Count(t) - Count(t.RChild) - 1;
while (t != null) {
var cmp = t.Value.CompareTo(v);
if (cmp > 0) {
ret = Math.Min(ret, idx);
t = t.LChild;
idx -= (Count(t == null ? null : t.RChild) + 1);
} else if (cmp <= 0) {
t = t.RChild;
idx += (Count(t == null ? null : t.LChild) + 1);
}
}
return ret == Int32.MaxValue ? Count(torg) : ret;
}
public static int LowerBound(Node t, T v) {
var torg = t;
if (t == null)
return -1;
var idx = Count(t) - Count(t.RChild) - 1;
var ret = Int32.MaxValue;
while (t != null) {
var cmp = t.Value.CompareTo(v);
if (cmp >= 0) {
if (cmp == 0)
ret = Math.Min(ret, idx);
t = t.LChild;
if (t == null)
ret = Math.Min(ret, idx);
idx -= t == null ? 0 : (Count(t.RChild) + 1);
} else if (cmp < 0) {
t = t.RChild;
idx += (Count(t == null ? null : t.LChild) + 1);
if (t == null)
return idx;
}
}
// return ret;
return ret == Int32.MaxValue ? Count(torg) : ret;
}
public static Node Insert(Node t, T v) {
var ub = LowerBound(t, v);
return InsertByIdx(t, ub, v);
}
static Node InsertByIdx(Node t, int k, T v) {
var s = Split(t, k);
return Merge(Merge(s.Item1, new Node(v)), s.Item2);
}
public static IEnumerable<T> Enumerate(Node t) {
var ret = new List<T>();
Enumerate(t, ret);
return ret;
}
static void Enumerate(Node t, List<T> ret) {
if (t == null)
return;
Enumerate(t.LChild, ret);
ret.Add(t.Value);
Enumerate(t.RChild, ret);
}
}
/// <summary>
/// C-like set
/// </summary>
public class Set<T>
where T : IComparable {
protected SB_BinarySearchTree<T>.Node _root;
public T this[int idx] {
get { return ElementAt(idx); }
}
public int Count() { return SB_BinarySearchTree<T>.Count(_root); }
public bool Any() { return _root != null; }
public virtual void Insert(T v) {
if (_root == null)
_root = new SB_BinarySearchTree<T>.Node(v);
else {
if (SB_BinarySearchTree<T>.Find(_root, v) != null)
return;
_root = SB_BinarySearchTree<T>.Insert(_root, v);
}
}
public void Clear() { _root = null; }
public void Remove(T v) { _root = SB_BinarySearchTree<T>.Remove(_root, v); }
public bool Contains(T v) {
return SB_BinarySearchTree<T>.Contains(_root, v);
}
public T ElementAt(int k) {
var node = SB_BinarySearchTree<T>.FindByIndex(_root, k);
if (node == null)
throw new IndexOutOfRangeException();
return node.Value;
}
public int Count(T v) {
return SB_BinarySearchTree<T>.UpperBound(_root, v) -
SB_BinarySearchTree<T>.LowerBound(_root, v);
}
public int LowerBound(T v) {
return SB_BinarySearchTree<T>.LowerBound(_root, v);
}
public int UpperBound(T v) {
return SB_BinarySearchTree<T>.UpperBound(_root, v);
}
public T max() {
SB_BinarySearchTree<T>.Node ima = _root;
while (ima.RChild != null) {
ima = ima.RChild;
}
return ima.Value;
}
public T min() {
SB_BinarySearchTree<T>.Node ima = _root;
while (ima.LChild != null) {
ima = ima.LChild;
}
return ima.Value;
}
public Tuple<int, int> EqualRange(T v) {
if (!Contains(v))
return new Tuple<int, int>(-1, -1);
return new Tuple<int, int>(SB_BinarySearchTree<T>.LowerBound(_root, v),
SB_BinarySearchTree<T>.UpperBound(_root, v) - 1);
}
public List<T> ToList() {
return new List<T>(SB_BinarySearchTree<T>.Enumerate(_root));
}
}
/// <summary>
/// C-like multiset
/// </summary>
public class MultiSet<T> : Set<T>
where T : IComparable {
public override void Insert(T v) {
if (_root == null)
_root = new SB_BinarySearchTree<T>.Node(v);
else
_root = SB_BinarySearchTree<T>.Insert(_root, v);
}
}
public class RollingHashSlow {
public const long B = (long)1e5 + 7;
public const long MOD = (long)1e9 + 7;
public string S { get; set; }
public int N { get; set; }
public long[] Power { get; set; }
public long[] Hash { get; set; }
public RollingHashSlow(string s) {
this.S = s;
this.N = s.Length;
// B^nを計算しておく
this.Power = new long[this.N + 1];
this.Power[0] = 1;
for (int i = 0; i < N; i++) {
this.Power[i + 1] = (this.Power[i] * B) % MOD;
}
// ハッシュを前計算する
this.Hash = new long[this.N + 1];
for (int i = 0; i < N; i++) {
this.Hash[i + 1] = (this.Hash[i] * B + S[i]) % MOD;
}
}
// S[l, r) のハッシュ値を求める
public long Get(int l, int r) {
var hash = this.Hash[r] - (this.Hash[l] * this.Power[r - l] % MOD);
if (hash < 0)
hash += MOD;
return hash;
}
}
class RollingHashFast {
public const ulong B = (ulong)1e9 + 7;
public string S { get; set; }
public int N { get; set; }
public ulong[] Power { get; set; }
public ulong[] Hash { get; set; }
public RollingHashFast(string s) {
this.S = s;
this.N = s.Length;
// B^nを計算しておく
this.Power = new ulong[this.N + 1];
this.Power[0] = 1;
for (int i = 0; i < N; i++) {
this.Power[i + 1] = this.Power[i] * B;
}
// ハッシュを前計算する
this.Hash = new ulong[this.N + 1];
for (int i = 0; i < N; i++) {
this.Hash[i + 1] = this.Hash[i] * B + S[i];
}
}
// [l, r) のハッシュ値を求める
public ulong Get(int l, int r) {
var hash = this.Hash[r] - (this.Hash[l] * this.Power[r - l]);
return hash;
}
}
class Segtree<T> {
int n;
T[] tree;
Func<T, T, T> f;
T exnum;
public Segtree(int m, Func<T, T, T> f, T ex) {
this.f = f;
this.exnum = ex;
n = 1;
while (n < m)
n <<= 1;
tree = new T[(n << 1) - 1];
for (int i = 0; i < tree.Length; i++)
tree[i] = ex;
}
public Segtree(int m, T ini, Func<T, T, T> f, T ex) : this(m, f, ex) {
for (int i = 0; i < m; ++i)
tree[i + n - 1] = ini;
all_update();
}
public void assign_without_update(int j, T x) { tree[j + n - 1] = x; }
public void update(int j, T x) {
int i = j + n - 1;
tree[i] = x;
while (i > 0) {
i = (i - 1) >> 1;
tree[i] = f(tree[(i << 1) + 1], tree[(i << 1) + 2]);
}
}
public void all_update() {
for (int i = n - 2; i >= 0; i--)
tree[i] = f(tree[(i << 1) + 1], tree[(i << 1) + 2]);
}
public T look(int i) { return tree[i + n - 1]; }
// [s, t)
public T run(int s, int t) { return query(s, t, 0, 0, n); }
T query(int s, int t, int k, int l, int r) {
if (r <= s || t <= l)
return exnum;
if (s <= l && r <= t)
return tree[k];
return f(query(s, t, (k << 1) + 1, l, (l + r) >> 1),
query(s, t, (k + 1) << 1, (l + r) >> 1, r));
}
}
public class WarshallFloyd {
public int V { get; set; }
public long[,] DP { get; set; }
public long INF = long.MaxValue;
public bool[] Negative;
public WarshallFloyd(int v) {
this.V = v;
this.DP = new long[V, V];
for (int i = 0; i < V; i++) {
for (int j = 0; j < V; j++) {
this.DP[i, j] = INF;
}
this.DP[i, i] = 0;
}
}
public void SetCost(int a, int b, int c = 1) { this.DP[a, b] = c; }
public long[,] CalcMinCost() {
this.Negative = new bool[V];
for (int k = 0; k < V; k++) {
for (int i = 0; i < V; i++) {
for (int j = 0; j < V; j++) {
if (DP[i, k] == INF || DP[k, j] == INF)
continue;
DP[i, j] = Math.Min(DP[i, j], DP[i, k] + DP[k, j]);
}
}
}
for (int k = 0; k < V; k++) {
for (int i = 0; i < V; i++) {
for (int j = 0; j < V; j++) {
if (DP[i, k] == INF || DP[k, j] == INF)
continue;
if (DP[i, j] > DP[i, k] + DP[k, j]) {
this.Negative[i] = true;
this.Negative[j] = true;
this.Negative[k] = true;
}
}
}
}
return DP;
}
public long GetMinCost(int a, int b) { return DP[a, b]; }
public bool IsINF(int a, int b) { return DP[a, b] >= INF; }
public bool IsNegative(params int[] vs) {
if (vs.Length == 0)
vs = Enumerable.Range(0, V).ToArray();
foreach (var v in vs) {
if (Negative[v])
return true;
}
return false;
}
}
/// <summary>
/// Get min cost between two points
/// </summary>
public class Dijkstra {
private int maxIndex = -1;
private const int INF = Int32.MaxValue;
private int[,] _edgeArray;
/// <summary>
/// Dijkstra, get min cost between two points
/// should not contain negatie cost path
/// </summary>
/// <param name="size">max index of vertices</param>
public Dijkstra(int size) {
maxIndex = size + 1;
_edgeArray = new int[maxIndex, maxIndex];
for (int i = 0; i < _edgeArray.GetLength(0); i++) {
for (int j = 0; j < _edgeArray.GetLength(1); j++) {
_edgeArray[i, j] = INF;
if (i == j)
_edgeArray[i, j] = 0;
}
}
}
// Add a path(no direction) with its cost
public void AddPath(int s, int t, int cost) {
_edgeArray[s, t] = Math.Min(_edgeArray[s, t], cost);
_edgeArray[t, s] = _edgeArray[s, t];
}
// Get the min cost between s and t
// return Int32.MaxValue if no path
public int GetMinCost(int s, int t) {
int[] cost = new int[maxIndex];
for (int i = 0; i < cost.Length; i++)
cost[i] = INF;
cost[s] = 0;
var priorityQueue = new PriorityQueue<CPair<int, int>>();
priorityQueue.Enqueue(new CPair<int, int>(0, s));
while (priorityQueue.Count() > 0) {
var costDestinationPair = priorityQueue.Dequeue();
if (cost[costDestinationPair.Item2] < costDestinationPair.Item1)
continue;
for (int i = 0; i < maxIndex; i++) {
int newCostToi = _edgeArray[costDestinationPair.Item2, i] == INF
? INF
: costDestinationPair.Item1 +
_edgeArray[costDestinationPair.Item2, i];
if (newCostToi < cost[i]) {
cost[i] = newCostToi;
priorityQueue.Enqueue(new CPair<int, int>(newCostToi, i));
}
}
}
return cost[t];
}
}
class Deque<T> : IEnumerable<T> {
public T this[int i] {
get { return this.Buffer[(this.FirstIndex + i) % this.Capacity]; }
set {
if (i < 0)
throw new ArgumentOutOfRangeException();
this.Buffer[(this.FirstIndex + i) % this.Capacity] = value;
}
}
private T[] Buffer;
private int Capacity;
private int FirstIndex;
private int LastIndex {
get { return (this.FirstIndex + this.Length) % this.Capacity; }
}
public int Length;
public Deque(int capacity = 16) {
this.Capacity = capacity;
this.Buffer = new T[this.Capacity];
this.FirstIndex = 0;
}
public void PushBack(T data) {
if (this.Length == this.Capacity)
this.Resize();
this.Buffer[this.LastIndex] = data;
this.Length++;
}
public void PushFront(T data) {
if (this.Length == this.Capacity)
this.Resize();
var index = this.FirstIndex - 1;
if (index < 0)
index = this.Capacity - 1;
this.Buffer[index] = data;
this.Length++;
this.FirstIndex = index;
}
public T PopBack() {
if (this.Length == 0)
throw new InvalidOperationException("データが空です。");
var data = this[this.Length - 1];
this.Length--;
return data;
}
public T PopFront() {
if (this.Length == 0)
throw new InvalidOperationException("データが空です。");
var data = this[0];
this.FirstIndex++;
this.FirstIndex %= this.Capacity;
this.Length--;
return data;
}
private void Resize() {
var newArray = new T[this.Capacity * 2];
for (int i = 0; i < this.Length; i++) {
newArray[i] = this[i];
}
this.FirstIndex = 0;
this.Capacity *= 2;
this.Buffer = newArray;
}
public IEnumerator<T> GetEnumerator() {
for (int i = 0; i < this.Length; i++) {
yield return this[i];
}
}
IEnumerator IEnumerable.GetEnumerator() {
for (int i = 0; i < this.Length; i++) {
yield return this[i];
}
}
}
public struct Edge {
public int from;
public int to;
public long dist;
public Edge(int t, long c) {
from = -1;
to = t;
dist = c;
}
public Edge(int f, int t, long c) {
from = f;
to = t;
dist = c;
}
}
public class PotentializedUnionFind {
int _count;
int[] par, sizes, rank;
long[] weight;
public PotentializedUnionFind(int N) {
_count = N;
par = new int[N];
sizes = new int[N];
rank = new int[N];
weight = new long[N];
for (int i = 0; i < N; ++i) {
par[i] = i;
sizes[i] = 1;
rank[i] = 0;
}
}
int Root(int X) {
if (par[X] == X) {
return X;
} else {
int r = Root(par[X]);
weight[X] += weight[par[X]];
return (par[X] = r);
}
}
public bool Merge(int X, int Y, long W) {
W += GetWeight(X);
W -= GetWeight(Y);
X = Root(X);
Y = Root(Y);
if (X == Y)
return false;
--_count;
if (rank[X] < rank[Y]) {
par[X] = Y;
sizes[Y] += sizes[X];
weight[X] = -W;
} else {
par[Y] = X;
sizes[X] += sizes[Y];
if (rank[X] == rank[Y])
++rank[X];
weight[Y] = W;
}
return true;
}
public bool IsSame(int X, int Y) => Root(X) == Root(Y);
public int Count => _count;
public bool IsParent(int X) => X == Root(X);
public int GetParent(int X) => Root(X);
public int Size(int X) => sizes[Root(X)];
public long GetWeight(int X) {
Root(X);
return weight[X];
}
public long GetDiff(int X, int Y) => GetWeight(Y) - GetWeight(X);
}
public static class BellmanFord {
public class Vertex {
public long Distance { get; set; }
public Vertex() { Distance = long.MaxValue; }
}
public class Edge {
public int From { get; private set; }
public int To { get; private set; }
public long Weight { get; private set; }
public Edge(int from, int to, long weight) {
From = from;
To = to;
Weight = weight;
}
}
private static void GetReachable(int origin, ref HashSet<int> reached,
ref Dictionary<int, int[]> paths) {
if (reached.Contains(origin))
return;
reached.Add(origin);
if (paths.ContainsKey(origin) == false)
return;
foreach (var p in paths[origin])
GetReachable(p, ref reached, ref paths);
}
/// <summary>
/// null: 負の無限大
/// long.MaxValue: たどり着けない
/// その他: 距離
/// </summary>
public static long? RunBellmanFord(int vertexCount, List<Edge> rawEdges,
int source, int dest) {
var forwards =
rawEdges.GroupBy(x => x.From)
.ToDictionary(x => x.Key, x => x.Select(xs => xs.To).ToArray());
var reverses = rawEdges.GroupBy(x => x.To).ToDictionary(
x => x.Key, x => x.Select(xs => xs.From).ToArray());
var fromSource = new HashSet<int>();
var toDest = new HashSet<int>();
GetReachable(source, ref fromSource, ref forwards);
GetReachable(dest, ref toDest, ref reverses);
var edges = rawEdges.Where(e => fromSource.Contains(e.From))
.Where(e => fromSource.Contains(e.To))
.Where(e => toDest.Contains(e.From))
.Where(e => toDest.Contains(e.To))
.ToArray();
// initialize distances
var vertices = new List<Vertex>();
for (int i = 0; i < vertexCount; i++)
vertices.Add(new Vertex());
vertices[source].Distance = 0L;
// update distances
for (int i = 0; i < vertices.Count; i++) {
foreach (var e in edges) {
var from = vertices[e.From];
var to = vertices[e.To];
if (from.Distance == long.MaxValue)
continue;
var newDistance = from.Distance + e.Weight;
if (to.Distance > newDistance) {
to.Distance = newDistance;
}
}
}
// check negative cycle
foreach (var e in edges) {
var from = vertices[e.From];
var to = vertices[e.To];
if (from.Distance + e.Weight < to.Distance)
return null;
}
return vertices[dest].Distance;
}
}
public class SortedMultiSet<T> : IEnumerable<T> {
private SortedDictionary<T, int> _dict;
public SortedMultiSet() { _dict = new SortedDictionary<T, int>(); }
public SortedMultiSet(IEnumerable<T> items) : this() { Add(items); }
public bool Contains(T item) { return _dict.ContainsKey(item); }
public void Add(T item) {
if (_dict.ContainsKey(item))
_dict[item]++;
else
_dict[item] = 1;
}
public void Add(IEnumerable<T> items) {
foreach (var item in items)
Add(item);
}
public void Remove(T item) {
if (!_dict.ContainsKey(item))
throw new ArgumentException();
if (--_dict[item] == 0)
_dict.Remove(item);
}
// Return the last value in the multiset
public T Peek() {
if (!_dict.Any())
throw new NullReferenceException();
return _dict.Last().Key;
}
// Return the last value in the multiset and remove it.
public T Pop() {
T item = Peek();
Remove(item);
return item;
}
public IEnumerator<T> GetEnumerator() {
foreach (var kvp in _dict)
for (int i = 0; i < kvp.Value; i++)
yield return kvp.Key;
}
IEnumerator IEnumerable.GetEnumerator() { return this.GetEnumerator(); }
}
class Treap<T> : IEnumerable<T>
where T : IComparable {
public int Length {
get { return this.Root == null ? 0 : this.NodeCount(this.Root); }
}
public T this[int i] {
get {
if (this.Root.Count < i - 1)
throw new IndexOutOfRangeException();
return this.Root.Get(i);
}
}
public Node Root;
private IComparer<T> Cmp = Comparer<T>.Default;
public Treap(IComparer<T> cmp = null) {
if (cmp != null)
this.Cmp = cmp;
}
public Node Merge(Node l, Node r) {
if (l == null || r == null)
return l == null ? r : l;
if (l.Priority > r.Priority) {
l.R = this.Merge(l.R, r);
return this.Update(l);
} else {
r.L = this.Merge(l, r.L);
return this.Update(r);
}
}
// 左にk個、右に残り(n-k)個に分割する
public (Node, Node) Split(int k) { return this.Split(this.Root, k); }
public (Node, Node) Split(Node t, int k) {
if (t == null)
return (null, null);
if (k <= this.NodeCount(t.L)) {
var s = this.Split(t.L, k);
t.L = s.Item2;
return (s.Item1, this.Update(t));
} else {
var s = this.Split(t.R, k - this.NodeCount(t.L) - 1);
t.R = s.Item1;
return (this.Update(t), s.Item2);
}
}
public int NodeCount(Node node) { return node == null ? 0 : node.Count; }
public int LowerBouond(T value) { return this.LowerBouond(this.Root, value); }
public int LowerBouond(Node node, T value) {
if (node == null)
return 0;
if (this.Cmp.Compare(value, node.Value) <= 0)
return this.LowerBouond(node.L, value);
else
return this.NodeCount(node.L) + 1 + this.LowerBouond(node.R, value);
}
public int UpperBound(T value) { return this.UpperBound(this.Root, value); }
public int UpperBound(Node node, T value) {
if (node == null)
return 0;
if (this.Cmp.Compare(value, node.Value) >= 0)
return this.NodeCount(node.L) + 1 + this.UpperBound(node.R, value);
else
return this.UpperBound(node.L, value);
}
public int ValueCount(T value) {
return this.UpperBound(value) - this.LowerBouond(value);
}
public void Insert(T value) {
var sub = this.Split(this.Root, this.LowerBouond(value));
var newNode = new Node(value);
var merged = this.Merge(sub.Item1, newNode);
this.Root = this.Merge(merged, sub.Item2);
}
public void Erase(T value) {
if (this.ValueCount(value) == 0)
return;
var sub = this.Split(this.Root, this.LowerBouond(value));
this.Root = this.Merge(sub.Item1, this.Split(sub.Item2, 1).Item2);
}
public void InsertAt(Node node, int k) {
var sub = this.Split(this.Root, k);
var merged = this.Merge(sub.Item1, node);
this.Root = this.Merge(merged, sub.Item2);
}
public void InsertAt(T value, int k) {
var node = new Node(value);
var sub = this.Split(this.Root, k);
var merged = this.Merge(sub.Item1, node);
this.Root = this.Merge(merged, sub.Item2);
}
public Node EraseAt(int k) {
var sub = this.Split(this.Root, k);
var sub2 = this.Split(sub.Item2, 1);
var res = sub2.Item1;
this.Root = this.Merge(sub.Item1, sub2.Item2);
return res;
}
public Node Update(Node node) {
node.Count = this.NodeCount(node.L) + this.NodeCount(node.R) + 1;
return node;
}
public class Node {
private static Random Rand = new Random();
public T Value;
public Node L = null;
public Node R = null;
public int Count;
public double Priority;
public Node(T value, double priority) {
this.Value = value;
this.Priority = priority;
this.Count = 1;
}
public Node(T value) : this(value, Rand.NextDouble()) {}
public T Get(int i) { return this.GetNode(i).Value; }
public Node GetNode(int i) {
var lcount = 0;
if (this.L != null)
lcount = this.L.Count;
if (lcount == i)
return this;
else if (lcount < i)
return this.R.GetNode(i - lcount - 1);
else
return this.L.GetNode(i);
}
}
public IEnumerator<T> GetEnumerator() {
for (int i = 0; i < this.Length; i++)
yield return this.Root.Get(i);
}
IEnumerator IEnumerable.GetEnumerator() { return this.GetEnumerator(); }
}
public static class ObjectExtension {
// ディープコピーの複製を作る拡張メソッド
public static T DeepClone<T>(this T src) {
using (var memoryStream = new System.IO.MemoryStream()) {
var binaryFormatter =
new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
binaryFormatter.Serialize(memoryStream, src); // シリアライズ
memoryStream.Seek(0, System.IO.SeekOrigin.Begin);
return (T)binaryFormatter.Deserialize(memoryStream); // デシリアライズ
}
}
}
}
|
[["-", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["-", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 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], ["+", 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], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 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]]
| 8
| 13,776
| 17
|
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
namespace AtCoder.C {
public class Program {
public static void Main() {
var r = GetResult();
Debug.WriteLine(r);
Console.Write(r);
}
private static object GetResult() {
var N = ReadLong();
var a = ReadLongs();
var count = 0L;
if (a.Any(x => 1 <= x && x <= 399))
count++;
if (a.Any(x => 400 <= x && x <= 799))
count++;
if (a.Any(x => 800 <= x && x <= 1199))
count++;
if (a.Any(x => 1200 <= x && x <= 1599))
count++;
if (a.Any(x => 1600 <= x && x <= 1999))
count++;
if (a.Any(x => 2000 <= x && x <= 2399))
count++;
if (a.Any(x => 2400 <= x && x <= 2799))
count++;
if (a.Any(x => 2800 <= x && x <= 3199))
count++;
var xCount = a.Count(x => x >= 3200);
/*
レート 1-399:灰色
レート 400-799:茶色
レート 800-1199:緑色
レート 1200-1599:水色
レート 1600-1999:青色
レート 2000-2399:黄色
レート 2400-2799:橙色
レート 2800-3199:赤色
*/
return $"{count} {count + xCount}";
}
#region Console.Read
public static string ReadText() { return Console.ReadLine(); }
public static List<string> ReadTexts() {
return Console.ReadLine().Split(' ').ToList();
}
public static long ReadLong() { return long.Parse(Console.ReadLine()); }
public static (long, long) Read2Longs() {
var ls = ReadLongs();
return (ls[0], ls[1]);
}
public static (long, long, long) Read3Longs() {
var ls = ReadLongs();
return (ls[0], ls[1], ls[2]);
}
public static (long, long, long, long) Read4Longs() {
var ls = ReadLongs();
return (ls[0], ls[1], ls[2], ls[3]);
}
public static (long, long, long, long, long) Read5Longs() {
var ls = ReadLongs();
return (ls[0], ls[1], ls[2], ls[3], ls[4]);
}
public static List<long> ReadLongs() {
return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
}
#endregion
}
}
|
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
namespace AtCoder.C {
public class Program {
public static void Main() {
var r = GetResult();
Debug.WriteLine(r);
Console.Write(r);
}
private static object GetResult() {
var N = ReadLong();
var a = ReadLongs();
if (N == 1) {
return $"1 1";
}
var count = 0L;
if (a.Any(x => 1 <= x && x <= 399))
count++;
if (a.Any(x => 400 <= x && x <= 799))
count++;
if (a.Any(x => 800 <= x && x <= 1199))
count++;
if (a.Any(x => 1200 <= x && x <= 1599))
count++;
if (a.Any(x => 1600 <= x && x <= 1999))
count++;
if (a.Any(x => 2000 <= x && x <= 2399))
count++;
if (a.Any(x => 2400 <= x && x <= 2799))
count++;
if (a.Any(x => 2800 <= x && x <= 3199))
count++;
var xCount = a.Count(x => x >= 3200);
/*
レート 1-399:灰色
レート 400-799:茶色
レート 800-1199:緑色
レート 1200-1599:水色
レート 1600-1999:青色
レート 2000-2399:黄色
レート 2400-2799:橙色
レート 2800-3199:赤色
*/
return $"{(count == 0 ? 1 : count)} {count + xCount}";
}
#region Console.Read
public static string ReadText() { return Console.ReadLine(); }
public static List<string> ReadTexts() {
return Console.ReadLine().Split(' ').ToList();
}
public static long ReadLong() { return long.Parse(Console.ReadLine()); }
public static (long, long) Read2Longs() {
var ls = ReadLongs();
return (ls[0], ls[1]);
}
public static (long, long, long) Read3Longs() {
var ls = ReadLongs();
return (ls[0], ls[1], ls[2]);
}
public static (long, long, long, long) Read4Longs() {
var ls = ReadLongs();
return (ls[0], ls[1], ls[2], ls[3]);
}
public static (long, long, long, long, long) Read5Longs() {
var ls = ReadLongs();
return (ls[0], ls[1], ls[2], ls[3], ls[4]);
}
public static List<long> ReadLongs() {
return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
}
#endregion
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 0, 57, 64, 196, 0, 37, 0, 283, 0, 295], ["+", 0, 57, 64, 196, 0, 37, 0, 283, 0, 296], ["+", 0, 57, 64, 196, 0, 37, 0, 283, 0, 62], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 0, 37, 0, 283, 0, 284, 0, 23, 0, 24], ["+", 0, 284, 0, 23, 0, 41, 15, 16, 31, 22], ["+", 0, 284, 0, 23, 0, 41, 15, 16, 17, 60], ["+", 0, 284, 0, 23, 0, 41, 15, 16, 12, 203], ["+", 0, 283, 0, 284, 0, 23, 0, 41, 0, 101], ["+", 0, 283, 0, 284, 0, 23, 0, 41, 64, 203], ["+", 0, 283, 0, 284, 0, 23, 0, 41, 0, 102], ["+", 0, 37, 0, 283, 0, 284, 0, 23, 0, 25]]
| 8
| 555
| 21
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder {
class Program {
static public long[] Sarray() {
return ReadLine().Split().Select(long.Parse).ToArray();
}
static public List<long> Slist() {
return ReadLine().Split().Select(long.Parse).ToList();
}
static readonly long Mod = 1000000000 + 7;
static void Main(string[] args) {
// SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
var N = Sarray()[0];
var ai = Sarray();
var free = 0L;
var rate = new bool[8];
foreach (var a in ai) {
if (3199 < a)
++free;
else
rate[a / 400] = true;
}
var min = rate.Count(r => r);
var max = min + free;
WriteLine($"{min} {max}");
// Out.Flush();
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder {
class Program {
static public long[] Sarray() {
return ReadLine().Split().Select(long.Parse).ToArray();
}
static public List<long> Slist() {
return ReadLine().Split().Select(long.Parse).ToList();
}
static readonly long Mod = 1000000000 + 7;
static void Main(string[] args) {
// SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
var N = Sarray()[0];
var ai = Sarray();
var free = 0L;
var rate = new bool[8];
foreach (var a in ai) {
if (3199 < a)
++free;
else
rate[a / 400] = true;
}
var max = rate.Count(r => r) + free;
var min = Max(rate.Count(r => r), 1);
WriteLine($"{min} {max}");
// Out.Flush();
}
}
}
|
[["-", 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, 16, 17, 72], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 213, 63, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 218, 0, 221], ["+", 0, 213, 3, 4, 0, 28, 0, 218, 8, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25], ["+", 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
| 219
| 22
|
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
namespace FertiLib.Contest.C {
static class Program {
public static void Solve(Scanner cin) {
int n = cin.ReadInt();
var a = cin.ReadIntArray(n);
var min = 0;
for (int i = 0; i < 8; i++) {
min += a.Count(x => i * 400 <= x && x < (i + 1) * 400);
}
Console.WriteLine($"{min} {min + a.Count(x => x >= 3200)}");
}
public static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var cin = new Scanner();
Solve(cin);
Console.Out.Flush();
}
public static void
YESNO(bool condition) => Console.WriteLine(condition ? "YES" : "NO");
public static void
YesNo(bool condition) => Console.WriteLine(condition ? "Yes" : "No");
public static void
yesno(bool condition) => Console.WriteLine(condition ? "yes" : "no");
public static bool Chmax<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) >= 0)
return false;
a = b;
return true;
}
public static bool Chmin<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) <= 0)
return false;
a = b;
return true;
}
}
static class Util {
public static string
Join<T>(this IEnumerable<T> x,
string separator = "") => string.Join(separator, x);
}
class Scanner {
string[] s;
int i;
char[] separator = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string Read() => ReadString();
public string ReadString() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(separator, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return ReadString();
i = 0;
return s[i++];
}
public string[] ReadStringArray(int N) {
string[] Array = new string[N];
for (int i = 0; i < N; i++) {
Array[i] = ReadString();
}
return Array;
}
public int ReadInt() { return int.Parse(ReadString()); }
public int[] ReadIntArray(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = ReadInt() + add;
}
return Array;
}
public long ReadLong() { return long.Parse(ReadString()); }
public long[] ReadLongArray(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = ReadLong() + add;
}
return Array;
}
public double ReadDouble() { return double.Parse(ReadString()); }
public double[] ReadDoubleArray(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = ReadDouble() + add;
}
return Array;
}
public T1 ReadValue<T1>() => (T1)Convert.ChangeType(ReadString(),
typeof(T1));
public (T1, T2) ReadValue<T1, T2>() {
var inputs = ReadStringArray(2);
var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
return (v1, v2);
}
public (T1, T2, T3) ReadValue<T1, T2, T3>() {
var inputs = ReadStringArray(3);
var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
return (v1, v2, v3);
}
public (T1, T2, T3, T4) ReadValue<T1, T2, T3, T4>() {
var inputs = ReadStringArray(4);
var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));
return (v1, v2, v3, v4);
}
public (T1, T2, T3, T4, T5) ReadValue<T1, T2, T3, T4, T5>() {
var inputs = ReadStringArray(5);
var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));
var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5));
return (v1, v2, v3, v4, v5);
}
public (T1, T2, T3, T4, T5, T6) ReadValue<T1, T2, T3, T4, T5, T6>() {
var inputs = ReadStringArray(6);
var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));
var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5));
var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6));
return (v1, v2, v3, v4, v5, v6);
}
public (T1, T2, T3, T4, T5, T6,
T7) ReadValue<T1, T2, T3, T4, T5, T6, T7>() {
var inputs = ReadStringArray(7);
var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));
var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5));
var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6));
var v7 = (T7)Convert.ChangeType(inputs[6], typeof(T7));
return (v1, v2, v3, v4, v5, v6, v7);
}
public T1[] ReadValueArray<T1>(int N) {
var v1 = new T1[N];
for (int i = 0; i < N; i++) {
v1[i] = ReadValue<T1>();
}
return v1;
}
public (T1[], T2[]) ReadValueArray<T1, T2>(int N) {
var (v1, v2) = (new T1[N], new T2[N]);
for (int i = 0; i < N; i++) {
var (t1, t2) = ReadValue<T1, T2>();
v1[i] = t1;
v2[i] = t2;
}
return (v1, v2);
}
public (T1[], T2[], T3[]) ReadValueArray<T1, T2, T3>(int N) {
var (v1, v2, v3) = (new T1[N], new T2[N], new T3[N]);
for (int i = 0; i < N; i++) {
var (t1, t2, t3) = ReadValue<T1, T2, T3>();
v1[i] = t1;
v2[i] = t2;
v3[i] = t3;
}
return (v1, v2, v3);
}
public (T1[], T2[], T3[], T4[]) ReadValueArray<T1, T2, T3, T4>(int N) {
var (v1, v2, v3, v4) = (new T1[N], new T2[N], new T3[N], new T4[N]);
for (int i = 0; i < N; i++) {
var (t1, t2, t3, t4) = ReadValue<T1, T2, T3, T4>();
v1[i] = t1;
v2[i] = t2;
v3[i] = t3;
v4[i] = t4;
}
return (v1, v2, v3, v4);
}
public (T1[], T2[], T3[], T4[],
T5[]) ReadValueArray<T1, T2, T3, T4, T5>(int N) {
var (v1, v2, v3, v4, v5) =
(new T1[N], new T2[N], new T3[N], new T4[N], new T5[N]);
for (int i = 0; i < N; i++) {
var (t1, t2, t3, t4, t5) = ReadValue<T1, T2, T3, T4, T5>();
v1[i] = t1;
v2[i] = t2;
v3[i] = t3;
v4[i] = t4;
v5[i] = t5;
}
return (v1, v2, v3, v4, v5);
}
public (T1[], T2[], T3[], T4[], T5[],
T6[]) ReadValueArray<T1, T2, T3, T4, T5, T6>(int N) {
var (v1, v2, v3, v4, v5, v6) =
(new T1[N], new T2[N], new T3[N], new T4[N], new T5[N], new T6[N]);
for (int i = 0; i < N; i++) {
var (t1, t2, t3, t4, t5, t6) = ReadValue<T1, T2, T3, T4, T5, T6>();
v1[i] = t1;
v2[i] = t2;
v3[i] = t3;
v4[i] = t4;
v5[i] = t5;
v6[i] = t6;
}
return (v1, v2, v3, v4, v5, v6);
}
public (T1[], T2[], T3[], T4[], T5[], T6[],
T7[]) ReadValueArray<T1, T2, T3, T4, T5, T6, T7>(int N) {
var (v1, v2, v3, v4, v5, v6, v7) =
(new T1[N], new T2[N], new T3[N], new T4[N], new T5[N], new T6[N],
new T7[N]);
for (int i = 0; i < N; i++) {
var (t1, t2, t3, t4, t5, t6, t7) =
ReadValue<T1, T2, T3, T4, T5, T6, T7>();
v1[i] = t1;
v2[i] = t2;
v3[i] = t3;
v4[i] = t4;
v5[i] = t5;
v6[i] = t6;
v7[i] = t7;
}
return (v1, v2, v3, v4, v5, v6, v7);
}
}
}
|
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
namespace FertiLib.Contest.C {
static class Program {
public static void Solve(Scanner cin) {
int n = cin.ReadInt();
var a = cin.ReadIntArray(n);
var min = 0;
for (int i = 0; i < 8; i++) {
min += a.Count(x => i * 400 <= x && x < (i + 1) * 400) > 0 ? 1 : 0;
}
Console.WriteLine(
$"{(min > 0 ? min : 1)} {min + a.Count(x => x >= 3200)}");
}
public static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var cin = new Scanner();
Solve(cin);
Console.Out.Flush();
}
public static void
YESNO(bool condition) => Console.WriteLine(condition ? "YES" : "NO");
public static void
YesNo(bool condition) => Console.WriteLine(condition ? "Yes" : "No");
public static void
yesno(bool condition) => Console.WriteLine(condition ? "yes" : "no");
public static bool Chmax<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) >= 0)
return false;
a = b;
return true;
}
public static bool Chmin<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) <= 0)
return false;
a = b;
return true;
}
}
static class Util {
public static string
Join<T>(this IEnumerable<T> x,
string separator = "") => string.Join(separator, x);
}
class Scanner {
string[] s;
int i;
char[] separator = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string Read() => ReadString();
public string ReadString() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(separator, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return ReadString();
i = 0;
return s[i++];
}
public string[] ReadStringArray(int N) {
string[] Array = new string[N];
for (int i = 0; i < N; i++) {
Array[i] = ReadString();
}
return Array;
}
public int ReadInt() { return int.Parse(ReadString()); }
public int[] ReadIntArray(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = ReadInt() + add;
}
return Array;
}
public long ReadLong() { return long.Parse(ReadString()); }
public long[] ReadLongArray(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = ReadLong() + add;
}
return Array;
}
public double ReadDouble() { return double.Parse(ReadString()); }
public double[] ReadDoubleArray(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = ReadDouble() + add;
}
return Array;
}
public T1 ReadValue<T1>() => (T1)Convert.ChangeType(ReadString(),
typeof(T1));
public (T1, T2) ReadValue<T1, T2>() {
var inputs = ReadStringArray(2);
var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
return (v1, v2);
}
public (T1, T2, T3) ReadValue<T1, T2, T3>() {
var inputs = ReadStringArray(3);
var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
return (v1, v2, v3);
}
public (T1, T2, T3, T4) ReadValue<T1, T2, T3, T4>() {
var inputs = ReadStringArray(4);
var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));
return (v1, v2, v3, v4);
}
public (T1, T2, T3, T4, T5) ReadValue<T1, T2, T3, T4, T5>() {
var inputs = ReadStringArray(5);
var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));
var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5));
return (v1, v2, v3, v4, v5);
}
public (T1, T2, T3, T4, T5, T6) ReadValue<T1, T2, T3, T4, T5, T6>() {
var inputs = ReadStringArray(6);
var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));
var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5));
var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6));
return (v1, v2, v3, v4, v5, v6);
}
public (T1, T2, T3, T4, T5, T6,
T7) ReadValue<T1, T2, T3, T4, T5, T6, T7>() {
var inputs = ReadStringArray(7);
var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));
var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5));
var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6));
var v7 = (T7)Convert.ChangeType(inputs[6], typeof(T7));
return (v1, v2, v3, v4, v5, v6, v7);
}
public T1[] ReadValueArray<T1>(int N) {
var v1 = new T1[N];
for (int i = 0; i < N; i++) {
v1[i] = ReadValue<T1>();
}
return v1;
}
public (T1[], T2[]) ReadValueArray<T1, T2>(int N) {
var (v1, v2) = (new T1[N], new T2[N]);
for (int i = 0; i < N; i++) {
var (t1, t2) = ReadValue<T1, T2>();
v1[i] = t1;
v2[i] = t2;
}
return (v1, v2);
}
public (T1[], T2[], T3[]) ReadValueArray<T1, T2, T3>(int N) {
var (v1, v2, v3) = (new T1[N], new T2[N], new T3[N]);
for (int i = 0; i < N; i++) {
var (t1, t2, t3) = ReadValue<T1, T2, T3>();
v1[i] = t1;
v2[i] = t2;
v3[i] = t3;
}
return (v1, v2, v3);
}
public (T1[], T2[], T3[], T4[]) ReadValueArray<T1, T2, T3, T4>(int N) {
var (v1, v2, v3, v4) = (new T1[N], new T2[N], new T3[N], new T4[N]);
for (int i = 0; i < N; i++) {
var (t1, t2, t3, t4) = ReadValue<T1, T2, T3, T4>();
v1[i] = t1;
v2[i] = t2;
v3[i] = t3;
v4[i] = t4;
}
return (v1, v2, v3, v4);
}
public (T1[], T2[], T3[], T4[],
T5[]) ReadValueArray<T1, T2, T3, T4, T5>(int N) {
var (v1, v2, v3, v4, v5) =
(new T1[N], new T2[N], new T3[N], new T4[N], new T5[N]);
for (int i = 0; i < N; i++) {
var (t1, t2, t3, t4, t5) = ReadValue<T1, T2, T3, T4, T5>();
v1[i] = t1;
v2[i] = t2;
v3[i] = t3;
v4[i] = t4;
v5[i] = t5;
}
return (v1, v2, v3, v4, v5);
}
public (T1[], T2[], T3[], T4[], T5[],
T6[]) ReadValueArray<T1, T2, T3, T4, T5, T6>(int N) {
var (v1, v2, v3, v4, v5, v6) =
(new T1[N], new T2[N], new T3[N], new T4[N], new T5[N], new T6[N]);
for (int i = 0; i < N; i++) {
var (t1, t2, t3, t4, t5, t6) = ReadValue<T1, T2, T3, T4, T5, T6>();
v1[i] = t1;
v2[i] = t2;
v3[i] = t3;
v4[i] = t4;
v5[i] = t5;
v6[i] = t6;
}
return (v1, v2, v3, v4, v5, v6);
}
public (T1[], T2[], T3[], T4[], T5[], T6[],
T7[]) ReadValueArray<T1, T2, T3, T4, T5, T6, T7>(int N) {
var (v1, v2, v3, v4, v5, v6, v7) =
(new T1[N], new T2[N], new T3[N], new T4[N], new T5[N], new T6[N],
new T7[N]);
for (int i = 0; i < N; i++) {
var (t1, t2, t3, t4, t5, t6, t7) =
ReadValue<T1, T2, T3, T4, T5, T6, T7>();
v1[i] = t1;
v2[i] = t2;
v3[i] = t3;
v4[i] = t4;
v5[i] = t5;
v6[i] = t6;
v7[i] = t7;
}
return (v1, v2, v3, v4, v5, v6, v7);
}
}
}
|
[["+", 0, 1, 0, 11, 12, 41, 15, 16, 17, 47], ["+", 0, 1, 0, 11, 12, 41, 15, 16, 12, 203], ["+", 8, 196, 0, 1, 0, 11, 12, 41, 0, 101], ["+", 8, 196, 0, 1, 0, 11, 12, 41, 64, 203], ["+", 8, 196, 0, 1, 0, 11, 12, 41, 0, 102], ["+", 8, 196, 0, 1, 0, 11, 12, 41, 75, 203], ["+", 0, 28, 0, 283, 0, 284, 0, 23, 0, 24], ["+", 0, 284, 0, 23, 0, 41, 15, 16, 31, 22], ["+", 0, 284, 0, 23, 0, 41, 15, 16, 17, 47], ["+", 0, 284, 0, 23, 0, 41, 15, 16, 12, 203], ["+", 0, 283, 0, 284, 0, 23, 0, 41, 0, 101], ["+", 0, 283, 0, 284, 0, 23, 0, 41, 0, 102], ["+", 0, 283, 0, 284, 0, 23, 0, 41, 75, 203], ["+", 0, 28, 0, 283, 0, 284, 0, 23, 0, 25]]
| 8
| 2,709
| 14
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.IO.Pipes;
using System.ComponentModel;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
int[] Arr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
int[] col = new int[8];
int or = 0;
int min = 0;
int max = 0;
for (int i = 0; i < N; i++) {
if (Arr[i] >= 3200) {
or++;
} else {
col[Arr[i] / 400] = 1;
}
}
min = col.Sum();
if (min + or >= 8) {
max = 8;
} else {
max = min + or;
}
if (min == 0) {
min = 1;
}
Console.WriteLine(min + " " + max);
}
}
}
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.IO.Pipes;
using System.ComponentModel;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
int[] Arr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
int[] col = new int[8];
int or = 0;
int min = 0;
int max = 0;
for (int i = 0; i < N; i++) {
if (Arr[i] >= 3200) {
or++;
} else {
col[Arr[i] / 400] = 1;
}
}
min = col.Sum();
max = min + or;
if (min == 0) {
min = 1;
}
Console.WriteLine(min + " " + max);
}
}
}
|
[["-", 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, 72], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 20], ["-", 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, 12, 203], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["-", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["-", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["-", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 233
| 17
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
namespace atcorder2 {
class Program {
public static long Read() { return long.Parse(Console.ReadLine()); }
public static long[] Reads() {
return Console.ReadLine().Split().Select(long.Parse).ToArray();
}
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var n = Read();
var a = Reads();
var count = new long[9];
for (int i = 0; i < n; i++) {
for (int j = 0; j < 8; j++) {
if (400 * j <= a[i] && a[i] < 400 * (j + 1))
count[j]++;
}
if (a[i] >= 3200)
count[8]++;
}
long ans = 0;
for (int i = 0; i < 8; i++) {
if (count[i] != 0)
ans++;
}
Console.WriteLine("{0} {1}", ans, ans + count[8]);
Console.Out.Flush();
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
namespace atcorder2 {
class Program {
public static long Read() { return long.Parse(Console.ReadLine()); }
public static long[] Reads() {
return Console.ReadLine().Split().Select(long.Parse).ToArray();
}
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var n = Read();
var a = Reads();
var count = new long[9];
for (int i = 0; i < n; i++) {
for (int j = 0; j < 8; j++) {
if (400 * j <= a[i] && a[i] < 400 * (j + 1))
count[j]++;
}
if (a[i] >= 3200)
count[8]++;
}
long ans = 0;
for (int i = 0; i < 8; i++) {
if (count[i] != 0)
ans++;
}
if (ans != 0)
Console.WriteLine("{0} {1}", ans, ans + count[8]);
else
Console.WriteLine("{0} {1}", 1, ans + count[8]);
Console.Out.Flush();
}
}
}
|
[["+", 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, 79], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 21], ["+", 64, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 3, 4, 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, 64, 1, 0, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 57, 75, 1, 0, 213, 63, 214, 205, 22], ["+", 0, 57, 75, 1, 0, 213, 63, 214, 0, 131], ["+", 0, 57, 75, 1, 0, 213, 63, 214, 141, 22], ["+", 0, 57, 75, 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, 57, 75, 1, 0, 213, 3, 4, 0, 21], ["+", 75, 1, 0, 213, 3, 4, 0, 28, 0, 203]]
| 8
| 275
| 25
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace C {
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 N = int.Parse(Console.ReadLine());
var A = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
var over3200 = 0;
var checker = new bool[8];
for (var i = 0; i < A.Length; i++) {
var rate = A[i] / 400;
if (rate < 8)
checker[rate] = true;
else
over3200++;
}
var min = checker.Count(x => x);
if (min == 0 && over3200 > 0) {
min = 1;
over3200--;
}
var max = Math.Min(8, min + over3200);
Console.WriteLine($"{min} {max}");
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace C {
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 N = int.Parse(Console.ReadLine());
var A = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
var over3200 = 0;
var checker = new bool[8];
for (var i = 0; i < A.Length; i++) {
var rate = A[i] / 400;
if (rate < 8)
checker[rate] = true;
else
over3200++;
}
var min = checker.Count(x => x);
if (min == 0 && over3200 > 0) {
min = 1;
over3200--;
}
var max = min + over3200;
Console.WriteLine($"{min} {max}");
}
}
}
|
[["-", 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, 203], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 21], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25]]
| 8
| 254
| 7
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;
namespace Atcoder {
class Program {
static StreamWriter sw =
new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
static void Main(string[] args) {
try {
SetOut(sw);
Solve.Answer();
Out.Flush();
} catch (Exception ex) {
WriteLine(ex.ToString());
}
}
}
public class Solve {
public static void Answer() {
var n = IO.RInt;
var a = IO.RSInt;
Array.Sort(a);
int max = 0;
int min = 0;
int hai = 0;
int br = 0;
int gri = 0;
int ablu = 0;
int blu = 0;
int ki = 0;
int dai = 0;
int red = 0;
int other = 0;
for (int i = 0; i < a.Length; i++) {
if (a[i] <= 399) {
if (hai == 0)
min++;
hai++;
}
if (400 <= a[i] && a[i] <= 799) {
if (br == 0)
min++;
br++;
}
if (800 <= a[i] && a[i] <= 1199) {
if (gri == 0)
min++;
gri++;
}
if (1200 <= a[i] && a[i] <= 1599) {
if (ablu == 0)
min++;
ablu++;
}
if (1600 <= a[i] && a[i] <= 1999) {
if (blu == 0)
min++;
blu++;
}
if (2000 <= a[i] && a[i] <= 2399) {
if (ki == 0)
min++;
ki++;
}
if (2400 <= a[i] && a[i] <= 2799) {
if (dai == 0)
min++;
dai++;
}
if (2800 <= a[i] && a[i] <= 3199) {
if (red == 0)
min++;
red++;
}
if (3200 <= a[i])
other++;
}
WriteLine(min + " " + (min + other));
}
}
public class IO {
#region Input
public static int RInt => int.Parse(ReadLine());
public static long RLong => long.Parse(ReadLine());
public static double RDouble => double.Parse(ReadLine());
public static string[] RSString => ReadLine().Split();
public static int[] RSInt =>
ReadLine().Split().Select(s => int.Parse(s)).ToArray();
public static long[] RSLong =>
ReadLine().Split().Select(s => long.Parse(s)).ToArray();
public static double[] RSDouble =>
ReadLine().Split().Select(s => double.Parse(s)).ToArray();
#endregion
#region Output
public static void
OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes"
: "No");
public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES"
: "NO");
#endregion
}
public class Mod {
#region
private readonly static long M = 1000000007;
public static long Add(long a, long b) => (a * b) % M;
public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M
: (a - b) % M + M;
public static long Multi(long a, long b) => (a * b) % M;
#endregion
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;
namespace Atcoder {
class Program {
static StreamWriter sw =
new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
static void Main(string[] args) {
try {
SetOut(sw);
Solve.Answer();
Out.Flush();
} catch (Exception ex) {
WriteLine(ex.ToString());
}
}
}
public class Solve {
public static void Answer() {
var n = IO.RInt;
var a = IO.RSInt;
Array.Sort(a);
int max = 0;
int min = 0;
int hai = 0;
int br = 0;
int gri = 0;
int ablu = 0;
int blu = 0;
int ki = 0;
int dai = 0;
int red = 0;
int other = 0;
for (int i = 0; i < a.Length; i++) {
if (a[i] <= 399) {
if (hai == 0)
min++;
hai++;
}
if (400 <= a[i] && a[i] <= 799) {
if (br == 0)
min++;
br++;
}
if (800 <= a[i] && a[i] <= 1199) {
if (gri == 0)
min++;
gri++;
}
if (1200 <= a[i] && a[i] <= 1599) {
if (ablu == 0)
min++;
ablu++;
}
if (1600 <= a[i] && a[i] <= 1999) {
if (blu == 0)
min++;
blu++;
}
if (2000 <= a[i] && a[i] <= 2399) {
if (ki == 0)
min++;
ki++;
}
if (2400 <= a[i] && a[i] <= 2799) {
if (dai == 0)
min++;
dai++;
}
if (2800 <= a[i] && a[i] <= 3199) {
if (red == 0)
min++;
red++;
}
if (3200 <= a[i])
other++;
}
if (min == 0) {
min = 1;
other--;
}
WriteLine(min + " " + (min + other));
}
}
public class IO {
#region Input
public static int RInt => int.Parse(ReadLine());
public static long RLong => long.Parse(ReadLine());
public static double RDouble => double.Parse(ReadLine());
public static string[] RSString => ReadLine().Split();
public static int[] RSInt =>
ReadLine().Split().Select(s => int.Parse(s)).ToArray();
public static long[] RSLong =>
ReadLine().Split().Select(s => long.Parse(s)).ToArray();
public static double[] RSDouble =>
ReadLine().Split().Select(s => double.Parse(s)).ToArray();
#endregion
#region Output
public static void
OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes"
: "No");
public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES"
: "NO");
#endregion
}
public class Mod {
#region
private readonly static long M = 1000000007;
public static long Add(long a, long b) => (a * b) % M;
public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M
: (a - b) % M + M;
public static long Multi(long a, long b) => (a * b) % M;
#endregion
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 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, 57, 64, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 68], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 818
| 15
|
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AtCoder {
class Program {
static void Main(string[] args) {
var n = int.Parse(ReadLine());
var line = ReadLine()
.Split(' ')
.Select(value => int.Parse(value))
.OrderBy(value => value)
.ToArray();
var colors = new int[9];
foreach (var point in line) {
var i = point / 400;
if (point >= 3200) {
i = 8;
}
colors[i]++;
}
var count = 0;
for (var i = 0; i < colors.Length; i++) {
if (i != colors.Length - 1) {
count += colors[i] > 0 ? 1 : 0;
} else {
Write($"{count} ");
WriteLine(count + colors[i]);
}
}
}
}
}
|
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AtCoder {
class Program {
static void Main(string[] args) {
var n = int.Parse(ReadLine());
var line =
ReadLine().Split(' ').Select(value => int.Parse(value)).ToArray();
var colors = new int[9];
foreach (var point in line) {
var i = point / 400;
if (point >= 3200) {
i = 8;
}
colors[i]++;
}
var count = 0;
for (var i = 0; i < colors.Length; i++) {
if (i != colors.Length - 1) {
count += colors[i] > 0 ? 1 : 0;
} else {
if (count != 0) {
Write($"{count} ");
} else {
Write("1 ");
}
WriteLine(count + colors[i]);
}
}
}
}
}
|
[["-", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["-", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["-", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["-", 205, 213, 3, 4, 0, 28, 0, 218, 0, 221], ["-", 205, 213, 3, 4, 0, 28, 0, 218, 8, 22], ["-", 0, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["+", 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, 79], ["+", 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, 213, 3, 4, 0, 28, 0, 283, 0, 62], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 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, 213, 63, 22], ["+", 75, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 57, 75, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 211
| 25
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Program {
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
static void Solve() {
var N = sc.ReadInt();
var A = sc.ReadIntArray(N);
var color = new List<int>();
var x = 0;
for (int i = 0; i < N; i++) {
if (A[i] >= 3200)
x++;
else
color.Add(A[i] / 400);
}
var count = color.Distinct().Count();
var max = Math.Min(8, count + x);
var min = Math.Max(1, count);
Console.WriteLine($"{min} {max}");
}
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.IO;
using System.Linq;
class Program {
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
static void Solve() {
var N = sc.ReadInt();
var A = sc.ReadIntArray(N);
var color = new List<int>();
var x = 0;
for (int i = 0; i < N; i++) {
if (A[i] >= 3200)
x++;
else
color.Add(A[i] / 400);
}
var count = color.Distinct().Count();
var max = count + x;
var min = Math.Max(1, count);
Console.WriteLine($"{min} {max}");
}
static Scanner sc = new Scanner();
}
class Scanner {
string[] S = new string[0];
int Index = 0;
char[] Separators = new char[] { ' ' };
public string Next() {
if (this.Index < this.S.Length)
return this.S[this.Index++];
var line = "";
while (line == "")
line = Console.ReadLine();
this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
if (this.S.Length == 0)
return this.Next();
this.Index = 0;
return this.S[this.Index++];
}
public string ReadStr() { return this.Next(); }
public char ReadChar() { return this.Next()[0]; }
public int ReadInt() { return int.Parse(this.Next()); }
public uint ReadUInt() { return uint.Parse(this.Next()); }
public long ReadLong() { return long.Parse(this.Next()); }
public double ReadDouble() { return double.Parse(this.Next()); }
public Tuple<int, int> ReadTup(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add);
}
public Tuple<long, long> ReadTupLong(int add = 0) {
return Tuple.Create(this.ReadLong() + add, this.ReadLong() + add);
}
public Tuple<int, int, int> ReadTup3(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add);
}
public Tuple<int, int, int, int> ReadTup4(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add, this.ReadInt() + add);
}
public int[] ReadIntArray(int n) {
var array = new int[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadInt();
}
return array;
}
public long[] ReadLongArray(int n) {
var array = new long[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadLong();
}
return array;
}
public double[] ReadDoubleArray(int n) {
var array = new double[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadDouble();
}
return array;
}
public char[] ReadCharArray(int n) {
var array = new char[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadChar();
}
return array;
}
public string[] ReadStrArray(int n) {
var array = new string[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadStr();
}
return array;
}
public Tuple<long, long>[] ReadTupLongArray(int n, int add = 0) {
var array = new Tuple<long, long>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTupLong(add);
}
return array;
}
public Tuple<int, int>[] ReadTupArray(int n, int add = 0) {
var array = new Tuple<int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup(add);
}
return array;
}
public Tuple<int, int, int>[] ReadTup3Array(int n, int add = 0) {
var array = new Tuple<int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup3(add);
}
return array;
}
public Tuple<int, int, int, int>[] ReadTup4Array(int n, int add = 0) {
var array = new Tuple<int, int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup4(add);
}
return array;
}
}
|
[["-", 0, 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, 203], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 21], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25]]
| 8
| 1,180
| 7
|
using Yorukatsu025.Questions;
using Yorukatsu025.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace Yorukatsu025.Questions {
/// <summary>
/// ABC064 C
/// </summary>
public class QuestionB : AtCoderQuestionBase {
public override IEnumerable<object> Solve(TextReader inputStream) {
var n = inputStream.ReadInt();
var colors = inputStream.ReadIntArray()
.Select(i => i / 400)
.ToArray(); // 0 ~ 12, 0~7は固定色
var colorCount = colors.Where(i => i < 8).Distinct().Count();
var wildColor = colors.Count(i => i >= 8);
var min = Math.Max(colorCount, 1);
var max = Math.Min(colorCount + wildColor, 8);
yield return $"{min} {max}";
}
}
}
namespace Yorukatsu025 {
class Program {
static void Main(string[] args) {
IAtCoderQuestion question = new QuestionB(); // 問題に合わせて書き換え
var answers = question.Solve(Console.In);
foreach (var answer in answers) {
Console.WriteLine(answer);
}
}
}
}
#region Base Classes
namespace Yorukatsu025.Questions {
public interface IAtCoderQuestion {
IEnumerable<object> Solve(string input);
IEnumerable<object> Solve(TextReader inputStream);
}
public abstract class AtCoderQuestionBase : IAtCoderQuestion {
public IEnumerable<object> Solve(string input) {
var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
var reader = new StreamReader(stream, Encoding.Unicode);
return Solve(reader);
}
public abstract IEnumerable<object> Solve(TextReader inputStream);
}
}
#endregion
#region Extensions
namespace Yorukatsu025.Extensions {
internal static class TextReaderExtensions {
internal static int
ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
internal static long
ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
internal static double
ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
internal static string
ReadString(this TextReader reader) => reader.ReadLine();
internal static int[] ReadIntArray(this TextReader reader,
char separator = ' ') =>
ReadStringArray(reader, separator).Select(int.Parse).ToArray();
internal static long[] ReadLongArray(this TextReader reader,
char separator = ' ') =>
ReadStringArray(reader, separator).Select(long.Parse).ToArray();
internal static double[] ReadDoubleArray(this TextReader reader,
char separator = ' ') =>
ReadStringArray(reader, separator).Select(double.Parse).ToArray();
internal static string[] ReadStringArray(this TextReader reader,
char separator = ' ') =>
reader.ReadLine().Split(separator);
}
}
#endregion
|
using Yorukatsu025.Questions;
using Yorukatsu025.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace Yorukatsu025.Questions {
/// <summary>
/// ABC064 C
/// </summary>
public class QuestionB : AtCoderQuestionBase {
public override IEnumerable<object> Solve(TextReader inputStream) {
var n = inputStream.ReadInt();
var colors = inputStream.ReadIntArray()
.Select(i => i / 400)
.ToArray(); // 0 ~ 12, 0~7は固定色
var colorCount = colors.Where(i => i < 8).Distinct().Count();
var wildColor = colors.Count(i => i >= 8);
var min = Math.Max(colorCount, 1);
var max = colorCount + wildColor;
yield return $"{min} {max}";
}
}
}
namespace Yorukatsu025 {
class Program {
static void Main(string[] args) {
IAtCoderQuestion question = new QuestionB(); // 問題に合わせて書き換え
var answers = question.Solve(Console.In);
foreach (var answer in answers) {
Console.WriteLine(answer);
}
}
}
}
#region Base Classes
namespace Yorukatsu025.Questions {
public interface IAtCoderQuestion {
IEnumerable<object> Solve(string input);
IEnumerable<object> Solve(TextReader inputStream);
}
public abstract class AtCoderQuestionBase : IAtCoderQuestion {
public IEnumerable<object> Solve(string input) {
var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
var reader = new StreamReader(stream, Encoding.Unicode);
return Solve(reader);
}
public abstract IEnumerable<object> Solve(TextReader inputStream);
}
}
#endregion
#region Extensions
namespace Yorukatsu025.Extensions {
internal static class TextReaderExtensions {
internal static int
ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
internal static long
ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
internal static double
ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
internal static string
ReadString(this TextReader reader) => reader.ReadLine();
internal static int[] ReadIntArray(this TextReader reader,
char separator = ' ') =>
ReadStringArray(reader, separator).Select(int.Parse).ToArray();
internal static long[] ReadLongArray(this TextReader reader,
char separator = ' ') =>
ReadStringArray(reader, separator).Select(long.Parse).ToArray();
internal static double[] ReadDoubleArray(this TextReader reader,
char separator = ' ') =>
ReadStringArray(reader, separator).Select(double.Parse).ToArray();
internal static string[] ReadStringArray(this TextReader reader,
char separator = ' ') =>
reader.ReadLine().Split(separator);
}
}
#endregion
|
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 21], ["-", 0, 212, 0, 213, 3, 4, 0, 28, 0, 203], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25]]
| 8
| 563
| 7
|
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
class Program {
const string Yes = "Yes";
const string No = "No";
const char White = '.';
const char Black = '#';
const long Mod = 1000000007;
static void Main(string[] args) {
#if DEBUG
MyDebugger.Test(process, "../TextFile1.txt");
#else
object ret = process(new StreamReader(Console.OpenStandardInput()));
Console.WriteLine(ret);
#endif
}
static object process(TextReader input) {
var n = int.Parse(input.ReadLine());
var ary = ToIntArray(input.ReadLine(), n);
var co = new int[8];
var all = 0;
foreach (var a in ary) {
var c = a / 400;
if (c < 8)
co[c]++;
else
all++;
}
var min = co.Where(x => x > 0).Count();
var max = min + all; // Math.Min(min + all, 8);
return min + " " + max;
}
static int[] ToIntArray(string strs, int n) {
var ret = new int[n];
var spl = strs.Split(' ');
for (int i = 0; i < n; i++)
ret[i] = int.Parse(spl[i]);
return ret;
}
}
|
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
class Program {
const string Yes = "Yes";
const string No = "No";
const char White = '.';
const char Black = '#';
const long Mod = 1000000007;
static void Main(string[] args) {
#if DEBUG
MyDebugger.Test(process, "../TextFile1.txt");
#else
object ret = process(new StreamReader(Console.OpenStandardInput()));
Console.WriteLine(ret);
#endif
}
static object process(TextReader input) {
var n = int.Parse(input.ReadLine());
var ary = ToIntArray(input.ReadLine(), n);
var co = new int[8];
var all = 0;
foreach (var a in ary) {
var c = a / 400;
if (c < 8)
co[c]++;
else
all++;
}
var min = co.Where(x => x > 0).Count();
var max = min + all; // Math.Min(min + all, 8);
return Math.Max(min, 1) + " " + max;
}
static int[] ToIntArray(string strs, int n) {
var ret = new int[n];
var spl = strs.Split(' ');
for (int i = 0; i < n; i++)
ret[i] = int.Parse(spl[i]);
return ret;
}
}
|
[["+", 0, 16, 31, 16, 31, 213, 63, 214, 205, 22], ["+", 0, 16, 31, 16, 31, 213, 63, 214, 0, 131], ["+", 0, 16, 31, 16, 31, 213, 63, 214, 141, 22], ["+", 0, 16, 31, 16, 31, 213, 3, 4, 0, 24], ["+", 0, 16, 31, 16, 31, 213, 3, 4, 0, 21], ["+", 31, 16, 31, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 16, 31, 16, 31, 213, 3, 4, 0, 25]]
| 8
| 316
| 7
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class AtCoderA {
static void Main() {
var sc = new Scanner();
int n = sc.NextInt();
int[] a = sc.IntArray();
bool[] colors = new bool[8];
int over = 0;
foreach (var s in a) {
if (s >= 3200) {
over++;
continue;
}
colors[s / 400] = true;
}
int min = colors.Where(i => i).Count();
int max = Math.Min(8, min + over);
if (min == 0 && over > 0) {
min = 1;
}
Console.WriteLine(min + " " + max);
}
class Scanner {
private string[] _line;
private int _index;
private const char Separator = ' ';
public Scanner() {
_line = new string[0];
_index = 0;
}
public string Next() {
while (_index >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_index = 0;
}
return _line[_index++];
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
public decimal NextDecimal() => decimal.Parse(Next());
public char NextChar() => Next()[0];
public char[] NextCharArray() => Next().ToCharArray();
public string[] Array() {
_line = Console.ReadLine().Split(Separator);
_index = _line.Length;
return _line;
}
public int[] IntArray() => Array().Select(int.Parse).ToArray();
public long[] LongArray() => Array().Select(long.Parse).ToArray();
public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class AtCoderA {
static void Main() {
var sc = new Scanner();
int n = sc.NextInt();
int[] a = sc.IntArray();
bool[] colors = new bool[8];
int over = 0;
foreach (var s in a) {
if (s >= 3200) {
over++;
continue;
}
colors[s / 400] = true;
}
int min = colors.Where(i => i).Count();
int max = min + over;
if (min == 0 && over > 0) {
min = 1;
}
Console.WriteLine(min + " " + max);
}
class Scanner {
private string[] _line;
private int _index;
private const char Separator = ' ';
public Scanner() {
_line = new string[0];
_index = 0;
}
public string Next() {
while (_index >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_index = 0;
}
return _line[_index++];
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
public decimal NextDecimal() => decimal.Parse(Next());
public char NextChar() => Next()[0];
public char[] NextCharArray() => Next().ToCharArray();
public string[] Array() {
_line = Console.ReadLine().Split(Separator);
_index = _line.Length;
return _line;
}
public int[] IntArray() => Array().Select(int.Parse).ToArray();
public long[] LongArray() => Array().Select(long.Parse).ToArray();
public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
}
}
|
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 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, 203], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 21], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25]]
| 8
| 460
| 7
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace kakomon {
class Program {
static void Main(string[] args) { abc064_c(); }
static void abc064_c() {
// ABC064 C - Colorful Leaderboard
int n = int.Parse(Console.ReadLine());
int[] A = Console.ReadLine().Trim().Split().Select(int.Parse).ToArray();
int ans_min;
int ans_max;
// 色(ランク)はレート400刻みなので400で切り捨て除算してランクを出す
const int len_rank = 8;
int[] color = new int[len_rank];
int free = 0;
for (int i = 0; i < n; i++) {
int rank = (int)Math.Floor((double)(A[i] / 400));
if (rank < len_rank)
color[rank] += 1;
else
free += 1;
}
// 最小:色固定の人数(フリーは既存の色にする)、または、1(全員フリー)
// 最大:全色の数(8)、または、色固定人数+色フリー人数、の小さいほう
int fix = color.Count(x => x > 0);
ans_min = Math.Max(fix, 1);
ans_max = Math.Min(len_rank, fix + free);
// 出力
Console.WriteLine(String.Format("{0} {1}", ans_min, ans_max));
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace kakomon {
class Program {
static void Main(string[] args) { abc064_c(); }
static void abc064_c() {
// ABC064 C - Colorful Leaderboard
int n = int.Parse(Console.ReadLine());
int[] A = Console.ReadLine().Trim().Split().Select(int.Parse).ToArray();
int ans_min;
int ans_max;
// 色(ランク)はレート400刻みなので400で切り捨て除算してランクを出す
const int len_rank = 8;
int[] color = new int[len_rank];
int free = 0;
for (int i = 0; i < n; i++) {
int rank = (int)(A[i] / 400);
if (rank < len_rank)
color[rank] += 1;
else
free += 1;
}
// 最小:色固定の人数(フリーは既存の色にする)、または、1(全員フリー)
// 最大:全色の数(8)、または、色固定人数+色フリー人数、の小さいほう
int fix = color.Count(x => x > 0);
ans_min = Math.Max(fix, 1);
ans_max = fix + free;
// 出力
Console.WriteLine(String.Format("{0} {1}", ans_min, ans_max));
}
}
}
|
[["-", 0, 212, 0, 74, 51, 213, 63, 214, 205, 22], ["-", 0, 212, 0, 74, 51, 213, 63, 214, 0, 131], ["-", 0, 212, 0, 74, 51, 213, 63, 214, 141, 22], ["-", 51, 213, 3, 4, 0, 28, 0, 74, 0, 24], ["-", 51, 213, 3, 4, 0, 28, 0, 74, 39, 199], ["-", 51, 213, 3, 4, 0, 28, 0, 74, 0, 25], ["-", 3, 4, 0, 28, 0, 74, 51, 23, 0, 24], ["-", 0, 212, 0, 74, 51, 213, 3, 4, 0, 25], ["-", 0, 1, 0, 11, 12, 213, 63, 214, 205, 22], ["-", 0, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["-", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["-", 0, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["-", 0, 11, 12, 213, 3, 4, 0, 28, 0, 22], ["-", 0, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["-", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25]]
| 8
| 235
| 15
|
using System;
using System.Collections.Generic;
using System.Linq;
class Progaram {
static void Main(string[] args) {
var cs = new bool [8].Select(x => false).ToArray();
int e = 0;
var n = int.Parse(Console.ReadLine());
var l = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
foreach (var i in l) {
if (399 >= i)
cs[0] = true;
if (400 <= i && 799 >= i)
cs[1] = true;
if (800 <= i && 1199 >= i)
cs[2] = true;
if (1200 <= i && 1599 >= i)
cs[3] = true;
if (1600 <= i && 1999 >= i)
cs[4] = true;
if (2000 <= i && 2399 >= i)
cs[5] = true;
if (2400 <= i && 2799 >= i)
cs[6] = true;
if (2800 <= i && 3199 >= i)
cs[7] = true;
if (3200 <= i)
e++;
}
int max, min;
var ca = cs.Where(x => x).ToArray().Length;
max = (ca + e < 9) ? ca + e : 8;
min = (ca != 0) ? ca : 1;
Console.WriteLine($"{min} {max}");
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Progaram {
static void Main(string[] args) {
var cs = new bool [8].Select(x => false).ToArray();
int e = 0;
var n = int.Parse(Console.ReadLine());
var l = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
foreach (var i in l) {
if (399 >= i)
cs[0] = true;
if (400 <= i && 799 >= i)
cs[1] = true;
if (800 <= i && 1199 >= i)
cs[2] = true;
if (1200 <= i && 1599 >= i)
cs[3] = true;
if (1600 <= i && 1999 >= i)
cs[4] = true;
if (2000 <= i && 2399 >= i)
cs[5] = true;
if (2400 <= i && 2799 >= i)
cs[6] = true;
if (2800 <= i && 3199 >= i)
cs[7] = true;
if (3200 <= i)
e++;
}
int max, min;
var ca = cs.Where(x => x).ToArray().Length;
max = ca + e;
min = (ca != 0) ? ca : 1;
Console.WriteLine($"{min} {max}");
}
}
|
[["-", 0, 1, 0, 11, 12, 41, 15, 23, 0, 24], ["-", 12, 41, 15, 23, 0, 16, 31, 16, 31, 22], ["-", 12, 41, 15, 23, 0, 16, 31, 16, 17, 72], ["-", 12, 41, 15, 23, 0, 16, 31, 16, 12, 22], ["-", 0, 11, 12, 41, 15, 23, 0, 16, 17, 18], ["-", 0, 11, 12, 41, 15, 23, 0, 16, 12, 203], ["-", 0, 1, 0, 11, 12, 41, 15, 23, 0, 25], ["-", 8, 196, 0, 1, 0, 11, 12, 41, 0, 101], ["-", 8, 196, 0, 1, 0, 11, 12, 41, 0, 102], ["-", 8, 196, 0, 1, 0, 11, 12, 41, 75, 203]]
| 8
| 314
| 10
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;
using static _20200407.abc064_c.Cin;
using static _20200407.abc064_c.Util;
// using Pair = System.ValueTuple<long, long>;
namespace _20200407.abc064_c {
public class Program {
public static void Main(string[] args) {
int N = ri;
int[] A = ria;
int[] cnts = new int[9];
foreach (var a in A) {
cnts[Min(a / 400, 8)]++;
}
int min = 0;
int max = 0;
for (int i = 0; i < 8; i++) {
if (cnts[i] > 0)
min++;
}
max = min + cnts[8];
Console.WriteLine("{0} {1}", min, max);
}
}
/// <summary>
/// 競プロライブラリ
/// https://github.com/ha2ne2/ABC/tree/master/Lib
/// </summary>
public struct Mint : System.IComparable<Mint>, System.IEquatable<Mint> {
public static readonly long MOD = (long)1e9 + 7;
public long Value;
public Mint(long val) {
Value = val % MOD;
if (Value < 0)
Value += MOD;
}
private static Mint Ctor(long val) { return new Mint() { Value = val }; }
public static Mint operator +(Mint a, Mint b) {
long res = a.Value + b.Value;
if (res > MOD)
res -= MOD;
return Ctor(res);
}
public static Mint operator -(Mint a, Mint b) {
long res = a.Value - b.Value;
if (res < 0)
res += MOD;
return Ctor(res);
}
public static Mint operator *(Mint a, Mint b) {
long res = a.Value * b.Value;
if (res > MOD)
res %= MOD;
return Ctor(res);
}
public static Mint operator /(Mint a, Mint b) { return a * Inv(b); }
public override bool Equals(object obj) {
return obj is Mint && Value == ((Mint)obj).Value;
}
public override int GetHashCode() { return Value.GetHashCode(); }
public override string ToString() { return Value.ToString(); }
public static implicit operator Mint(long a) { return new Mint(a); }
public static explicit operator long(Mint a) { return a.Value; }
public static Mint Pow(Mint a, long n) {
if (n == 0)
return new Mint(1);
Mint b = Pow(a, n >> 1);
b *= b;
if ((n & 1) == 1)
b *= a;
return b;
}
public static Mint Inv(Mint n) {
long a = n.Value;
long b = MOD;
long x = 1;
long u = 0;
while (b != 0) {
long k = a / b;
long _x = u;
u = x - k * u;
x = _x;
long _a = a;
a = b;
b = _a - (k * b);
}
return new Mint(x);
}
public bool Equals(Mint other) { return Value == other.Value; }
public int CompareTo(Mint other) {
return Comparer<long>.Default.Compare(Value, other.Value);
}
}
public class HashMap<K, V> : System.Collections.Generic.Dictionary<K, V> {
private V DefaultValue;
private static Func<V> CreateInstance =
System.Linq.Expressions.Expression
.Lambda<Func<V>>(System.Linq.Expressions.Expression.New(typeof(V)))
.Compile();
public HashMap() {}
public HashMap(V defaultValue) { DefaultValue = defaultValue; }
new public V this[K i] { get { V v;
if (TryGetValue(i, out v)) {
return v;
} else {
return base[i] = DefaultValue != null ? DefaultValue : CreateInstance();
}
}
set { base[i] = value; }
}
}
public static class Cin {
public static int ri {
get { return ReadInt(); }
}
public static int[] ria {
get { return ReadIntArray(); }
}
public static long rl {
get { return ReadLong(); }
}
public static long[] rla {
get { return ReadLongArray(); }
}
public static double rd {
get { return ReadDouble(); }
}
public static double[] rda {
get { return ReadDoubleArray(); }
}
public static string rs {
get { return ReadString(); }
}
public static string[] rsa {
get { return ReadStringArray(); }
}
public static int ReadInt() { return int.Parse(Next()); }
public static long ReadLong() { return long.Parse(Next()); }
public static double ReadDouble() { return double.Parse(Next()); }
public static string ReadString() { return Next(); }
public static int[] ReadIntArray() {
Tokens = null;
return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
}
public static long[] ReadLongArray() {
Tokens = null;
return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
}
public static double[] ReadDoubleArray() {
Tokens = null;
return Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
}
public static string[] ReadStringArray() {
Tokens = null;
return Console.ReadLine().Split(' ');
}
public static void ReadCol(out long[] a, long N) {
a = new long[N];
for (int i = 0; i < N; i++) {
a[i] = ReadLong();
}
}
public static void ReadCols(out long[] a, out long[] b, long N) {
a = new long[N];
b = new long[N];
for (int i = 0; i < N; i++) {
a[i] = ReadLong();
b[i] = ReadLong();
}
}
public static void ReadCols(out long[] a, out long[] b, out long[] c,
long N) {
a = new long[N];
b = new long[N];
c = new long[N];
for (int i = 0; i < N; i++) {
a[i] = ReadLong();
b[i] = ReadLong();
c[i] = ReadLong();
}
}
public static int[,] ReadIntTable(int h, int w) {
Tokens = null;
int[,] ret = new int[h, w];
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
ret[i, j] = ReadInt();
}
}
return ret;
}
public static long[,] ReadLongTable(long h, long w) {
Tokens = null;
long[,] ret = new long[h, w];
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
ret[i, j] = ReadLong();
}
}
return ret;
}
public static char[,] ReadCharTable(int h, int w) {
Tokens = null;
char[,] res = new char[h, w];
for (int i = 0; i < h; i++) {
string s = ReadString();
for (int j = 0; j < w; j++) {
res[i, j] = s[j];
}
}
return res;
}
private static string[] Tokens;
private static int Pointer;
private static string Next() {
if (Tokens == null || Tokens.Length <= Pointer) {
Tokens = Console.ReadLine().Split(' ');
Pointer = 0;
}
return Tokens[Pointer++];
}
}
public static class Util {
public static readonly long INF = (long)1e17;
public readonly static long MOD = (long)1e9 + 7;
public readonly static int[] DXY4 = { 0, 1, 0, -1, 0 };
public readonly static int[] DXY8 = { 1, 1, 0, 1, -1, 0, -1, -1, 1 };
public static void DontAutoFlush() {
if (Console.IsOutputRedirected)
return;
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
}
public static void Flush() { Console.Out.Flush(); }
public static T[] Sort<T>(T[] array) {
Array.Sort<T>(array);
return array;
}
public static T[] SortDecend<T>(T[] array) {
Array.Sort<T>(array);
Array.Reverse(array);
return array;
}
public static void Swap<T>(ref T a, ref T b) {
T _a = a;
a = b;
b = _a;
}
public static long GCD(long a, long b) {
while (b != 0) {
long _a = a;
a = b;
b = _a % b;
}
return a;
}
public static long LCM(long a, long b) {
if (a == 0 || b == 0)
return 0;
return a * b / GCD(a, b);
}
public static void ChMax(ref long a, long b) {
if (a < b)
a = b;
}
public static void ChMin(ref long a, long b) {
if (a > b)
a = b;
}
public static void ChMax(ref int a, int b) {
if (a < b)
a = b;
}
public static void ChMin(ref int a, int b) {
if (a > b)
a = b;
}
public static void FillArray<T>(T[] array, T value) {
int max = array.Length;
for (int i = 0; i < max; i++) {
array[i] = value;
}
}
public static void FillArray<T>(T[,] array, T value) {
int max0 = array.GetLength(0);
int max1 = array.GetLength(1);
for (int i = 0; i < max0; i++) {
for (int j = 0; j < max1; j++) {
array[i, j] = value;
}
}
}
public static void FillArray<T>(T[,,] array, T value) {
int max0 = array.GetLength(0);
int max1 = array.GetLength(1);
int max2 = array.GetLength(2);
for (int i = 0; i < max0; i++) {
for (int j = 0; j < max1; j++) {
for (int k = 0; k < max2; k++) {
array[i, j, k] = value;
}
}
}
}
public static long[] Accumulate(long[] array) {
long[] acc = new long[array.Length + 1];
for (int i = 0; i < array.Length; i++) {
acc[i + 1] = acc[i] + array[i];
}
return acc;
}
public static double[] Accumulate(double[] array) {
double[] acc = new double[array.Length + 1];
for (int i = 0; i < array.Length; i++) {
acc[i + 1] = acc[i] + array[i];
}
return acc;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;
using static _20200407.abc064_c.Cin;
using static _20200407.abc064_c.Util;
// using Pair = System.ValueTuple<long, long>;
namespace _20200407.abc064_c {
public class Program {
public static void Main(string[] args) {
int N = ri;
int[] A = ria;
int[] cnts = new int[9];
foreach (var a in A) {
cnts[Min(a / 400, 8)]++;
}
int min = 0;
int max = 0;
for (int i = 0; i < 8; i++) {
if (cnts[i] > 0)
min++;
}
max = min + cnts[8];
if (min == 0)
min = 1;
Console.WriteLine("{0} {1}", min, max);
}
}
/// <summary>
/// 競プロライブラリ
/// https://github.com/ha2ne2/ABC/tree/master/Lib
/// </summary>
public struct Mint : System.IComparable<Mint>, System.IEquatable<Mint> {
public static readonly long MOD = (long)1e9 + 7;
public long Value;
public Mint(long val) {
Value = val % MOD;
if (Value < 0)
Value += MOD;
}
private static Mint Ctor(long val) { return new Mint() { Value = val }; }
public static Mint operator +(Mint a, Mint b) {
long res = a.Value + b.Value;
if (res > MOD)
res -= MOD;
return Ctor(res);
}
public static Mint operator -(Mint a, Mint b) {
long res = a.Value - b.Value;
if (res < 0)
res += MOD;
return Ctor(res);
}
public static Mint operator *(Mint a, Mint b) {
long res = a.Value * b.Value;
if (res > MOD)
res %= MOD;
return Ctor(res);
}
public static Mint operator /(Mint a, Mint b) { return a * Inv(b); }
public override bool Equals(object obj) {
return obj is Mint && Value == ((Mint)obj).Value;
}
public override int GetHashCode() { return Value.GetHashCode(); }
public override string ToString() { return Value.ToString(); }
public static implicit operator Mint(long a) { return new Mint(a); }
public static explicit operator long(Mint a) { return a.Value; }
public static Mint Pow(Mint a, long n) {
if (n == 0)
return new Mint(1);
Mint b = Pow(a, n >> 1);
b *= b;
if ((n & 1) == 1)
b *= a;
return b;
}
public static Mint Inv(Mint n) {
long a = n.Value;
long b = MOD;
long x = 1;
long u = 0;
while (b != 0) {
long k = a / b;
long _x = u;
u = x - k * u;
x = _x;
long _a = a;
a = b;
b = _a - (k * b);
}
return new Mint(x);
}
public bool Equals(Mint other) { return Value == other.Value; }
public int CompareTo(Mint other) {
return Comparer<long>.Default.Compare(Value, other.Value);
}
}
public class HashMap<K, V> : System.Collections.Generic.Dictionary<K, V> {
private V DefaultValue;
private static Func<V> CreateInstance =
System.Linq.Expressions.Expression
.Lambda<Func<V>>(System.Linq.Expressions.Expression.New(typeof(V)))
.Compile();
public HashMap() {}
public HashMap(V defaultValue) { DefaultValue = defaultValue; }
new public V this[K i] { get { V v;
if (TryGetValue(i, out v)) {
return v;
} else {
return base[i] = DefaultValue != null ? DefaultValue : CreateInstance();
}
}
set { base[i] = value; }
}
}
public static class Cin {
public static int ri {
get { return ReadInt(); }
}
public static int[] ria {
get { return ReadIntArray(); }
}
public static long rl {
get { return ReadLong(); }
}
public static long[] rla {
get { return ReadLongArray(); }
}
public static double rd {
get { return ReadDouble(); }
}
public static double[] rda {
get { return ReadDoubleArray(); }
}
public static string rs {
get { return ReadString(); }
}
public static string[] rsa {
get { return ReadStringArray(); }
}
public static int ReadInt() { return int.Parse(Next()); }
public static long ReadLong() { return long.Parse(Next()); }
public static double ReadDouble() { return double.Parse(Next()); }
public static string ReadString() { return Next(); }
public static int[] ReadIntArray() {
Tokens = null;
return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
}
public static long[] ReadLongArray() {
Tokens = null;
return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
}
public static double[] ReadDoubleArray() {
Tokens = null;
return Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
}
public static string[] ReadStringArray() {
Tokens = null;
return Console.ReadLine().Split(' ');
}
public static void ReadCol(out long[] a, long N) {
a = new long[N];
for (int i = 0; i < N; i++) {
a[i] = ReadLong();
}
}
public static void ReadCols(out long[] a, out long[] b, long N) {
a = new long[N];
b = new long[N];
for (int i = 0; i < N; i++) {
a[i] = ReadLong();
b[i] = ReadLong();
}
}
public static void ReadCols(out long[] a, out long[] b, out long[] c,
long N) {
a = new long[N];
b = new long[N];
c = new long[N];
for (int i = 0; i < N; i++) {
a[i] = ReadLong();
b[i] = ReadLong();
c[i] = ReadLong();
}
}
public static int[,] ReadIntTable(int h, int w) {
Tokens = null;
int[,] ret = new int[h, w];
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
ret[i, j] = ReadInt();
}
}
return ret;
}
public static long[,] ReadLongTable(long h, long w) {
Tokens = null;
long[,] ret = new long[h, w];
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
ret[i, j] = ReadLong();
}
}
return ret;
}
public static char[,] ReadCharTable(int h, int w) {
Tokens = null;
char[,] res = new char[h, w];
for (int i = 0; i < h; i++) {
string s = ReadString();
for (int j = 0; j < w; j++) {
res[i, j] = s[j];
}
}
return res;
}
private static string[] Tokens;
private static int Pointer;
private static string Next() {
if (Tokens == null || Tokens.Length <= Pointer) {
Tokens = Console.ReadLine().Split(' ');
Pointer = 0;
}
return Tokens[Pointer++];
}
}
public static class Util {
public static readonly long INF = (long)1e17;
public readonly static long MOD = (long)1e9 + 7;
public readonly static int[] DXY4 = { 0, 1, 0, -1, 0 };
public readonly static int[] DXY8 = { 1, 1, 0, 1, -1, 0, -1, -1, 1 };
public static void DontAutoFlush() {
if (Console.IsOutputRedirected)
return;
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
}
public static void Flush() { Console.Out.Flush(); }
public static T[] Sort<T>(T[] array) {
Array.Sort<T>(array);
return array;
}
public static T[] SortDecend<T>(T[] array) {
Array.Sort<T>(array);
Array.Reverse(array);
return array;
}
public static void Swap<T>(ref T a, ref T b) {
T _a = a;
a = b;
b = _a;
}
public static long GCD(long a, long b) {
while (b != 0) {
long _a = a;
a = b;
b = _a % b;
}
return a;
}
public static long LCM(long a, long b) {
if (a == 0 || b == 0)
return 0;
return a * b / GCD(a, b);
}
public static void ChMax(ref long a, long b) {
if (a < b)
a = b;
}
public static void ChMin(ref long a, long b) {
if (a > b)
a = b;
}
public static void ChMax(ref int a, int b) {
if (a < b)
a = b;
}
public static void ChMin(ref int a, int b) {
if (a > b)
a = b;
}
public static void FillArray<T>(T[] array, T value) {
int max = array.Length;
for (int i = 0; i < max; i++) {
array[i] = value;
}
}
public static void FillArray<T>(T[,] array, T value) {
int max0 = array.GetLength(0);
int max1 = array.GetLength(1);
for (int i = 0; i < max0; i++) {
for (int j = 0; j < max1; j++) {
array[i, j] = value;
}
}
}
public static void FillArray<T>(T[,,] array, T value) {
int max0 = array.GetLength(0);
int max1 = array.GetLength(1);
int max2 = array.GetLength(2);
for (int i = 0; i < max0; i++) {
for (int j = 0; j < max1; j++) {
for (int k = 0; k < max2; k++) {
array[i, j, k] = value;
}
}
}
}
public static long[] Accumulate(long[] array) {
long[] acc = new long[array.Length + 1];
for (int i = 0; i < array.Length; i++) {
acc[i + 1] = acc[i] + array[i];
}
return acc;
}
public static double[] Accumulate(double[] array) {
double[] acc = new double[array.Length + 1];
for (int i = 0; i < array.Length; i++) {
acc[i + 1] = acc[i] + array[i];
}
return acc;
}
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 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
| 2,468
| 10
|
using System;
namespace _064c {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int count_max = 0;
int count_min = 0;
int count = 0;
int valiable_num = 0;
int[] a_n = new int[8];
for (int i = 0; i < N; i++) {
if (a[i] >= 3200) {
valiable_num++;
} else {
a_n[a[i] / 400] = 1;
}
}
for (int j = 0; j < 8; j++) {
count += a_n[j];
// Console.WriteLine(a_n[j]);
}
count_max = count + valiable_num;
count_min = count;
Console.WriteLine("{0} {1}", count_min, count_max);
}
}
}
|
using System;
namespace _064c {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int count_max = 0;
int count_min = 0;
int count = 0;
int valiable_num = 0;
int[] a_n = new int[8];
for (int i = 0; i < N; i++) {
if (a[i] >= 3200) {
valiable_num++;
} else {
a_n[a[i] / 400] = 1;
}
}
for (int j = 0; j < 8; j++) {
count += a_n[j];
// Console.WriteLine(a_n[j]);
}
count_max = count + valiable_num;
if (count == 0) {
count_min = 1;
} else {
count_min = count;
}
Console.WriteLine("{0} {1}", count_min, count_max);
}
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 183
| 15
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
class Program {
const long mod = 1000000007;
static void Main(string[] args) {
// 入力
var n = long.Parse(Console.ReadLine());
long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
Array.Sort(a);
bool gray = false;
bool brown = false;
bool green = false;
bool lbule = false;
bool bule = false;
bool yellow = false;
bool orange = false;
bool red = false;
var max = 0;
var min = 0;
for (int i = 0; i < a.Length; i++) {
if (a[i] < 400) {
if (!gray) {
max++;
min++;
}
gray = true;
} else if (a[i] < 800) {
if (!brown) {
max++;
min++;
}
brown = true;
} else if (a[i] < 1200) {
if (!green) {
max++;
min++;
}
green = true;
} else if (a[i] < 1600) {
if (!lbule) {
max++;
min++;
}
lbule = true;
} else if (a[i] < 2000) {
if (!bule) {
max++;
min++;
}
bule = true;
} else if (a[i] < 2400) {
if (!yellow) {
max++;
min++;
}
yellow = true;
} else if (a[i] < 2800) {
if (!orange) {
max++;
min++;
}
orange = true;
} else if (a[i] < 3200) {
if (!red) {
max++;
min++;
}
red = true;
} else {
max++;
}
}
Console.WriteLine(min + " " + max);
}
}
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
class Program {
static void Main(string[] args) {
// 入力
var n = long.Parse(Console.ReadLine());
long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
bool gray = false;
bool brown = false;
bool green = false;
bool lbule = false;
bool bule = false;
bool yellow = false;
bool orange = false;
bool red = false;
var max = 0;
var min = 0;
for (int i = 0; i < a.Length; i++) {
if (a[i] < 400) {
if (!gray) {
max++;
min++;
}
gray = true;
} else if (a[i] < 800) {
if (!brown) {
max++;
min++;
}
brown = true;
} else if (a[i] < 1200) {
if (!green) {
max++;
min++;
}
green = true;
} else if (a[i] < 1600) {
if (!lbule) {
max++;
min++;
}
lbule = true;
} else if (a[i] < 2000) {
if (!bule) {
max++;
min++;
}
bule = true;
} else if (a[i] < 2400) {
if (!yellow) {
max++;
min++;
}
yellow = true;
} else if (a[i] < 2800) {
if (!orange) {
max++;
min++;
}
orange = true;
} else if (a[i] < 3200) {
if (!red) {
max++;
min++;
}
red = true;
} else {
max++;
}
}
if (min == 0) {
min++;
}
Console.WriteLine(min + " " + max);
}
}
|
[["-", 0, 235, 8, 201, 0, 124, 0, 251, 0, 154], ["-", 0, 235, 8, 201, 0, 124, 0, 198, 39, 199], ["-", 8, 201, 0, 124, 0, 198, 0, 200, 141, 22], ["-", 0, 124, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 124, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 208, 0, 235, 8, 201, 0, 124, 0, 35], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 75, 57, 75, 57, 75, 57, 75, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 29], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35]]
| 8
| 412
| 24
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp107 {
class Program {
static ulong mod = 1000000007;
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
int cnt_gray = 0;
int cnt_brown = 0;
int cnt_green = 0;
int cnt_skyblue = 0;
int cnt_blue = 0;
int cnt_yellow = 0;
int cnt_orange = 0;
int cnt_red = 0;
int cnt_other = 0;
for (int i = 0; i < N; i++) {
if (a[i] < 400) {
cnt_gray++;
} else if (a[i] < 800) {
cnt_brown++;
} else if (a[i] < 1200) {
cnt_green++;
} else if (a[i] < 1600) {
cnt_skyblue++;
} else if (a[i] < 2000) {
cnt_blue++;
} else if (a[i] < 2400) {
cnt_yellow++;
} else if (a[i] < 2800) {
cnt_orange++;
} else if (a[i] < 3200) {
cnt_red++;
} else {
cnt_other++;
}
}
var color_list =
new List<int> { cnt_gray, cnt_brown, cnt_green, cnt_skyblue,
cnt_blue, cnt_yellow, cnt_orange, cnt_red };
int color_num = color_list.Where(x => x != 0).Count();
Console.WriteLine(color_num + " " + (color_num + cnt_other));
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp107 {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
int cnt_gray = 0;
int cnt_brown = 0;
int cnt_green = 0;
int cnt_skyblue = 0;
int cnt_blue = 0;
int cnt_yellow = 0;
int cnt_orange = 0;
int cnt_red = 0;
int cnt_other = 0;
for (int i = 0; i < N; i++) {
if (a[i] < 400) {
cnt_gray++;
} else if (a[i] < 800) {
cnt_brown++;
} else if (a[i] < 1200) {
cnt_green++;
} else if (a[i] < 1600) {
cnt_skyblue++;
} else if (a[i] < 2000) {
cnt_blue++;
} else if (a[i] < 2400) {
cnt_yellow++;
} else if (a[i] < 2800) {
cnt_orange++;
} else if (a[i] < 3200) {
cnt_red++;
} else {
cnt_other++;
}
}
var color_list =
new List<int> { cnt_gray, cnt_brown, cnt_green, cnt_skyblue,
cnt_blue, cnt_yellow, cnt_orange, cnt_red };
int color_num = color_list.Where(x => x != 0).Count();
Console.WriteLine(Math.Max(color_num, 1) + " " + (color_num + cnt_other));
}
}
}
|
[["-", 0, 235, 8, 201, 0, 124, 0, 198, 39, 199], ["-", 8, 201, 0, 124, 0, 198, 0, 200, 141, 22], ["-", 0, 124, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 124, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 201, 0, 235, 8, 201, 0, 124, 0, 35], ["-", 0, 235, 8, 201, 0, 195, 0, 251, 0, 115], ["+", 0, 16, 31, 16, 31, 213, 63, 214, 205, 22], ["+", 0, 16, 31, 16, 31, 213, 63, 214, 0, 131], ["+", 0, 16, 31, 16, 31, 213, 63, 214, 141, 22], ["+", 0, 16, 31, 16, 31, 213, 3, 4, 0, 24], ["+", 0, 16, 31, 16, 31, 213, 3, 4, 0, 21], ["+", 31, 16, 31, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 16, 31, 16, 31, 213, 3, 4, 0, 25]]
| 8
| 337
| 13
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace abc064_c {
class Program {
static void Main(string[] args) {
var N = GetInt();
var a = GetIntList();
var c = new bool[8];
var c32 = 0;
for (int i = 0; i < N; i++) {
for (int j = 1; j <= 8; j++)
if (a[i] < 400 * j) {
c[j - 1] = true;
break;
}
if (a[i] >= 3200)
c32++;
}
var cc = c.Where(x => x).Count();
if (c32 > cc)
Console.WriteLine("1 " + c32);
else
Console.WriteLine(cc + " " + (c32 + cc));
Console.ReadKey();
}
public static string GetStr() => Console.ReadLine();
public static int GetInt() => int.Parse(Console.ReadLine());
public static long GetLong() => long.Parse(Console.ReadLine());
public static double GetDouble() => double.Parse(Console.ReadLine());
public static decimal GetDecimal() => decimal.Parse(Console.ReadLine());
public static List<string>
GetStrList() => Console.ReadLine().Split(' ').ToList();
public static List<int> GetIntList() =>
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
public static List<long> GetLongList() =>
Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
public static List<double> GetDoubleList() =>
Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToList();
public static List<decimal> GetDecimalList() =>
Console.ReadLine().Split(' ').Select(x => decimal.Parse(x)).ToList();
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace abc064_c {
class Program {
static void Main(string[] args) {
var N = GetInt();
var a = GetIntList();
var c = new bool[8];
var c32 = 0;
for (int i = 0; i < N; i++) {
for (int j = 1; j <= 8; j++)
if (a[i] < 400 * j) {
c[j - 1] = true;
break;
}
if (a[i] >= 3200)
c32++;
}
var cc = c.Where(x => x).Count();
if (cc == 0)
Console.WriteLine("1 " + c32);
else
Console.WriteLine(cc + " " + (c32 + cc));
}
public static string GetStr() => Console.ReadLine();
public static int GetInt() => int.Parse(Console.ReadLine());
public static long GetLong() => long.Parse(Console.ReadLine());
public static double GetDouble() => double.Parse(Console.ReadLine());
public static decimal GetDecimal() => decimal.Parse(Console.ReadLine());
public static List<string>
GetStrList() => Console.ReadLine().Split(' ').ToList();
public static List<int> GetIntList() =>
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
public static List<long> GetLongList() =>
Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
public static List<double> GetDoubleList() =>
Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToList();
public static List<decimal> GetDecimalList() =>
Console.ReadLine().Split(' ').Select(x => decimal.Parse(x)).ToList();
}
}
|
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["-", 3, 4, 0, 28, 0, 16, 12, 23, 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
| 453
| 10
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp11 {
class Class46 {
static void Main() {
int N = int.Parse(Console.ReadLine());
var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
var check = Enumerable.Repeat(false, 8).ToArray();
int count = 0;
for (int i = 0; i < N; i++) {
if (a[i] / 400 < 8) {
check[a[i] / 400] = true;
} else
count++;
}
int min = check.Count(x => x == true);
int max = min + count;
Console.WriteLine($"{min} {max}");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp11 {
class Class46 {
static void Main() {
int N = int.Parse(Console.ReadLine());
var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
var check = Enumerable.Repeat(false, 8).ToArray();
int count = 0;
for (int i = 0; i < N; i++) {
if (a[i] / 400 < 8) {
check[a[i] / 400] = true;
} else
count++;
}
int min = check.Count(x => x == true);
int max = min + count;
if (min == 0)
min = 1;
Console.WriteLine($"{min} {max}");
}
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 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
| 182
| 10
|
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() {
//ここから
int N = IO.ReadLineToInt();
var a = IO.ReadLineToIntList();
bool[] color = new bool[8];
for (int i = 0; i < 8; i++) {
color[i] = false;
}
int free = 0;
for (int i = 0; i < N; i++) {
var n = a[i] / 400;
if (n > 7) {
free++;
} else {
color[n] = true;
}
}
int min = Math.Max(1, color.Count(c => c == true));
int max = Math.Min(9, color.Count(c => c == true) + free);
//ここまで
Console.WriteLine(min + " " + max);
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() {
//ここから
int N = IO.ReadLineToInt();
var a = IO.ReadLineToIntList();
bool[] color = new bool[8];
for (int i = 0; i < 8; i++) {
color[i] = false;
}
int free = 0;
for (int i = 0; i < N; i++) {
var n = a[i] / 400;
if (n > 7) {
free++;
} else {
color[n] = true;
}
}
int min = Math.Max(1, color.Count(c => c == true));
int max = color.Count(c => c == true) + free;
//ここまで
Console.WriteLine(min + " " + max);
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 + " ");
}
}
}
}
|
[["-", 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, 203], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 21], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25]]
| 8
| 752
| 7
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
class Program {
static int[] A;
static void Main(string[] args) {
//入力を受け取る
var N = int.Parse(Console.ReadLine());
A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
var type = 0;
type = IsZeroRange(1, 399);
for (int i = 1; i <= 7; i++) {
type += IsZeroRange(400 * i, 400 * (i + 1) - 1);
}
var red = A.Where(num => num >= 3200).ToArray().Length;
var maxtype = Math.Min(type + red, 8);
var mintype = type;
if (type == 0 && red > 0) {
mintype = 1;
}
Console.WriteLine(1 + " " + 5);
}
static int IsZeroRange(int l, int r) {
// Console.WriteLine(l+" "+r);
if (A.Where(num => num >= l && num <= r).ToArray().Length != 0) {
return 1;
} else {
return 0;
}
}
}
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
class Program {
static int[] A;
static void Main(string[] args) {
//入力を受け取る
var N = int.Parse(Console.ReadLine());
A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
var type = 0;
type = IsZeroRange(1, 399);
for (int i = 1; i <= 7; i++) {
type += IsZeroRange(400 * i, 400 * (i + 1) - 1);
}
var red = A.Where(num => num >= 3200).ToArray().Length;
var maxtype = type + red;
var mintype = type;
if (type == 0 && red > 0) {
mintype = 1;
}
Console.WriteLine(mintype + " " + maxtype);
}
static int IsZeroRange(int l, int r) {
// Console.WriteLine(l+" "+r);
if (A.Where(num => num >= l && num <= r).ToArray().Length != 0) {
return 1;
} else {
return 0;
}
}
}
|
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 21], ["-", 0, 212, 0, 213, 3, 4, 0, 28, 0, 203], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["-", 3, 4, 0, 28, 0, 16, 31, 16, 31, 203], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 31, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22]]
| 8
| 262
| 11
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace C {
class Program {
static void Main(string[] args) {
var n = int.Parse(Console.ReadLine());
var a = Console.ReadLine().Split().Select(int.Parse).ToList();
var over3200 = a.Count(x => x >= 3200);
var colorList =
a.Where(x => x < 3200).Select(x => x / 400).Distinct().ToList();
var minAns = colorList.Count();
var maxAns = minAns + over3200;
Console.WriteLine($"{minAns} {maxAns}");
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace C {
class Program {
static void Main(string[] args) {
var n = int.Parse(Console.ReadLine());
var a = Console.ReadLine().Split().Select(int.Parse).ToList();
var over3200 = a.Count(x => x >= 3200);
var colorList =
a.Where(x => x < 3200).Select(x => x / 400).Distinct().ToList();
int minAns, maxAns;
if (over3200 == n) {
minAns = 1;
maxAns = over3200;
} else {
minAns = colorList.Count();
maxAns = minAns + over3200;
}
Console.WriteLine($"{minAns} {maxAns}");
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 0, 21], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 148
| 26
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCorder {
class Program {
static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
var N = cin.ReadInt;
var a = cin.ReadIntArray(N);
var rate = new int[9];
for (int i = 0; i < 9; i++) {
rate[i] = 0;
}
for (int i = 0; i < N; i++) {
if (a[i] > 3200) {
a[i] = 3200;
}
rate[a[i] / 400]++;
}
var min = 0;
for (int i = 0; i < 8; i++) {
if (rate[i] != 0) {
min++;
}
}
if (min != 0) {
var max = Min(8, min + rate[8]);
WriteLine(min + " " + max);
} else {
var max = Min(8, rate[8]);
WriteLine(1 + " " + max);
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
}
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCorder {
class Program {
static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
var N = cin.ReadInt;
var a = cin.ReadIntArray(N);
var rate = new int[9];
for (int i = 0; i < 9; i++) {
rate[i] = 0;
}
for (int i = 0; i < N; i++) {
if (a[i] > 3200) {
a[i] = 3200;
}
rate[a[i] / 400]++;
}
var min = 0;
for (int i = 0; i < 8; i++) {
if (rate[i] != 0) {
min++;
}
}
var max = min + rate[8];
if (min != 0) {
WriteLine(min + " " + max);
} else {
WriteLine(1 + " " + max);
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
}
|
[["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 79], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["-", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 0, 198, 0, 200, 0, 212, 0, 213, 63, 22], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["-", 0, 212, 0, 213, 3, 4, 0, 28, 0, 203], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 21], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 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, 79], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 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, 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], ["-", 8, 196, 0, 57, 75, 196, 0, 197, 0, 35]]
| 8
| 612
| 32
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace AtCoder {
class Program {
static void Main(string[] args) {
//[summary]C - Colorful Leaderboard
int n = int.Parse(Console.ReadLine());
var a = ReadLine();
var rank = new int[9];
foreach (var ai in a) {
int index = ai / 400;
if (index > 7) {
rank[8]++;
} else {
rank[index]++;
}
}
int min = 0;
for (int i = 0; i < 8; i++) {
if (rank[i] > 0) {
min++;
}
}
Console.WriteLine("{0} {1}", min, min + rank[8]);
}
static List<int> ReadLine() {
var line = Console.ReadLine();
var array = line.Split(' ');
return array.Select(x => int.Parse(x)).ToList();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace AtCoder {
class Program {
static void Main(string[] args) {
//[summary]C - Colorful Leaderboard
int n = int.Parse(Console.ReadLine());
var a = ReadLine();
var rank = new int[9];
foreach (var ai in a) {
int index = ai / 400;
if (index > 7) {
rank[8]++;
} else {
rank[index]++;
}
}
int min = 0;
for (int i = 0; i < 8; i++) {
if (rank[i] > 0) {
min++;
}
}
int max = min + rank[8];
//全員スコアが3200以上の可能性もある
if (min == 0) {
min = 1;
}
Console.WriteLine("{0} {1}", min, max);
}
static List<int> ReadLine() {
var line = Console.ReadLine();
var array = line.Split(' ');
return array.Select(x => int.Parse(x)).ToList();
}
}
}
|
[["+", 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, 16, 31, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["+", 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], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 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], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["-", 3, 4, 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, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 207
| 29
|
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;
namespace SolutionCS {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
int[] r = new int[8];
int c = 0;
string[] s = Console.ReadLine().Split(' ');
for (int i = 0; i < N; i++) {
int v = int.Parse(s[i]);
v /= 400;
if (v >= 8) {
c++;
} else {
r[v]++;
}
}
int kind = 0;
for (int i = 0; i < 8; i++) {
if (0 != r[i]) {
kind++;
}
}
int min = 0;
int max = 0;
if (c == 0) {
min = kind;
max = kind;
} else if (kind == 0) {
min = 1;
max = Math.Min(c, 8);
} else {
min = kind;
max = Math.Min(kind + c, 8);
}
Console.WriteLine("{0} {1}", min, max);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;
namespace SolutionCS {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
int[] r = new int[8];
int c = 0;
string[] s = Console.ReadLine().Split(' ');
for (int i = 0; i < N; i++) {
int v = int.Parse(s[i]);
v /= 400;
if (v >= 8) {
c++;
} else {
r[v]++;
}
}
int kind = 0;
for (int i = 0; i < 8; i++) {
if (0 != r[i]) {
kind++;
}
}
int min = 0;
int max = 0;
if (c == 0) {
min = kind;
max = kind;
} else if (kind == 0) {
min = 1;
max = c;
} else {
min = kind;
max = kind + c;
}
Console.WriteLine("{0} {1}", min, max);
}
}
}
|
[["-", 0, 1, 0, 11, 12, 213, 63, 214, 205, 22], ["-", 0, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["-", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["-", 0, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["-", 0, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["-", 0, 11, 12, 213, 3, 4, 0, 28, 0, 203], ["-", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25]]
| 8
| 263
| 14
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;
class MyUtil {
public static int[] ReadIntArray() {
return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
}
}
class Program {
public static void Main() {
int n = int.Parse(ReadLine());
int[] a = ReadIntArray();
bool[] cs = new bool[8];
int ncolor = 0;
int nOver = 0;
for (int i = 0; i < n; i++) {
int c = a[i] / 400;
if (c < 8 && !cs[c]) {
ncolor++;
cs[c] = true;
} else if (c >= 8) {
nOver++;
}
}
int min = Math.Min(8, Math.Max(ncolor, nOver));
int max = Math.Min(8, ncolor + nOver);
WriteLine($"{min} {max}");
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;
class MyUtil {
public static int[] ReadIntArray() {
return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
}
}
class Program {
public static void Main() {
int n = int.Parse(ReadLine());
int[] a = ReadIntArray();
bool[] cs = new bool[8];
int ncolor = 0;
int nOver = 0;
for (int i = 0; i < n; i++) {
int c = a[i] / 400;
if (c < 8 && !cs[c]) {
ncolor++;
cs[c] = true;
} else if (c >= 8) {
nOver++;
}
}
int min = Math.Max(1, ncolor);
int max = ncolor + nOver;
WriteLine($"{min} {max}");
}
}
|
[["-", 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, 203], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 21], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["-", 0, 28, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 212, 0, 213, 3, 4, 0, 28, 0, 203], ["-", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25], ["+", 0, 212, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 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, 25]]
| 8
| 233
| 18
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
int[] ans = new int[9];
for (int i = 0; i < n; i++) {
if (a[i] < 400)
ans[0] = 1;
else if (a[i] >= 400 && a[i] < 800)
ans[1] = 1;
else if (a[i] >= 800 && a[i] < 1200)
ans[2] = 1;
else if (a[i] >= 1200 && a[i] < 1600)
ans[3] = 1;
else if (a[i] >= 1600 && a[i] < 2000)
ans[4] = 1;
else if (a[i] >= 2000 && a[i] < 2400)
ans[5] = 1;
else if (a[i] >= 2400 && a[i] < 2800)
ans[6] = 1;
else if (a[i] >= 2800 && a[i] < 3200)
ans[7] = 1;
else
ans[8]++;
}
int min = ans.Where((x, y) => y < 8).Sum();
int max = ans.Where((x, y) => y < 8).Sum() + (ans[8] > 0 ? ans[8] : 0);
Console.WriteLine("{0} {1}", min, max);
}
}
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
int[] ans = new int[9];
for (int i = 0; i < n; i++) {
if (a[i] < 400)
ans[0] = 1;
else if (a[i] >= 400 && a[i] < 800)
ans[1] = 1;
else if (a[i] >= 800 && a[i] < 1200)
ans[2] = 1;
else if (a[i] >= 1200 && a[i] < 1600)
ans[3] = 1;
else if (a[i] >= 1600 && a[i] < 2000)
ans[4] = 1;
else if (a[i] >= 2000 && a[i] < 2400)
ans[5] = 1;
else if (a[i] >= 2400 && a[i] < 2800)
ans[6] = 1;
else if (a[i] >= 2800 && a[i] < 3200)
ans[7] = 1;
else
ans[8]++;
}
int min = ans.Where((x, y) => y < 8).Sum() +
(ans.Where((x, y) => y < 8).Sum() > 0 ? 0 : 1);
int max = ans.Where((x, y) => y < 8).Sum() + (ans[8] > 0 ? ans[8] : 0);
Console.WriteLine("{0} {1}", min, max);
}
}
|
[["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["+", 0, 200, 0, 212, 0, 16, 12, 23, 0, 24], ["+", 31, 213, 63, 214, 205, 213, 63, 214, 205, 22], ["+", 31, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["+", 31, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 31, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 218, 54, 55, 0, 24], ["+", 0, 28, 0, 218, 54, 55, 0, 220, 141, 22], ["+", 3, 4, 0, 28, 0, 218, 54, 55, 0, 21], ["+", 3, 4, 0, 28, 0, 218, 54, 55, 0, 25], ["+", 205, 213, 3, 4, 0, 28, 0, 218, 0, 221], ["+", 3, 4, 0, 28, 0, 218, 8, 16, 31, 22], ["+", 3, 4, 0, 28, 0, 218, 8, 16, 17, 18], ["+", 3, 4, 0, 28, 0, 218, 8, 16, 12, 203], ["+", 31, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["+", 0, 41, 15, 16, 31, 213, 63, 214, 0, 131], ["+", 0, 41, 15, 16, 31, 213, 63, 214, 141, 22], ["+", 0, 41, 15, 16, 31, 213, 3, 4, 0, 24], ["+", 0, 41, 15, 16, 31, 213, 3, 4, 0, 25], ["+", 0, 16, 12, 23, 0, 41, 15, 16, 17, 47], ["+", 0, 16, 12, 23, 0, 41, 15, 16, 12, 203], ["+", 0, 212, 0, 16, 12, 23, 0, 41, 0, 101], ["+", 0, 212, 0, 16, 12, 23, 0, 41, 64, 203], ["+", 0, 212, 0, 16, 12, 23, 0, 41, 0, 102], ["+", 0, 212, 0, 16, 12, 23, 0, 41, 75, 203], ["+", 0, 200, 0, 212, 0, 16, 12, 23, 0, 25]]
| 8
| 354
| 27
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;
public class C {
public static void Main() {
int N = GetInt();
int[] numPerColor = new int[8];
int numFreeColor = 0;
for (int i = 0; i < N; i++) {
int a = GetInt();
if (a >= 3200) {
numFreeColor++;
} else {
numPerColor[a / 400]++;
}
}
int min = 0;
for (int i = 0; i < 8; i++) {
if (numPerColor[i] > 0)
min++;
}
int max = min + numFreeColor;
Console.WriteLine("{0} {1}", min, max);
}
}
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() { return int.Parse(getArg()); }
public static long GetLong() { return long.Parse(getArg()); }
public static double GetDouble() { return double.Parse(getArg()); }
public static string GetString() { return getArg(); }
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;
public class C {
public static void Main() {
int N = GetInt();
int[] numPerColor = new int[8];
int numFreeColor = 0;
for (int i = 0; i < N; i++) {
int a = GetInt();
if (a >= 3200) {
numFreeColor++;
} else {
numPerColor[a / 400]++;
}
}
int numBaseColor = 0;
for (int i = 0; i < 8; i++) {
if (numPerColor[i] > 0)
numBaseColor++;
}
int min = Math.Max(1, numBaseColor);
int max = numBaseColor + numFreeColor;
Console.WriteLine("{0} {1}", min, max);
}
}
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() { return int.Parse(getArg()); }
public static long GetLong() { return long.Parse(getArg()); }
public static double GetDouble() { return double.Parse(getArg()); }
public static string GetString() { return getArg(); }
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 8, 196, 0, 57, 64, 1, 0, 223, 0, 22], ["+", 8, 196, 0, 57, 64, 1, 0, 223, 0, 22], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 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, 212, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 21], ["+", 0, 212, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 31, 22]]
| 8
| 304
| 18
|
using System;
using System.Linq;
using System.Collections.Generic;
class Mondai {
static void Main() {
var N = Int32.Parse(Console.ReadLine());
var a = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
var array = new int[9];
var rate = new int[] { 400, 800, 1200, 1600, 2000, 2400, 2800, 3200, 4801 };
for (int i = 0; i < 9; ++i)
array[i] = 0;
for (int i = 0; i < N; ++i) {
for (int j = 0; j < rate.Length; ++j) {
if (j == 8) {
array[j]++;
} else if (a[i] < rate[j]) {
if (array[j] == 0) {
array[j]++;
}
break;
}
}
}
var type = array.Take(8).Sum();
var min = type == 0 ? 1 : type;
var max = type + array[8];
if (8 < max)
max = 8;
Console.WriteLine($"{min} {max}");
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
class Mondai {
static void Main() {
var N = Int32.Parse(Console.ReadLine());
var a = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
var array = new int[9];
var rate = new int[] { 400, 800, 1200, 1600, 2000, 2400, 2800, 3200, 4801 };
for (int i = 0; i < 9; ++i)
array[i] = 0;
for (int i = 0; i < N; ++i) {
for (int j = 0; j < rate.Length; ++j) {
if (j == rate.Length - 1) {
array[j]++;
} else if (a[i] < rate[j]) {
if (array[j] == 0) {
array[j]++;
}
break;
}
}
}
var type = array.Take(rate.Length - 1).Sum();
var min = type == 0 ? 1 : type;
var max = type + array[rate.Length - 1];
Console.WriteLine($"{min} {max}");
}
}
|
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 57, 15, 16, 12, 16, 31, 214, 205, 22], ["+", 0, 57, 15, 16, 12, 16, 31, 214, 0, 131], ["+", 0, 57, 15, 16, 12, 16, 31, 214, 141, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 33], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["-", 63, 214, 205, 213, 3, 4, 0, 28, 0, 203], ["+", 3, 4, 0, 28, 0, 16, 31, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 16, 31, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 16, 31, 214, 141, 22], ["+", 205, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 205, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["-", 0, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 206, 207, 0, 28, 0, 16, 31, 214, 205, 22], ["+", 206, 207, 0, 28, 0, 16, 31, 214, 0, 131], ["+", 206, 207, 0, 28, 0, 16, 31, 214, 141, 22], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 31, 203], ["-", 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], ["-", 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]]
| 8
| 271
| 10
|
using System;
using System.Linq;
using System.Collections.Generic;
class Mondai {
static void Main() {
var N = Int32.Parse(Console.ReadLine());
var a = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
var array = new int[9];
var rate = new int[] { 400, 800, 1200, 1600, 2000, 2400, 2800, 3200, 4801 };
for (int i = 0; i < 9; ++i)
array[i] = 0;
for (int i = 0; i < N; ++i) {
for (int j = 0; j < rate.Length; ++j) {
if (j == 8) {
array[j]++;
} else if (a[i] < rate[j]) {
if (array[j] == 0) {
array[j]++;
}
break;
}
}
}
var type = array.Take(8).Sum();
var min = type == 0 ? 1 : type;
var max = type + array[8];
if (8 < max)
max = 8;
Console.WriteLine($"{min} {max}");
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
class Mondai {
static void Main() {
var N = Int32.Parse(Console.ReadLine());
var a = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
var array = new int[9];
var rate = new int[] { 400, 800, 1200, 1600, 2000, 2400, 2800, 3200, 4801 };
for (int i = 0; i < 9; ++i)
array[i] = 0;
for (int i = 0; i < N; ++i) {
for (int j = 0; j < rate.Length; ++j) {
if (j == 8) {
array[j]++;
} else if (a[i] < rate[j]) {
if (array[j] == 0) {
array[j]++;
}
break;
}
}
}
var type = array.Take(8).Sum();
var min = type == 0 ? 1 : type;
var max = type + array[8];
Console.WriteLine($"{min} {max}");
}
}
|
[["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 31, 203], ["-", 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], ["-", 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
| 271
| 10
|
using System;
using System.Linq;
using System.IO;
using System.Collections.Generic;
using System.Text;
namespace AtCoder {
public class Program {
static int[] getKeys(char delimiter = ' ') {
var Keys = Console.ReadLine().Split(delimiter);
int N = Keys.Length;
int[] Ns = new int[N];
for (int i = 0; i < N; i++) {
Ns[i] = int.Parse(Keys[i]);
}
return Ns;
}
static long[] getKeys_L(char delimiter = ' ') {
var Keys = Console.ReadLine().Split(delimiter);
int N = Keys.Length;
long[] Ns = new long[N];
for (int i = 0; i < N; i++) {
Ns[i] = long.Parse(Keys[i]);
}
return Ns;
}
static double[] getKeys_D(char delimiter = ' ') {
var Keys = Console.ReadLine().Split(delimiter);
int N = Keys.Length;
var Ns = new double[N];
for (int i = 0; i < N; i++) {
Ns[i] = double.Parse(Keys[i]);
}
return Ns;
}
static int[] getLines(int N, char delimiter = ' ') {
int[] Ns = new int[N];
for (int i = 0; i < N; i++) {
Ns[i] = int.Parse(Console.ReadLine());
}
return Ns;
}
static long[] getLines_L(int N, char delimiter = ' ') {
long[] Ns = new long[N];
for (int i = 0; i < N; i++) {
Ns[i] = long.Parse(Console.ReadLine());
}
return Ns;
}
static double[] getLines_D(int N, char delimiter = ' ') {
double[] Ns = new double[N];
for (int i = 0; i < N; i++) {
Ns[i] = double.Parse(Console.ReadLine());
}
return Ns;
}
public static void Show<T>(T[,] map) {
int H = map.GetLength(0);
int W = map.GetLength(1);
Console.WriteLine("-------------------------");
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
Console.Write(map[i, j] + " ");
}
Console.WriteLine();
}
Console.WriteLine("-------------------------");
}
public static void Show<T>(T[,] map, string delimiter) {
int H = map.GetLength(0);
int W = map.GetLength(1);
Console.WriteLine("-------------------------");
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
Console.Write(map[i, j] + delimiter);
}
Console.WriteLine();
}
Console.WriteLine("-------------------------");
}
public static void Show<T>(IEnumerable<T> ts) {
foreach (var item in ts) {
Console.Write(item + " ");
}
Console.WriteLine();
}
public static void Show<T>(IEnumerable<T> ts, string delimiter) {
foreach (var item in ts) {
Console.Write(item + delimiter);
}
Console.WriteLine();
}
public static void ShowDictionary<T1, T2>(Dictionary<T1, T2> dictionary) {
foreach (var item in dictionary) {
Console.WriteLine(item);
}
}
static T[] getUniform<T>(int length, T value) {
T[] Ts = new T[length];
for (int i = 0; i < length; i++) {
Ts[i] = value;
}
return Ts;
}
static void setUniform<T>(T[] ts, T value) {
int length = ts.Length;
for (int i = 0; i < length; i++) {
ts[i] = value;
}
}
static T[,] getUniform<T>(int row, int col, T value) {
T[,] Ts = new T[row, col];
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
Ts[j, i] = value;
}
}
return Ts;
}
static void setUniform<T>(T[,] ts, T value) {
int N = ts.GetLength(0);
int M = ts.GetLength(1);
for (int i = 0; i < M; i++) {
for (int j = 0; j < N; j++) {
ts[j, i] = value;
}
}
}
static Tuple<int, int> findIndex<T>(T[,] map, T value)
where T : IComparable {
int row = map.GetLength(0);
int col = map.GetLength(1);
for (int i = 0; i < col; i++) {
for (int j = 0; j < row; j++) {
if (value.CompareTo(map[j, i]) == 0)
return new Tuple<int, int>(j, i);
}
}
return new Tuple<int, int>(-1, -1);
}
static void Main() {
Console.ReadLine();
var keys = getKeys();
bool[] exist = new bool[8];
int top = 0;
for (int i = 0; i < keys.Length; i++) {
if (keys[i] < 3200) {
exist[keys[i] / 400] = true;
} else {
top++;
}
}
int min = exist.Where(t => t).Count();
int max = min + top;
Console.WriteLine(min + " " + max);
}
}
}
|
using System;
using System.Linq;
using System.IO;
using System.Collections.Generic;
using System.Text;
namespace AtCoder {
public class Program {
static int[] getKeys(char delimiter = ' ') {
var Keys = Console.ReadLine().Split(delimiter);
int N = Keys.Length;
int[] Ns = new int[N];
for (int i = 0; i < N; i++) {
Ns[i] = int.Parse(Keys[i]);
}
return Ns;
}
static long[] getKeys_L(char delimiter = ' ') {
var Keys = Console.ReadLine().Split(delimiter);
int N = Keys.Length;
long[] Ns = new long[N];
for (int i = 0; i < N; i++) {
Ns[i] = long.Parse(Keys[i]);
}
return Ns;
}
static double[] getKeys_D(char delimiter = ' ') {
var Keys = Console.ReadLine().Split(delimiter);
int N = Keys.Length;
var Ns = new double[N];
for (int i = 0; i < N; i++) {
Ns[i] = double.Parse(Keys[i]);
}
return Ns;
}
static int[] getLines(int N, char delimiter = ' ') {
int[] Ns = new int[N];
for (int i = 0; i < N; i++) {
Ns[i] = int.Parse(Console.ReadLine());
}
return Ns;
}
static long[] getLines_L(int N, char delimiter = ' ') {
long[] Ns = new long[N];
for (int i = 0; i < N; i++) {
Ns[i] = long.Parse(Console.ReadLine());
}
return Ns;
}
static double[] getLines_D(int N, char delimiter = ' ') {
double[] Ns = new double[N];
for (int i = 0; i < N; i++) {
Ns[i] = double.Parse(Console.ReadLine());
}
return Ns;
}
public static void Show<T>(T[,] map) {
int H = map.GetLength(0);
int W = map.GetLength(1);
Console.WriteLine("-------------------------");
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
Console.Write(map[i, j] + " ");
}
Console.WriteLine();
}
Console.WriteLine("-------------------------");
}
public static void Show<T>(T[,] map, string delimiter) {
int H = map.GetLength(0);
int W = map.GetLength(1);
Console.WriteLine("-------------------------");
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
Console.Write(map[i, j] + delimiter);
}
Console.WriteLine();
}
Console.WriteLine("-------------------------");
}
public static void Show<T>(IEnumerable<T> ts) {
foreach (var item in ts) {
Console.Write(item + " ");
}
Console.WriteLine();
}
public static void Show<T>(IEnumerable<T> ts, string delimiter) {
foreach (var item in ts) {
Console.Write(item + delimiter);
}
Console.WriteLine();
}
public static void ShowDictionary<T1, T2>(Dictionary<T1, T2> dictionary) {
foreach (var item in dictionary) {
Console.WriteLine(item);
}
}
static T[] getUniform<T>(int length, T value) {
T[] Ts = new T[length];
for (int i = 0; i < length; i++) {
Ts[i] = value;
}
return Ts;
}
static void setUniform<T>(T[] ts, T value) {
int length = ts.Length;
for (int i = 0; i < length; i++) {
ts[i] = value;
}
}
static T[,] getUniform<T>(int row, int col, T value) {
T[,] Ts = new T[row, col];
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
Ts[j, i] = value;
}
}
return Ts;
}
static void setUniform<T>(T[,] ts, T value) {
int N = ts.GetLength(0);
int M = ts.GetLength(1);
for (int i = 0; i < M; i++) {
for (int j = 0; j < N; j++) {
ts[j, i] = value;
}
}
}
static Tuple<int, int> findIndex<T>(T[,] map, T value)
where T : IComparable {
int row = map.GetLength(0);
int col = map.GetLength(1);
for (int i = 0; i < col; i++) {
for (int j = 0; j < row; j++) {
if (value.CompareTo(map[j, i]) == 0)
return new Tuple<int, int>(j, i);
}
}
return new Tuple<int, int>(-1, -1);
}
static void Main() {
Console.ReadLine();
var keys = getKeys();
bool[] exist = new bool[8];
int top = 0;
for (int i = 0; i < keys.Length; i++) {
if (keys[i] < 3200) {
exist[keys[i] / 400] = true;
} else {
top++;
}
}
int colors = exist.Where(t => t).Count();
if (colors == 0) {
int min = 1;
int max = top;
Console.WriteLine(min + " " + max);
} else {
int min = colors;
int max = colors + top;
Console.WriteLine(min + " " + max);
}
}
}
}
|
[["-", 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, 3, 4, 0, 24], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 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, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 197, 0, 35], ["+", 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, 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], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 57, 75, 196, 0, 197, 0, 198, 39, 199], ["+", 75, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 57, 75, 196, 0, 197, 0, 35], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 1,308
| 41
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC_C {
class C064 {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
string[] s1 = Console.ReadLine().Split(' ');
int[] color = new int[8];
int freeCount = 0;
foreach (string s in s1) {
int c = int.Parse(s) / 400;
if (c >= 8)
freeCount++;
else
color[c]++;
}
int min = color.Count(x => x > 0);
if (min == 0) {
min = 1;
freeCount--;
}
int max = Math.Min(8, min + freeCount);
Console.WriteLine(min.ToString() + " " + max.ToString());
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC_C {
class C064 {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
string[] s1 = Console.ReadLine().Split(' ');
int[] color = new int[8];
int freeCount = 0;
foreach (string s in s1) {
int c = int.Parse(s) / 400;
if (c >= 8)
freeCount++;
else
color[c]++;
}
int min = color.Count(x => x > 0);
if (min == 0) {
min = 1;
freeCount--;
}
int max = min + freeCount;
Console.WriteLine(min.ToString() + " " + max.ToString());
}
}
}
|
[["-", 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, 203], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 21], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25]]
| 8
| 195
| 7
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.IO;
using System.Text;
using System.Diagnostics;
using static util;
using P = pair<int, int>;
using Binary = System.Func<System.Linq.Expressions.ParameterExpression,
System.Linq.Expressions.ParameterExpression,
System.Linq.Expressions.BinaryExpression>;
using Unary = System.Func<System.Linq.Expressions.ParameterExpression,
System.Linq.Expressions.UnaryExpression>;
class Program {
static StreamWriter sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
static Scan sc = new Scan();
const int M = 1000000007;
const double eps = 1e-11;
static readonly int[] dd = { 0, 1, 0, -1, 0 };
static void Main() {
int n = sc.Int;
var a = sc.IntArr.Select(x => x / 400).ToArray();
int cnt = 0;
for (int i = 0; i < 8; i++) {
if (a.Contains(i))
++cnt;
}
Prt(cnt, cnt + a.Count(x => x > 7));
sw.Flush();
}
static void DBG(string a) { Console.WriteLine(a); }
static void DBG<T>(IEnumerable<T> a) { DBG(string.Join(" ", a)); }
static void DBG(params object[] a) { DBG(string.Join(" ", a)); }
static void Prt(string a) { sw.WriteLine(a); }
static void Prt<T>(IEnumerable<T> a) { Prt(string.Join(" ", a)); }
static void Prt(params object[] a) { Prt(string.Join(" ", a)); }
// for AOJ
// static string Join<T>(string sep, IEnumerable<T> a) { return
// string.Join(sep, a.Select(x => x.ToString()).ToArray()); } static void
// DBG<T>(IEnumerable<T> a) { DBG(Join(" ", a)); } static void DBG(params
// object[] a) { DBG(Join(" ", a)); } static void Prt<T>(IEnumerable<T> a) {
// Prt(Join(" ", a)); } static void Prt(params object[] a) { Prt(Join(" ",
// a)); }
}
class pair<T, U> : IComparable<pair<T, U>>
where T : IComparable<T>
where U : IComparable<U> {
public T v1;
public U v2;
public pair(T v1, U v2) {
this.v1 = v1;
this.v2 = v2;
}
public int CompareTo(pair<T, U> a) {
return v1.CompareTo(a.v1) != 0 ? v1.CompareTo(a.v1) : v2.CompareTo(a.v2);
}
public override string ToString() { return v1 + " " + v2; }
}
static class util {
public static pair<T, U> make_pair<T, U>(T v1, U v2)
where T : IComparable<T>
where U : IComparable<U> { return new pair<T, U>(v1, v2); }
public static T sqr<T>(T a) { return Operator<T>.Multiply(a, a); }
public static T Max<T>(params T[] a) { return a.Max(); }
public static T Min<T>(params T[] a) { return a.Min(); }
public static void swap<T>(ref T a, ref T b) {
var t = a;
a = b;
b = t;
}
public static void swap<T>(this IList<T> a, int i, int j) {
var t = a[i];
a[i] = a[j];
a[j] = t;
}
public static T[] copy<T>(this IList<T> a) {
var ret = new T[a.Count];
for (int i = 0; i < a.Count; i++)
ret[i] = a[i];
return ret;
}
}
static class Operator<T> {
static readonly ParameterExpression x = Expression.Parameter(typeof(T), "x");
static readonly ParameterExpression y = Expression.Parameter(typeof(T), "y");
public static readonly Func<T, T, T> Add = Lambda(Expression.Add);
public static readonly Func<T, T, T> Subtract = Lambda(Expression.Subtract);
public static readonly Func<T, T, T> Multiply = Lambda(Expression.Multiply);
public static readonly Func<T, T, T> Divide = Lambda(Expression.Divide);
public static readonly Func<T, T> Plus = Lambda(Expression.UnaryPlus);
public static readonly Func<T, T> Negate = Lambda(Expression.Negate);
public static Func<T, T, T> Lambda(Binary op) {
return Expression.Lambda<Func<T, T, T>>(op(x, y), x, y).Compile();
}
public static Func<T, T> Lambda(Unary op) {
return Expression.Lambda<Func<T, T>>(op(x), x).Compile();
}
}
class Scan {
public int Int {
get { return int.Parse(Str); }
}
public long Long {
get { return long.Parse(Str); }
}
public double Double {
get { return double.Parse(Str); }
}
public string Str {
get { return Console.ReadLine().Trim(); }
}
public int[] IntArr {
get { return StrArr.Select(int.Parse).ToArray(); }
}
public long[] LongArr {
get { return StrArr.Select(long.Parse).ToArray(); }
}
public double[] DoubleArr {
get { return StrArr.Select(double.Parse).ToArray(); }
}
public string[] StrArr {
get {
return Str.Split(new[] { ' ' },
System.StringSplitOptions.RemoveEmptyEntries);
}
}
bool eq<T, U>() { return typeof(T).Equals(typeof(U)); }
T ct<T, U>(U a) { return (T)Convert.ChangeType(a, typeof(T)); }
T cv<T>(string s) {
return 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);
}
public void Multi<T>(out T a) { a = cv<T>(Str); }
public void Multi<T, U>(out T a, out U b) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
public void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
public void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
}
public void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d,
out X e) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
}
public 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 = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
f = cv<Y>(ar[5]);
}
}
static class mymath {
public static long Mod = 1000000007;
public static bool isprime(long a) {
if (a < 2)
return false;
for (long i = 2; i * i <= a; i++)
if (a % i == 0)
return false;
return true;
}
public static bool[] sieve(int n) {
var p = new bool[n + 1];
for (int i = 2; i <= n; i++)
p[i] = true;
for (int i = 2; i * i <= n; i++)
if (p[i])
for (int j = i * i; j <= n; j += i)
p[j] = false;
return p;
}
public static List<int> getprimes(int n) {
var prs = new List<int>();
var p = sieve(n);
for (int i = 2; i <= n; i++)
if (p[i])
prs.Add(i);
return prs;
}
public static long[][] E(int n) {
var ret = new long [n][];
for (int i = 0; i < n; i++) {
ret[i] = new long[n];
ret[i][i] = 1;
}
return ret;
}
public static double[][] dE(int n) {
var ret = new double [n][];
for (int i = 0; i < n; i++) {
ret[i] = new double[n];
ret[i][i] = 1;
}
return ret;
}
public static long[][] pow(long[][] A, long n) {
if (n == 0)
return E(A.Length);
var t = pow(A, n / 2);
if ((n & 1) == 0)
return mul(t, t);
return mul(mul(t, t), A);
}
public static double[][] pow(double[][] A, long n) {
if (n == 0)
return dE(A.Length);
var t = pow(A, n / 2);
if ((n & 1) == 0)
return mul(t, t);
return mul(mul(t, t), A);
}
public static double dot(double[] x, double[] y) {
int n = x.Length;
double ret = 0;
for (int i = 0; i < n; i++)
ret += x[i] * y[i];
return ret;
}
public static double _dot(double[] x, double[] y) {
int n = x.Length;
double ret = 0, r = 0;
for (int i = 0; i < n; i++) {
double s = ret + (x[i] * y[i] + r);
r = (x[i] * y[i] + r) - (s - ret);
ret = s;
}
return ret;
}
public static long dot(long[] x, long[] y) {
int n = x.Length;
long ret = 0;
for (int i = 0; i < n; i++)
ret = (ret + x[i] * y[i]) % Mod;
return ret;
}
public static T[][] trans<T>(T[][] A) {
int n = A[0].Length, m = A.Length;
var ret = new T[n][];
for (int i = 0; i < n; i++) {
ret[i] = new T[m];
for (int j = 0; j < m; j++)
ret[i][j] = A[j][i];
}
return ret;
}
public static double[] mul(double[][] A, double[] x) {
int n = A.Length;
var ret = new double[n];
for (int i = 0; i < n; i++)
ret[i] = dot(x, A[i]);
return ret;
}
public static long[] mul(long[][] A, long[] x) {
int n = A.Length;
var ret = new long[n];
for (int i = 0; i < n; i++)
ret[i] = dot(x, A[i]);
return ret;
}
public static long[][] mul(long[][] A, long[][] B) {
int n = A.Length;
var Bt = trans(B);
var ret = new long [n][];
for (int i = 0; i < n; i++)
ret[i] = mul(Bt, A[i]);
return ret;
}
public static double[][] mul(double[][] A, double[][] B) {
int n = A.Length;
var Bt = trans(B);
var ret = new double [n][];
for (int i = 0; i < n; i++)
ret[i] = mul(Bt, A[i]);
return ret;
}
public static long[] add(long[] x, long[] y) {
int n = x.Length;
var ret = new long[n];
for (int i = 0; i < n; i++)
ret[i] = (x[i] + y[i]) % Mod;
return ret;
}
public static long[][] add(long[][] A, long[][] B) {
int n = A.Length;
var ret = new long [n][];
for (int i = 0; i < n; i++)
ret[i] = add(A[i], B[i]);
return ret;
}
public static long pow(long a, long b) {
if (a >= Mod)
return pow(a % Mod, b);
if (a == 0)
return 0;
if (b == 0)
return 1;
var t = pow(a, b / 2);
if ((b & 1) == 0)
return t * t % Mod;
return t * t % Mod * a % Mod;
}
public static long inv(long a) { return pow(a, Mod - 2); }
public static long gcd(long a, long b) {
while (b > 0) {
var t = a % b;
a = b;
b = t;
}
return a;
}
// a x + b y = gcd(a, b)
public static long extgcd(long a, long b, out long x, out long y) {
long g = a;
x = 1;
y = 0;
if (b > 0) {
g = extgcd(b, a % b, out y, out x);
y -= a / b * x;
}
return g;
}
public static long lcm(long a, long b) { return a / gcd(a, b) * b; }
static long[] facts;
public static long[] setfacts(int n) {
facts = new long[n + 1];
facts[0] = 1;
for (int i = 0; i < n; i++)
facts[i + 1] = facts[i] * (i + 1) % Mod;
return facts;
}
public static long comb(int n, int r) {
if (n < 0 || r < 0 || r > n)
return 0;
if (n - r < r)
r = n - r;
if (r == 0)
return 1;
if (r == 1)
return n;
if (facts != null && facts.Length > n)
return facts[n] * inv(facts[r]) % Mod * inv(facts[n - r]) % Mod;
int[] numer = new int[r], denom = new int[r];
for (int k = 0; k < r; k++) {
numer[k] = n - r + k + 1;
denom[k] = k + 1;
}
for (int p = 2; p <= r; p++) {
int piv = denom[p - 1];
if (piv > 1) {
int ofst = (n - r) % p;
for (int k = p - 1; k < r; k += p) {
numer[k - ofst] /= piv;
denom[k] /= piv;
}
}
}
long ret = 1;
for (int k = 0; k < r; k++)
if (numer[k] > 1)
ret = ret * numer[k] % Mod;
return ret;
}
public static long[][] getcombs(int n) {
var ret = new long [n + 1][];
for (int i = 0; i <= n; i++) {
ret[i] = new long[i + 1];
ret[i][0] = ret[i][i] = 1;
for (int j = 1; j < i; j++)
ret[i][j] = (ret[i - 1][j - 1] + ret[i - 1][j]) % Mod;
}
return ret;
}
// nC0, nC2, ..., nCn
public static long[] getcomb(int n) {
var ret = new long[n + 1];
ret[0] = 1;
for (int i = 0; i < n; i++)
ret[i + 1] = ret[i] * (n - i) % Mod * inv(i + 1) % Mod;
return ret;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.IO;
using System.Text;
using System.Diagnostics;
using static util;
using P = pair<int, int>;
using Binary = System.Func<System.Linq.Expressions.ParameterExpression,
System.Linq.Expressions.ParameterExpression,
System.Linq.Expressions.BinaryExpression>;
using Unary = System.Func<System.Linq.Expressions.ParameterExpression,
System.Linq.Expressions.UnaryExpression>;
class Program {
static StreamWriter sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
static Scan sc = new Scan();
const int M = 1000000007;
const double eps = 1e-11;
static readonly int[] dd = { 0, 1, 0, -1, 0 };
static void Main() {
int n = sc.Int;
var a = sc.IntArr.Select(x => x / 400).ToArray();
int cnt = 0;
for (int i = 0; i < 8; i++) {
if (a.Contains(i))
++cnt;
}
Prt(Math.Max(cnt, 1), cnt + a.Count(x => x > 7));
sw.Flush();
}
static void DBG(string a) { Console.WriteLine(a); }
static void DBG<T>(IEnumerable<T> a) { DBG(string.Join(" ", a)); }
static void DBG(params object[] a) { DBG(string.Join(" ", a)); }
static void Prt(string a) { sw.WriteLine(a); }
static void Prt<T>(IEnumerable<T> a) { Prt(string.Join(" ", a)); }
static void Prt(params object[] a) { Prt(string.Join(" ", a)); }
// for AOJ
// static string Join<T>(string sep, IEnumerable<T> a) { return
// string.Join(sep, a.Select(x => x.ToString()).ToArray()); } static void
// DBG<T>(IEnumerable<T> a) { DBG(Join(" ", a)); } static void DBG(params
// object[] a) { DBG(Join(" ", a)); } static void Prt<T>(IEnumerable<T> a) {
// Prt(Join(" ", a)); } static void Prt(params object[] a) { Prt(Join(" ",
// a)); }
}
class pair<T, U> : IComparable<pair<T, U>>
where T : IComparable<T>
where U : IComparable<U> {
public T v1;
public U v2;
public pair(T v1, U v2) {
this.v1 = v1;
this.v2 = v2;
}
public int CompareTo(pair<T, U> a) {
return v1.CompareTo(a.v1) != 0 ? v1.CompareTo(a.v1) : v2.CompareTo(a.v2);
}
public override string ToString() { return v1 + " " + v2; }
}
static class util {
public static pair<T, U> make_pair<T, U>(T v1, U v2)
where T : IComparable<T>
where U : IComparable<U> { return new pair<T, U>(v1, v2); }
public static T sqr<T>(T a) { return Operator<T>.Multiply(a, a); }
public static T Max<T>(params T[] a) { return a.Max(); }
public static T Min<T>(params T[] a) { return a.Min(); }
public static void swap<T>(ref T a, ref T b) {
var t = a;
a = b;
b = t;
}
public static void swap<T>(this IList<T> a, int i, int j) {
var t = a[i];
a[i] = a[j];
a[j] = t;
}
public static T[] copy<T>(this IList<T> a) {
var ret = new T[a.Count];
for (int i = 0; i < a.Count; i++)
ret[i] = a[i];
return ret;
}
}
static class Operator<T> {
static readonly ParameterExpression x = Expression.Parameter(typeof(T), "x");
static readonly ParameterExpression y = Expression.Parameter(typeof(T), "y");
public static readonly Func<T, T, T> Add = Lambda(Expression.Add);
public static readonly Func<T, T, T> Subtract = Lambda(Expression.Subtract);
public static readonly Func<T, T, T> Multiply = Lambda(Expression.Multiply);
public static readonly Func<T, T, T> Divide = Lambda(Expression.Divide);
public static readonly Func<T, T> Plus = Lambda(Expression.UnaryPlus);
public static readonly Func<T, T> Negate = Lambda(Expression.Negate);
public static Func<T, T, T> Lambda(Binary op) {
return Expression.Lambda<Func<T, T, T>>(op(x, y), x, y).Compile();
}
public static Func<T, T> Lambda(Unary op) {
return Expression.Lambda<Func<T, T>>(op(x), x).Compile();
}
}
class Scan {
public int Int {
get { return int.Parse(Str); }
}
public long Long {
get { return long.Parse(Str); }
}
public double Double {
get { return double.Parse(Str); }
}
public string Str {
get { return Console.ReadLine().Trim(); }
}
public int[] IntArr {
get { return StrArr.Select(int.Parse).ToArray(); }
}
public long[] LongArr {
get { return StrArr.Select(long.Parse).ToArray(); }
}
public double[] DoubleArr {
get { return StrArr.Select(double.Parse).ToArray(); }
}
public string[] StrArr {
get {
return Str.Split(new[] { ' ' },
System.StringSplitOptions.RemoveEmptyEntries);
}
}
bool eq<T, U>() { return typeof(T).Equals(typeof(U)); }
T ct<T, U>(U a) { return (T)Convert.ChangeType(a, typeof(T)); }
T cv<T>(string s) {
return 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);
}
public void Multi<T>(out T a) { a = cv<T>(Str); }
public void Multi<T, U>(out T a, out U b) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
public void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
public void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
}
public void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d,
out X e) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
}
public 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 = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
f = cv<Y>(ar[5]);
}
}
static class mymath {
public static long Mod = 1000000007;
public static bool isprime(long a) {
if (a < 2)
return false;
for (long i = 2; i * i <= a; i++)
if (a % i == 0)
return false;
return true;
}
public static bool[] sieve(int n) {
var p = new bool[n + 1];
for (int i = 2; i <= n; i++)
p[i] = true;
for (int i = 2; i * i <= n; i++)
if (p[i])
for (int j = i * i; j <= n; j += i)
p[j] = false;
return p;
}
public static List<int> getprimes(int n) {
var prs = new List<int>();
var p = sieve(n);
for (int i = 2; i <= n; i++)
if (p[i])
prs.Add(i);
return prs;
}
public static long[][] E(int n) {
var ret = new long [n][];
for (int i = 0; i < n; i++) {
ret[i] = new long[n];
ret[i][i] = 1;
}
return ret;
}
public static double[][] dE(int n) {
var ret = new double [n][];
for (int i = 0; i < n; i++) {
ret[i] = new double[n];
ret[i][i] = 1;
}
return ret;
}
public static long[][] pow(long[][] A, long n) {
if (n == 0)
return E(A.Length);
var t = pow(A, n / 2);
if ((n & 1) == 0)
return mul(t, t);
return mul(mul(t, t), A);
}
public static double[][] pow(double[][] A, long n) {
if (n == 0)
return dE(A.Length);
var t = pow(A, n / 2);
if ((n & 1) == 0)
return mul(t, t);
return mul(mul(t, t), A);
}
public static double dot(double[] x, double[] y) {
int n = x.Length;
double ret = 0;
for (int i = 0; i < n; i++)
ret += x[i] * y[i];
return ret;
}
public static double _dot(double[] x, double[] y) {
int n = x.Length;
double ret = 0, r = 0;
for (int i = 0; i < n; i++) {
double s = ret + (x[i] * y[i] + r);
r = (x[i] * y[i] + r) - (s - ret);
ret = s;
}
return ret;
}
public static long dot(long[] x, long[] y) {
int n = x.Length;
long ret = 0;
for (int i = 0; i < n; i++)
ret = (ret + x[i] * y[i]) % Mod;
return ret;
}
public static T[][] trans<T>(T[][] A) {
int n = A[0].Length, m = A.Length;
var ret = new T[n][];
for (int i = 0; i < n; i++) {
ret[i] = new T[m];
for (int j = 0; j < m; j++)
ret[i][j] = A[j][i];
}
return ret;
}
public static double[] mul(double[][] A, double[] x) {
int n = A.Length;
var ret = new double[n];
for (int i = 0; i < n; i++)
ret[i] = dot(x, A[i]);
return ret;
}
public static long[] mul(long[][] A, long[] x) {
int n = A.Length;
var ret = new long[n];
for (int i = 0; i < n; i++)
ret[i] = dot(x, A[i]);
return ret;
}
public static long[][] mul(long[][] A, long[][] B) {
int n = A.Length;
var Bt = trans(B);
var ret = new long [n][];
for (int i = 0; i < n; i++)
ret[i] = mul(Bt, A[i]);
return ret;
}
public static double[][] mul(double[][] A, double[][] B) {
int n = A.Length;
var Bt = trans(B);
var ret = new double [n][];
for (int i = 0; i < n; i++)
ret[i] = mul(Bt, A[i]);
return ret;
}
public static long[] add(long[] x, long[] y) {
int n = x.Length;
var ret = new long[n];
for (int i = 0; i < n; i++)
ret[i] = (x[i] + y[i]) % Mod;
return ret;
}
public static long[][] add(long[][] A, long[][] B) {
int n = A.Length;
var ret = new long [n][];
for (int i = 0; i < n; i++)
ret[i] = add(A[i], B[i]);
return ret;
}
public static long pow(long a, long b) {
if (a >= Mod)
return pow(a % Mod, b);
if (a == 0)
return 0;
if (b == 0)
return 1;
var t = pow(a, b / 2);
if ((b & 1) == 0)
return t * t % Mod;
return t * t % Mod * a % Mod;
}
public static long inv(long a) { return pow(a, Mod - 2); }
public static long gcd(long a, long b) {
while (b > 0) {
var t = a % b;
a = b;
b = t;
}
return a;
}
// a x + b y = gcd(a, b)
public static long extgcd(long a, long b, out long x, out long y) {
long g = a;
x = 1;
y = 0;
if (b > 0) {
g = extgcd(b, a % b, out y, out x);
y -= a / b * x;
}
return g;
}
public static long lcm(long a, long b) { return a / gcd(a, b) * b; }
static long[] facts;
public static long[] setfacts(int n) {
facts = new long[n + 1];
facts[0] = 1;
for (int i = 0; i < n; i++)
facts[i + 1] = facts[i] * (i + 1) % Mod;
return facts;
}
public static long comb(int n, int r) {
if (n < 0 || r < 0 || r > n)
return 0;
if (n - r < r)
r = n - r;
if (r == 0)
return 1;
if (r == 1)
return n;
if (facts != null && facts.Length > n)
return facts[n] * inv(facts[r]) % Mod * inv(facts[n - r]) % Mod;
int[] numer = new int[r], denom = new int[r];
for (int k = 0; k < r; k++) {
numer[k] = n - r + k + 1;
denom[k] = k + 1;
}
for (int p = 2; p <= r; p++) {
int piv = denom[p - 1];
if (piv > 1) {
int ofst = (n - r) % p;
for (int k = p - 1; k < r; k += p) {
numer[k - ofst] /= piv;
denom[k] /= piv;
}
}
}
long ret = 1;
for (int k = 0; k < r; k++)
if (numer[k] > 1)
ret = ret * numer[k] % Mod;
return ret;
}
public static long[][] getcombs(int n) {
var ret = new long [n + 1][];
for (int i = 0; i <= n; i++) {
ret[i] = new long[i + 1];
ret[i][0] = ret[i][i] = 1;
for (int j = 1; j < i; j++)
ret[i][j] = (ret[i - 1][j - 1] + ret[i - 1][j]) % Mod;
}
return ret;
}
// nC0, nC2, ..., nCn
public static long[] getcomb(int n) {
var ret = new long[n + 1];
ret[0] = 1;
for (int i = 0; i < n; i++)
ret[i + 1] = ret[i] * (n - i) % Mod * inv(i + 1) % Mod;
return ret;
}
}
|
[["+", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 21], ["+", 0, 28, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25]]
| 8
| 3,940
| 7
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace test {
class Program {
static void Main(string[] args) {
var N = ReadInt();
var A = ReadArrayInt();
var exists = new bool[8];
var free = 0;
for (int i = 0; i < A.Length; i++) {
if (A[i] < 400)
exists[0] = true;
else if (A[i] < 800)
exists[1] = true;
else if (A[i] < 1200)
exists[2] = true;
else if (A[i] < 1600)
exists[3] = true;
else if (A[i] < 2000)
exists[4] = true;
else if (A[i] < 2400)
exists[5] = true;
else if (A[i] < 2800)
exists[6] = true;
else if (A[i] < 3200)
exists[7] = true;
else
free++;
}
var min = exists.Count(b => b);
var max = min + free;
Console.WriteLine(min + " " + max);
Console.ReadLine();
}
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 test {
class Program {
static void Main(string[] args) {
var N = ReadInt();
var A = ReadArrayInt();
var exists = new bool[8];
var free = 0;
for (int i = 0; i < A.Length; i++) {
if (A[i] < 400)
exists[0] = true;
else if (A[i] < 800)
exists[1] = true;
else if (A[i] < 1200)
exists[2] = true;
else if (A[i] < 1600)
exists[3] = true;
else if (A[i] < 2000)
exists[4] = true;
else if (A[i] < 2400)
exists[5] = true;
else if (A[i] < 2800)
exists[6] = true;
else if (A[i] < 3200)
exists[7] = true;
else
free++;
}
int min = 0, max = 0;
if (exists.Count(b => b) > 0) {
min = exists.Count(b => b);
max = min + free;
} else {
min = 1;
max = free;
}
Console.WriteLine(min + " " + max);
Console.ReadLine();
}
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();
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 0, 21], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 57, 15, 16, 31, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 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, 1, 0, 11, 12, 213, 63, 214, 205, 22], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["+", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["+", 12, 213, 3, 4, 0, 28, 0, 218, 0, 221], ["+", 12, 213, 3, 4, 0, 28, 0, 218, 8, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 379
| 37
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Numerics;
#if DEBUG
using Microsoft.VisualStudio.TestTools.UnitTesting;
#endif
namespace competitive_programming {
public class Program {
static void Main(string[] args) {
#if DEBUG
var scanner = new IO.StreamScanner(File.Open("input.txt", FileMode.Open));
#else
var scanner = new IO.StreamScanner(Console.OpenStandardInput());
#endif
var n = scanner.Integer();
var a = scanner.ScanLine().Split().Select(v => int.Parse(v)).ToList();
var colors = new int[9];
foreach (var v in a)
colors[(v / 400 > 8) ? 8 : v / 400]++;
var num = 0;
for (int i = 0; i < 8; i++) {
if (colors[i] > 0)
num++;
}
var minNum = num > 0 ? num : 1;
var maxNum = num + Math.Min(colors[8], (8 - num));
IO.Printer.Out.WriteLine(minNum + " " + maxNum);
IO.Printer.Out.Flush();
}
}
}
#if DEBUG
#endif
#region INOUT
namespace IO {
using System.IO;
using System.Text;
using System.Globalization;
public class Printer : StreamWriter {
static Printer() {
Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false };
}
public static Printer Out { get; set; }
public override IFormatProvider FormatProvider {
get { return CultureInfo.InvariantCulture; }
}
public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) {}
public Printer(Stream stream, Encoding encoding) : base(stream, encoding) {}
public void Write<T>(string format, T[] source) {
base.Write(format, source.OfType<object>().ToArray());
}
public void WriteLine<T>(string format, T[] source) {
base.WriteLine(format, source.OfType<object>().ToArray());
}
}
public class StreamScanner {
public StreamScanner(Stream stream) { str = stream; }
public readonly Stream str;
private readonly byte[] buf = new byte[1024];
private int len, ptr;
public bool isEof;
public bool IsEndOfStream {
get { return isEof; }
}
private byte read() {
if (isEof)
return 0;
if (ptr < len)
return buf[ptr++];
ptr = 0;
if ((len = str.Read(buf, 0, 1024)) > 0)
return buf[ptr++];
isEof = true;
return 0;
}
public char Char() {
byte b;
do
b = read();
while ((b < 33 || 126 < b) && !isEof);
return (char)b;
}
public string Scan() {
var sb = new StringBuilder();
for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
sb.Append(b);
return sb.ToString();
}
public string ScanLine() {
var sb = new StringBuilder();
for (var b = Char(); b != '\n'; b = (char)read())
if (b == 0)
break;
else if (b != '\r')
sb.Append(b);
return sb.ToString();
}
public long Long() {
if (isEof)
return long.MinValue;
long ret = 0;
byte b;
var ng = false;
do
b = read();
while (b != 0 && b != '-' && (b < '0' || '9' < b));
if (b == 0)
return long.MinValue;
if (b == '-') {
ng = true;
b = read();
}
for (;; b = read()) {
if (b < '0' || '9' < b)
return ng ? -ret : ret;
ret = ret * 10 + b - '0';
}
}
public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }
public double Double() {
var s = Scan();
return s != "" ? double.Parse(s, CultureInfo.InvariantCulture) : double.NaN;
}
static T[] enumerate<T>(int n, Func<T> f) {
var a = new T[n];
for (int i = 0; i < n; ++i)
a[i] = f();
return a;
}
public char[] Char(int n) { return enumerate(n, Char); }
public string[] Scan(int n) { return enumerate(n, Scan); }
public double[] Double(int n) { return enumerate(n, Double); }
public int[] Integer(int n) { return enumerate(n, Integer); }
public long[] Long(int n) { return enumerate(n, Long); }
}
}
#endregion
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Numerics;
#if DEBUG
using Microsoft.VisualStudio.TestTools.UnitTesting;
#endif
namespace competitive_programming {
public class Program {
static void Main(string[] args) {
#if DEBUG
var scanner = new IO.StreamScanner(File.Open("input.txt", FileMode.Open));
#else
var scanner = new IO.StreamScanner(Console.OpenStandardInput());
#endif
var n = scanner.Integer();
var a = scanner.ScanLine().Split().Select(v => int.Parse(v)).ToList();
var colors = new int[9];
foreach (var v in a)
colors[(v / 400 > 8) ? 8 : v / 400]++;
var num = 0;
for (int i = 0; i < 8; i++) {
if (colors[i] > 0)
num++;
}
var minNum = num > 0 ? num : 1;
var maxNum = num + colors[8];
IO.Printer.Out.WriteLine(minNum + " " + maxNum);
IO.Printer.Out.Flush();
}
}
}
#if DEBUG
#endif
#region INOUT
namespace IO {
using System.IO;
using System.Text;
using System.Globalization;
public class Printer : StreamWriter {
static Printer() {
Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false };
}
public static Printer Out { get; set; }
public override IFormatProvider FormatProvider {
get { return CultureInfo.InvariantCulture; }
}
public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) {}
public Printer(Stream stream, Encoding encoding) : base(stream, encoding) {}
public void Write<T>(string format, T[] source) {
base.Write(format, source.OfType<object>().ToArray());
}
public void WriteLine<T>(string format, T[] source) {
base.WriteLine(format, source.OfType<object>().ToArray());
}
}
public class StreamScanner {
public StreamScanner(Stream stream) { str = stream; }
public readonly Stream str;
private readonly byte[] buf = new byte[1024];
private int len, ptr;
public bool isEof;
public bool IsEndOfStream {
get { return isEof; }
}
private byte read() {
if (isEof)
return 0;
if (ptr < len)
return buf[ptr++];
ptr = 0;
if ((len = str.Read(buf, 0, 1024)) > 0)
return buf[ptr++];
isEof = true;
return 0;
}
public char Char() {
byte b;
do
b = read();
while ((b < 33 || 126 < b) && !isEof);
return (char)b;
}
public string Scan() {
var sb = new StringBuilder();
for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
sb.Append(b);
return sb.ToString();
}
public string ScanLine() {
var sb = new StringBuilder();
for (var b = Char(); b != '\n'; b = (char)read())
if (b == 0)
break;
else if (b != '\r')
sb.Append(b);
return sb.ToString();
}
public long Long() {
if (isEof)
return long.MinValue;
long ret = 0;
byte b;
var ng = false;
do
b = read();
while (b != 0 && b != '-' && (b < '0' || '9' < b));
if (b == 0)
return long.MinValue;
if (b == '-') {
ng = true;
b = read();
}
for (;; b = read()) {
if (b < '0' || '9' < b)
return ng ? -ret : ret;
ret = ret * 10 + b - '0';
}
}
public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }
public double Double() {
var s = Scan();
return s != "" ? double.Parse(s, CultureInfo.InvariantCulture) : double.NaN;
}
static T[] enumerate<T>(int n, Func<T> f) {
var a = new T[n];
for (int i = 0; i < n; ++i)
a[i] = f();
return a;
}
public char[] Char(int n) { return enumerate(n, Char); }
public string[] Scan(int n) { return enumerate(n, Scan); }
public double[] Double(int n) { return enumerate(n, Double); }
public int[] Integer(int n) { return enumerate(n, Integer); }
public long[] Long(int n) { return enumerate(n, Long); }
}
}
#endregion
|
[["-", 0, 212, 0, 16, 12, 213, 63, 214, 205, 22], ["-", 0, 212, 0, 16, 12, 213, 63, 214, 0, 131], ["-", 0, 212, 0, 16, 12, 213, 63, 214, 141, 22], ["-", 0, 212, 0, 16, 12, 213, 3, 4, 0, 24], ["-", 0, 212, 0, 16, 12, 213, 3, 4, 0, 21], ["-", 12, 213, 3, 4, 0, 28, 0, 23, 0, 24], ["-", 3, 4, 0, 28, 0, 23, 0, 16, 31, 203], ["-", 3, 4, 0, 28, 0, 23, 0, 16, 17, 33], ["-", 3, 4, 0, 28, 0, 23, 0, 16, 12, 22], ["-", 12, 213, 3, 4, 0, 28, 0, 23, 0, 25], ["-", 0, 212, 0, 16, 12, 213, 3, 4, 0, 25]]
| 8
| 1,107
| 11
|
using System;
namespace ABC064C {
class Program {
static void Main(string[] args) {
int N = Int32.Parse(Console.ReadLine());
string[] bufs = Console.ReadLine().Split(' ');
bool[] exist = new bool[8];
int master = 0;
for (int i = 0; i < N; i++) {
int rank = Int32.Parse(bufs[i]) / 400;
if (rank < 8) {
exist[rank] = true;
} else {
master++;
}
}
int res = 0;
for (int i = 0; i < 8; i++) {
if (exist[i]) {
res++;
}
}
if (res == 0) {
res = 1;
}
Console.WriteLine("{0} {1}", res, res + master);
}
}
}
|
using System;
namespace ABC064C {
class Program {
static void Main(string[] args) {
int N = Int32.Parse(Console.ReadLine());
string[] bufs = Console.ReadLine().Split(' ');
bool[] exist = new bool[8];
int master = 0;
for (int i = 0; i < N; i++) {
int rank = Int32.Parse(bufs[i]) / 400;
if (rank < 8) {
exist[rank] = true;
} else {
master++;
}
}
int res = 0;
for (int i = 0; i < 8; i++) {
if (exist[i]) {
res++;
}
}
if (res == 0) {
Console.WriteLine("{0} {1}", 1, master);
} else {
Console.WriteLine("{0} {1}", res, res + master);
}
}
}
}
|
[["-", 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, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 21], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 182
| 16
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
using static System.Console;
class Program {
static Scanner sc = new Scanner();
internal static void Main(string[] args) {
var N = sc.nextInt();
var a = sc.ArrayInt(N);
var lst = new List<int>();
var free = 0;
for (int i = 0; i < N; i++) {
if (a[i] >= 3200) {
free++;
continue;
}
lst.Add(a[i] / 400);
}
lst = lst.Distinct().ToList();
Write(lst.Count() + " ");
WriteLine(lst.Count + free);
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
using static System.Console;
class Program {
static Scanner sc = new Scanner();
internal static void Main(string[] args) {
var N = sc.nextInt();
var a = sc.ArrayInt(N);
var lst = new List<int>();
var free = 0;
for (int i = 0; i < N; i++) {
if (a[i] >= 3200) {
free++;
continue;
}
lst.Add(a[i] / 400);
}
lst = lst.Distinct().ToList();
Write(Math.Max(lst.Count(), 1) + " ");
WriteLine(lst.Count + free);
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
|
[["+", 0, 28, 0, 16, 31, 213, 63, 214, 205, 22], ["+", 0, 28, 0, 16, 31, 213, 63, 214, 0, 131], ["+", 0, 28, 0, 16, 31, 213, 63, 214, 141, 22], ["+", 0, 28, 0, 16, 31, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25], ["+", 0, 28, 0, 16, 31, 213, 3, 4, 0, 21], ["+", 0, 16, 31, 213, 3, 4, 0, 28, 0, 203]]
| 8
| 514
| 7
|
using System;
using System.Linq;
using System.Collections.Generic;
public class Hello {
public static void Main() {
var N = int.Parse(Console.ReadLine());
var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var hash = new HashSet<int>();
var fill = 0;
var ans = 0; //最小値
var ans2 = 0; //最大値
for (var i = 0; i < N; i++) {
if (a[i] >= 3200) {
fill++;
continue;
}
hash.Add(a[i] / 400);
}
if (hash.Count == 0) {
ans = 1;
ans2 = Math.Min(8, fill);
} else {
ans = hash.Count;
ans2 = Math.Min(8, fill + hash.Count);
}
Console.WriteLine($"{ans} {ans2}");
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
public class Hello {
public static void Main() {
var N = int.Parse(Console.ReadLine());
var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var hash = new HashSet<int>();
var fill = 0;
var ans = 0; //最小値
var ans2 = 0; //最大値
for (var i = 0; i < N; i++) {
if (a[i] >= 3200) {
fill++;
continue;
}
hash.Add(a[i] / 400);
}
if (hash.Count == 0) {
ans = 1;
ans2 = fill;
} else {
ans = hash.Count;
ans2 = fill + hash.Count;
}
Console.WriteLine($"{ans} {ans2}");
}
}
|
[["-", 0, 1, 0, 11, 12, 213, 63, 214, 205, 22], ["-", 0, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["-", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["-", 0, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["-", 0, 11, 12, 213, 3, 4, 0, 28, 0, 203], ["-", 0, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["-", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25]]
| 8
| 205
| 14
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace AtCoder {
class Program {
static void Main() {
int n = int.Parse(Console.ReadLine());
var inp = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int target = 0;
var ans = new List<int>();
for (int i = 0; i < n; i++) {
if (inp[i] < 3200)
ans.Add(inp[i] / 400);
else
target++;
}
Console.WriteLine("{0} {1}", ans.Distinct().Count(),
ans.Distinct().Count() + target);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace AtCoder {
class Program {
static void Main() {
int n = int.Parse(Console.ReadLine());
var inp = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int target = 0;
var ans = new List<int>();
for (int i = 0; i < n; i++) {
if (inp[i] < 3200)
ans.Add(inp[i] / 400);
else
target++;
}
Console.WriteLine("{0} {1}", Math.Max(ans.Distinct().Count(), 1),
ans.Distinct().Count() + target);
}
}
}
|
[["+", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 21], ["+", 0, 28, 0, 213, 3, 4, 0, 28, 0, 203]]
| 8
| 154
| 7
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using static System.Console;
using static System.Math;
//using CS_Contest.Graph;
using CS_Contest.Loop;
using CS_Contest.Utils;
using static Nakov.IO.Cin;
using static CS_Contest.IO.IO;
using static CS_Contest.Utils.MyMath;
namespace CS_Contest {
using Li = List<int>;
using LLi = List<List<int>>;
using Ll = List<long>;
using ti3 = Tuple<int, int, int>;
using ti2 = Tuple<int, int>;
internal class Program {
private static void Main(string[] args) {
var sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
SetOut(sw);
new Calc().Solve();
Out.Flush();
}
public class Calc
{
public void Solve() {
var N = NextInt();
var A = NextIntList();
var box = new int[9];
foreach (var item in A) {
if (item >= 3200) box[8]++;
else {
box[item / 400]++;
}
}
var stable = box.Take(8).Count(x => x != 0);
var max = Min(N, stable + box[8]);
$"{stable} {max}".WL();
return;
}
}
}
}
namespace Nakov.IO {
using System;
using System.Text;
using System.Globalization;
public static class Cin {
public static string NextToken() {
StringBuilder tokenChars = new StringBuilder();
bool tokenFinished = false;
bool skipWhiteSpaceMode = true;
while (!tokenFinished) {
int nextChar = Console.Read();
if (nextChar == -1) {
tokenFinished = true;
} else {
char ch = (char)nextChar;
if (char.IsWhiteSpace(ch)) {
if (!skipWhiteSpaceMode) {
tokenFinished = true;
if (ch == '\r' && (Environment.NewLine == "\r\n")) {
Console.Read();
}
}
} else {
skipWhiteSpaceMode = false;
tokenChars.Append(ch);
}
}
}
string token = tokenChars.ToString();
return token;
}
public static int NextInt() {
string token = Cin.NextToken();
return int.Parse(token);
}
public static long NextLong() {
string token = Cin.NextToken();
return long.Parse(token);
}
public static double NextDouble(bool acceptAnyDecimalSeparator = true) {
string token = Cin.NextToken();
if (acceptAnyDecimalSeparator) {
token = token.Replace(',', '.');
double result = double.Parse(token, CultureInfo.InvariantCulture);
return result;
} else {
double result = double.Parse(token);
return result;
}
}
public static decimal NextDecimal(bool acceptAnyDecimalSeparator = true) {
string token = Cin.NextToken();
if (acceptAnyDecimalSeparator) {
token = token.Replace(',', '.');
decimal result = decimal.Parse(token, CultureInfo.InvariantCulture);
return result;
} else {
decimal result = decimal.Parse(token);
return result;
}
}
}
}
namespace CS_Contest.Loop {
[DebuggerStepThrough]
public static class Loop {
public static void REP(this int n, Action<int> act) {
for (var i = 0; i < n; i++) {
act(i);
}
}
public static void ForeachWith<T>(this IEnumerable<T> ie, Action<int, T> act) {
var i = 0;
foreach (var item in ie) {
act(i, item);
i++;
}
}
public static void Foreach<T>(this IEnumerable<T> ie, Action<T> act) {
foreach (var item in ie) {
act(item);
}
}
}
public class Generate
{
public static IEnumerable<int> Seq(int e) => Seq(0, e, 1);
public static IEnumerable<int> Seq(int s, int e) => Seq(s, e, 1);
public static IEnumerable<int> Seq(int s, int e, int a) {
while (s != e) {
yield return s;
s += a;
}
}
public static List<T> Repeat<T>(Func<int, T> result, int range) =>
Enumerable.Range(0, range).Select(result).ToList();
}
}
namespace CS_Contest.IO {
using Li = List<int>;
using Ll = List<long>;
public static class IO {
public static void WL(this object obj) => WriteLine(obj);
public static void WL(this string obj) => WriteLine(obj);
public static void WL<T>(this IEnumerable<T> list) => list.ToList().ForEach(x => x.WL());
public static Li NextIntList() => ReadLine().Split().Select(int.Parse).ToList();
public static Li NextIntList(int n) => Enumerable.Repeat(0, n).Select(x => ReadLine()).Select(int.Parse).ToList();
public static Ll NextLongList() => ReadLine().Split().Select(long.Parse).ToList();
public static T Tee<T>(this T t, Func<T, string> formatter = null) {
if (formatter == null) formatter = arg => arg.ToString();
formatter(t).WL();
return t;
}
public static void JoinWL<T>(this IEnumerable<T> @this, string sp = " ") => @this.StringJoin(sp).WL();
public static void W(this object @this) => Write(@this);
public static T[,] GetBox<T>(int h, int w, Func<int, int, T> getFunc) {
var rt = new T[h, w];
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
rt[i, j] = getFunc(i, j);
}
}
return rt;
}
}
}
namespace CS_Contest.Utils {
using Li = List<int>;
using Ll = List<long>;
[DebuggerStepThrough]
public static class Utils {
public static bool AnyOf<T>(this T @this, params T[] these) where T:IComparable {
return these.Contains(@this);
}
public static bool Within(int x, int y, int lx, int ly) => !(x < 0 || x >= lx || y < 0 || y >= ly);
public static void Add<T1, T2>(this List<Tuple<T1, T2>> list, T1 t1, T2 t2) => list.Add(new Tuple<T1, T2>(t1, t2));
public static string StringJoin<T>(this IEnumerable<T> l, string separator = "") => string.Join(separator, l);
public static Queue<T> ToQueue<T>(this IEnumerable<T> iEnumerable) {
var rt = new Queue<T>();
foreach (var item in iEnumerable) {
rt.Enqueue(item);
}
return rt;
}
public static void Swap<T>(ref T x, ref T y) {
var tmp = x;
x = y;
y = tmp;
}
public static List<Tuple<TKey, TValue>> ToTupleList<TKey, TValue>(this Map<TKey, TValue> @this) =>
@this.Select(x => Tuple.Create(x.Key, x.Value)).ToList();
public static Map<TKey, int> CountUp<TKey>(this IEnumerable<TKey> l) {
var dic = new Map<TKey, int>();
foreach (var item in l) {
dic[item]++;
}
return dic;
}
public static int Count<T>(this IEnumerable<T> l, T target) => l.Count(x => x.Equals(target));
public static IEnumerable<T> SkipAt<T>(this IEnumerable<T> @this, int at) {
var enumerable = @this as T[] ?? @this.ToArray();
for (var i = 0; i < enumerable.Count(); i++) {
if (i == at) continue;
yield return enumerable.ElementAt(i);
}
}
public static int LowerBound<T>(this List<T> @this, T x) where T : IComparable
{
int lb = -1, ub = @this.Count;
while (ub - lb > 1)
{
int mid = (ub + lb) >> 1;
if (@this[mid].CompareTo(x) >= 0) ub = mid;
else lb = mid;
}
return ub;
}
public static int UpperBound<T>(this List<T> @this, T x) where T : IComparable
{
int lb = -1, ub = @this.Count;
while (ub - lb > 1)
{
int mid = (ub + lb) >> 1;
if (@this[mid].CompareTo(x) > 0) ub = mid;
else lb = mid;
}
return ub;
}
}
public class Map<TKey, TValue> : Dictionary<TKey, TValue> {
public Map() : base() { }
public Map(int capacity) : base(capacity) { }
public new TValue this[TKey index] {
get {
TValue v;
return this.TryGetValue(index, out v) ? v : base[index] = default(TValue);
}
set { base[index] = value; }
}
}
public static class MyMath {
public static T EMin<T>(params T[] a) where T : IComparable<T> => a.Min();
public static T EMax<T>(params T[] a) where T : IComparable<T> => a.Max();
}
}
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using static System.Console;
using static System.Math;
//using CS_Contest.Graph;
using CS_Contest.Loop;
using CS_Contest.Utils;
using static Nakov.IO.Cin;
using static CS_Contest.IO.IO;
using static CS_Contest.Utils.MyMath;
namespace CS_Contest {
using Li = List<int>;
using LLi = List<List<int>>;
using Ll = List<long>;
using ti3 = Tuple<int, int, int>;
using ti2 = Tuple<int, int>;
internal class Program {
private static void Main(string[] args) {
var sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
SetOut(sw);
new Calc().Solve();
Out.Flush();
}
public class Calc
{
public void Solve() {
var N = NextInt();
var A = NextIntList();
var box = new int[9];
foreach (var item in A) {
if (item >= 3200) box[8]++;
else {
box[item / 400]++;
}
}
var stable = box.Take(8).Count(x => x != 0);
var max = Min(N, stable + box[8]);
if (stable == 0) stable++;
$"{stable} {max}".WL();
return;
}
}
}
}
namespace Nakov.IO {
using System;
using System.Text;
using System.Globalization;
public static class Cin {
public static string NextToken() {
StringBuilder tokenChars = new StringBuilder();
bool tokenFinished = false;
bool skipWhiteSpaceMode = true;
while (!tokenFinished) {
int nextChar = Console.Read();
if (nextChar == -1) {
tokenFinished = true;
} else {
char ch = (char)nextChar;
if (char.IsWhiteSpace(ch)) {
if (!skipWhiteSpaceMode) {
tokenFinished = true;
if (ch == '\r' && (Environment.NewLine == "\r\n")) {
Console.Read();
}
}
} else {
skipWhiteSpaceMode = false;
tokenChars.Append(ch);
}
}
}
string token = tokenChars.ToString();
return token;
}
public static int NextInt() {
string token = Cin.NextToken();
return int.Parse(token);
}
public static long NextLong() {
string token = Cin.NextToken();
return long.Parse(token);
}
public static double NextDouble(bool acceptAnyDecimalSeparator = true) {
string token = Cin.NextToken();
if (acceptAnyDecimalSeparator) {
token = token.Replace(',', '.');
double result = double.Parse(token, CultureInfo.InvariantCulture);
return result;
} else {
double result = double.Parse(token);
return result;
}
}
public static decimal NextDecimal(bool acceptAnyDecimalSeparator = true) {
string token = Cin.NextToken();
if (acceptAnyDecimalSeparator) {
token = token.Replace(',', '.');
decimal result = decimal.Parse(token, CultureInfo.InvariantCulture);
return result;
} else {
decimal result = decimal.Parse(token);
return result;
}
}
}
}
namespace CS_Contest.Loop {
[DebuggerStepThrough]
public static class Loop {
public static void REP(this int n, Action<int> act) {
for (var i = 0; i < n; i++) {
act(i);
}
}
public static void ForeachWith<T>(this IEnumerable<T> ie, Action<int, T> act) {
var i = 0;
foreach (var item in ie) {
act(i, item);
i++;
}
}
public static void Foreach<T>(this IEnumerable<T> ie, Action<T> act) {
foreach (var item in ie) {
act(item);
}
}
}
public class Generate
{
public static IEnumerable<int> Seq(int e) => Seq(0, e, 1);
public static IEnumerable<int> Seq(int s, int e) => Seq(s, e, 1);
public static IEnumerable<int> Seq(int s, int e, int a) {
while (s != e) {
yield return s;
s += a;
}
}
public static List<T> Repeat<T>(Func<int, T> result, int range) =>
Enumerable.Range(0, range).Select(result).ToList();
}
}
namespace CS_Contest.IO {
using Li = List<int>;
using Ll = List<long>;
public static class IO {
public static void WL(this object obj) => WriteLine(obj);
public static void WL(this string obj) => WriteLine(obj);
public static void WL<T>(this IEnumerable<T> list) => list.ToList().ForEach(x => x.WL());
public static Li NextIntList() => ReadLine().Split().Select(int.Parse).ToList();
public static Li NextIntList(int n) => Enumerable.Repeat(0, n).Select(x => ReadLine()).Select(int.Parse).ToList();
public static Ll NextLongList() => ReadLine().Split().Select(long.Parse).ToList();
public static T Tee<T>(this T t, Func<T, string> formatter = null) {
if (formatter == null) formatter = arg => arg.ToString();
formatter(t).WL();
return t;
}
public static void JoinWL<T>(this IEnumerable<T> @this, string sp = " ") => @this.StringJoin(sp).WL();
public static void W(this object @this) => Write(@this);
public static T[,] GetBox<T>(int h, int w, Func<int, int, T> getFunc) {
var rt = new T[h, w];
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
rt[i, j] = getFunc(i, j);
}
}
return rt;
}
}
}
namespace CS_Contest.Utils {
using Li = List<int>;
using Ll = List<long>;
[DebuggerStepThrough]
public static class Utils {
public static bool AnyOf<T>(this T @this, params T[] these) where T:IComparable {
return these.Contains(@this);
}
public static bool Within(int x, int y, int lx, int ly) => !(x < 0 || x >= lx || y < 0 || y >= ly);
public static void Add<T1, T2>(this List<Tuple<T1, T2>> list, T1 t1, T2 t2) => list.Add(new Tuple<T1, T2>(t1, t2));
public static string StringJoin<T>(this IEnumerable<T> l, string separator = "") => string.Join(separator, l);
public static Queue<T> ToQueue<T>(this IEnumerable<T> iEnumerable) {
var rt = new Queue<T>();
foreach (var item in iEnumerable) {
rt.Enqueue(item);
}
return rt;
}
public static void Swap<T>(ref T x, ref T y) {
var tmp = x;
x = y;
y = tmp;
}
public static List<Tuple<TKey, TValue>> ToTupleList<TKey, TValue>(this Map<TKey, TValue> @this) =>
@this.Select(x => Tuple.Create(x.Key, x.Value)).ToList();
public static Map<TKey, int> CountUp<TKey>(this IEnumerable<TKey> l) {
var dic = new Map<TKey, int>();
foreach (var item in l) {
dic[item]++;
}
return dic;
}
public static int Count<T>(this IEnumerable<T> l, T target) => l.Count(x => x.Equals(target));
public static IEnumerable<T> SkipAt<T>(this IEnumerable<T> @this, int at) {
var enumerable = @this as T[] ?? @this.ToArray();
for (var i = 0; i < enumerable.Count(); i++) {
if (i == at) continue;
yield return enumerable.ElementAt(i);
}
}
public static int LowerBound<T>(this List<T> @this, T x) where T : IComparable
{
int lb = -1, ub = @this.Count;
while (ub - lb > 1)
{
int mid = (ub + lb) >> 1;
if (@this[mid].CompareTo(x) >= 0) ub = mid;
else lb = mid;
}
return ub;
}
public static int UpperBound<T>(this List<T> @this, T x) where T : IComparable
{
int lb = -1, ub = @this.Count;
while (ub - lb > 1)
{
int mid = (ub + lb) >> 1;
if (@this[mid].CompareTo(x) > 0) ub = mid;
else lb = mid;
}
return ub;
}
}
public class Map<TKey, TValue> : Dictionary<TKey, TValue> {
public Map() : base() { }
public Map(int capacity) : base(capacity) { }
public new TValue this[TKey index] {
get {
TValue v;
return this.TryGetValue(index, out v) ? v : base[index] = default(TValue);
}
set { base[index] = value; }
}
}
public static class MyMath {
public static T EMin<T>(params T[] a) where T : IComparable<T> => a.Min();
public static T EMax<T>(params T[] a) where T : IComparable<T> => a.Max();
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 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, 223, 0, 22], ["+", 8, 196, 0, 57, 64, 1, 0, 223, 0, 29], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35]]
| 8
| 2,101
| 9
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AtCoder {
class Program {
private const int MODULO = 1000000007;
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 Color(int a) {
for (int i = 400; i <= 3200; i += 400) {
if (a < i) {
return i;
}
}
return -1;
}
static IEnumerable<int> Solve(int[] A) {
int reds = 0;
var colors = new Dictionary<int, int>();
foreach (int a in A) {
int key = Color(a);
if (key < 0) {
++reds;
} else {
if (!colors.ContainsKey(key)) {
colors[key] = 0;
}
++colors[key];
}
}
return new[] { colors.Count, colors.Count + reds };
}
static void Main(string[] args) {
int N = ReadInt();
int[] A = ReadInts();
Console.WriteLine(string.Join(" ", Solve(A)));
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AtCoder {
class Program {
private const int MODULO = 1000000007;
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 Color(int a) {
for (int i = 400; i <= 3200; i += 400) {
if (a < i) {
return i;
}
}
return -1;
}
static IEnumerable<int> Solve(int[] A) {
int reds = 0;
var colors = new Dictionary<int, int>();
foreach (int a in A) {
int key = Color(a);
if (key < 0) {
++reds;
} else {
if (!colors.ContainsKey(key)) {
colors[key] = 0;
}
++colors[key];
}
}
return new[] { Math.Max(colors.Count, 1), colors.Count + reds };
}
static void Main(string[] args) {
int N = ReadInt();
int[] A = ReadInts();
Console.WriteLine(string.Join(" ", Solve(A)));
}
}
}
|
[["+", 0, 297, 0, 229, 0, 213, 63, 214, 205, 22], ["+", 0, 297, 0, 229, 0, 213, 63, 214, 0, 131], ["+", 0, 297, 0, 229, 0, 213, 63, 214, 141, 22], ["+", 0, 297, 0, 229, 0, 213, 3, 4, 0, 24], ["+", 0, 297, 0, 229, 0, 213, 3, 4, 0, 21], ["+", 0, 229, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 297, 0, 229, 0, 213, 3, 4, 0, 25]]
| 8
| 379
| 7
|
using System;
using System.Linq;
using System.Collections.Generic;
public class Hello {
public static void Main() {
int N = int.Parse(Console.ReadLine());
string[] s = Console.ReadLine().Split(' ');
int[] num = s_to_i(s);
bool[] color = new bool[8];
for (int i = 0; i < 8; i++)
color[i] = false;
int pro_count = 0;
for (int i = 0; i < N; i++) {
if (num[i] < 3200)
color[num[i] / 400] = true;
else {
pro_count++;
}
}
int ans_min = 0;
for (int i = 0; i < 8; i++)
if (color[i])
ans_min++;
if (ans_min == 0) {
ans_min = 1;
pro_count--;
}
int ans_max = ans_min + pro_count;
if (ans_max > 8)
ans_max = 8;
Console.WriteLine("{0} {1}", ans_min, ans_max);
}
static int[] s_to_i(string[] s) {
int[] ret = Array.ConvertAll<string, int>(
s, delegate(string value) { return int.Parse(value); });
return ret;
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
public class Hello {
public static void Main() {
int N = int.Parse(Console.ReadLine());
string[] s = Console.ReadLine().Split(' ');
int[] num = s_to_i(s);
bool[] color = new bool[8];
for (int i = 0; i < 8; i++)
color[i] = false;
int pro_count = 0;
for (int i = 0; i < N; i++) {
if (num[i] < 3200)
color[num[i] / 400] = true;
else {
pro_count++;
}
}
int ans_min = 0;
for (int i = 0; i < 8; i++)
if (color[i])
ans_min++;
if (ans_min == 0) {
ans_min = 1;
pro_count--;
}
int ans_max = ans_min + pro_count;
Console.WriteLine("{0} {1}", ans_min, ans_max);
}
static int[] s_to_i(string[] s) {
int[] ret = Array.ConvertAll<string, int>(
s, delegate(string value) { return int.Parse(value); });
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, 47], ["-", 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
| 273
| 10
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
class Program {
static void Main() { new Magatro().Solve(); }
}
class Magatro {
int N;
int[] A;
private void Scan() {
N = int.Parse(Console.ReadLine());
A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
public void Solve() {
Scan();
int rand = 0;
bool[] b = new bool[8];
foreach (int i in A) {
if (i >= 3200) {
rand++;
continue;
}
b[i / 400] = true;
}
int min = b.Count(bo => bo);
Console.WriteLine("{0} {1}", min, min + rand);
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
class Program {
static void Main() { new Magatro().Solve(); }
}
class Magatro {
int N;
int[] A;
private void Scan() {
N = int.Parse(Console.ReadLine());
A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
public void Solve() {
Scan();
int rand = 0;
bool[] b = new bool[8];
foreach (int i in A) {
if (i >= 3200) {
rand++;
continue;
}
b[i / 400] = true;
}
int min = b.Count(bo => bo);
if (min == 0) {
Console.WriteLine("1 {0}", rand);
} else {
Console.WriteLine("{0} {1}", min, min + rand);
}
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 21], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 202
| 22
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
namespace AtCoder {
class MainClass {
readonly int[] c = { 3200, 2800, 2400, 2000, 1600, 1200, 800, 400, 1 };
int N;
int[] a;
void Solve() {
io.i(out N);
io.ini(out a, N);
int[] num = new int[c.Length];
for (int i = 0; i < N; i++) {
for (int j = 0; j < c.Length; j++) {
if (a[i] >= c[j]) {
num[j]++;
break;
}
}
}
int min, max, used;
used = num.Where(n => n > 0).Count();
min = Math.Max(0, (num.First() > 0) ? used - 1 : used);
max = used + Math.Max(0, num.First() - 1);
io.ol(min, max);
}
public static void Main(string[] args) { new MainClass().Stream(); }
IO io = new IO();
void Stream() {
Solve();
io.writeFlush();
}
class IO {
string[] nextBuffer;
int BufferCnt;
char[] cs = new char[] { ' ' };
StreamWriter sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
public IO() {
nextBuffer = new string[0];
BufferCnt = 0;
Console.SetOut(sw);
}
public string next() {
if (BufferCnt < nextBuffer.Length)
return nextBuffer[BufferCnt++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
BufferCnt = 0;
return nextBuffer[BufferCnt++];
}
public char nextChar() { return char.Parse(next()); }
public int nextInt() { return int.Parse(next()); }
public long nextLong() { return long.Parse(next()); }
public double nextDouble() { return double.Parse(next()); }
public string[] array() { return Console.ReadLine().Split(' '); }
public char[] arrayChar() { return Array.ConvertAll(array(), char.Parse); }
public int[] arrayInt() { return Array.ConvertAll(array(), int.Parse); }
public long[] arrayLong() { return Array.ConvertAll(array(), long.Parse); }
public double[] arrayDouble() {
return Array.ConvertAll(array(), double.Parse);
}
private bool typeEQ<T, U>() { return typeof(T).Equals(typeof(U)); }
private T convertType<T, U>(U v) {
return (T)Convert.ChangeType(v, typeof(T));
}
private T suitType<T>(string s) {
if (typeEQ<T, int>())
return convertType<T, int>(int.Parse(s));
if (typeEQ<T, long>())
return convertType<T, long>(long.Parse(s));
if (typeEQ<T, double>())
return convertType<T, double>(double.Parse(s));
if (typeEQ<T, char>())
return convertType<T, char>(char.Parse(s));
return convertType<T, string>(s);
}
public void i<T>(out T v) { v = suitType<T>(next()); }
public void i<T, U>(out T v1, out U v2) {
var a = array();
v1 = suitType<T>(a[0]);
v2 = suitType<U>(a[1]);
}
public void i<T, U, V>(out T v1, out U v2, out V v3) {
var a = array();
v1 = suitType<T>(a[0]);
v2 = suitType<U>(a[1]);
v3 = suitType<V>(a[2]);
}
public void i<T, U, V, W>(out T v1, out U v2, out V v3, out W v4) {
var a = array();
v1 = suitType<T>(a[0]);
v2 = suitType<U>(a[1]);
v3 = suitType<V>(a[2]);
v4 = suitType<W>(a[3]);
}
public void ini(out int[] a, int size) {
a = new int[size];
for (int i = 0; i < size; i++)
a[i] = nextInt();
}
public void ini(out int[] a1, out int[] a2, int size) {
a1 = new int[size];
a2 = new int[size];
for (int i = 0; i < size; i++) {
a1[i] = nextInt();
a2[i] = nextInt();
}
}
public void ini(out string[] a, int size) {
a = new string[size];
for (int i = 0; i < size; i++)
a[i] = next();
}
public void inii(out int[] a, int size) {
a = new int[size];
for (int i = 0; i < size; i++)
a[i] = nextInt() - 1;
}
public void o<T>(T v) { Console.WriteLine(v); }
public void o<T>(params T[] a) {
foreach (T v in a)
Console.WriteLine(v);
}
public void o<T>(List<T> l) {
foreach (T v in l)
sw.WriteLine(v);
}
public void ol<T>(T v) { Console.Write(v + " "); }
public void ol<T>(params T[] a) {
foreach (T v in a)
Console.Write(v + " ");
Console.WriteLine("");
}
public void YN(bool f) { Console.WriteLine(f ? "YES" : "NO"); }
public void Yn(bool f) { Console.WriteLine(f ? "Yes" : "No"); }
public void yn(bool f) { Console.WriteLine(f ? "yes" : "no"); }
public void writeFlush() { Console.Out.Flush(); }
}
class Mathf {
public int mod = 1000000007; // 10^9+7
public long Pow(long a, long b) {
if (b == 0)
return 1;
if (b % 2 == 1)
return (a % mod * Pow(a % mod, b - 1) % mod) % mod;
else
return Pow(a * a % mod, b / 2) % mod;
}
public long Fact(long n) {
return n != 0 ? (n % mod * (Fact(n - 1) % mod) % mod) : 1;
}
public long C(long n, long r) {
if (r == 0 || n == r)
return 1;
else
return (Fact(n) % mod *
Pow((Fact(n - r) % mod * Fact(r) % mod) % mod, mod - 2) % mod) %
mod;
}
public long Sum(params long[] a) {
return a.Aggregate((v, next) => (v % mod + next) % mod);
}
public int GCD(int a, int b) {
if (a < b)
Swap(ref a, ref b);
return b == 0 ? a : GCD(b, a % b);
}
public int GCD(int[] array) {
return array.Aggregate((v, next) => GCD(v, next));
}
public void Swap<T>(ref T a, ref T b) {
T tmp = a;
a = b;
b = tmp;
}
public T Max<T>(params T[] v) { return v.Max(); }
public T Min<T>(params T[] v) { return v.Min(); }
}
}
static class StringEX {
public static string Reversed(this string s) {
return string.Join("", s.Reverse());
}
public static string Repeat(this string s, int n) {
return string.Concat(Enumerable.Repeat(s, n).ToArray());
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
namespace AtCoder {
class MainClass {
readonly int[] c = { 3200, 2800, 2400, 2000, 1600, 1200, 800, 400, 1 };
int N;
int[] a;
void Solve() {
io.i(out N);
io.ini(out a, N);
int[] num = new int[c.Length];
for (int i = 0; i < N; i++) {
for (int j = 0; j < c.Length; j++) {
if (a[i] >= c[j]) {
num[j]++;
break;
}
}
}
int min, max, used;
used = num.Where(n => n > 0).Count();
min = Math.Max((used == 0) ? 0 : 1, (num.First() > 0) ? used - 1 : used);
max = used + Math.Max(0, num.First() - 1);
io.ol(min, max);
}
public static void Main(string[] args) { new MainClass().Stream(); }
IO io = new IO();
void Stream() {
Solve();
io.writeFlush();
}
class IO {
string[] nextBuffer;
int BufferCnt;
char[] cs = new char[] { ' ' };
StreamWriter sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
public IO() {
nextBuffer = new string[0];
BufferCnt = 0;
Console.SetOut(sw);
}
public string next() {
if (BufferCnt < nextBuffer.Length)
return nextBuffer[BufferCnt++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
BufferCnt = 0;
return nextBuffer[BufferCnt++];
}
public char nextChar() { return char.Parse(next()); }
public int nextInt() { return int.Parse(next()); }
public long nextLong() { return long.Parse(next()); }
public double nextDouble() { return double.Parse(next()); }
public string[] array() { return Console.ReadLine().Split(' '); }
public char[] arrayChar() { return Array.ConvertAll(array(), char.Parse); }
public int[] arrayInt() { return Array.ConvertAll(array(), int.Parse); }
public long[] arrayLong() { return Array.ConvertAll(array(), long.Parse); }
public double[] arrayDouble() {
return Array.ConvertAll(array(), double.Parse);
}
private bool typeEQ<T, U>() { return typeof(T).Equals(typeof(U)); }
private T convertType<T, U>(U v) {
return (T)Convert.ChangeType(v, typeof(T));
}
private T suitType<T>(string s) {
if (typeEQ<T, int>())
return convertType<T, int>(int.Parse(s));
if (typeEQ<T, long>())
return convertType<T, long>(long.Parse(s));
if (typeEQ<T, double>())
return convertType<T, double>(double.Parse(s));
if (typeEQ<T, char>())
return convertType<T, char>(char.Parse(s));
return convertType<T, string>(s);
}
public void i<T>(out T v) { v = suitType<T>(next()); }
public void i<T, U>(out T v1, out U v2) {
var a = array();
v1 = suitType<T>(a[0]);
v2 = suitType<U>(a[1]);
}
public void i<T, U, V>(out T v1, out U v2, out V v3) {
var a = array();
v1 = suitType<T>(a[0]);
v2 = suitType<U>(a[1]);
v3 = suitType<V>(a[2]);
}
public void i<T, U, V, W>(out T v1, out U v2, out V v3, out W v4) {
var a = array();
v1 = suitType<T>(a[0]);
v2 = suitType<U>(a[1]);
v3 = suitType<V>(a[2]);
v4 = suitType<W>(a[3]);
}
public void ini(out int[] a, int size) {
a = new int[size];
for (int i = 0; i < size; i++)
a[i] = nextInt();
}
public void ini(out int[] a1, out int[] a2, int size) {
a1 = new int[size];
a2 = new int[size];
for (int i = 0; i < size; i++) {
a1[i] = nextInt();
a2[i] = nextInt();
}
}
public void ini(out string[] a, int size) {
a = new string[size];
for (int i = 0; i < size; i++)
a[i] = next();
}
public void inii(out int[] a, int size) {
a = new int[size];
for (int i = 0; i < size; i++)
a[i] = nextInt() - 1;
}
public void o<T>(T v) { Console.WriteLine(v); }
public void o<T>(params T[] a) {
foreach (T v in a)
Console.WriteLine(v);
}
public void o<T>(List<T> l) {
foreach (T v in l)
sw.WriteLine(v);
}
public void ol<T>(T v) { Console.Write(v + " "); }
public void ol<T>(params T[] a) {
foreach (T v in a)
Console.Write(v + " ");
Console.WriteLine("");
}
public void YN(bool f) { Console.WriteLine(f ? "YES" : "NO"); }
public void Yn(bool f) { Console.WriteLine(f ? "Yes" : "No"); }
public void yn(bool f) { Console.WriteLine(f ? "yes" : "no"); }
public void writeFlush() { Console.Out.Flush(); }
}
class Mathf {
public int mod = 1000000007; // 10^9+7
public long Pow(long a, long b) {
if (b == 0)
return 1;
if (b % 2 == 1)
return (a % mod * Pow(a % mod, b - 1) % mod) % mod;
else
return Pow(a * a % mod, b / 2) % mod;
}
public long Fact(long n) {
return n != 0 ? (n % mod * (Fact(n - 1) % mod) % mod) : 1;
}
public long C(long n, long r) {
if (r == 0 || n == r)
return 1;
else
return (Fact(n) % mod *
Pow((Fact(n - r) % mod * Fact(r) % mod) % mod, mod - 2) % mod) %
mod;
}
public long Sum(params long[] a) {
return a.Aggregate((v, next) => (v % mod + next) % mod);
}
public int GCD(int a, int b) {
if (a < b)
Swap(ref a, ref b);
return b == 0 ? a : GCD(b, a % b);
}
public int GCD(int[] array) {
return array.Aggregate((v, next) => GCD(v, next));
}
public void Swap<T>(ref T a, ref T b) {
T tmp = a;
a = b;
b = tmp;
}
public T Max<T>(params T[] v) { return v.Max(); }
public T Min<T>(params T[] v) { return v.Min(); }
}
}
static class StringEX {
public static string Reversed(this string s) {
return string.Join("", s.Reverse());
}
public static string Repeat(this string s, int n) {
return string.Concat(Enumerable.Repeat(s, n).ToArray());
}
}
}
|
[["+", 3, 4, 0, 28, 0, 41, 15, 23, 0, 24], ["+", 0, 28, 0, 41, 15, 23, 0, 16, 31, 22], ["+", 0, 28, 0, 41, 15, 23, 0, 16, 17, 60], ["+", 0, 28, 0, 41, 15, 23, 0, 16, 12, 203], ["+", 3, 4, 0, 28, 0, 41, 15, 23, 0, 25], ["+", 12, 213, 3, 4, 0, 28, 0, 41, 0, 101], ["+", 12, 213, 3, 4, 0, 28, 0, 41, 0, 102], ["+", 12, 213, 3, 4, 0, 28, 0, 41, 75, 203]]
| 8
| 1,905
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main() {
var N = int.Parse(Console.ReadLine());
var NX = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
int out1 = 0;
int i;
int[] num = new int[8];
int others = 0;
for (i = 0; i < N; i++) {
int n = (NX[i] / 400) > 7? others = others + 1 : num[NX[i] / 400] = 1;
}
out1 = num.Sum() + others > 8 ? 8 : num.Sum() + others;
Console.WriteLine(out1);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main() {
var N = int.Parse(Console.ReadLine());
var NX = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
int out1, out2;
int i;
int[] num = new int[8];
int others = 0;
for (i = 0; i < N; i++) {
int n = (NX[i] / 400) > 7? others = others + 1 : num[NX[i] / 400] = 1;
}
out1 = num.Sum();
if (out1 == 0)
out1 = 1;
out2 = num.Sum() + others;
Console.WriteLine(out1 + " " + out2);
}
}
|
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 0, 21], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 11, 12, 41, 15, 16, 31, 16, 17, 72], ["-", 0, 11, 12, 41, 15, 16, 31, 16, 12, 22], ["-", 0, 1, 0, 11, 12, 41, 15, 16, 17, 47], ["-", 0, 1, 0, 11, 12, 41, 15, 16, 12, 203], ["-", 8, 196, 0, 1, 0, 11, 12, 41, 0, 101], ["-", 8, 196, 0, 1, 0, 11, 12, 41, 64, 203], ["-", 8, 196, 0, 1, 0, 11, 12, 41, 0, 102], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 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], ["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 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], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22]]
| 8
| 179
| 30
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp2 {
class Program {
static void Main(string[] args) {
/*
レート 1-399:灰色
レート 400-799:茶色
レート 800-1199:緑色
レート 1200-1599:水色
レート 1600-1999:青色
レート 2000-2399:黄色
レート 2400-2799:橙色
レート 2800-3199:赤色
*/
bool[] color = new bool[8];
for (int i = 0; i < 8; i++)
color[i] = false;
int N = int.Parse(Console.ReadLine());
int data;
int cnt = 0;
var temp = Console.ReadLine().Split(' ');
for (int i = 0; i < N; i++) {
data = int.Parse(temp[i]);
if (data < 400)
color[0] = true;
else if (data < 800)
color[1] = true;
else if (data < 1200)
color[2] = true;
else if (data < 1600)
color[3] = true;
else if (data < 2000)
color[4] = true;
else if (data < 2400)
color[5] = true;
else if (data < 2800)
color[6] = true;
else if (data < 3200)
color[7] = true;
else
cnt++;
}
var app = 0;
for (int i = 0; i < 8; i++) {
if (color[i]) {
app++;
}
}
var min = app;
var max = app;
max += cnt;
max = (max > 8) ? 8 : max;
min = (min >= 0) ? 1 : min;
Console.WriteLine(min + " " + max);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp2 {
class Program {
static void Main(string[] args) {
/*
レート 1-399:灰色
レート 400-799:茶色
レート 800-1199:緑色
レート 1200-1599:水色
レート 1600-1999:青色
レート 2000-2399:黄色
レート 2400-2799:橙色
レート 2800-3199:赤色
*/
bool[] color = new bool[8];
for (int i = 0; i < 8; i++)
color[i] = false;
int N = int.Parse(Console.ReadLine());
int data;
int cnt = 0;
var temp = Console.ReadLine().Split(' ');
for (int i = 0; i < N; i++) {
data = int.Parse(temp[i]);
if (data < 400)
color[0] = true;
else if (data < 800)
color[1] = true;
else if (data < 1200)
color[2] = true;
else if (data < 1600)
color[3] = true;
else if (data < 2000)
color[4] = true;
else if (data < 2400)
color[5] = true;
else if (data < 2800)
color[6] = true;
else if (data < 3200)
color[7] = true;
else
cnt++;
}
var app = 0;
for (int i = 0; i < 8; i++) {
if (color[i]) {
app++;
}
}
var min = app;
var max = app;
max += cnt;
min = (min <= 0) ? 1 : min;
Console.WriteLine(min + " " + max);
}
}
}
|
[["-", 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, 41, 15, 23, 0, 24], ["-", 0, 11, 12, 41, 15, 23, 0, 16, 31, 22], ["-", 0, 11, 12, 41, 15, 23, 0, 16, 17, 47], ["-", 0, 11, 12, 41, 15, 23, 0, 16, 12, 203], ["-", 0, 1, 0, 11, 12, 41, 15, 23, 0, 25], ["-", 8, 196, 0, 1, 0, 11, 12, 41, 0, 101], ["-", 8, 196, 0, 1, 0, 11, 12, 41, 64, 203], ["-", 8, 196, 0, 1, 0, 11, 12, 41, 0, 102], ["-", 8, 196, 0, 1, 0, 11, 12, 41, 75, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["-", 0, 11, 12, 41, 15, 23, 0, 16, 17, 20], ["+", 0, 11, 12, 41, 15, 23, 0, 16, 17, 19]]
| 8
| 344
| 14
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProCon {
class Program {
static void Main(string[] args) {
Console.ReadLine();
string[] input = Console.ReadLine().Split(' ');
int min = 0;
int max = 0;
bool[] flags = new bool[8];
for (int i = 0; i < 8; ++i) {
flags[i] = false;
}
for (int i = 0; i < input.Length; ++i) {
int t = int.Parse(input[i]);
if (t < 3200) {
if (!flags[t / 400]) {
flags[t / 400] = true;
min += 1;
max += 1;
}
} else {
max++;
}
}
Console.WriteLine(min + " " + max);
}
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProCon {
class Program {
static void Main(string[] args) {
Console.ReadLine();
string[] input = Console.ReadLine().Split(' ');
int min = 0;
int max = 0;
bool[] flags = new bool[8];
for (int i = 0; i < 8; ++i) {
flags[i] = false;
}
for (int i = 0; i < input.Length; ++i) {
int t = int.Parse(input[i]);
if (t < 3200) {
if (!flags[t / 400]) {
flags[t / 400] = true;
min += 1;
max += 1;
}
} else {
max++;
}
}
if (min == 0) {
min = 1;
}
Console.WriteLine(min + " " + max);
}
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 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
| 206
| 12
|
using System;
using System.Linq;
class Program {
public static void Main(string[] args) {
int N = int.Parse(System.Console.ReadLine());
var parms = System.Console.ReadLine().Split();
int[] nColor = new int[9];
for (int i = 0; i < N; i++) {
int rate = int.Parse(parms[i]);
if (rate <= 3199) {
nColor[(int)(rate / 400)] = 1;
} else {
nColor[8]++;
}
}
int max = nColor.Sum();
int min = max - nColor[8];
System.Console.WriteLine("{0} {1}", min, max);
}
}
|
using System;
using System.Linq;
class Program {
public static void Main(string[] args) {
int N = int.Parse(System.Console.ReadLine());
var parms = System.Console.ReadLine().Split();
int[] nColor = new int[9];
for (int i = 0; i < N; i++) {
int rate = int.Parse(parms[i]);
if (rate <= 3199) {
nColor[(int)(rate / 400)] = 1;
} else {
nColor[8]++;
}
}
int max = nColor.Sum();
int min = max - nColor[8];
min = min == 0 ? 1 : min;
System.Console.WriteLine("{0} {1}", min, max);
}
}
|
[["+", 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, 41, 15, 16, 31, 22], ["+", 0, 1, 0, 11, 12, 41, 15, 16, 17, 60], ["+", 0, 1, 0, 11, 12, 41, 15, 16, 12, 203], ["+", 8, 196, 0, 1, 0, 11, 12, 41, 0, 101], ["+", 8, 196, 0, 1, 0, 11, 12, 41, 64, 203], ["+", 8, 196, 0, 1, 0, 11, 12, 41, 0, 102], ["+", 8, 196, 0, 1, 0, 11, 12, 41, 75, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 160
| 10
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
namespace AtCoder.ABC064 {
class ColorfulLeaderBoard {
public static void Main() {
var n = int.Parse(ReadLine().Trim());
var a = ReadLine().Trim().Split(' ').Select(_ => int.Parse(_) / 400);
var constColor = a.Where(_ => _ < 8).Distinct().ToArray().Length;
var variableColor = a.Where(_ => _ >= 8).ToArray().Length;
var min = constColor;
var max =
(constColor + variableColor > 8) ? 8 : (constColor + variableColor);
WriteLine(min.ToString() + ' ' + max.ToString());
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
namespace AtCoder.ABC064 {
class ColorfulLeaderBoard {
public static void Main() {
var n = int.Parse(ReadLine().Trim());
var a = ReadLine().Trim().Split(' ').Select(_ => int.Parse(_) / 400);
var constColor = a.Where(_ => _ < 8).Distinct().ToArray().Length;
var variableColor = a.Where(_ => _ >= 8).ToArray().Length;
var min = constColor == 0 ? 1 : constColor;
var max = constColor + variableColor;
WriteLine(min.ToString() + ' ' + max.ToString());
}
}
}
|
[["+", 0, 200, 0, 212, 0, 41, 15, 16, 17, 60], ["+", 0, 200, 0, 212, 0, 41, 15, 16, 12, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 41, 0, 101], ["+", 0, 198, 0, 200, 0, 212, 0, 41, 64, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 41, 0, 102], ["+", 0, 198, 0, 200, 0, 212, 0, 41, 75, 22], ["-", 0, 200, 0, 212, 0, 41, 15, 23, 0, 24], ["-", 0, 41, 15, 23, 0, 16, 31, 16, 31, 22], ["-", 0, 41, 15, 23, 0, 16, 31, 16, 17, 72], ["-", 0, 41, 15, 23, 0, 16, 31, 16, 12, 22], ["-", 0, 212, 0, 41, 15, 23, 0, 16, 17, 47], ["-", 0, 212, 0, 41, 15, 23, 0, 16, 12, 203], ["-", 0, 200, 0, 212, 0, 41, 15, 23, 0, 25], ["-", 0, 198, 0, 200, 0, 212, 0, 41, 0, 101], ["-", 0, 198, 0, 200, 0, 212, 0, 41, 64, 203], ["-", 0, 198, 0, 200, 0, 212, 0, 41, 0, 102], ["-", 0, 200, 0, 212, 0, 41, 75, 23, 0, 24], ["-", 0, 200, 0, 212, 0, 41, 75, 23, 0, 25]]
| 8
| 186
| 18
|
using System;
using System.Linq;
namespace abc064_c {
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
bool[] a = new bool[8];
int secret = 0;
for (int i = 0; i < n; i++) {
if (x[i] < 3200)
a[x[i] / 400] = true;
else
secret++;
}
int ret = 0;
for (int i = 0; i < 8; i++) {
if (a[i])
ret++;
}
Console.WriteLine(ret + " " + (ret + secret));
}
}
}
|
using System;
using System.Linq;
namespace abc064_c {
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
bool[] a = new bool[8];
int secret = 0;
for (int i = 0; i < n; i++) {
if (x[i] < 3200)
a[x[i] / 400] = true;
else
secret++;
}
int ret = 0;
for (int i = 0; i < 8; i++) {
if (a[i])
ret++;
}
Console.WriteLine(Math.Max(1, ret) + " " + (ret + secret));
}
}
}
|
[["+", 0, 16, 31, 16, 31, 213, 63, 214, 205, 22], ["+", 0, 16, 31, 16, 31, 213, 63, 214, 0, 131], ["+", 0, 16, 31, 16, 31, 213, 63, 214, 141, 22], ["+", 0, 16, 31, 16, 31, 213, 3, 4, 0, 24], ["+", 31, 16, 31, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 16, 31, 16, 31, 213, 3, 4, 0, 21], ["+", 0, 16, 31, 16, 31, 213, 3, 4, 0, 25]]
| 8
| 172
| 7
|
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
class Program {
static void Main() {
const int NumberOfColors = 8;
int n = int.Parse(Console.ReadLine());
int[] a =
Console.ReadLine().Split(' ').Select(elem => int.Parse(elem)).ToArray();
bool existGrey = false, existBrown = false, existGreen = false,
existLightBlue = false, existBlue = false, existYellow = false,
existOrange = false, existRed = false;
int NumberOfFreeColorPerson = 0;
int cnt = 0;
for (int i = 0; i < n; i++) {
if (a[i] <= 399) {
if (!existGrey) {
existGrey = true;
cnt++;
Console.Error.WriteLine("grey");
}
} else if (a[i] <= 799) {
if (!existBrown) {
existBrown = true;
cnt++;
Console.Error.WriteLine("brown");
}
} else if (a[i] <= 1199) {
if (!existGreen) {
existGreen = true;
cnt++;
Console.Error.WriteLine("green");
}
} else if (a[i] <= 1599) {
if (!existLightBlue) {
existLightBlue = true;
cnt++;
Console.Error.WriteLine("lblue");
}
} else if (a[i] <= 1999) {
if (!existBlue) {
existBlue = true;
cnt++;
Console.Error.WriteLine("blue");
}
} else if (a[i] <= 2399) {
if (!existYellow) {
existYellow = true;
cnt++;
Console.Error.WriteLine("yellow");
}
} else if (a[i] <= 2799) {
if (!existOrange) {
existOrange = true;
cnt++;
Console.Error.WriteLine("orange");
}
} else if (a[i] <= 3199) {
if (!existRed) {
existRed = true;
cnt++;
Console.Error.WriteLine("red");
}
} else
NumberOfFreeColorPerson++;
}
int min = Math.Max(cnt, 1);
int max = min;
if (NumberOfFreeColorPerson != 0) {
max = Math.Min(NumberOfColors, NumberOfFreeColorPerson + cnt);
}
Console.WriteLine("{0} {1}", min, max);
}
}
|
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
class Program {
static void Main() {
const int NumberOfColors = 8;
int n = int.Parse(Console.ReadLine());
int[] a =
Console.ReadLine().Split(' ').Select(elem => int.Parse(elem)).ToArray();
bool existGrey = false, existBrown = false, existGreen = false,
existLightBlue = false, existBlue = false, existYellow = false,
existOrange = false, existRed = false;
int NumberOfFreeColorPerson = 0;
int cnt = 0;
for (int i = 0; i < n; i++) {
if (a[i] <= 399) {
if (!existGrey) {
existGrey = true;
cnt++;
Console.Error.WriteLine("grey");
}
} else if (a[i] <= 799) {
if (!existBrown) {
existBrown = true;
cnt++;
Console.Error.WriteLine("brown");
}
} else if (a[i] <= 1199) {
if (!existGreen) {
existGreen = true;
cnt++;
Console.Error.WriteLine("green");
}
} else if (a[i] <= 1599) {
if (!existLightBlue) {
existLightBlue = true;
cnt++;
Console.Error.WriteLine("lblue");
}
} else if (a[i] <= 1999) {
if (!existBlue) {
existBlue = true;
cnt++;
Console.Error.WriteLine("blue");
}
} else if (a[i] <= 2399) {
if (!existYellow) {
existYellow = true;
cnt++;
Console.Error.WriteLine("yellow");
}
} else if (a[i] <= 2799) {
if (!existOrange) {
existOrange = true;
cnt++;
Console.Error.WriteLine("orange");
}
} else if (a[i] <= 3199) {
if (!existRed) {
existRed = true;
cnt++;
Console.Error.WriteLine("red");
}
} else
NumberOfFreeColorPerson++;
}
int min = Math.Max(cnt, 1);
int max = min;
if (NumberOfFreeColorPerson != 0) {
max = NumberOfFreeColorPerson + cnt;
}
Console.WriteLine("{0} {1}", min, max);
}
}
|
[["-", 0, 1, 0, 11, 12, 213, 63, 214, 205, 22], ["-", 0, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["-", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["-", 0, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["-", 0, 11, 12, 213, 3, 4, 0, 28, 0, 22], ["-", 0, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["-", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25]]
| 8
| 511
| 7
|
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
public class Program {
public void Proc() {
/*
* レート 1-399:灰色
レート 400-799:茶色
レート 800-1199:緑色
レート 1200-1599:水色
レート 1600-1999:青色
レート 2000-2399:黄色
レート 2400-2799:橙色
レート 2800-3199:赤色
*/
int inputCount = int.Parse(Reader.ReadLine());
int[] scoreList =
Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
int overRed = 0;
Dictionary<string, int> cnt = new Dictionary<string, int>();
scoreList.ToList().ForEach(a => {
if (a >= 3200) {
overRed++;
} else if (a >= 2800) {
cnt["red"] = 1;
} else if (a >= 2400) {
cnt["orange"] = 1;
} else if (a >= 2000) {
cnt["yellow"] = 1;
} else if (a >= 1600) {
cnt["blue"] = 1;
} else if (a >= 1200) {
cnt["aqua"] = 1;
} else if (a >= 800) {
cnt["green"] = 1;
} else if (a >= 400) {
cnt["brown"] = 1;
} else {
cnt["gray"] = 1;
}
});
int maxColorCount = 8;
int min = Math.Max(cnt.Count(), 1);
int max = Math.Min(cnt.Count() + overRed, maxColorCount);
Console.WriteLine(min + " " + max);
}
public class Reader {
private static StringReader sr;
public static bool IsDebug = false;
public static string ReadLine() {
if (IsDebug) {
if (sr == null) {
sr = new StringReader(InputText.Trim());
}
return sr.ReadLine();
} else {
return Console.ReadLine();
}
}
private static string InputText = @"
5
1100 1900 2800 3200 3200
";
}
public static void Main(string[] args) {
#if DEBUG
Reader.IsDebug = true;
#endif
Program prg = new Program();
prg.Proc();
}
}
|
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
public class Program {
public void Proc() {
/*
* レート 1-399:灰色
レート 400-799:茶色
レート 800-1199:緑色
レート 1200-1599:水色
レート 1600-1999:青色
レート 2000-2399:黄色
レート 2400-2799:橙色
レート 2800-3199:赤色
*/
int inputCount = int.Parse(Reader.ReadLine());
int[] scoreList =
Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
int overRed = 0;
Dictionary<string, int> cnt = new Dictionary<string, int>();
scoreList.ToList().ForEach(a => {
if (a >= 3200) {
overRed++;
} else if (a >= 2800) {
cnt["red"] = 1;
} else if (a >= 2400) {
cnt["orange"] = 1;
} else if (a >= 2000) {
cnt["yellow"] = 1;
} else if (a >= 1600) {
cnt["blue"] = 1;
} else if (a >= 1200) {
cnt["aqua"] = 1;
} else if (a >= 800) {
cnt["green"] = 1;
} else if (a >= 400) {
cnt["brown"] = 1;
} else {
cnt["gray"] = 1;
}
});
int maxColorCount = 8;
int min = Math.Max(cnt.Count(), 1);
int max = cnt.Count() + overRed;
Console.WriteLine(min + " " + max);
}
public class Reader {
private static StringReader sr;
public static bool IsDebug = false;
public static string ReadLine() {
if (IsDebug) {
if (sr == null) {
sr = new StringReader(InputText.Trim());
}
return sr.ReadLine();
} else {
return Console.ReadLine();
}
}
private static string InputText = @"
5
1100 1900 2800 3200 3200
";
}
public static void Main(string[] args) {
#if DEBUG
Reader.IsDebug = true;
#endif
Program prg = new Program();
prg.Proc();
}
}
|
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 21], ["-", 0, 212, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25]]
| 8
| 431
| 7
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program {
static void Main(string[] args) {
string str = Console.ReadLine();
int N = int.Parse(str);
int[] a = new int[N];
string[] stra = Console.ReadLine().Split(' ');
bool[] flag = new bool[8];
int min, max, count;
count = min = max = 0;
for (int i = 0; i < N; i++) {
a[i] = int.Parse(stra[i]);
}
for (int i = 0; i < N; i++) {
if (a[i] <= 399) {
if (flag[0] == false) {
flag[0] = true;
count++;
}
} else if (a[i] <= 799) {
if (flag[1] == false) {
flag[1] = true;
count++;
}
} else if (a[i] <= 1199) {
if (flag[2] == false) {
flag[2] = true;
count++;
}
} else if (a[i] <= 1599) {
if (flag[3] == false) {
flag[3] = true;
count++;
}
} else if (a[i] <= 1999) {
if (flag[4] == false) {
flag[4] = true;
count++;
}
} else if (a[i] <= 2399) {
if (flag[5] == false) {
flag[5] = true;
count++;
}
} else if (a[i] <= 2799) {
if (flag[6] == false) {
flag[6] = true;
count++;
}
} else if (a[i] <= 3199) {
if (flag[7] == false) {
flag[7] = true;
count++;
}
} else {
for (int j = 0; j < 8; j++) {
if (flag[j] == false) {
flag[j] = true;
max++;
break;
}
}
}
}
min = count;
if (min == 0) {
min++;
} else {
max = count + max;
}
Console.WriteLine(min + " " + (max));
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program {
static void Main(string[] args) {
string str = Console.ReadLine();
int N = int.Parse(str);
int[] a = new int[N];
string[] stra = Console.ReadLine().Split(' ');
bool[] flag = new bool[8];
int min, max, count;
count = min = max = 0;
for (int i = 0; i < N; i++) {
a[i] = int.Parse(stra[i]);
}
for (int i = 0; i < N; i++) {
if (a[i] <= 399) {
if (flag[0] == false) {
flag[0] = true;
count++;
}
} else if (a[i] <= 799) {
if (flag[1] == false) {
flag[1] = true;
count++;
}
} else if (a[i] <= 1199) {
if (flag[2] == false) {
flag[2] = true;
count++;
}
} else if (a[i] <= 1599) {
if (flag[3] == false) {
flag[3] = true;
count++;
}
} else if (a[i] <= 1999) {
if (flag[4] == false) {
flag[4] = true;
count++;
}
} else if (a[i] <= 2399) {
if (flag[5] == false) {
flag[5] = true;
count++;
}
} else if (a[i] <= 2799) {
if (flag[6] == false) {
flag[6] = true;
count++;
}
} else if (a[i] <= 3199) {
if (flag[7] == false) {
flag[7] = true;
count++;
}
} else {
max++;
}
}
min = count;
if (min == 0) {
min++;
} else {
max = count + max;
}
Console.WriteLine(min + " " + (max));
}
}
|
[["-", 75, 57, 75, 57, 75, 196, 0, 7, 0, 88], ["-", 75, 57, 75, 57, 75, 196, 0, 7, 0, 24], ["-", 75, 57, 75, 196, 0, 7, 10, 198, 39, 199], ["-", 75, 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], ["-", 75, 57, 75, 57, 75, 196, 0, 7, 0, 35], ["-", 75, 57, 75, 196, 0, 7, 15, 16, 31, 22], ["-", 75, 57, 75, 196, 0, 7, 15, 16, 17, 18], ["-", 75, 57, 75, 196, 0, 7, 15, 16, 12, 203], ["-", 75, 57, 75, 196, 0, 7, 26, 223, 0, 22], ["-", 75, 57, 75, 196, 0, 7, 26, 223, 0, 29], ["-", 75, 57, 75, 57, 75, 196, 0, 7, 0, 25], ["-", 75, 57, 75, 196, 0, 7, 8, 196, 0, 45], ["-", 75, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["-", 75, 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], ["-", 8, 196, 0, 57, 15, 16, 12, 211, 0, 147], ["-", 75, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 64, 196, 0, 1, 0, 11, 31, 204, 205, 22], ["-", 0, 1, 0, 11, 31, 204, 206, 207, 0, 70], ["-", 0, 11, 31, 204, 206, 207, 0, 28, 0, 22], ["-", 0, 1, 0, 11, 31, 204, 206, 207, 0, 73], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 64, 196, 0, 1, 0, 11, 12, 211, 0, 146], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 75, 57, 75, 196, 0, 7, 8, 196, 0, 46]]
| 8
| 500
| 36
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication32 {
class Program {
static void Main(string[] args) {
int a = int.Parse(Console.ReadLine());
int[] b = new int[a];
int[] co = new int[9];
int mim = 0;
int max = 0;
b = Console.ReadLine().Split().Select(int.Parse).ToArray();
for (int c = 0; c < a; c++) {
if (b[c] < 400)
co[0]++;
else if (b[c] < 800)
co[1]++;
else if (b[c] < 1200)
co[2]++;
else if (b[c] < 1600)
co[3]++;
else if (b[c] < 2000)
co[4]++;
else if (b[c] < 2400)
co[5]++;
else if (b[c] < 2800)
co[6]++;
else if (b[c] < 3200)
co[7]++;
else if (3199 < b[c])
co[8]++;
}
for (int c = 0; c < 8; c++)
if (co[c] > 0) {
mim += 1;
max += 1;
}
if (mim == 0)
mim += 1;
else
max += co[8];
Console.WriteLine("{0} {1}", mim, max);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication32 {
class Program {
static void Main(string[] args) {
int a = int.Parse(Console.ReadLine());
int[] b = new int[a];
int[] co = new int[9];
int mim = 0;
int max = 0;
b = Console.ReadLine().Split().Select(int.Parse).ToArray();
for (int c = 0; c < a; c++) {
if (b[c] < 400)
co[0]++;
else if (b[c] < 800)
co[1]++;
else if (b[c] < 1200)
co[2]++;
else if (b[c] < 1600)
co[3]++;
else if (b[c] < 2000)
co[4]++;
else if (b[c] < 2400)
co[5]++;
else if (b[c] < 2800)
co[6]++;
else if (b[c] < 3200)
co[7]++;
else if (3199 < b[c])
co[8]++;
}
for (int c = 0; c < 8; c++)
if (co[c] > 0) {
mim += 1;
max += 1;
}
if (mim == 0) {
mim += 1;
max += co[8];
} else
max += co[8];
Console.WriteLine("{0} {1}", mim, max);
}
}
}
|
[["+", 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, 107], ["+", 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, 203], ["+", 0, 1, 0, 11, 12, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 331
| 9
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC064C {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
string[] vals = Console.ReadLine().Split(' ');
int hai = 0;
int cha = 0;
int midori = 0;
int mizu = 0;
int ao = 0;
int ki = 0;
int daidai = 0;
int aka = 0;
int overR = 0;
int a;
for (int i = 0; i < N; i++) {
a = int.Parse(vals[i]);
if (1 <= a && a <= 399) {
hai = 1;
} else if (400 <= a && a <= 799) {
cha = 1;
} else if (800 <= a && a <= 1199) {
midori = 1;
} else if (1200 <= a && a <= 1599) {
mizu = 1;
} else if (1600 <= a && a <= 1999) {
ao = 1;
} else if (2000 <= a && a <= 2399) {
ki = 1;
} else if (2400 <= a && a <= 2799) {
daidai = 1;
} else if (2800 <= a && a <= 3199) {
aka = 1;
} else if (3200 <= a) {
overR++;
}
}
int num = hai + cha + midori + mizu + ao + ki + daidai + aka;
int max = Math.Min(num + overR, 8);
if (num == 0 && overR >= 1) {
num = 1;
}
Console.WriteLine("{0} {1}", num, max);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC064C {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
string[] vals = Console.ReadLine().Split(' ');
int hai = 0;
int cha = 0;
int midori = 0;
int mizu = 0;
int ao = 0;
int ki = 0;
int daidai = 0;
int aka = 0;
int overR = 0;
int a;
for (int i = 0; i < N; i++) {
a = int.Parse(vals[i]);
if (1 <= a && a <= 399) {
hai = 1;
} else if (400 <= a && a <= 799) {
cha = 1;
} else if (800 <= a && a <= 1199) {
midori = 1;
} else if (1200 <= a && a <= 1599) {
mizu = 1;
} else if (1600 <= a && a <= 1999) {
ao = 1;
} else if (2000 <= a && a <= 2399) {
ki = 1;
} else if (2400 <= a && a <= 2799) {
daidai = 1;
} else if (2800 <= a && a <= 3199) {
aka = 1;
} else if (3200 <= a) {
overR++;
}
}
int num = hai + cha + midori + mizu + ao + ki + daidai + aka;
// int max = Math.Min(num + overR, 8);
int max = num + overR;
if (num == 0 && overR >= 1) {
num = 1;
}
Console.WriteLine("{0} {1}", num, max);
}
}
}
|
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 21], ["-", 0, 212, 0, 213, 3, 4, 0, 28, 0, 203], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25]]
| 8
| 363
| 7
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program {
static void Main(string[] args) {
HashSet<string> shurui = new HashSet<string> {};
Console.ReadLine();
long[] a = Read.longs();
long FREEs = 0;
long[] s = new long[a.Length];
for (long i = 0; i < a.Length; i++) {
/* if (a[i] < 400) { s[i] = 1; }
else if (a[i] < 800) { s[i] = 2; }
else if (a[i] < 1200) { s[i] = 3; }
else if (a[i] < 1600) { s[i] = 4; }
else if (a[i] < 2000) { s[i] = 5; }
else if (a[i] < 2400) { s[i] = 6; }
else if (a[i] < 2800) { s[i] = 7; }
else if (a[i] < 3200) { s[i] = 8; }
*/
if (a[i] < 3200) {
s[i] = a[i] / 400 + 1;
shurui.Add(s[i].ToString());
} else {
FREEs++;
}
}
long saisho = shurui.Count();
if (saisho == 0) {
saisho = 1;
}
long saidai = Math.Min((shurui.Count() + FREEs), 8);
Console.WriteLine(saisho + " " + saidai);
Console.ReadLine();
}
public static Boolean uso() { return false; }
public static long gcd(long a, long b) {
while (true) {
if (a == 0) {
return b;
}
if (b == 0) {
return a;
}
if (a > b) {
a -= b;
} else {
b -= a;
}
}
}
public static long lcm(long a, long b) { return a * b / gcd(a, b); }
public static bool IsPrime(long n) {
if (n < 2)
return false;
if (n == 2)
return true;
for (long i = 2; i < n; i++) {
if (n % i == 0)
return false;
}
return true;
}
}
public static class Read {
public static void outl(string n = "") {
Console.WriteLine(n);
return;
}
public static long Long() { return long.Parse(Console.ReadLine()); }
public static long[] longs() {
return Console.ReadLine().Split().Select(long.Parse).ToArray();
}
public static string Str() { return Console.ReadLine(); }
public static string[] Strs() { return Console.ReadLine().Split(); }
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program {
static void Main(string[] args) {
HashSet<string> shurui = new HashSet<string> {};
Console.ReadLine();
long[] a = Read.longs();
long FREEs = 0;
long[] s = new long[a.Length];
for (long i = 0; i < a.Length; i++) {
/* if (a[i] < 400) { s[i] = 1; }
else if (a[i] < 800) { s[i] = 2; }
else if (a[i] < 1200) { s[i] = 3; }
else if (a[i] < 1600) { s[i] = 4; }
else if (a[i] < 2000) { s[i] = 5; }
else if (a[i] < 2400) { s[i] = 6; }
else if (a[i] < 2800) { s[i] = 7; }
else if (a[i] < 3200) { s[i] = 8; }
*/
if (a[i] < 3200) {
s[i] = a[i] / 400 + 1;
shurui.Add(s[i].ToString());
} else {
FREEs++;
}
}
long saisho = shurui.Count();
if (saisho == 0) {
saisho = 1;
}
long saidai = (shurui.Count() + FREEs);
Console.WriteLine(saisho + " " + saidai);
Console.ReadLine();
}
public static Boolean uso() { return false; }
public static long gcd(long a, long b) {
while (true) {
if (a == 0) {
return b;
}
if (b == 0) {
return a;
}
if (a > b) {
a -= b;
} else {
b -= a;
}
}
}
public static long lcm(long a, long b) { return a * b / gcd(a, b); }
public static bool IsPrime(long n) {
if (n < 2)
return false;
if (n == 2)
return true;
for (long i = 2; i < n; i++) {
if (n % i == 0)
return false;
}
return true;
}
}
public static class Read {
public static void outl(string n = "") {
Console.WriteLine(n);
return;
}
public static long Long() { return long.Parse(Console.ReadLine()); }
public static long[] longs() {
return Console.ReadLine().Split().Select(long.Parse).ToArray();
}
public static string Str() { return Console.ReadLine(); }
public static string[] Strs() { return Console.ReadLine().Split(); }
}
|
[["-", 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, 213, 3, 4, 0, 28, 0, 23, 0, 24], ["-", 0, 213, 3, 4, 0, 28, 0, 23, 0, 25], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 21], ["-", 0, 212, 0, 213, 3, 4, 0, 28, 0, 203]]
| 8
| 478
| 7
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contest {
class Program {
static void Main() {
int N = int.Parse(Console.ReadLine());
var a = Console.ReadLine().Split().Select(int.Parse);
int[] rating = { 3200, 2800, 2400, 2000, 1600, 1200, 800, 400, 1 };
int[] contestants = new int[rating.Length];
foreach (var item in a) {
for (int i = 0; i < rating.Length; i++) {
if (item >= rating[i]) {
contestants[i]++;
break;
}
}
}
int count = contestants.Count(item => item > 0);
if (count == 1) {
Console.WriteLine("1 1");
} else if (contestants[0] > 0) {
Console.WriteLine($"{count - 1} {count + contestants[0] - 1}");
} else {
Console.WriteLine($"{count} {count}");
}
#if DEBUG
Console.ReadKey();
#endif
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contest {
class Program {
static void Main() {
int N = int.Parse(Console.ReadLine());
var a = Console.ReadLine().Split().Select(int.Parse);
int[] rating = { 3200, 2800, 2400, 2000, 1600, 1200, 800, 400, 1 };
int[] contestants = new int[rating.Length];
foreach (var item in a) {
for (int i = 0; i < rating.Length; i++) {
if (item >= rating[i]) {
contestants[i]++;
break;
}
}
}
int count = contestants.Count(item => item > 0);
if (contestants[0] > 0) {
if (count == 1) {
Console.WriteLine($"1 {contestants[0]}");
} else {
Console.WriteLine($"{count - 1} {count + contestants[0] - 1}");
}
} else {
Console.WriteLine($"{count} {count}");
}
#if DEBUG
Console.ReadKey();
#endif
}
}
}
|
[["+", 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, 203], ["+", 0, 57, 15, 16, 31, 204, 206, 207, 0, 73], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["-", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["-", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 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, 57, 0, 121], ["+", 0, 213, 3, 4, 0, 28, 0, 283, 0, 295], ["+", 0, 213, 3, 4, 0, 28, 0, 283, 0, 296], ["+", 3, 4, 0, 28, 0, 283, 0, 284, 0, 45], ["-", 8, 196, 0, 57, 75, 57, 15, 16, 17, 47], ["-", 8, 196, 0, 57, 75, 57, 15, 16, 12, 203], ["+", 3, 4, 0, 28, 0, 283, 0, 284, 0, 46], ["+", 0, 213, 3, 4, 0, 28, 0, 283, 0, 62], ["+", 64, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 95], ["+", 0, 57, 64, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 256
| 30
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contests {
class Program {
static void Main(string[] args) {
var n = int.Parse(Console.ReadLine());
var inputs = Console.ReadLine().Split(' ').Select((x) => int.Parse(x));
var colors = new int[8];
int over = 0;
int variant = 0;
foreach (var x in inputs) {
var ix = x / 400;
if (ix > 7)
over++;
else {
if (colors[ix] == 0)
variant++;
colors[ix]++;
}
}
Console.WriteLine("{0} {1}", Math.Max(over > 0 ? 1 : 0, variant),
Math.Min(8, variant + over));
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contests {
class Program {
static void Main(string[] args) {
var n = int.Parse(Console.ReadLine());
var inputs = Console.ReadLine().Split(' ').Select((x) => int.Parse(x));
var colors = new int[8];
int over = 0;
int variant = 0;
foreach (var x in inputs) {
var ix = x / 400;
if (ix > 7)
over++;
else {
if (colors[ix] == 0)
variant++;
colors[ix]++;
}
}
Console.WriteLine("{0} {1}", Math.Max(1, variant), variant + over);
}
}
}
|
[["-", 3, 4, 0, 28, 0, 41, 15, 16, 31, 22], ["-", 3, 4, 0, 28, 0, 41, 15, 16, 17, 47], ["-", 3, 4, 0, 28, 0, 41, 15, 16, 12, 203], ["-", 0, 213, 3, 4, 0, 28, 0, 41, 0, 101], ["-", 0, 213, 3, 4, 0, 28, 0, 41, 0, 102], ["-", 0, 213, 3, 4, 0, 28, 0, 41, 75, 203], ["-", 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], ["-", 0, 28, 0, 213, 3, 4, 0, 28, 0, 203], ["-", 3, 4, 0, 28, 0, 213, 3, 4, 0, 21], ["-", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25]]
| 8
| 190
| 13
|
using System;
using System.Collections.Generic;
using System.Linq;
class Solution {
static void Main() {
var n = int.Parse(Console.ReadLine());
var array = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var colors = new int[9];
foreach (var a in array) {
var c = Math.Min(a / 400, 8);
colors[c]++;
}
var min = colors.Take(8).Count(c => c != 0);
var max = min + colors.Last();
Console.WriteLine($"{min} {max}");
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Solution {
static void Main() {
var n = int.Parse(Console.ReadLine());
var array = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var colors = new int[9];
foreach (var a in array) {
var c = Math.Min(a / 400, 8);
colors[c]++;
}
var min = colors.Take(8).Count(c => c != 0);
var max = min + colors.Last();
min = Math.Max(1, min);
Console.WriteLine($"{min} {max}");
}
}
|
[["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 205, 22], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["+", 0, 11, 12, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["+", 0, 11, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 150
| 11
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve {
public Solve() {}
StringBuilder sb;
public static int Main() {
new Solve().Run();
return 0;
}
void Run() {
sb = new StringBuilder();
Calc();
Console.Write(sb.ToString());
}
void Calc() {
int N = int.Parse(Console.ReadLine());
string[] str = Console.ReadLine().Split(' ');
int[] a = new int[N];
for (int i = 0; i < N; i++) {
a[i] = int.Parse(str[i]);
}
int count = 0;
int c = 0;
bool[] b = new bool[8];
for (int i = 0; i < N; i++) {
int x = a[i] / 400;
if (x >= 8) {
c++;
} else if (!b[x]) {
b[x] = true;
count++;
}
}
int max = Math.Min(8, c + count);
int min = Math.Max(1, count);
sb.Append(min + " " + max + "\n");
}
}
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve {
public Solve() {}
StringBuilder sb;
public static int Main() {
new Solve().Run();
return 0;
}
void Run() {
sb = new StringBuilder();
Calc();
Console.Write(sb.ToString());
}
void Calc() {
int N = int.Parse(Console.ReadLine());
string[] str = Console.ReadLine().Split(' ');
int[] a = new int[N];
for (int i = 0; i < N; i++) {
a[i] = int.Parse(str[i]);
}
int count = 0;
int c = 0;
bool[] b = new bool[8];
for (int i = 0; i < N; i++) {
int x = a[i] / 400;
if (x >= 8) {
c++;
} else if (!b[x]) {
b[x] = true;
count++;
}
}
int max = c + count;
int min = Math.Max(1, count);
sb.Append(min + " " + max + "\n");
}
}
|
[["-", 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, 203], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 21], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25]]
| 8
| 283
| 7
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace abc64 {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
string[] str = Console.ReadLine().Split(' ');
int[] rate = { 0, 0, 0, 0, 0, 0, 0, 0 };
int pro = 0;
for (int i = 0; i < N; i++) {
int temp = int.Parse(str[i]);
if (temp >= 3200) {
pro++;
} else {
rate[temp / 400] = 1;
}
}
int ans = 0;
for (int i = 0; i < 8; i++) {
ans += rate[i];
}
Console.WriteLine("{0} {1}", ans, ans + pro);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace abc64 {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
string[] str = Console.ReadLine().Split(' ');
int[] rate = { 0, 0, 0, 0, 0, 0, 0, 0 };
int pro = 0;
for (int i = 0; i < N; i++) {
int temp = int.Parse(str[i]);
if (temp >= 3200) {
pro++;
} else {
rate[temp / 400] = 1;
}
}
int ans = 0;
for (int i = 0; i < 8; i++) {
ans += rate[i];
}
if (ans == 0) {
ans++;
pro--;
}
Console.WriteLine("{0} {1}", ans, ans + pro);
}
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 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, 68], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 201
| 14
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
// using System.Numerics; //comment out if AOJ
using System.Text;
using Problem = Tmp.Problem;
using MyIO;
#pragma warning disable // for AOJ
namespace Tmp {
class Problem : IDisposable {
bool IsGCJ;
int Repeat;
Scanner sc;
Printer pr;
public Problem(bool isGCJ, Scanner scanner, Printer printer) {
sc = scanner;
pr = printer;
IsGCJ = isGCJ;
if (isGCJ)
Repeat = sc.nextInt();
else
Read();
}
public Problem(bool isGCJ) : this(isGCJ, new Scanner(), new Printer()) {}
public Problem(bool isGCJ, Scanner scanner)
: this(isGCJ, scanner, new Printer()) {}
public Problem(bool isGCJ, Printer printer)
: this(isGCJ, new Scanner(), printer) {}
public void Solve() {
if (IsGCJ)
for (var i = 0; i < Repeat; i++) {
Read();
pr.Write("Case #" + (i + 1) + ": ");
SolveOne();
}
else
SolveOne();
}
public void Dispose() {
sc.Dispose();
pr.Dispose();
}
public int Size {
get { return 1; }
}
public const long Mod = 1000000007;
// 使用する変数をここに書く
// string S;
// int a;
/// <summary>
/// 読み込み処理をここに書く
/// </summary>
void Read() {}
/// <summary>
/// メイン処理をここに書く
/// </summary>
void SolveOne() {
int n = sc.nextInt();
int[] a = sc.nextInt(n);
int[] c = new int[9];
for (int i = 0; i < n; i++) {
int r = Math.Min(a[i] / 400, 8);
c[r]++;
}
int ans = 0;
;
for (int i = 0; i < 8; i++) {
if (c[i] > 0)
ans++;
}
Console.WriteLine("{0} {1}", ans, ans + c[8]);
}
}
}
class Program {
// public static RandomSFMT rand = new RandomSFMT();
public static bool IsJudgeMode = true;
public static bool IsGCJMode = false;
public static bool IsSolveCreated = true;
static void Main() {
if (IsJudgeMode)
if (IsGCJMode)
using (var problem =
new Problem(true, new Scanner("C-large-practice.in.txt"),
new Printer("output.txt"))) problem.Solve();
else
using (var problem = new Problem(false, new Printer())) problem.Solve();
else {
var num = 1;
int size = 0;
decimal time = 0;
for (var tmp = 0; tmp < num; tmp++) {
using (var P = IsSolveCreated
? new Problem(false, new Scanner("input.txt"),
new Printer())
: new Problem(false)) {
size = P.Size;
// time += Func.MeasureTime(() => P.Solve());
}
}
Console.WriteLine("{0}, {1}ms", size, time / num);
}
}
}
/// <summary>
/// カスタマイズしたIO
/// </summary>
namespace MyIO {
class Printer : IDisposable {
bool isConsole;
TextWriter file;
public Printer() {
file = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
isConsole = true;
}
public Printer(string path) {
file = new StreamWriter(path, false) { AutoFlush = false };
isConsole = false;
}
public void Write<T>(T value) { file.Write(value); }
public void Write(bool b) { file.Write(b ? "YES" : "NO"); }
public void Write(string str, params object[] args) { file.Write(str, args); }
public void WriteLine() { file.WriteLine(); }
public void WriteLine<T>(T value) { file.WriteLine(value); }
public void WriteLine(bool b) { file.WriteLine(b ? "YES" : "NO"); }
public void WriteLine<T>(IEnumerable<T> list) {
foreach (var x in list)
file.WriteLine(x);
}
public void WriteLine<T>(List<T> list) {
foreach (var x in list)
file.WriteLine(x);
}
public void WriteLine<T>(T[] list) {
foreach (var x in list)
file.WriteLine(x);
}
public void WriteLine(string str, params object[] args) {
file.WriteLine(str, args);
}
public void Dispose() {
file.Flush();
if (!isConsole)
file.Dispose();
}
}
class Scanner : IDisposable {
bool isConsole;
TextReader file;
public Scanner() { file = Console.In; }
public Scanner(string path) {
file = new StreamReader(path);
isConsole = false;
}
public void Dispose() {
if (!isConsole)
file.Dispose();
}
#region next読み込み
string[] nextBuffer = new string[0];
int BufferCnt = 0;
char[] cs = new char[] { ' ' };
public string next() {
while (BufferCnt >= nextBuffer.Length) {
string st = file.ReadLine();
while (st == "")
st = file.ReadLine();
nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
BufferCnt = 0;
}
return nextBuffer[BufferCnt++];
}
public int nextInt() { return int.Parse(next()); }
public long nextLong() { return long.Parse(next()); }
public double nextDouble() { return double.Parse(next()); }
private T[] enumerate<T>(int n, Func<T> f) {
var a = new T[n];
for (int i = 0; i < n; ++i)
a[i] = f();
return a;
}
public string[] next(int n) { return enumerate(n, next); }
public double[] nextDouble(int n) { return enumerate(n, nextDouble); }
public int[] nextInt(int n) { return enumerate(n, nextInt); }
public long[] nextLong(int n) { return enumerate(n, nextLong); }
#endregion
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
// using System.Numerics; //comment out if AOJ
using System.Text;
using Problem = Tmp.Problem;
using MyIO;
#pragma warning disable // for AOJ
namespace Tmp {
class Problem : IDisposable {
bool IsGCJ;
int Repeat;
Scanner sc;
Printer pr;
public Problem(bool isGCJ, Scanner scanner, Printer printer) {
sc = scanner;
pr = printer;
IsGCJ = isGCJ;
if (isGCJ)
Repeat = sc.nextInt();
else
Read();
}
public Problem(bool isGCJ) : this(isGCJ, new Scanner(), new Printer()) {}
public Problem(bool isGCJ, Scanner scanner)
: this(isGCJ, scanner, new Printer()) {}
public Problem(bool isGCJ, Printer printer)
: this(isGCJ, new Scanner(), printer) {}
public void Solve() {
if (IsGCJ)
for (var i = 0; i < Repeat; i++) {
Read();
pr.Write("Case #" + (i + 1) + ": ");
SolveOne();
}
else
SolveOne();
}
public void Dispose() {
sc.Dispose();
pr.Dispose();
}
public int Size {
get { return 1; }
}
public const long Mod = 1000000007;
// 使用する変数をここに書く
// string S;
// int a;
/// <summary>
/// 読み込み処理をここに書く
/// </summary>
void Read() {}
/// <summary>
/// メイン処理をここに書く
/// </summary>
void SolveOne() {
int n = sc.nextInt();
int[] a = sc.nextInt(n);
int[] c = new int[9];
for (int i = 0; i < n; i++) {
int r = Math.Min(a[i] / 400, 8);
c[r]++;
}
int ans = 0;
for (int i = 0; i < 8; i++) {
if (c[i] > 0)
ans++;
}
Console.WriteLine("{0} {1}", Math.Max(ans, 1), ans + c[8]);
}
}
}
class Program {
// public static RandomSFMT rand = new RandomSFMT();
public static bool IsJudgeMode = true;
public static bool IsGCJMode = false;
public static bool IsSolveCreated = true;
static void Main() {
if (IsJudgeMode)
if (IsGCJMode)
using (var problem =
new Problem(true, new Scanner("C-large-practice.in.txt"),
new Printer("output.txt"))) problem.Solve();
else
using (var problem = new Problem(false, new Printer())) problem.Solve();
else {
var num = 1;
int size = 0;
decimal time = 0;
for (var tmp = 0; tmp < num; tmp++) {
using (var P = IsSolveCreated
? new Problem(false, new Scanner("input.txt"),
new Printer())
: new Problem(false)) {
size = P.Size;
// time += Func.MeasureTime(() => P.Solve());
}
}
Console.WriteLine("{0}, {1}ms", size, time / num);
}
}
}
/// <summary>
/// カスタマイズしたIO
/// </summary>
namespace MyIO {
class Printer : IDisposable {
bool isConsole;
TextWriter file;
public Printer() {
file = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
isConsole = true;
}
public Printer(string path) {
file = new StreamWriter(path, false) { AutoFlush = false };
isConsole = false;
}
public void Write<T>(T value) { file.Write(value); }
public void Write(bool b) { file.Write(b ? "YES" : "NO"); }
public void Write(string str, params object[] args) { file.Write(str, args); }
public void WriteLine() { file.WriteLine(); }
public void WriteLine<T>(T value) { file.WriteLine(value); }
public void WriteLine(bool b) { file.WriteLine(b ? "YES" : "NO"); }
public void WriteLine<T>(IEnumerable<T> list) {
foreach (var x in list)
file.WriteLine(x);
}
public void WriteLine<T>(List<T> list) {
foreach (var x in list)
file.WriteLine(x);
}
public void WriteLine<T>(T[] list) {
foreach (var x in list)
file.WriteLine(x);
}
public void WriteLine(string str, params object[] args) {
file.WriteLine(str, args);
}
public void Dispose() {
file.Flush();
if (!isConsole)
file.Dispose();
}
}
class Scanner : IDisposable {
bool isConsole;
TextReader file;
public Scanner() { file = Console.In; }
public Scanner(string path) {
file = new StreamReader(path);
isConsole = false;
}
public void Dispose() {
if (!isConsole)
file.Dispose();
}
#region next読み込み
string[] nextBuffer = new string[0];
int BufferCnt = 0;
char[] cs = new char[] { ' ' };
public string next() {
while (BufferCnt >= nextBuffer.Length) {
string st = file.ReadLine();
while (st == "")
st = file.ReadLine();
nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
BufferCnt = 0;
}
return nextBuffer[BufferCnt++];
}
public int nextInt() { return int.Parse(next()); }
public long nextLong() { return long.Parse(next()); }
public double nextDouble() { return double.Parse(next()); }
private T[] enumerate<T>(int n, Func<T> f) {
var a = new T[n];
for (int i = 0; i < n; ++i)
a[i] = f();
return a;
}
public string[] next(int n) { return enumerate(n, next); }
public double[] nextDouble(int n) { return enumerate(n, nextDouble); }
public int[] nextInt(int n) { return enumerate(n, nextInt); }
public long[] nextLong(int n) { return enumerate(n, nextLong); }
#endregion
}
}
|
[["-", 8, 201, 0, 195, 8, 196, 0, 260, 0, 35], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 21], ["+", 0, 28, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25]]
| 8
| 1,287
| 8
|
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AtCoder {
class Program {
static void Main(string[] args) {
var n = int.Parse(ReadLine());
var s = ReadLine();
var insertIndex = 0;
var index = 0;
var count = 0;
while (index < s.Length) {
if (s[index] == '(') {
count++;
} else {
count--;
}
if (count == 1) {
insertIndex = index;
} else if (count == -1) {
s = s.Insert(insertIndex, "(");
count = 0;
index++;
}
index++;
}
insertIndex = s.Length;
index = s.Length - 1;
count = 0;
while (index >= 0) {
if (s[index] == ')') {
count++;
} else {
count--;
}
if (count == 1) {
insertIndex = index;
} else if (count == -1) {
s = s.Insert(insertIndex, ")");
count = 0;
}
index--;
}
WriteLine(s);
}
}
}
|
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AtCoder {
class Program {
static void Main(string[] args) {
var n = int.Parse(ReadLine());
var s = ReadLine();
var insertIndex = 0;
var index = 0;
var count = 0;
while (index < s.Length) {
if (s[index] == '(') {
count++;
} else {
count--;
}
if (count == -1) {
s = s.Insert(insertIndex, "(");
count = 0;
index++;
}
index++;
}
insertIndex = s.Length;
index = s.Length - 1;
count = 0;
while (index >= 0) {
if (s[index] == ')') {
count++;
} else {
count--;
}
if (count == -1) {
s = s.Insert(insertIndex, ")");
count = 0;
}
index--;
}
WriteLine(s);
}
}
}
|
[["-", 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, 11, 31, 22], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 0, 52, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 8, 196, 0, 52, 8, 196, 0, 57, 0, 95], ["-", 0, 52, 8, 196, 0, 57, 75, 57, 0, 121], ["-", 0, 52, 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, 60], ["-", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["-", 0, 52, 8, 196, 0, 57, 75, 196, 0, 46], ["-", 8, 196, 0, 52, 8, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 52, 8, 196, 0, 57, 0, 24], ["-", 0, 52, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 52, 8, 196, 0, 57, 15, 16, 17, 60]]
| 8
| 254
| 26
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
class Program {
static void Main() { new Magatro().Solve(); }
}
class Magatro {
int N;
string S;
private void Scan() {
N = int.Parse(Console.ReadLine());
S = Console.ReadLine();
}
public void Solve() {
Scan();
int cnt = 0;
int min = int.MaxValue;
for (int i = 0; i < S.Length; i++) {
if (S[i] == '(') {
cnt++;
}
if (S[i] == ')') {
cnt--;
}
min = Math.Min(min, cnt);
}
S = new string('(', -min) + S + new string(')', cnt - min);
Console.WriteLine(S);
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
class Program {
static void Main() { new Magatro().Solve(); }
}
class Magatro {
int N;
string S;
private void Scan() {
N = int.Parse(Console.ReadLine());
S = Console.ReadLine();
}
public void Solve() {
Scan();
int cnt = 0;
int min = int.MaxValue;
for (int i = 0; i < S.Length; i++) {
if (S[i] == '(') {
cnt++;
}
if (S[i] == ')') {
cnt--;
}
min = Math.Min(min, cnt);
}
if (min < 0) {
S = S = new string('(', -min) + S;
cnt -= min;
}
S = S + new string(')', cnt);
Console.WriteLine(S);
}
}
|
[["+", 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, 1, 0, 11, 12, 11, 12, 16, 12, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 110], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["-", 12, 230, 3, 4, 0, 28, 0, 16, 17, 33], ["-", 12, 230, 3, 4, 0, 28, 0, 16, 12, 22]]
| 8
| 215
| 20
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Program {
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
static void Solve() {
var N = sc.ReadInt();
var S = sc.ReadStr();
var rle = RLE(S).ToArray();
var countL = 0;
var countR = 0;
var ans = "";
foreach (var r in rle) {
if (r.Item1 == ')') {
if (countL < r.Item2) {
ans += new string('(', r.Item2 - countL);
countL = 0;
} else {
countL -= r.Item2;
}
} else {
countL++;
}
}
ans += S;
foreach (var r in rle.Reverse()) {
if (r.Item1 == '(') {
if (countR < r.Item2) {
ans += new string(')', r.Item2 - countR);
countR = 0;
} else {
countR -= r.Item2;
}
} else {
countR++;
}
}
Console.WriteLine(ans);
}
static IEnumerable<Tuple<char, int>> RLE(string s) {
var count = 1;
var c = s[0];
for (int i = 1; i < s.Length; i++) {
if (c == s[i]) {
count++;
} else {
yield return Tuple.Create(c, count);
count = 1;
}
c = s[i];
}
yield return Tuple.Create(c, count);
}
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.IO;
using System.Linq;
class Program {
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
static void Solve() {
var N = sc.ReadInt();
var S = sc.ReadStr();
var rle = RLE(S).ToArray();
var countL = 0;
var countR = 0;
var ans = "";
foreach (var r in rle) {
if (r.Item1 == ')') {
if (countL < r.Item2) {
ans += new string('(', r.Item2 - countL);
countL = 0;
} else {
countL -= r.Item2;
}
} else {
countL += r.Item2;
}
}
ans += S;
foreach (var r in rle.Reverse()) {
if (r.Item1 == '(') {
if (countR < r.Item2) {
ans += new string(')', r.Item2 - countR);
countR = 0;
} else {
countR -= r.Item2;
}
} else {
countR += r.Item2;
}
}
Console.WriteLine(ans);
}
static IEnumerable<Tuple<char, int>> RLE(string s) {
var count = 1;
var c = s[0];
for (int i = 1; i < s.Length; i++) {
if (c == s[i]) {
count++;
} else {
yield return Tuple.Create(c, count);
count = 1;
}
c = s[i];
}
yield return Tuple.Create(c, count);
}
static Scanner sc = new Scanner();
}
class Scanner {
string[] S = new string[0];
int Index = 0;
char[] Separators = new char[] { ' ' };
public string Next() {
if (this.Index < this.S.Length)
return this.S[this.Index++];
var line = "";
while (line == "")
line = Console.ReadLine();
this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
if (this.S.Length == 0)
return this.Next();
this.Index = 0;
return this.S[this.Index++];
}
public string ReadStr() { return this.Next(); }
public char ReadChar() { return this.Next()[0]; }
public int ReadInt() { return int.Parse(this.Next()); }
public uint ReadUInt() { return uint.Parse(this.Next()); }
public long ReadLong() { return long.Parse(this.Next()); }
public double ReadDouble() { return double.Parse(this.Next()); }
public Tuple<int, int> ReadTup(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add);
}
public Tuple<long, long> ReadTupLong(int add = 0) {
return Tuple.Create(this.ReadLong() + add, this.ReadLong() + add);
}
public Tuple<int, int, int> ReadTup3(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add);
}
public Tuple<int, int, int, int> ReadTup4(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add, this.ReadInt() + add);
}
public int[] ReadIntArray(int n) {
var array = new int[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadInt();
}
return array;
}
public long[] ReadLongArray(int n) {
var array = new long[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadLong();
}
return array;
}
public double[] ReadDoubleArray(int n) {
var array = new double[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadDouble();
}
return array;
}
public char[] ReadCharArray(int n) {
var array = new char[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadChar();
}
return array;
}
public string[] ReadStrArray(int n) {
var array = new string[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadStr();
}
return array;
}
public Tuple<long, long>[] ReadTupLongArray(int n, int add = 0) {
var array = new Tuple<long, long>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTupLong(add);
}
return array;
}
public Tuple<int, int>[] ReadTupArray(int n, int add = 0) {
var array = new Tuple<int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup(add);
}
return array;
}
public Tuple<int, int, int>[] ReadTup3Array(int n, int add = 0) {
var array = new Tuple<int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup3(add);
}
return array;
}
public Tuple<int, int, int, int>[] ReadTup4Array(int n, int add = 0) {
var array = new Tuple<int, int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup4(add);
}
return array;
}
}
|
[["-", 0, 57, 75, 196, 0, 1, 0, 223, 0, 29], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 75, 196, 0, 1, 0, 11, 12, 214, 205, 22], ["+", 75, 196, 0, 1, 0, 11, 12, 214, 0, 131], ["+", 75, 196, 0, 1, 0, 11, 12, 214, 141, 22]]
| 8
| 1,341
| 10
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace ConsoleApp2 {
public class Program {
static long mod = (long)Math.Pow(10, 9) + 7;
public static void Main(string[] args) {
long N = int.Parse(Console.ReadLine());
string S = Console.ReadLine();
string testS = S;
int index = (int)(N - 1);
while (index > 0) {
if (testS[index] == ')' && testS[index - 1] == '(') {
testS = testS.Remove(index - 1, 2);
}
index--;
}
string addsL = "";
string addsR = "";
for (int i = 0; i < testS.Length; i++) {
if (testS[i] == ')') {
addsR += '(';
} else {
addsL += ')';
}
}
Console.WriteLine(addsR + S + addsL);
Console.ReadLine();
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace ConsoleApp2 {
public class Program {
static long mod = (long)Math.Pow(10, 9) + 7;
public static void Main(string[] args) {
long N = int.Parse(Console.ReadLine());
string S = Console.ReadLine();
string testS = S;
int index = (int)(N - 1);
while (index > 0) {
if (testS[index] == ')' && testS[index - 1] == '(') {
testS = testS.Remove(index - 1, 2);
if (testS.Length < index)
index--;
}
index--;
}
string addsL = "";
string addsR = "";
for (int i = 0; i < testS.Length; i++) {
if (testS[i] == ')') {
addsR += '(';
} else {
addsL += ')';
}
}
Console.WriteLine(addsR + S + addsL);
Console.ReadLine();
}
}
}
|
[["+", 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, 214, 205, 22], ["+", 64, 196, 0, 57, 15, 16, 31, 214, 0, 131], ["+", 64, 196, 0, 57, 15, 16, 31, 214, 141, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["+", 64, 196, 0, 57, 64, 1, 0, 223, 0, 22], ["+", 64, 196, 0, 57, 64, 1, 0, 223, 0, 68], ["+", 0, 57, 64, 196, 0, 57, 64, 1, 0, 35]]
| 8
| 217
| 11
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;
public class D {
public static void Main() {
int N = GetInt();
string S = GetString();
bool[] isIgnore = new bool[N];
bool isUpdated = true;
while (isUpdated) {
isUpdated = false;
bool isAfterLeft = false;
for (int i = 0; i < N; i++) {
if (isIgnore[i])
continue;
if (S[i] == '(') {
isAfterLeft = true;
continue;
}
if (isAfterLeft) {
isIgnore[i - 1] = true;
isIgnore[i] = true;
isAfterLeft = false;
isUpdated = true;
}
}
}
int numAddLeft = 0;
int numAddRight = 0;
for (int i = 0; i < N; i++) {
if (isIgnore[i])
continue;
if (S[i] == ')') {
numAddLeft++;
} else {
numAddRight++;
}
}
StringBuilder ans = new StringBuilder();
for (int i = 0; i < numAddLeft; i++)
ans.Append('(');
ans.Append(S);
for (int i = 0; i < numAddRight; i++)
ans.Append(')');
Console.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() { return int.Parse(getArg()); }
public static long GetLong() { return long.Parse(getArg()); }
public static double GetDouble() { return double.Parse(getArg()); }
public static string GetString() { return getArg(); }
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;
public class D {
public static void Main() {
int N = GetInt();
string S = GetString();
bool[] isIgnore = new bool[N];
bool isUpdated = true;
while (isUpdated) {
isUpdated = false;
int iLeft = -1;
for (int i = 0; i < N; i++) {
if (isIgnore[i])
continue;
if (S[i] == '(') {
iLeft = i;
continue;
}
if (iLeft != -1) {
isIgnore[iLeft] = true;
isIgnore[i] = true;
iLeft = -1;
isUpdated = true;
}
}
}
int numAddLeft = 0;
int numAddRight = 0;
for (int i = 0; i < N; i++) {
if (isIgnore[i])
continue;
if (S[i] == ')') {
numAddLeft++;
} else {
numAddRight++;
}
}
StringBuilder ans = new StringBuilder();
for (int i = 0; i < numAddLeft; i++)
ans.Append('(');
ans.Append(S);
for (int i = 0; i < numAddRight; i++)
ans.Append(')');
Console.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() { return int.Parse(getArg()); }
public static long GetLong() { return long.Parse(getArg()); }
public static double GetDouble() { return double.Parse(getArg()); }
public static string GetString() { return getArg(); }
}
|
[["-", 0, 52, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 52, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 198, 0, 200, 0, 212, 0, 211, 0, 147], ["+", 0, 198, 0, 200, 0, 212, 0, 241, 0, 33], ["+", 0, 198, 0, 200, 0, 212, 0, 241, 0, 203], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 64, 196, 0, 1, 0, 11, 12, 211, 0, 146], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 15, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 79], ["+", 8, 196, 0, 57, 15, 16, 12, 241, 0, 33], ["+", 8, 196, 0, 57, 15, 16, 12, 241, 0, 203], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 0, 11, 31, 204, 206, 207, 0, 28, 0, 22], ["-", 64, 196, 0, 1, 0, 11, 12, 211, 0, 147], ["+", 64, 196, 0, 1, 0, 11, 12, 241, 0, 33], ["+", 64, 196, 0, 1, 0, 11, 12, 241, 0, 203]]
| 8
| 427
| 25
|
using System.Linq;
using System;
class Program {
static void Main() {
var N = int.Parse(Console.ReadLine());
var S = Console.ReadLine();
int left = 0;
for (int i = 0; i < N; i++) {
if (S[i] == '(') {
left++;
} else {
if (left > 0) {
left--;
} else {
S = S.Substring(0, i) + "(" + S.Substring(i);
N++;
i++;
}
}
}
while (left-- > 0) {
S = S + ")";
}
Console.WriteLine(S);
}
}
|
using System;
class Program {
static void Main() {
var N = int.Parse(Console.ReadLine());
var S = Console.ReadLine();
int left = 0;
for (int i = 0; i < N; i++) {
if (S[i] == '(') {
left++;
} else {
if (left > 0) {
left--;
} else {
S = "(" + S;
N++;
i++;
}
}
}
while (left-- > 0) {
S = S + ")";
}
Console.WriteLine(S);
}
}
|
[["-", 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, 233], ["-", 36, 36, 36, 36, 0, 208, 0, 231, 141, 22], ["-", 36, 36, 36, 36, 0, 208, 0, 231, 0, 35], ["-", 12, 16, 31, 16, 31, 213, 63, 214, 205, 22], ["-", 12, 16, 31, 16, 31, 213, 63, 214, 0, 131], ["-", 12, 16, 31, 16, 31, 213, 63, 214, 141, 22], ["-", 12, 16, 31, 16, 31, 213, 3, 4, 0, 24], ["-", 31, 16, 31, 213, 3, 4, 0, 28, 0, 203], ["-", 12, 16, 31, 16, 31, 213, 3, 4, 0, 21], ["-", 31, 16, 31, 213, 3, 4, 0, 28, 0, 22], ["-", 12, 16, 31, 16, 31, 213, 3, 4, 0, 25], ["-", 0, 1, 0, 11, 12, 16, 31, 16, 17, 72], ["-", 0, 11, 12, 16, 12, 213, 63, 214, 0, 131], ["-", 0, 11, 12, 16, 12, 213, 63, 214, 141, 22], ["-", 0, 11, 12, 16, 12, 213, 3, 4, 0, 24], ["-", 12, 16, 12, 213, 3, 4, 0, 28, 0, 22], ["-", 0, 11, 12, 16, 12, 213, 3, 4, 0, 25]]
| 8
| 148
| 19
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program {
static void Main(string[] args) {
string str = Console.ReadLine();
int N = int.Parse(str);
int[] a = new int[N + 1];
bool[] b = new bool[N + 1];
int current;
int cnt = 1;
for (int i = 1; i < N + 1; i++) {
str = Console.ReadLine();
a[i] = int.Parse(str);
}
current = a[1];
b[1] = true;
for (int i = 2; i < N + 1; i++) {
if (!b[current]) {
if (current == 2) {
Console.WriteLine(cnt);
return;
}
cnt++;
current = a[current];
} else {
Console.WriteLine(-1);
break;
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program {
static void Main(string[] args) {
string str = Console.ReadLine();
int N = int.Parse(str);
int[] a = new int[N + 1];
bool[] b = new bool[N + 1];
int current;
int cnt = 1;
for (int i = 1; i < N + 1; i++) {
str = Console.ReadLine();
a[i] = int.Parse(str);
}
current = a[1];
b[1] = true;
for (int i = 1; i < N; i++) {
if (!b[current]) {
if (current == 2) {
Console.WriteLine(cnt);
return;
}
cnt++;
current = a[current];
} else {
Console.WriteLine(-1);
break;
}
}
if (cnt == N) {
Console.WriteLine(-1);
}
}
}
|
[["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 72], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 241, 0, 33], ["+", 0, 213, 3, 4, 0, 28, 0, 241, 0, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35]]
| 8
| 208
| 20
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class AtCoderA {
static void Main() {
var sc = new Scanner();
int n = sc.NextInt();
int m = sc.NextInt();
int mod = 1000000007;
int answer = 1;
for (int i = 1; i <= n; i++) {
answer *= i;
answer = answer % mod;
}
for (int i = 1; i <= m; i++) {
answer *= i;
answer = answer % mod;
}
if (n == m) {
answer *= 2;
answer = answer % mod;
}
Console.WriteLine(answer);
}
class Scanner {
private string[] _line;
private int _index;
private const char Separator = ' ';
public Scanner() {
_line = new string[0];
_index = 0;
}
public string Next() {
while (_index >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_index = 0;
}
return _line[_index++];
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
public decimal NextDecimal() => decimal.Parse(Next());
public char NextChar() => Next()[0];
public char[] NextCharArray() => Next().ToCharArray();
public string[] Array() {
_line = Console.ReadLine().Split(Separator);
_index = _line.Length;
return _line;
}
public int[] IntArray() => Array().Select(int.Parse).ToArray();
public long[] LongArray() => Array().Select(long.Parse).ToArray();
public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class AtCoderA {
static void Main() {
var sc = new Scanner();
long n = sc.NextLong();
long m = sc.NextLong();
int mod = 1000000007;
long answer = 1;
for (long i = 1; i <= n; i++) {
answer *= i;
answer = answer % mod;
}
for (long i = 1; i <= m; i++) {
answer *= i;
answer = answer % mod;
}
if (n == m) {
answer *= 2;
answer = answer % mod;
}
if (Math.Abs(n - m) >= 2) {
answer = 0;
}
Console.WriteLine(answer);
}
class Scanner {
private string[] _line;
private int _index;
private const char Separator = ' ';
public Scanner() {
_line = new string[0];
_index = 0;
}
public string Next() {
while (_index >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_index = 0;
}
return _line[_index++];
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
public decimal NextDecimal() => decimal.Parse(Next());
public char NextChar() => Next()[0];
public char[] NextCharArray() => Next().ToCharArray();
public string[] Array() {
_line = Console.ReadLine().Split(Separator);
_index = _line.Length;
return _line;
}
public int[] IntArray() => Array().Select(int.Parse).ToArray();
public long[] LongArray() => Array().Select(long.Parse).ToArray();
public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 57, 15, 16, 31, 213, 63, 214, 205, 22], ["+", 0, 57, 15, 16, 31, 213, 63, 214, 0, 131], ["+", 0, 57, 15, 16, 31, 213, 63, 214, 141, 22], ["+", 0, 57, 15, 16, 31, 213, 3, 4, 0, 24], ["+", 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, 57, 15, 16, 31, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 20], ["+", 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
| 439
| 33
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
class Program {
static long waru = 1000000007;
static void Main(string[] args) {
//入力を受け取る
var NM = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
var N = NM[0];
var M = NM[1];
var SA = Math.Abs(N - M);
var ans = 0L;
if (SA == 0) {
ans = 2 * kaijo(N) * kaijo(M);
} else if (SA == 1) {
ans = kaijo(N) * kaijo(M);
} else {
}
Console.WriteLine(ans % waru);
}
static long kaijo(long num) {
var res = 1L;
while (num != 1) {
res *= num % waru;
num--;
}
return res % waru;
}
}
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
class Program {
static long waru = 1000000007;
static void Main(string[] args) {
//入力を受け取る
var NM = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
var N = NM[0];
var M = NM[1];
var SA = Math.Abs(N - M);
var ans = 0L;
if (SA == 0) {
ans = 2 * kaijo(N) * kaijo(M);
} else if (SA == 1) {
ans = kaijo(N) * kaijo(M);
} else {
}
Console.WriteLine(ans % waru);
}
static long kaijo(long num) {
long res = 1;
var count = 0;
// Console.WriteLine(res);
while (num != 1) {
res *= (num % waru);
num--;
res = res % waru;
}
return res % waru;
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 8, 196, 0, 1, 0, 11, 12, 23, 0, 24], ["+", 8, 196, 0, 1, 0, 11, 12, 23, 0, 25], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 0, 208, 0, 235, 8, 201, 0, 195, 8, 196], ["+", 0, 235, 8, 201, 0, 195, 8, 196, 0, 197], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 198], ["+", 8, 196, 0, 197, 0, 198, 39, 199, 0, 200], ["+", 0, 197, 0, 198, 39, 199, 0, 200, 0, 197], ["+", 0, 198, 39, 199, 0, 200, 0, 197, 0, 198], ["+", 39, 199, 0, 200, 0, 197, 0, 198, 39, 216], ["+", 0, 200, 0, 197, 0, 198, 39, 216, 0, 200], ["+", 0, 197, 0, 198, 39, 216, 0, 200, 0, 169], ["+", 0, 198, 39, 216, 0, 200, 0, 169, 0, 52], ["+", 39, 216, 0, 200, 0, 169, 0, 52, 15, 16], ["+", 0, 200, 0, 169, 0, 52, 15, 16, 31, 22], ["+", 0, 169, 0, 52, 15, 16, 31, 22, 12, 203], ["+", 0, 52, 15, 16, 31, 22, 12, 203, 8, 196], ["+", 15, 16, 31, 22, 12, 203, 8, 196, 0, 1], ["+", 31, 22, 12, 203, 8, 196, 0, 1, 0, 1], ["+", 12, 203, 8, 196, 0, 1, 0, 1, 0, 1], ["+", 8, 196, 0, 1, 0, 1, 0, 1, 0, 37], ["+", 0, 1, 0, 1, 0, 1, 0, 37, 0, 16], ["+", 0, 1, 0, 1, 0, 37, 0, 16, 31, 22], ["+", 0, 1, 0, 37, 0, 16, 31, 22, 12, 22]]
| 8
| 207
| 18
|
using System;
using System.Linq;
namespace ABC065 {
class C {
static void Main(string[] args) {
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int N = input[0];
int M = input[1];
long mod = 1000000007;
if (1 < Math.Abs(N - M)) {
Console.WriteLine();
return;
} else {
long p = 1;
long p2 = 1;
long res = 0;
for (int i = Math.Max(N, M); i >= 1; i--) {
p = (p * i) % mod;
if (i < Math.Max(N, M))
p2 = (p2 * i) % mod;
}
if (M == N) {
res = 2 * (p * p) % mod;
} else {
res = (p * p2) % mod;
}
Console.WriteLine(res);
}
}
}
}
|
using System;
using System.Linq;
namespace ABC065 {
class C {
static void Main(string[] args) {
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int N = input[0];
int M = input[1];
long mod = 1000000007;
if (M < N - 1 || N < M - 1) {
Console.WriteLine(0);
return;
} else {
long p = 1;
long p2 = 1;
long res = 0;
for (int i = Math.Max(N, M); i >= 1; i--) {
p = (p * i) % mod;
if (i < Math.Max(N, M))
p2 = (p2 * i) % mod;
}
if (M == N) {
res = 2 * (p * p) % mod;
} else {
res = (p * p2) % mod;
}
Console.WriteLine(res);
}
}
}
}
|
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 31, 203], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["-", 0, 57, 15, 16, 12, 213, 63, 214, 205, 22], ["-", 0, 57, 15, 16, 12, 213, 63, 214, 0, 131], ["-", 0, 57, 15, 16, 12, 213, 63, 214, 141, 22], ["-", 0, 57, 15, 16, 12, 213, 3, 4, 0, 24], ["+", 0, 57, 15, 16, 31, 16, 12, 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, 18], ["-", 0, 57, 15, 16, 12, 213, 3, 4, 0, 25], ["+", 0, 57, 15, 16, 12, 16, 12, 16, 17, 33], ["+", 0, 57, 15, 16, 12, 16, 12, 16, 12, 203], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203]]
| 8
| 211
| 14
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main() {
Scanner cin = new Scanner();
long N = cin.Long();
long M = cin.Long();
if (Math.Abs(N - M) > 1)
Console.WriteLine(0);
else {
long ans = 1;
while (M >= 1) {
ans = ans * M % 1000000007;
M--;
}
while (N >= 1) {
ans = ans * N % 1000000007;
N--;
}
Console.WriteLine(Math.Abs(N - M) == 1 ? ans : (2 * ans) % 1000000007);
}
Console.ReadLine();
}
}
class Scanner //標準入力
{
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int Int() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = Int() + add;
}
return Array;
}
public long Long() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = Long() + add;
}
return Array;
}
public double Double() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = Double() + add;
}
return Array;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main() {
// ABC065
Scanner cin = new Scanner();
long N = cin.Long();
long M = cin.Long();
var n = N;
var m = M;
if (Math.Abs(N - M) > 1)
Console.WriteLine(0);
else {
long ans = 1;
while (M >= 1) {
ans = ans * M % 1000000007;
M--;
}
while (N >= 1) {
ans = ans * N % 1000000007;
N--;
}
Console.WriteLine(Math.Abs(n - m) == 1 ? ans : 2 * ans % 1000000007);
}
Console.ReadLine();
}
}
class Scanner //標準入力
{
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int Int() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = Int() + add;
}
return Array;
}
public long Long() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = Long() + add;
}
return Array;
}
public double Double() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = Double() + add;
}
return Array;
}
}
|
[["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 31, 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, 12, 22], ["+", 31, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["-", 0, 28, 0, 41, 75, 16, 31, 23, 0, 24], ["-", 0, 28, 0, 41, 75, 16, 31, 23, 0, 25]]
| 8
| 513
| 16
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.