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;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AtCoder {
class Program {
static void Main(string[] args) {
var array = Console.ReadLine().Split().Select(int.Parse).ToArray();
var array2 = array.Distinct().ToArray();
if (array.Length == array2.Length) {
Console.WriteLine("No");
} else {
Console.WriteLine("Yes");
}
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AtCoder {
class Program {
static void Main(string[] args) {
var array = Console.ReadLine().Split().Select(int.Parse).ToArray();
var array2 = array.Distinct().ToArray();
if (array.Length != array2.Length && (array2.Length == 2)) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 79], ["+", 0, 57, 15, 16, 31, 16, 12, 214, 205, 22], ["+", 0, 57, 15, 16, 31, 16, 12, 214, 0, 131], ["+", 0, 57, 15, 16, 31, 16, 12, 214, 141, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 8, 196, 0, 57, 15, 16, 12, 23, 0, 24], ["+", 0, 57, 15, 16, 12, 23, 0, 16, 17, 60], ["+", 0, 57, 15, 16, 12, 23, 0, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 114
| 14
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static ConsoleApp.Util;
using static System.Math;
namespace ConsoleApp {
class Program {
static void Main(string[] args) {
var arr = ReadLine().Split().Select(int.Parse).OrderBy(x => x).ToArray();
if (arr[0] == arr[1] && arr[1] != arr[2])
WriteLine("Yes");
else
WriteLine("No");
}
}
static class Util {
public static void ChMin(ref long a, long b) {
if (a > b) {
a = b;
}
}
public static void ChMax(ref long a, long b) {
if (a < b) {
a = b;
}
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static ConsoleApp.Util;
using static System.Math;
namespace ConsoleApp {
class Program {
static void Main(string[] args) {
var arr = ReadLine().Split().Select(int.Parse).OrderBy(x => x).ToArray();
if (arr[0] == arr[1] && arr[1] != arr[2])
WriteLine("Yes");
else if (arr[0] != arr[1] && arr[1] == arr[2])
WriteLine("Yes");
else
WriteLine("No");
}
}
static class Util {
public static void ChMin(ref long a, long b) {
if (a > b) {
a = b;
}
}
public static void ChMax(ref long a, long b) {
if (a < b) {
a = b;
}
}
}
}
|
[["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 24], ["+", 75, 57, 15, 16, 31, 16, 31, 204, 205, 22], ["+", 15, 16, 31, 16, 31, 204, 206, 207, 0, 70], ["+", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 31, 16, 31, 204, 206, 207, 0, 73], ["+", 0, 57, 75, 57, 15, 16, 31, 16, 17, 79], ["+", 75, 57, 15, 16, 31, 16, 12, 204, 205, 22], ["+", 15, 16, 31, 16, 12, 204, 206, 207, 0, 70], ["+", 31, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 31, 16, 12, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 98], ["+", 75, 57, 15, 16, 12, 16, 31, 204, 205, 22], ["+", 15, 16, 12, 16, 31, 204, 206, 207, 0, 70], ["+", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 12, 16, 31, 204, 206, 207, 0, 73], ["+", 0, 57, 75, 57, 15, 16, 12, 16, 17, 60], ["+", 75, 57, 15, 16, 12, 16, 12, 204, 205, 22], ["+", 15, 16, 12, 16, 12, 204, 206, 207, 0, 70], ["+", 12, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 12, 16, 12, 204, 206, 207, 0, 73], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 25], ["+", 0, 57, 75, 57, 64, 1, 0, 213, 63, 22], ["+", 75, 57, 64, 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], ["+", 75, 57, 64, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 75, 57, 64, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 95]]
| 8
| 175
| 30
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp15 {
class Class19 {
static void Main() {
var abc = Console.ReadLine().Split();
string a = abc[0], b = abc[1], c = abc[2];
if (a == b) {
if (a != c) {
Console.WriteLine("Yes");
return;
}
}
if (a == c) {
if (a != b) {
Console.WriteLine("Yes");
return;
}
}
Console.WriteLine("No");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp15 {
class Class19 {
static void Main() {
var abc = Console.ReadLine().Split();
string a = abc[0], b = abc[1], c = abc[2];
if (a == b) {
if (a != c) {
Console.WriteLine("Yes");
return;
}
}
if (a == c) {
if (a != b) {
Console.WriteLine("Yes");
return;
}
}
if (b == c) {
if (b != a) {
Console.WriteLine("Yes");
return;
}
}
Console.WriteLine("No");
}
}
}
|
[["+", 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], ["+", 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, 79], ["+", 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], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 64, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 64, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 64, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22]]
| 8
| 140
| 27
|
using System;
using System.Linq;
namespace ABC155A {
class MainClass {
public static void Main(string[] args) {
int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
int cnt = 0;
if (a[0] == a[1])
cnt++;
if (a[1] == a[2])
cnt++;
Console.WriteLine(cnt == 1 ? "Yes" : "No");
}
}
}
|
using System;
using System.Linq;
namespace ABC155A {
class MainClass {
public static void Main(string[] args) {
int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
int cnt = 0;
if (a[0] == a[1])
cnt++;
if (a[1] == a[2])
cnt++;
if (a[0] == a[2])
cnt++;
Console.WriteLine(cnt == 1 ? "Yes" : "No");
}
}
}
|
[["+", 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, 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, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 204, 205, 22], ["+", 0, 57, 15, 16, 12, 204, 206, 207, 0, 70], ["+", 15, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 57, 15, 16, 12, 204, 206, 207, 0, 73], ["+", 8, 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
| 106
| 15
|
using System;
namespace ConsoleApp21 {
class Program {
static void Main(string[] args) {
//入力
int n = int.Parse(Console.ReadLine());
string line = Console.ReadLine();
string[] array = line.Split(' ');
int[] arr = new int[n];
for (int index = 0; index < n; index++) {
int num = int.Parse(array[index]);
arr[index] = num;
}
string a = null;
for (int i = 0; i < arr.Length; i++) {
if (arr[i] % 2 == 0) {
if (arr[i] % 3 == 0 || arr[i] % 5 == 0) {
a = "APPROVED";
} else {
a = "DENIED";
}
} else {
a = "APPROVED";
}
}
Console.WriteLine(a);
}
}
}
|
using System;
namespace ConsoleApp21 {
class Program {
static void Main(string[] args) {
//入力
int n = int.Parse(Console.ReadLine());
string line = Console.ReadLine();
string[] array = line.Split(' ');
int[] arr = new int[n];
for (int index = 0; index < n; index++) {
int num = int.Parse(array[index]);
arr[index] = num;
}
string a = null;
for (int i = 0; i < arr.Length; i++) {
if (arr[i] % 2 == 0) {
if (arr[i] % 3 != 0 && arr[i] % 5 != 0) {
a = "DENIED";
break;
} else {
a = "APPROVED";
}
} else {
a = "APPROVED";
}
}
Console.WriteLine(a);
}
}
}
|
[["-", 64, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 64, 196, 0, 57, 15, 16, 31, 16, 17, 79], ["-", 0, 57, 64, 196, 0, 57, 15, 16, 17, 106], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 98], ["-", 64, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 64, 196, 0, 57, 15, 16, 12, 16, 17, 79], ["-", 64, 196, 0, 1, 0, 11, 12, 5, 0, 222], ["+", 64, 196, 0, 1, 0, 11, 12, 5, 0, 222], ["+", 64, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 64, 196, 0, 57, 64, 196, 0, 93, 0, 35], ["-", 75, 196, 0, 1, 0, 11, 12, 5, 0, 222], ["+", 75, 196, 0, 1, 0, 11, 12, 5, 0, 222]]
| 8
| 196
| 12
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApp14 {
class Program {
static void Main(string[] args) {
var solver = new Solver();
solver.Calc();
}
}
public class Solver {
public void Calc() {
var N = int.Parse(Console.ReadLine());
var As = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
Console.WriteLine(As.Count(x => x % 2 == 0) ==
As.Count(x => x % (2 * 3 * 5) == 0)
? "APPROVED"
: "DENIED");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApp14 {
class Program {
static void Main(string[] args) {
var solver = new Solver();
solver.Calc();
}
}
public class Solver {
public void Calc() {
var N = int.Parse(Console.ReadLine());
var As = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
Console.WriteLine(
As.Count(x => x % 2 == 0) ==
As.Count(x => x % (2 * 3) == 0 || x % (2 * 5) == 0)
? "APPROVED"
: "DENIED");
}
}
}
|
[["+", 8, 16, 31, 16, 31, 16, 12, 23, 0, 25], ["+", 0, 28, 0, 218, 8, 16, 31, 16, 17, 60], ["+", 0, 28, 0, 218, 8, 16, 31, 16, 12, 203], ["+", 3, 4, 0, 28, 0, 218, 8, 16, 17, 106], ["+", 0, 218, 8, 16, 12, 16, 31, 16, 31, 22], ["+", 0, 218, 8, 16, 12, 16, 31, 16, 17, 109], ["+", 8, 16, 12, 16, 31, 16, 12, 23, 0, 24], ["+", 12, 16, 31, 16, 12, 23, 0, 16, 31, 203]]
| 8
| 153
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace B {
class Program {
static void Main(string[] args) {
var time = int.Parse(Console.ReadLine());
var info = Console.ReadLine().Split(' ');
var nums = new int[time];
int check = 0;
for (int i = 0; i < time; i++) {
nums[i] = int.Parse(info[i]);
}
foreach (int num in nums) {
if (num % 2 == 0) {
if (num % 3 == 0 || num % 5 == 0) {
check++;
}
}
}
if (check == time)
Console.WriteLine("APPROVED");
else
Console.WriteLine("DENIED");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace B {
class Program {
static void Main(string[] args) {
var time = int.Parse(Console.ReadLine());
var info = Console.ReadLine().Split(' ');
var nums = new int[time];
bool check = true;
for (int i = 0; i < time; i++) {
nums[i] = int.Parse(info[i]);
}
foreach (int num in nums) {
if (num % 2 == 0) {
if (num % 3 != 0 && num % 5 != 0) {
check = false;
}
}
}
if (check == true)
Console.WriteLine("APPROVED");
else
Console.WriteLine("DENIED");
}
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 211, 0, 146], ["-", 64, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 64, 196, 0, 57, 15, 16, 31, 16, 17, 79], ["-", 0, 57, 64, 196, 0, 57, 15, 16, 17, 106], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 98], ["-", 64, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 64, 196, 0, 57, 15, 16, 12, 16, 17, 79], ["-", 0, 57, 64, 196, 0, 1, 0, 223, 0, 29], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 64, 196, 0, 1, 0, 11, 12, 211, 0, 147], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 211, 0, 146]]
| 8
| 184
| 15
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
var l1 = ReadIntArray();
var hp = l1[0];
var sp_types = l1[1];
var sp_damage_list = ReadIntArray();
var damage_total =
sp_damage_list.OrderByDescending(_ => _).Take(sp_types).Sum();
Console.WriteLine(damage_total);
Console.WriteLine(hp > damage_total ? "No" : "Yes");
}
static string[] ReadStringArray() {
var input = Console.ReadLine();
return input.Split(' ');
}
static int[] ReadIntArray() {
var inpArray = ReadStringArray();
return inpArray.Select(_ => int.Parse(_)).ToArray();
}
}
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
var l1 = ReadIntArray();
var hp = l1[0];
var sp_types = l1[1];
var sp_damage_list = ReadIntArray();
var damage_total =
sp_damage_list.OrderByDescending(_ => _).Take(sp_types).Sum();
Console.WriteLine(hp > damage_total ? "No" : "Yes");
}
static string[] ReadStringArray() { return Console.ReadLine().Split(' '); }
static int[] ReadIntArray() {
return ReadStringArray().Select(_ => int.Parse(_)).ToArray();
}
}
|
[["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 8, 201, 0, 195, 8, 196, 0, 37, 0, 38], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 8, 201, 0, 195, 8, 196, 0, 37, 0, 38], ["-", 8, 196, 0, 37, 0, 213, 63, 214, 205, 22], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 205, 22]]
| 8
| 161
| 21
|
using System;
using System.Collections.Generic;
using System.Linq;
class TEST {
public static void Main() {
string[] value1 = Console.ReadLine().Split(
new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
int num = int.Parse(value1[0]);
int hissatu = int.Parse(value1[1]);
long attackcount = 0;
List<long> hps = new List<long>();
hps.AddRange(StringToLongArray(Console.ReadLine().Split(
new string[] { " " }, StringSplitOptions.RemoveEmptyEntries)));
hps.Sort();
while (hps.Count > 0) {
if (hissatu > 0) {
hps.RemoveAt(0);
hissatu--;
continue;
}
attackcount += hps[0];
hps.RemoveAt(0);
}
Console.WriteLine(attackcount);
// Console.ReadLine();
}
static long[] StringToLongArray(string[] arr) {
long[] temp = new long[arr.Length];
for (int i = 0; i < temp.Length; i++) {
temp[i] = long.Parse(arr[i]);
}
return temp;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class TEST {
public static void Main() {
string[] value1 = Console.ReadLine().Split(
new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
int num = int.Parse(value1[0]);
int hissatu = int.Parse(value1[1]);
long attackcount = 0;
List<long> hps = new List<long>();
hps.AddRange(StringToLongArray(Console.ReadLine().Split(
new string[] { " " }, StringSplitOptions.RemoveEmptyEntries)));
hps.Sort();
// hps.Reverse();
while (hps.Count > 0) {
if (hissatu > 0) {
hps.RemoveAt(hps.Count - 1);
hissatu--;
continue;
}
attackcount += hps[hps.Count - 1];
hps.RemoveAt(hps.Count - 1);
}
Console.WriteLine(attackcount);
// Console.ReadLine();
}
static long[] StringToLongArray(string[] arr) {
long[] temp = new long[arr.Length];
for (int i = 0; i < temp.Length; i++) {
temp[i] = long.Parse(arr[i]);
}
return temp;
}
}
|
[["-", 0, 1, 0, 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], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["-", 0, 11, 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
| 251
| 18
|
using System;
using System.Linq;
namespace AtCoder2020Ned {
class Program {
static void Main(string[] args) {
var inputs = Console.ReadLine().Split(' ');
var numberOfMonsters = int.Parse(inputs[0]);
var numberOfFennecUltimate = int.Parse(inputs[1]);
var secondInputs = Console.ReadLine().Split(' ');
var monstersHp = new int[secondInputs.Length];
foreach (var item in secondInputs.Select(
(hp, index) => (new { Hp = hp, Index = index }))) {
monstersHp[item.Index] = int.Parse(item.Hp);
}
Array.Sort(monstersHp, (x, y) => (x - y));
for (int i = 0; i < numberOfFennecUltimate; i++) {
monstersHp[i] = 0;
}
ulong battleCount = 0;
foreach (var item in monstersHp) {
battleCount += (ulong)item;
}
Console.WriteLine(battleCount);
Console.Read();
}
}
}
|
using System;
using System.Linq;
namespace AtCoder2020Ned {
public class Program {
public static void Main(string[] args) {
var inputs = Console.ReadLine().Split(' ');
var numberOfMonsters = int.Parse(inputs[0]);
var numberOfFennecUltimate = int.Parse(inputs[1]);
var secondInputs = Console.ReadLine().Split(' ');
var monstersHp = new int[secondInputs.Length];
foreach (var item in secondInputs.Select(
(hp, index) => (new { Hp = hp, Index = index }))) {
monstersHp[item.Index] = int.Parse(item.Hp);
}
Array.Sort(monstersHp, (x, y) => (y - x));
if (numberOfFennecUltimate > monstersHp.Length) {
numberOfFennecUltimate = monstersHp.Length;
}
for (int i = 0; i < numberOfFennecUltimate; i++) {
monstersHp[i] = 0;
}
ulong battleCount = 0;
foreach (var item in monstersHp) {
battleCount += (ulong)item;
}
Console.WriteLine(battleCount);
Console.Read();
}
}
}
|
[["+", 0, 209, 8, 201, 0, 235, 0, 251, 0, 259], ["+", 0, 235, 8, 201, 0, 195, 0, 251, 0, 259], ["-", 0, 28, 0, 218, 8, 23, 0, 16, 31, 22], ["-", 0, 28, 0, 218, 8, 23, 0, 16, 17, 33], ["+", 0, 28, 0, 218, 8, 23, 0, 16, 17, 33], ["+", 0, 28, 0, 218, 8, 23, 0, 16, 12, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["+", 8, 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], ["+", 8, 196, 0, 57, 15, 16, 12, 214, 205, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 214, 0, 131], ["+", 8, 196, 0, 57, 15, 16, 12, 214, 141, 22], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 64, 196, 0, 1, 0, 11, 12, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 11, 12, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 11, 12, 214, 141, 22], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 219
| 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) {
string[] original_enemy = Console.ReadLine().Split();
int enemy = int.Parse(original_enemy[0]);
int special_attack = int.Parse(original_enemy[1]);
string[] original_hp = Console.ReadLine().Split();
long[] hp =
original_hp.Select(long.Parse).OrderByDescending(x => x).ToArray();
for (int i = 0; i < special_attack; i++) {
hp[i] = 0;
}
Console.WriteLine(hp.Where(x => x != 0).Sum());
Console.Read();
}
}
}
|
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[] original_enemy = Console.ReadLine().Split();
int enemy = int.Parse(original_enemy[0]);
int special_attack = int.Parse(original_enemy[1]);
string[] original_hp = Console.ReadLine().Split();
long[] hp =
original_hp.Select(long.Parse).OrderByDescending(x => x).ToArray();
if (special_attack > hp.Length) {
special_attack = hp.Length;
}
for (int i = 0; i < special_attack; i++) {
hp[i] = 0;
}
Console.WriteLine(hp.Sum());
Console.Read();
}
}
}
|
[["+", 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], ["+", 8, 196, 0, 57, 15, 16, 12, 214, 205, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 214, 0, 131], ["+", 8, 196, 0, 57, 15, 16, 12, 214, 141, 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], ["+", 64, 196, 0, 1, 0, 11, 12, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 11, 12, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 11, 12, 214, 141, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["-", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["-", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["-", 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, 79], ["-", 3, 4, 0, 28, 0, 218, 8, 16, 12, 203], ["-", 0, 213, 63, 214, 205, 213, 3, 4, 0, 25]]
| 8
| 176
| 33
|
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[] original_enemy = Console.ReadLine().Split();
int enemy = int.Parse(original_enemy[0]);
int special_attack = int.Parse(original_enemy[1]);
string[] original_hp = Console.ReadLine().Split();
long[] hp =
original_hp.Select(long.Parse).OrderByDescending(x => x).ToArray();
for (int i = 0; i < special_attack; i++) {
hp[i] = 0;
}
Console.WriteLine(hp.Where(x => x != 0).Sum());
Console.Read();
}
}
}
|
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[] original_enemy = Console.ReadLine().Split();
int enemy = int.Parse(original_enemy[0]);
int special_attack = int.Parse(original_enemy[1]);
string[] original_hp = Console.ReadLine().Split();
long[] hp = original_hp.Select(long.Parse).ToArray();
Array.Sort(hp);
Array.Reverse(hp);
if (special_attack > hp.Length) {
special_attack = hp.Length;
}
for (int i = 0; i < special_attack; i++) {
hp[i] = 0;
}
Console.WriteLine(hp.Where(x => x != 0).Sum());
Console.Read();
}
}
}
|
[["-", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 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], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 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, 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], ["+", 8, 196, 0, 57, 15, 16, 12, 214, 205, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 214, 0, 131], ["+", 8, 196, 0, 57, 15, 16, 12, 214, 141, 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], ["+", 64, 196, 0, 1, 0, 11, 12, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 11, 12, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 11, 12, 214, 141, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 176
| 33
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace abc153_c {
class Program {
static void Main(string[] args) {
string[] NK = Console.ReadLine().Split(' ');
long N = long.Parse(NK[0]); //攻撃モンスターの体力を1減らす
long K = long.Parse(NK[1]); //必殺技モンスターの体力を0にする
long[] H = new long[N];
string[] input = Console.ReadLine().Split(' ');
for (int i = 0; i < N; i++) {
H[i] = long.Parse(input[i]);
}
//攻撃回数の最小値
long ans = 0;
//必殺技の回数を引いた数だけans+
for (int i = 0; i < N - K; i++) {
ans += H[i];
}
Console.WriteLine(ans);
Console.Read();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace abc153_c {
class Program {
static void Main(string[] args) {
string[] NK = Console.ReadLine().Split(' ');
long N = long.Parse(NK[0]); //攻撃モンスターの体力を1減らす
long K = long.Parse(NK[1]); //必殺技モンスターの体力を0にする
long[] H = new long[N];
string[] input = Console.ReadLine().Split(' ');
for (int i = 0; i < N; i++) {
H[i] = long.Parse(input[i]);
}
Array.Sort(H); //並び替え(オーバーフロー対策)
long ans = 0; //攻撃回数の最小値
//必殺技の回数を引いた数だけans+
for (int i = 0; i < N - K; i++) {
ans += H[i];
}
Console.WriteLine(ans);
Console.Read();
}
}
}
|
[["+", 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]]
| 8
| 197
| 7
|
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atcoder {
public class Program {
static void Main(string[] args) {
var r = ReadSplit();
var N = r[0].ToInt();
var K = r[1].ToInt();
var r2 = ReadSplit();
var ar = new List<int>();
for (int i = 0; i < N; i++) {
ar.Add(r2[i].ToInt());
}
ar.Sort();
ar.Reverse();
for (int i = 0; i < K; i++) {
ar[i] = 0;
}
Write(ar.Sum());
}
public static string Read() { return Console.ReadLine(); }
public static string[] ReadSplit() { return Console.ReadLine().Split(' '); }
public static void Write(object str) {
Console.WriteLine(str);
Read();
}
}
}
public static class Extentions {
public static int ToInt(this object obj) { return int.Parse(obj.ToString()); }
public static decimal ToDecimal(this object obj) {
return decimal.Parse(obj.ToString());
}
public static double ToDouble(this object obj) {
return double.Parse(obj.ToString());
}
}
|
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atcoder {
public class Program {
static void Main(string[] args) {
var r = ReadSplit();
var N = r[0].ToDecimal();
var K = r[1].ToDecimal();
var r2 = ReadSplit();
var ar = new List<decimal>();
for (int i = 0; i < N; i++) {
ar.Add(r2[i].ToDecimal());
}
ar.Sort();
ar.Reverse();
for (int i = 0; i < K; i++) {
if (N <= i)
break;
ar[i] = 0;
}
Write(ar.Sum());
}
public static string Read() { return Console.ReadLine(); }
public static string[] ReadSplit() { return Console.ReadLine().Split(' '); }
public static void Write(object str) {
Console.WriteLine(str);
Read();
}
}
}
public static class Extentions {
public static int ToInt(this object obj) { return int.Parse(obj.ToString()); }
public static decimal ToDecimal(this object obj) {
return decimal.Parse(obj.ToString());
}
public static double ToDouble(this object obj) {
return double.Parse(obj.ToString());
}
}
|
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 212, 0, 230, 39, 236, 237, 238, 0, 199], ["+", 0, 212, 0, 230, 39, 236, 237, 238, 0, 199], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 19], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 93, 0, 94], ["+", 0, 7, 8, 196, 0, 57, 64, 93, 0, 35]]
| 8
| 310
| 16
|
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Linq;
namespace at_coder {
#if TEST
[TestClass]
#endif
public class Test_153_c {
#if TEST
public static void Test_Main()
#else
public static void Main()
#endif
{
var ar = ReadIntArray();
int N = ar[0];
int K = ar[1];
int[] H = ReadIntArray();
long n = Solve(N, K, H);
Console.WriteLine(n.ToString());
}
private static long Solve(int n, int k, int[] h) {
if (k > n)
return 0;
List<int> list = new List<int>(h);
list.Sort();
long l = 0;
int count = n - k;
foreach (int a in list) {
l += a;
count--;
if (count <= 0)
break;
}
return l;
}
private static int[] ReadIntArray() {
string[] ss = Console.ReadLine().Split(
new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
int[] ar = new int[ss.Length];
for (int i = 0; i < ss.Length; i++) {
ar[i] = int.Parse(ss[i]);
}
return ar;
}
#if TEST
#else
}
}
#endif
|
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Linq;
namespace at_coder {
#if TEST
[TestClass]
#endif
public class Test_153_c {
#if TEST
public static void Test_Main()
#else
public static void Main()
#endif
{
var ar = ReadIntArray();
int N = ar[0];
int K = ar[1];
int[] H = ReadIntArray();
long n = Solve(N, K, H);
Console.WriteLine(n.ToString());
}
private static long Solve(int n, int k, int[] h) {
if (k > n)
return 0;
List<int> list = new List<int>(h);
list.Sort();
long l = 0;
int count = n - k;
foreach (int a in list.Select(r => r).Take(n - k)) {
l += a;
}
return l;
}
private static int[] ReadIntArray() {
string[] ss = Console.ReadLine().Split(
new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
int[] ar = new int[ss.Length];
for (int i = 0; i < ss.Length; i++) {
ar[i] = int.Parse(ss[i]);
}
return ar;
}
#if TEST
#else
}
}
#endif
|
[["+", 12, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["+", 12, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 12, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["+", 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], ["+", 8, 196, 0, 210, 12, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 210, 12, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 210, 12, 213, 3, 4, 0, 24], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["+", 8, 196, 0, 210, 12, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 210, 0, 25], ["-", 8, 196, 0, 210, 8, 196, 0, 1, 0, 35], ["-", 0, 210, 8, 196, 0, 1, 0, 223, 0, 22], ["-", 0, 210, 8, 196, 0, 1, 0, 223, 0, 68], ["-", 8, 196, 0, 210, 8, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 210, 8, 196, 0, 57, 0, 24], ["-", 0, 210, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 210, 8, 196, 0, 57, 15, 16, 17, 19], ["-", 0, 210, 8, 196, 0, 57, 15, 16, 12, 203], ["-", 8, 196, 0, 210, 8, 196, 0, 57, 0, 25], ["-", 0, 210, 8, 196, 0, 57, 64, 93, 0, 94]]
| 8
| 302
| 25
|
using System;
class Program {
static void Main(string[] args) {
var line = System.Console.ReadLine();
var data = line.Split(new char[] { ' ' });
long N = Convert.ToInt64(data[0]);
long K = Convert.ToInt64(data[1]);
line = System.Console.ReadLine();
data = line.Split(new char[] { ' ' });
ulong[] Hs = new ulong[N];
for (int i = 0; i < N; i++) {
Hs[i] = Convert.ToUInt64(data[i]);
}
Array.Sort(Hs);
Array.Reverse(Hs);
ulong[] after = new ulong[Hs.Length - K];
ulong sumH = 0;
if (Hs.Length - K > 0) {
Array.Copy(Hs, K, after, 0, after.Length);
for (int i = 0; i < after.Length; i++) {
sumH += after[i];
}
}
Console.WriteLine(sumH.ToString());
}
}
|
using System;
class Program {
static void Main(string[] args) {
var line = System.Console.ReadLine();
var data = line.Split(new char[] { ' ' });
long N = Convert.ToInt64(data[0]);
long K = Convert.ToInt64(data[1]);
line = System.Console.ReadLine();
data = line.Split(new char[] { ' ' });
ulong[] Hs = new ulong[N];
for (int i = 0; i < N; i++) {
Hs[i] = Convert.ToUInt64(data[i]);
}
Array.Sort(Hs);
Array.Reverse(Hs);
ulong sumH = 0;
if (Hs.Length - K > 0) {
ulong[] after = new ulong[Hs.Length - K];
Array.Copy(Hs, K, after, 0, after.Length);
for (int i = 0; i < after.Length; i++) {
sumH += after[i];
}
}
Console.WriteLine(sumH.ToString());
}
}
|
[["-", 0, 197, 0, 198, 39, 224, 225, 226, 0, 70], ["-", 0, 197, 0, 198, 39, 224, 225, 226, 0, 73], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 198, 0, 200, 0, 212, 0, 227, 0, 228], ["-", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["-", 0, 212, 0, 227, 39, 224, 225, 226, 0, 70], ["-", 39, 224, 225, 226, 0, 16, 31, 214, 205, 22], ["-", 39, 224, 225, 226, 0, 16, 31, 214, 0, 131], ["-", 39, 224, 225, 226, 0, 16, 31, 214, 141, 22], ["-", 0, 227, 39, 224, 225, 226, 0, 16, 17, 33], ["-", 0, 227, 39, 224, 225, 226, 0, 16, 12, 22], ["-", 0, 212, 0, 227, 39, 224, 225, 226, 0, 73], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 64, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 0, 197, 0, 198, 39, 224, 225, 226, 0, 70], ["+", 0, 197, 0, 198, 39, 224, 225, 226, 0, 73], ["+", 64, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 227, 0, 228], ["+", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["+", 0, 212, 0, 227, 39, 224, 225, 226, 0, 70], ["+", 39, 224, 225, 226, 0, 16, 31, 214, 205, 22], ["+", 39, 224, 225, 226, 0, 16, 31, 214, 0, 131], ["+", 39, 224, 225, 226, 0, 16, 31, 214, 141, 22], ["+", 0, 227, 39, 224, 225, 226, 0, 16, 17, 33], ["+", 0, 227, 39, 224, 225, 226, 0, 16, 12, 22], ["+", 0, 212, 0, 227, 39, 224, 225, 226, 0, 73], ["+", 8, 196, 0, 57, 64, 196, 0, 197, 0, 35]]
| 8
| 241
| 30
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace abc153_c {
class Program {
static void Main(string[] args) {
List<decimal> input1 =
Console.ReadLine().Split(' ').Select(decimal.Parse).ToList();
List<decimal> input2 =
Console.ReadLine().Split(' ').Select(decimal.Parse).ToList();
decimal output = 0;
List<decimal> hList = input2.OrderByDescending(x => x).ToList();
hList.RemoveRange(0, (int)input1[1]);
// for (int index = 0; index < input1[1] ;index++)
//{
// if (hList.Count == 0)
// {
// break;
// }
// hList.RemoveAt(0);
//}
if (hList.Count != 0) {
output = hList.Sum();
}
Console.WriteLine(output);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace abc153_c {
class Program {
static void Main(string[] args) {
List<decimal> input1 =
Console.ReadLine().Split(' ').Select(decimal.Parse).ToList();
List<decimal> input2 =
Console.ReadLine().Split(' ').Select(decimal.Parse).ToList();
decimal output = 0;
List<decimal> hList = input2.OrderByDescending(x => x).ToList();
if (input1[0] > input1[1]) {
hList.RemoveRange(0, (int)input1[1]);
if (hList.Count != 0) {
output = hList.Sum();
}
}
Console.WriteLine(output);
}
}
}
|
[["+", 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, 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], ["+", 8, 196, 0, 57, 15, 16, 12, 204, 205, 22], ["+", 0, 57, 15, 16, 12, 204, 206, 207, 0, 70], ["+", 15, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 57, 15, 16, 12, 204, 206, 207, 0, 73], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 166
| 14
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace CSharp {
class Program {
static void Main(string[] args) {
// 入力
var input = Console.ReadLine().Split(' ');
var monsterCount = int.Parse(input[0]);
var specialAtk = int.Parse(input[1]);
input = Console.ReadLine().Split(' ');
long[] array = Array.ConvertAll<string, long>(
input, delegate(string value) { return long.Parse(value); });
// 出力
// モンスターの数より必殺技の数の方が多い場合は即戦闘終了
if (monsterCount <= specialAtk) {
Console.WriteLine(0);
return;
}
var sort = array.OrderByDescending(x => x);
var fight = sort.Skip(specialAtk).Take(array.Count() - specialAtk);
long sum = 0;
foreach (var item in fight) {
Console.WriteLine(item);
sum += item;
}
Console.WriteLine(sum);
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace CSharp {
class Program {
static void Main(string[] args) {
// 入力
var input = Console.ReadLine().Split(' ');
var monsterCount = int.Parse(input[0]);
var specialAtk = int.Parse(input[1]);
input = Console.ReadLine().Split(' ');
long[] array = Array.ConvertAll<string, long>(
input, delegate(string value) { return long.Parse(value); });
// 出力
// モンスターの数より必殺技の数の方が多い場合は即戦闘終了
if (monsterCount <= specialAtk) {
Console.WriteLine(0);
return;
}
var sort = array.OrderByDescending(x => x);
var fight = sort.Skip(specialAtk).Take(array.Count() - specialAtk);
long sum = 0;
foreach (var item in fight) {
sum += item;
}
Console.WriteLine(sum);
}
}
}
|
[["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 210, 8, 196, 0, 1, 0, 35]]
| 8
| 216
| 7
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC153 {
class Program {
static void Main(string[] args) { c(); }
public static void c() {
long[] nk =
Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
long n = nk[0];
long k = nk[1];
long[] h =
Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
Array.Reverse(h);
long ans = 0;
for (long i = 0; i < n; i++) {
if (i < k) {
continue;
} else {
ans += h[i];
}
}
Console.WriteLine(ans);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC153 {
class Program {
static void Main(string[] args) { c(); }
public static void c() {
long[] nk =
Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
long n = nk[0];
long k = nk[1];
long[] h =
Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
Array.Sort(h);
Array.Reverse(h);
long ans = 0;
for (long i = 0; i < n; i++) {
if (i < k) {
continue;
} else {
ans += h[i];
}
}
Console.WriteLine(ans);
}
}
}
|
[["+", 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], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131]]
| 8
| 197
| 7
|
using System;
using System.Linq;
namespace CSharp {
class Program {
static void Main() {
var input = Console.ReadLine().Split().Select(long.Parse).ToArray();
var N = input[0];
var K = input[1];
var H = Console.ReadLine().Split().Select(long.Parse).ToArray();
Array.Sort(H);
Array.Reverse(H);
for (var i = 0; i < K; i++) {
H[i] = 0L;
}
Console.WriteLine(H.Sum());
}
}
}
|
using System;
using System.Linq;
namespace CSharp {
class Program {
static void Main() {
var input = Console.ReadLine().Split().Select(long.Parse).ToArray();
var N = input[0];
var K = input[1];
var H = Console.ReadLine().Split().Select(long.Parse).ToArray();
Array.Sort(H);
Array.Reverse(H);
for (var i = 0; i < K; i++) {
if (i >= H.Length) {
break;
}
H[i] = 0L;
}
Console.WriteLine(H.Sum());
}
}
}
|
[["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 20], ["+", 8, 196, 0, 57, 15, 16, 12, 214, 205, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 214, 0, 131], ["+", 8, 196, 0, 57, 15, 16, 12, 214, 141, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 135
| 12
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
// WriteLine ("入力");
var H = cin.ReadLong;
long oneUnitBranchCount = 3;
long rightUnitCount = (long)Math.Floor(Math.Log((double)H, 2));
long branchCount = 0;
for (int i = 1; i <= rightUnitCount; i++) {
if (i != 1) {
branchCount -= (long)(1 * Math.Pow((double)2, (double)i - 1));
branchCount +=
oneUnitBranchCount * (long)(1 * Math.Pow((double)2, (double)i - 1));
} else {
branchCount += oneUnitBranchCount;
}
}
Console.WriteLine(branchCount);
}
}
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.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
// WriteLine ("入力");
var H = cin.ReadLong;
long oneUnitBranchCount = 3;
long rightUnitCount = (long)Math.Floor(Math.Log((double)H, 2));
long branchCount = 1;
for (int i = 1; i <= rightUnitCount; i++) {
branchCount -= (long)(1 * Math.Pow((double)2, (double)i - 1));
branchCount +=
oneUnitBranchCount * (long)(1 * Math.Pow((double)2, (double)i - 1));
}
Console.WriteLine(branchCount);
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 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, 79], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["-", 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, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["-", 0, 7, 8, 196, 0, 57, 75, 196, 0, 45], ["-", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["-", 75, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["-", 0, 57, 75, 196, 0, 1, 0, 11, 12, 22], ["-", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["-", 0, 7, 8, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 557
| 17
|
using System;
class DCaracalVsMonster {
static void Main(string[] args) {
long H = long.Parse(System.Console.ReadLine());
long rtn = 0;
int i = 0;
while (H > 1) {
System.Console.WriteLine(rtn.ToString());
H = H / 2;
rtn = rtn + ((long)(Math.Pow(2, i + 1)));
i++;
}
rtn = rtn + 1;
System.Console.WriteLine(rtn.ToString());
}
}
|
using System;
class DCaracalVsMonster {
static void Main(string[] args) {
long H = long.Parse(System.Console.ReadLine());
long rtn = 0;
int i = 0;
while (H > 1) {
H = H / 2;
rtn = rtn + ((long)(Math.Pow(2, i + 1)));
i++;
}
rtn = rtn + 1;
System.Console.WriteLine(rtn.ToString());
}
}
|
[["-", 0, 1, 0, 213, 63, 214, 205, 214, 205, 22], ["-", 0, 1, 0, 213, 63, 214, 205, 214, 0, 131], ["-", 0, 1, 0, 213, 63, 214, 205, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["-", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["-", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35]]
| 8
| 115
| 13
|
using System;
using System.Collections.Generic;
class A {
static void Main(string[] args) {
long N = long.Parse(Console.ReadLine());
long count = 0;
long d = 0;
while (N != 1) {
N /= 2;
count += (long)Math.Pow(2, d++);
}
Console.WriteLine(count);
Console.WriteLine(count + (long)Math.Pow(2, d));
}
}
|
using System;
using System.Collections.Generic;
class A {
static void Main(string[] args) {
long N = long.Parse(Console.ReadLine());
long count = 0;
long d = 0;
while (N != 1) {
N /= 2;
count += (long)Math.Pow(2, d++);
}
Console.WriteLine(count + (long)Math.Pow(2, d));
}
}
|
[["-", 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, 213, 3, 4, 0, 28, 0, 16, 31, 22]]
| 8
| 102
| 7
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace lineAralgebra {
class Program {
public static void Main(String[] args) {
var input = long.Parse(Console.ReadLine());
long ans = 1;
var height = Math.Log(input, 2);
System.Console.WriteLine(height);
for (double i = 0; i <= height; i++) {
ans *= 2;
}
System.Console.WriteLine(ans - 1);
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace lineAralgebra {
class Program {
public static void Main(String[] args) {
var input = long.Parse(Console.ReadLine());
long ans = 1;
var height = Math.Log(input, 2);
for (double i = 0; i <= height; i++) {
ans *= 2;
}
System.Console.WriteLine(ans - 1);
}
}
}
|
[["-", 0, 1, 0, 213, 63, 214, 205, 214, 205, 22], ["-", 0, 1, 0, 213, 63, 214, 205, 214, 0, 131], ["-", 0, 1, 0, 213, 63, 214, 205, 214, 141, 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]]
| 8
| 106
| 9
|
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
namespace FertiLib.Contest.E {
static class Program {
public static void Solve(Scanner cin) {
var (h, n) = cin.ReadValue<int, int>();
var (a, b) = cin.ReadValueArray<int, int>(n);
var dp = Enumerable.Repeat((long)int.MaxValue, 2 * h + 1).ToArray();
dp[0] = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < 2 * h + 1; j++) {
if (j - a[i] >= 0)
dp[j] = Math.Min(dp[j], dp[j - a[i]] + b[i]);
}
}
Console.WriteLine(dp.Skip(h).Min());
}
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;
using System.Runtime.CompilerServices;
namespace FertiLib.Contest.E {
static class Program {
public static void Solve(Scanner cin) {
var (h, n) = cin.ReadValue<int, int>();
var (a, b) = cin.ReadValueArray<int, int>(n);
var dp = Enumerable.Repeat((long)int.MaxValue, 50000).ToArray();
dp[0] = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < 50000; j++) {
if (j - a[i] >= 0)
dp[j] = Math.Min(dp[j], dp[j - a[i]] + b[i]);
}
}
Console.WriteLine(dp.Skip(h).Min());
}
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);
}
}
}
|
[["-", 3, 4, 0, 28, 0, 16, 31, 16, 31, 203], ["-", 3, 4, 0, 28, 0, 16, 31, 16, 17, 48], ["-", 3, 4, 0, 28, 0, 16, 31, 16, 12, 22], ["-", 205, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["-", 205, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 63, 214, 205, 213, 3, 4, 0, 28, 0, 203], ["-", 0, 7, 15, 16, 12, 16, 31, 16, 31, 203], ["-", 0, 7, 15, 16, 12, 16, 31, 16, 17, 48], ["-", 0, 7, 15, 16, 12, 16, 31, 16, 12, 22], ["-", 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, 7, 15, 16, 12, 203]]
| 8
| 2,787
| 12
|
using System;
using System.Linq;
namespace PracticeForAtCoder {
class Program {
static void Main(string[] args) {
//ここから
string[] str = Console.ReadLine().Split(' ');
int n = int.Parse(str[0]);
int k = int.Parse(str[1]);
str = Console.ReadLine().Split(' ');
int[] p = new int[n];
for (int i = 0; i < n; i++) {
p[i] = int.Parse(str[i]);
}
int max = 0;
for (int i = 0; i < k; i++) {
max += p[i];
}
int sum = max;
for (int i = k; i < n; i++) {
sum = sum - p[i - k] + p[i];
if (p[i] > p[i - k]) {
max = sum;
}
}
double d = (double)(max + k) / 2;
Console.WriteLine(d);
//ここまで
}
}
}
|
using System;
using System.Linq;
namespace PracticeForAtCoder {
class Program {
static void Main(string[] args) {
//ここから
string[] str = Console.ReadLine().Split(' ');
int n = int.Parse(str[0]);
int k = int.Parse(str[1]);
str = Console.ReadLine().Split(' ');
int[] p = new int[n];
for (int i = 0; i < n; i++) {
p[i] = int.Parse(str[i]);
}
int sum = 0;
for (int i = 0; i < k; i++) {
sum += p[i];
}
int max = sum;
for (int i = k; i < n; i++) {
sum = sum - p[i - k] + p[i];
max = (sum > max) ? sum : max;
}
double d = (double)(max + k) / 2;
Console.WriteLine(d);
//ここまで
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 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, 11, 12, 41, 15, 23, 0, 16, 31, 22], ["-", 8, 196, 0, 57, 15, 16, 12, 204, 205, 22], ["-", 0, 57, 15, 16, 12, 204, 206, 207, 0, 70], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 12, 22], ["-", 0, 57, 15, 16, 12, 204, 206, 207, 0, 73], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 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, 22], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 236
| 30
|
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
#if DEBUG
MyDebugger.Test(process, "../TextFile1.txt");
// MyDebugger.Test(process, "../TextFile2.txt");
// MyDebugger.MakeTestCase("../TextFile2.txt");
#else
object ret = process(new StreamReader(Console.OpenStandardInput()));
Console.WriteLine(ret);
#endif
}
static object process(TextReader input) {
var spl = input.ReadLine().Split(' ');
var h = int.Parse(spl[0]);
var n = int.Parse(spl[1]);
var magics = new Magic[n];
for (int i = 0; i < n; i++) {
spl = input.ReadLine().Split(' ');
var m = new Magic();
m.a = int.Parse(spl[0]);
m.b = int.Parse(spl[1]);
magics[i] = m;
}
var dp = new long[h * 2];
for (int i = 0; i < dp.Length; i++) {
if (i > 0 && dp[i] == 0)
continue;
foreach (var m in magics) {
long j = m.a + i;
long c = m.b + dp[i];
if (j < dp.Length && (dp[j] == 0 || c < dp[j])) {
dp[j] = c;
}
}
}
long ret = long.MaxValue;
for (int i = h; i < dp.Length; i++) {
if (dp[i] > 0 && dp[i] < ret) {
ret = dp[i];
}
}
// for(int i=0; i<dp.Length; i++) {
// Console.WriteLine(i + ":" + dp[i]);
//}
return ret;
}
class Magic {
public int a;
public int b;
}
}
|
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
#if DEBUG
MyDebugger.Test(process, "../TextFile1.txt");
// MyDebugger.Test(process, "../TextFile2.txt");
// MyDebugger.MakeTestCase("../TextFile2.txt");
#else
object ret = process(new StreamReader(Console.OpenStandardInput()));
Console.WriteLine(ret);
#endif
}
static object process(TextReader input) {
var spl = input.ReadLine().Split(' ');
var h = int.Parse(spl[0]);
var n = int.Parse(spl[1]);
var magics = new Magic[n];
for (int i = 0; i < n; i++) {
spl = input.ReadLine().Split(' ');
var m = new Magic();
m.a = int.Parse(spl[0]);
m.b = int.Parse(spl[1]);
magics[i] = m;
}
var dp = new long[h + magics.Max(x => x.a)];
for (int i = 0; i < dp.Length; i++) {
if (i > 0 && dp[i] == 0)
continue;
foreach (var m in magics) {
long j = m.a + i;
long c = m.b + dp[i];
if (j < dp.Length && (dp[j] == 0 || c < dp[j])) {
dp[j] = c;
}
}
}
long ret = long.MaxValue;
for (int i = h; i < dp.Length; i++) {
if (dp[i] > 0 && dp[i] < ret) {
ret = dp[i];
}
}
// for(int i=0; i<dp.Length; i++) {
// Console.WriteLine(i + ":" + dp[i]);
//}
return ret;
}
class Magic {
public int a;
public int b;
}
}
|
[["-", 0, 227, 39, 224, 225, 226, 0, 16, 17, 48], ["-", 0, 227, 39, 224, 225, 226, 0, 16, 12, 203], ["+", 0, 227, 39, 224, 225, 226, 0, 16, 17, 72], ["+", 225, 226, 0, 16, 12, 213, 63, 214, 205, 22], ["+", 225, 226, 0, 16, 12, 213, 63, 214, 0, 131], ["+", 225, 226, 0, 16, 12, 213, 63, 214, 141, 22], ["+", 225, 226, 0, 16, 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], ["+", 3, 4, 0, 28, 0, 218, 8, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 218, 8, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 218, 8, 214, 141, 22], ["+", 225, 226, 0, 16, 12, 213, 3, 4, 0, 25]]
| 8
| 397
| 13
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ClassLibrary1 {
public class ListNode {
public int val;
public ListNode next;
public ListNode(int x) { val = x; }
}
public class Class1 {
static Dictionary<Tuple<long, long>, long> dic =
new Dictionary<Tuple<long, long>, long>();
static long mod = 1000000007;
static long[] factorial = new long[100001];
static long[] invFactorial = new long[100001];
private static void calcFanctorial(long N) {
factorial[0] = 1;
for (int i = 1; i < N + 1; i++) {
factorial[i] = factorial[i - 1] * i;
factorial[i] %= mod;
}
invFactorial[N] = inv(factorial[N]);
for (int i = (int)N; i > 0; i--) {
invFactorial[i - 1] = invFactorial[i] * i % mod;
}
}
static void Main(string[] args) {
var AA = ReadLongArr();
long H = AA[0];
long N = AA[1];
long[][] AB = new long [N][];
for (int i = 0; i < N; i++) {
AB[i] = ReadLongArr();
}
var AB2 = AB.OrderBy(a => a[1]).ToArray();
long[] dp = new long[H + 1];
var point = AB2[0][0];
var cost = AB2[0][1];
var index = 0;
for (int i = 0; i < H + 1; i++) {
if (i <= point) {
// dp[i] = cost;
} else {
if (index == N - 1) {
break;
}
index++;
point = AB2[index][0];
cost = AB2[index][1];
}
dp[i] = cost;
for (int j = 1; j <= i - j; j++) {
dp[i] = Math.Min(dp[i], dp[j] + dp[i - j]);
}
}
index = 0;
for (long i = point + 1; i < H + 1; i++) {
var cc = AB2[0][1] + dp[i - 1];
for (int k = 0; k < N; k++) {
var pp = i - AB2[k][0];
if (pp > 0) {
cc = Math.Min(cc, AB2[k][1] + dp[pp]);
} else {
cc = Math.Min(cc, AB2[k][1]);
}
}
for (int j = 1; j <= i - j; j++) {
cc = Math.Min(cc, dp[j] + dp[i - j]);
}
dp[i] = cc;
}
Console.WriteLine(dp[H]);
}
private class AB {
long cost;
long point;
}
private static long nCm(long n, long m) {
if (n < m)
return 0;
return (factorial[n] * invFactorial[m] % mod) * invFactorial[n - m] % mod;
}
public static long pow(long a, long b, long mod) {
a %= mod;
if (b <= 0)
return 1;
var t = pow(a, b / 2, mod);
if ((b & 1) == 0)
return t * t % mod;
return t * t % mod * a % mod;
}
public static long Lcm(long a, long b) {
return a * b % mod * inv(Gcd(a, b)) % mod;
}
public static long Lcm(long[] a) {
List<long> vect = new List<long>();
long lcm = 1;
for (int i = 0; i < a.Count(); i++) {
var factor = a[i] / GcdVector(vect, a[i]);
vect.Add(factor);
lcm = lcm * factor % mod;
}
return lcm;
}
static long GcdVector(List<long> a, long b) {
long ma = 1;
for (int i = 0; i < a.Count; i++)
ma = ma * a[i] % b;
return Gcd(b, ma);
}
public static long Gcd(long a, long b) {
if (a < b)
// 引数を入替えて自分を呼び出す
return Gcd(b, a);
while (b != 0) {
var remainder = a % b;
a = b;
b = remainder;
}
return a;
}
public static long pow(long a, long b) => pow(a, b, mod);
public static long inv(long a) => pow(a, mod - 2);
private static char[][] ReadCharMatrix(long h) {
char[][] mtx = new char [h][];
for (int i = 0; i < h; i++) {
var s = ReadString();
mtx[i] = s.ToCharArray();
}
return mtx;
}
private static int[][] CreateIntMatrix(long h, long w) {
int[][] mtx = new int [h][];
for (int i = 0; i < h; i++) {
mtx[i] = new int[w];
}
return mtx;
}
private static string ReadString() { return Console.ReadLine(); }
private static string[] ReadStringArr() {
return Console.ReadLine().Split(' ');
}
private static long ReadLong() { return long.Parse(Console.ReadLine()); }
private static long[] ReadLongArr() {
string[] s = ReadStringArr();
long[] l = new long[s.Length];
for (int i = 0; i < l.Length; i++) {
l[i] = long.Parse(s[i]);
}
return l;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ClassLibrary1 {
public class ListNode {
public int val;
public ListNode next;
public ListNode(int x) { val = x; }
}
public class Class1 {
static Dictionary<Tuple<long, long>, long> dic =
new Dictionary<Tuple<long, long>, long>();
static long mod = 1000000007;
static long[] factorial = new long[100001];
static long[] invFactorial = new long[100001];
private static void calcFanctorial(long N) {
factorial[0] = 1;
for (int i = 1; i < N + 1; i++) {
factorial[i] = factorial[i - 1] * i;
factorial[i] %= mod;
}
invFactorial[N] = inv(factorial[N]);
for (int i = (int)N; i > 0; i--) {
invFactorial[i - 1] = invFactorial[i] * i % mod;
}
}
static void Main(string[] args) {
var AA = ReadLongArr();
long H = AA[0];
long N = AA[1];
long[][] AB = new long [N][];
for (int i = 0; i < N; i++) {
AB[i] = ReadLongArr();
}
var AB2 = AB.OrderBy(a => a[1]).ToArray();
long[] dp = new long[H + 1];
var point = AB2[0][0];
var cost = AB2[0][1];
var index = 0;
for (int i = 0; i < H + 1; i++) {
if (i <= point) {
// dp[i] = cost;
} else {
if (index == N - 1) {
break;
}
index++;
point = AB2[index][0];
cost = AB2[index][1];
}
dp[i] = cost;
for (int j = 1; j <= i - j; j++) {
dp[i] = Math.Min(dp[i], dp[j] + dp[i - j]);
}
}
index = 0;
for (long i = AB2[0][0] + 1; i < H + 1; i++) {
var cc = AB2[0][1] + dp[i - 1];
for (int k = 0; k < N; k++) {
var pp = i - AB2[k][0];
if (pp > 0) {
cc = Math.Min(cc, AB2[k][1] + dp[pp]);
} else {
cc = Math.Min(cc, AB2[k][1]);
}
}
for (int j = 1; j <= i - j; j++) {
cc = Math.Min(cc, dp[j] + dp[i - j]);
}
dp[i] = cc;
}
Console.WriteLine(dp[H]);
}
private class AB {
long cost;
long point;
}
private static long nCm(long n, long m) {
if (n < m)
return 0;
return (factorial[n] * invFactorial[m] % mod) * invFactorial[n - m] % mod;
}
public static long pow(long a, long b, long mod) {
a %= mod;
if (b <= 0)
return 1;
var t = pow(a, b / 2, mod);
if ((b & 1) == 0)
return t * t % mod;
return t * t % mod * a % mod;
}
public static long Lcm(long a, long b) {
return a * b % mod * inv(Gcd(a, b)) % mod;
}
public static long Lcm(long[] a) {
List<long> vect = new List<long>();
long lcm = 1;
for (int i = 0; i < a.Count(); i++) {
var factor = a[i] / GcdVector(vect, a[i]);
vect.Add(factor);
lcm = lcm * factor % mod;
}
return lcm;
}
static long GcdVector(List<long> a, long b) {
long ma = 1;
for (int i = 0; i < a.Count; i++)
ma = ma * a[i] % b;
return Gcd(b, ma);
}
public static long Gcd(long a, long b) {
if (a < b)
// 引数を入替えて自分を呼び出す
return Gcd(b, a);
while (b != 0) {
var remainder = a % b;
a = b;
b = remainder;
}
return a;
}
public static long pow(long a, long b) => pow(a, b, mod);
public static long inv(long a) => pow(a, mod - 2);
private static char[][] ReadCharMatrix(long h) {
char[][] mtx = new char [h][];
for (int i = 0; i < h; i++) {
var s = ReadString();
mtx[i] = s.ToCharArray();
}
return mtx;
}
private static int[][] CreateIntMatrix(long h, long w) {
int[][] mtx = new int [h][];
for (int i = 0; i < h; i++) {
mtx[i] = new int[w];
}
return mtx;
}
private static string ReadString() { return Console.ReadLine(); }
private static string[] ReadStringArr() {
return Console.ReadLine().Split(' ');
}
private static long ReadLong() { return long.Parse(Console.ReadLine()); }
private static long[] ReadLongArr() {
string[] s = ReadStringArr();
long[] l = new long[s.Length];
for (int i = 0; i < l.Length; i++) {
l[i] = long.Parse(s[i]);
}
return l;
}
}
}
|
[["-", 10, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["+", 0, 212, 0, 16, 31, 204, 205, 204, 205, 22], ["+", 0, 16, 31, 204, 205, 204, 206, 207, 0, 70], ["+", 31, 204, 205, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 16, 31, 204, 205, 204, 206, 207, 0, 73], ["+", 0, 212, 0, 16, 31, 204, 206, 207, 0, 70], ["+", 0, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 212, 0, 16, 31, 204, 206, 207, 0, 73]]
| 8
| 1,301
| 8
|
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
namespace Practice {
class Program {
static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
private const int MOD = 1000000007;
private const int MAX = 1000001;
static long[] fac = new long[MAX];
static long[] finv = new long[MAX];
static long[] inv = new long[MAX];
static void Solve() {
long h = Input.NextLong();
int n = Input.NextInt();
var a = new long[n];
var b = new long[n];
for (int i = 0; i < n; ++i) {
a[i] = Input.NextLong();
b[i] = Input.NextLong();
}
long amax = a.Max();
long len = amax * ((h - 1) / amax + 1) + 10;
var dp = new long[n + 2, len];
for (int i = 0; i < dp.GetLength(0); ++i) {
for (int j = 0; j < dp.GetLength(1); ++j) {
dp[i, j] = long.MaxValue / 10;
}
}
for (int i = 0; i < dp.GetLength(0); ++i) {
dp[i, 0] = 0; // 与えたダメージ0なら消費魔力0
}
for (int i = 0; i < n; ++i) {
for (long j = 0; j < dp.GetLength(1); ++j) {
dp[i + 1, j] = Math.Min(dp[i + 1, j], dp[i, j]);
if (j >= a[i]) {
dp[i + 1, j] = Math.Min(dp[i + 1, j], dp[i + 1, j - a[i]] + b[i]);
}
}
}
long ans = long.MaxValue;
for (int j = (int)h; j < dp.GetLength(1); ++j) {
ans = Math.Min(dp[n, j], ans);
}
Console.WriteLine(ans);
}
#region よく使う便利関数
private static Dictionary<long, int> Factorize(long n) {
var dic = new Dictionary<long, int>();
for (long i = 2; i * i <= n; ++i) {
while (n % i == 0) {
if (!dic.ContainsKey(i)) {
dic.Add(i, 0);
}
dic[i]++;
n /= i;
}
}
if (n != 1) {
dic.Add(n, 1);
}
return dic;
}
static void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
static long COM(long n, long k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
static class Input {
static char[] separator = { ' ' };
public static bool IsEof { get; set; }
static Queue<string> q { get; set; }
static Input() {
IsEof = false;
q = new Queue<string>();
}
/// <summary>
/// 入力予約
/// </summary>
/// <param name="items"></param>
public static void SetText(IEnumerable<string> items) {
foreach (var item in items) {
SetText(item);
}
}
/// <summary>
/// 入力予約
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static bool SetText(string s) {
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
q.Enqueue(elem);
}
return true;
}
/// <summary>
/// 内部queueに入力からの値をsplitして格納する
/// </summary>
/// <returns></returns>
static bool read() {
var s = Console.ReadLine();
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
q.Enqueue(elem);
}
if (!q.Any())
return read();
return true;
}
/// <summary>
/// 次のstringを一つ読み込む
/// </summary>
/// <returns></returns>
public static string Next() {
if (!q.Any()) {
if (!read()) {
IsEof = true;
return "";
}
}
return q.Dequeue();
}
public static int NextInt() => int.Parse(Next());
public static long NextLong() => long.Parse(Next());
public static double NextDouble() => double.Parse(Next());
public static List<string>
Next(int n) => Enumerable.Range(0, n).Select(_ => Next()).ToList();
public static List<int>
NextInt(int n) => Next(n).Select(x => int.Parse(x)).ToList();
public static List<long>
NextLong(int n) => Next(n).Select(x => long.Parse(x)).ToList();
public static List<double>
NextDouble(int n) => Next(n).Select(x => double.Parse(x)).ToList();
public static List<string>
NextLine() => Console.ReadLine()
.Trim()
.Split(separator, StringSplitOptions.RemoveEmptyEntries)
.ToList();
public static List<int>
NextIntLine() => NextLine().Select(x => int.Parse(x)).ToList();
public static List<long>
NextLongLine() => NextLine().Select(x => long.Parse(x)).ToList();
public static List<double>
NextDoubleLine() => NextLine().Select(x => double.Parse(x)).ToList();
}
private static bool isPrime(long x) {
if (x == 2) {
return true;
}
if (x < 2 || x % 2 == 0) {
return false;
}
long i = 3;
while (i * i <= x) {
if (x % i == 0) {
return false;
}
i = i + 2;
}
return true;
}
private static long lcm(long x, long y) { return x / gcd(x, y) * y; }
private static long gcd(long x, long y) { return y > 0 ? gcd(y, x % y) : x; }
private static long pow(long x, long n) {
if (n == 0) {
return 1;
}
long res = pow(x * x % MOD, n / 2);
if (n % 2 == 1) {
res = res * x % MOD;
}
return res;
}
private static void Swap<T>(ref T x, ref T y) {
T t = x;
x = y;
y = t;
}
/// <summary>
/// 指定した値以上の先頭のインデクスを返す
/// </summary>
/// <typeparam name="T">比較する値の型</typeparam>
/// <param name="arr">対象の配列(※ソート済みであること)</param>
/// <param name="start">開始インデクス [inclusive]</param>
/// <param name="end">終了インデクス [exclusive]</param>
/// <param name="value">検索する値</param>
/// <param name="comparer">比較関数(インターフェイス)</param>
/// <returns>指定した値以上の先頭のインデクス</returns>
public static int LowerBound<T>(IReadOnlyList<T> arr, int start, int end,
T value, IComparer<T> comparer) {
int low = start;
int high = end;
int mid;
while (low < high) {
mid = ((high - low) >> 1) + low;
if (comparer.Compare(arr[mid], value) < 0)
low = mid + 1;
else
high = mid;
}
return low;
}
//引数省略のオーバーロード
public static int LowerBound<T>(IReadOnlyList<T> arr, T value)
where T : IComparable {
return LowerBound(arr, 0, arr.Count, value, Comparer<T>.Default);
}
/// <summary>
/// 指定した値より大きい先頭のインデクスを返す
/// </summary>
/// <typeparam name="T">比較する値の型</typeparam>
/// <param name="arr">対象の配列(※ソート済みであること)</param>
/// <param name="start">開始インデクス [inclusive]</param>
/// <param name="end">終了インデクス [exclusive]</param>
/// <param name="value">検索する値</param>
/// <param name="comparer">比較関数(インターフェイス)</param>
/// <returns>指定した値より大きい先頭のインデクス</returns>
public static int UpperBound<T>(IReadOnlyList<T> arr, int start, int end,
T value, IComparer<T> comparer) {
int low = start;
int high = end;
int mid;
while (low < high) {
mid = ((high - low) >> 1) + low;
if (comparer.Compare(arr[mid], value) <= 0)
low = mid + 1;
else
high = mid;
}
return low;
}
//引数省略のオーバーロード
public static int UpperBound<T>(IReadOnlyList<T> arr, T value) {
return UpperBound(arr, 0, arr.Count, value, Comparer<T>.Default);
}
#endregion
}
public class DisjointSet {
private int[] rank;
private int[] p;
private int[] size;
public DisjointSet(int n) {
rank = new int[n];
p = new int[n];
size = new int[n];
for (int i = 0; i < n; ++i) {
MakeSet(i);
}
}
public void MakeSet(int x) {
p[x] = x;
rank[x] = 0;
size[x] = 1;
}
public bool IsSame(int x, int y) { return FindSet(x) == FindSet(y); }
public void Unite(int x, int y) { Link(FindSet(x), FindSet(y)); }
public void Link(int x, int y) {
if (rank[x] > rank[y]) {
p[y] = x;
size[x] += size[y];
size[y] = 0;
} else {
p[x] = y;
size[y] += size[x];
size[x] = 0;
if (rank[x] == rank[y]) {
rank[y]++;
}
}
}
public int FindSet(int x) {
if (x != p[x]) {
p[x] = FindSet(p[x]);
}
return p[x];
}
public int Size(int x) {
int root = FindSet(x);
return size[root];
}
}
public class PriorityQueue<T>
where T : IComparable {
private IComparer<T> _comparer = null;
private int _type = 0;
private T[] _heap;
private int _sz = 0;
private int _count = 0;
/// <summary>
/// Priority Queue with custom comparer
/// </summary>
public PriorityQueue(int maxSize, IComparer<T> comparer) {
_heap = new T[maxSize];
_comparer = comparer;
}
/// <summary>
/// Priority queue
/// </summary>
/// <param name="maxSize">max size</param>
/// <param name="type">0: asc, 1:desc</param>
public PriorityQueue(int maxSize, int type = 0) {
_heap = new T[maxSize];
_type = type;
}
private int Compare(T x, T y) {
if (_comparer != null)
return _comparer.Compare(x, y);
return _type == 0 ? x.CompareTo(y) : y.CompareTo(x);
}
public void Push(T x) {
_count++;
// node number
var i = _sz++;
while (i > 0) {
// parent node number
var p = (i - 1) / 2;
if (Compare(_heap[p], x) <= 0)
break;
_heap[i] = _heap[p];
i = p;
}
_heap[i] = x;
}
public T Pop() {
_count--;
T ret = _heap[0];
T x = _heap[--_sz];
int i = 0;
while (i * 2 + 1 < _sz) {
// children
int a = i * 2 + 1;
int b = i * 2 + 2;
if (b < _sz && Compare(_heap[b], _heap[a]) < 0)
a = b;
if (Compare(_heap[a], x) >= 0)
break;
_heap[i] = _heap[a];
i = a;
}
_heap[i] = x;
return ret;
}
public int Count() { return _count; }
public T Peek() { return _heap[0]; }
public bool Contains(T x) {
for (int i = 0; i < _sz; i++)
if (x.Equals(_heap[i]))
return true;
return false;
}
public void Clear() {
while (this.Count() > 0)
this.Pop();
}
public IEnumerator<T> GetEnumerator() {
var ret = new List<T>();
while (this.Count() > 0) {
ret.Add(this.Pop());
}
foreach (var r in ret) {
this.Push(r);
yield return r;
}
}
public T[] ToArray() {
T[] array = new T[_sz];
int i = 0;
foreach (var r in this) {
array[i++] = r;
}
return array;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
namespace Practice {
class Program {
static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
private const int MOD = 1000000007;
private const int MAX = 1000001;
static long[] fac = new long[MAX];
static long[] finv = new long[MAX];
static long[] inv = new long[MAX];
static void Solve() {
long h = Input.NextLong();
int n = Input.NextInt();
var a = new long[n];
var b = new long[n];
for (int i = 0; i < n; ++i) {
a[i] = Input.NextLong();
b[i] = Input.NextLong();
}
long amax = a.Max();
long len = h + amax;
var dp = new long[n + 2, len];
for (int i = 0; i < dp.GetLength(0); ++i) {
for (int j = 0; j < dp.GetLength(1); ++j) {
dp[i, j] = long.MaxValue / 10;
}
}
for (int i = 0; i < dp.GetLength(0); ++i) {
dp[0, 0] = 0; // 与えたダメージ0なら消費魔力0
}
for (int i = 0; i < n; ++i) {
for (long j = 0; j < dp.GetLength(1); ++j) {
dp[i + 1, j] = Math.Min(dp[i + 1, j], dp[i, j]);
if (j >= a[i]) {
dp[i + 1, j] = Math.Min(dp[i + 1, j], dp[i + 1, j - a[i]] + b[i]);
}
}
}
long ans = int.MaxValue;
for (int j = (int)h; j < dp.GetLength(1); ++j) {
ans = Math.Min(dp[n, j], ans);
}
Console.WriteLine(ans);
}
#region よく使う便利関数
private static Dictionary<long, int> Factorize(long n) {
var dic = new Dictionary<long, int>();
for (long i = 2; i * i <= n; ++i) {
while (n % i == 0) {
if (!dic.ContainsKey(i)) {
dic.Add(i, 0);
}
dic[i]++;
n /= i;
}
}
if (n != 1) {
dic.Add(n, 1);
}
return dic;
}
static void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
static long COM(long n, long k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
static class Input {
static char[] separator = { ' ' };
public static bool IsEof { get; set; }
static Queue<string> q { get; set; }
static Input() {
IsEof = false;
q = new Queue<string>();
}
/// <summary>
/// 入力予約
/// </summary>
/// <param name="items"></param>
public static void SetText(IEnumerable<string> items) {
foreach (var item in items) {
SetText(item);
}
}
/// <summary>
/// 入力予約
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static bool SetText(string s) {
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
q.Enqueue(elem);
}
return true;
}
/// <summary>
/// 内部queueに入力からの値をsplitして格納する
/// </summary>
/// <returns></returns>
static bool read() {
var s = Console.ReadLine();
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
q.Enqueue(elem);
}
if (!q.Any())
return read();
return true;
}
/// <summary>
/// 次のstringを一つ読み込む
/// </summary>
/// <returns></returns>
public static string Next() {
if (!q.Any()) {
if (!read()) {
IsEof = true;
return "";
}
}
return q.Dequeue();
}
public static int NextInt() => int.Parse(Next());
public static long NextLong() => long.Parse(Next());
public static double NextDouble() => double.Parse(Next());
public static List<string>
Next(int n) => Enumerable.Range(0, n).Select(_ => Next()).ToList();
public static List<int>
NextInt(int n) => Next(n).Select(x => int.Parse(x)).ToList();
public static List<long>
NextLong(int n) => Next(n).Select(x => long.Parse(x)).ToList();
public static List<double>
NextDouble(int n) => Next(n).Select(x => double.Parse(x)).ToList();
public static List<string>
NextLine() => Console.ReadLine()
.Trim()
.Split(separator, StringSplitOptions.RemoveEmptyEntries)
.ToList();
public static List<int>
NextIntLine() => NextLine().Select(x => int.Parse(x)).ToList();
public static List<long>
NextLongLine() => NextLine().Select(x => long.Parse(x)).ToList();
public static List<double>
NextDoubleLine() => NextLine().Select(x => double.Parse(x)).ToList();
}
private static bool isPrime(long x) {
if (x == 2) {
return true;
}
if (x < 2 || x % 2 == 0) {
return false;
}
long i = 3;
while (i * i <= x) {
if (x % i == 0) {
return false;
}
i = i + 2;
}
return true;
}
private static long lcm(long x, long y) { return x / gcd(x, y) * y; }
private static long gcd(long x, long y) { return y > 0 ? gcd(y, x % y) : x; }
private static long pow(long x, long n) {
if (n == 0) {
return 1;
}
long res = pow(x * x % MOD, n / 2);
if (n % 2 == 1) {
res = res * x % MOD;
}
return res;
}
private static void Swap<T>(ref T x, ref T y) {
T t = x;
x = y;
y = t;
}
/// <summary>
/// 指定した値以上の先頭のインデクスを返す
/// </summary>
/// <typeparam name="T">比較する値の型</typeparam>
/// <param name="arr">対象の配列(※ソート済みであること)</param>
/// <param name="start">開始インデクス [inclusive]</param>
/// <param name="end">終了インデクス [exclusive]</param>
/// <param name="value">検索する値</param>
/// <param name="comparer">比較関数(インターフェイス)</param>
/// <returns>指定した値以上の先頭のインデクス</returns>
public static int LowerBound<T>(IReadOnlyList<T> arr, int start, int end,
T value, IComparer<T> comparer) {
int low = start;
int high = end;
int mid;
while (low < high) {
mid = ((high - low) >> 1) + low;
if (comparer.Compare(arr[mid], value) < 0)
low = mid + 1;
else
high = mid;
}
return low;
}
//引数省略のオーバーロード
public static int LowerBound<T>(IReadOnlyList<T> arr, T value)
where T : IComparable {
return LowerBound(arr, 0, arr.Count, value, Comparer<T>.Default);
}
/// <summary>
/// 指定した値より大きい先頭のインデクスを返す
/// </summary>
/// <typeparam name="T">比較する値の型</typeparam>
/// <param name="arr">対象の配列(※ソート済みであること)</param>
/// <param name="start">開始インデクス [inclusive]</param>
/// <param name="end">終了インデクス [exclusive]</param>
/// <param name="value">検索する値</param>
/// <param name="comparer">比較関数(インターフェイス)</param>
/// <returns>指定した値より大きい先頭のインデクス</returns>
public static int UpperBound<T>(IReadOnlyList<T> arr, int start, int end,
T value, IComparer<T> comparer) {
int low = start;
int high = end;
int mid;
while (low < high) {
mid = ((high - low) >> 1) + low;
if (comparer.Compare(arr[mid], value) <= 0)
low = mid + 1;
else
high = mid;
}
return low;
}
//引数省略のオーバーロード
public static int UpperBound<T>(IReadOnlyList<T> arr, T value) {
return UpperBound(arr, 0, arr.Count, value, Comparer<T>.Default);
}
#endregion
}
public class DisjointSet {
private int[] rank;
private int[] p;
private int[] size;
public DisjointSet(int n) {
rank = new int[n];
p = new int[n];
size = new int[n];
for (int i = 0; i < n; ++i) {
MakeSet(i);
}
}
public void MakeSet(int x) {
p[x] = x;
rank[x] = 0;
size[x] = 1;
}
public bool IsSame(int x, int y) { return FindSet(x) == FindSet(y); }
public void Unite(int x, int y) { Link(FindSet(x), FindSet(y)); }
public void Link(int x, int y) {
if (rank[x] > rank[y]) {
p[y] = x;
size[x] += size[y];
size[y] = 0;
} else {
p[x] = y;
size[y] += size[x];
size[x] = 0;
if (rank[x] == rank[y]) {
rank[y]++;
}
}
}
public int FindSet(int x) {
if (x != p[x]) {
p[x] = FindSet(p[x]);
}
return p[x];
}
public int Size(int x) {
int root = FindSet(x);
return size[root];
}
}
public class PriorityQueue<T>
where T : IComparable {
private IComparer<T> _comparer = null;
private int _type = 0;
private T[] _heap;
private int _sz = 0;
private int _count = 0;
/// <summary>
/// Priority Queue with custom comparer
/// </summary>
public PriorityQueue(int maxSize, IComparer<T> comparer) {
_heap = new T[maxSize];
_comparer = comparer;
}
/// <summary>
/// Priority queue
/// </summary>
/// <param name="maxSize">max size</param>
/// <param name="type">0: asc, 1:desc</param>
public PriorityQueue(int maxSize, int type = 0) {
_heap = new T[maxSize];
_type = type;
}
private int Compare(T x, T y) {
if (_comparer != null)
return _comparer.Compare(x, y);
return _type == 0 ? x.CompareTo(y) : y.CompareTo(x);
}
public void Push(T x) {
_count++;
// node number
var i = _sz++;
while (i > 0) {
// parent node number
var p = (i - 1) / 2;
if (Compare(_heap[p], x) <= 0)
break;
_heap[i] = _heap[p];
i = p;
}
_heap[i] = x;
}
public T Pop() {
_count--;
T ret = _heap[0];
T x = _heap[--_sz];
int i = 0;
while (i * 2 + 1 < _sz) {
// children
int a = i * 2 + 1;
int b = i * 2 + 2;
if (b < _sz && Compare(_heap[b], _heap[a]) < 0)
a = b;
if (Compare(_heap[a], x) >= 0)
break;
_heap[i] = _heap[a];
i = a;
}
_heap[i] = x;
return ret;
}
public int Count() { return _count; }
public T Peek() { return _heap[0]; }
public bool Contains(T x) {
for (int i = 0; i < _sz; i++)
if (x.Equals(_heap[i]))
return true;
return false;
}
public void Clear() {
while (this.Count() > 0)
this.Pop();
}
public IEnumerator<T> GetEnumerator() {
var ret = new List<T>();
while (this.Count() > 0) {
ret.Add(this.Pop());
}
foreach (var r in ret) {
this.Push(r);
yield return r;
}
}
public T[] ToArray() {
T[] array = new T[_sz];
int i = 0;
foreach (var r in this) {
array[i++] = r;
}
return array;
}
}
}
|
[["-", 0, 200, 0, 212, 0, 16, 31, 16, 31, 22], ["-", 0, 200, 0, 212, 0, 16, 31, 16, 17, 48], ["-", 0, 212, 0, 16, 31, 16, 12, 23, 0, 24], ["-", 12, 23, 0, 16, 31, 16, 31, 23, 0, 24], ["-", 0, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["-", 0, 16, 31, 16, 31, 23, 0, 16, 12, 203], ["-", 12, 23, 0, 16, 31, 16, 31, 23, 0, 25], ["-", 31, 16, 12, 23, 0, 16, 31, 16, 17, 85], ["-", 31, 16, 12, 23, 0, 16, 31, 16, 12, 22], ["-", 0, 16, 31, 16, 12, 23, 0, 16, 17, 72], ["-", 0, 16, 31, 16, 12, 23, 0, 16, 12, 203], ["-", 0, 212, 0, 16, 31, 16, 12, 23, 0, 25], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["-", 0, 11, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 11, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 198, 0, 200, 0, 212, 0, 214, 205, 199], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 205, 199]]
| 8
| 2,749
| 18
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
namespace A {
class StartingPoint {
static void Main(string[] args) {
if (args?.Any() == true) {
var assembly = Assembly.GetEntryAssembly();
var resourceName = "AtCoderCSharp.In.txt";
var stream = assembly.GetManifestResourceStream(resourceName);
var streamReader = new StreamReader(stream, Encoding.UTF8);
var str = streamReader.ReadToEnd();
var textReader = new StringReader(str);
Console.SetIn(textReader);
}
try {
foreach (var s in new Program().Solve()) {
Console.WriteLine(s);
}
} catch (Exception e) {
Console.WriteLine(e);
if (args?.Any() != true)
throw e;
}
if (args?.Any() == true)
Console.ReadKey();
}
}
class Program {
public List<int> ScanInts(int count) =>
Enumerable.Range(0, count).Select(_ => ScanInt).ToList();
public List<int> ScanInts(long count) => ScanInts((int)count);
public List<long>
ScanLongs(int count) => Enumerable.Range(0, count).Select(_ => Scan).ToList();
public List<long> ScanLongs(long count) => ScanLongs((int)count);
public int ScanInt => int.Parse(Str);
public long Scan => long.Parse(Str);
public double ScanDouble => (double)Scan;
StringBuilder sb = new StringBuilder();
public string Str => ScanStr();
public string ScanStr() {
sb.Clear();
int r = 0;
bool? b = null;
do {
r = Console.Read();
b = IsBreak(r);
} while (b == true);
if (b == null)
throw new Exception("input error: unexpected end of stream");
do {
sb.Append((char)r);
r = Console.Read();
b = IsBreak(r);
} while (b == false);
return sb.ToString();
}
bool? IsBreak(int c) {
switch (c) {
case -1:
return null;
case (int)' ':
case (int)'\n':
case (int)'\r':
return true;
default:
return false;
}
}
public IEnumerable<int> Loop(int count) => Enumerable.Range(0, count);
public IEnumerable<int> Loop(int from,
int to) => Enumerable.Range(from, to - from + 1);
public IEnumerable<long> Loop(long count) => Loop(0, count - 1);
public IEnumerable<long> Loop(long from, long to) {
for (long i = from; i <= to; i++)
yield return i;
}
public string YesNo(bool isYes) => isYes ? "Yes" : "No";
public HashSet<T> ToHashSet<T>(IEnumerable<T> ts) => new HashSet<T>(ts);
public class M {
public int a;
public int b;
}
public IEnumerable<string> Solve() {
var h = ScanInt;
var n = ScanInt;
var ms = new List<M>();
foreach (var i in Loop(n)) {
ms.Add(new M() { a = ScanInt, b = ScanInt });
}
// var r = new Random();
// foreach (var i in Loop(1000))
//{
// ms.Add(new M() { a = r.Next(), b = r.Next() });
//}
var dict = new Dictionary<long, long>();
dict.Add(0, 0);
var res = 0L;
for (int key = 0; key < 10001; key++) {
if (dict.ContainsKey(key) == false)
continue;
var value = dict[key];
if (key >= h) {
res = dict[key];
break;
}
foreach (var m in ms) {
var newKey = Math.Min(10000, key + m.a);
var newValue = value + m.b;
var val = 0L;
if (dict.TryGetValue(newKey, out val)) {
if (val > newValue)
dict[newKey] = newValue;
} else {
dict.Add(newKey, newValue);
}
}
dict.Remove(key);
}
yield return res.ToString();
}
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
namespace A {
class StartingPoint {
static void Main(string[] args) {
if (args?.Any() == true) {
var assembly = Assembly.GetEntryAssembly();
var resourceName = "AtCoderCSharp.In.txt";
var stream = assembly.GetManifestResourceStream(resourceName);
var streamReader = new StreamReader(stream, Encoding.UTF8);
var str = streamReader.ReadToEnd();
var textReader = new StringReader(str);
Console.SetIn(textReader);
}
try {
foreach (var s in new Program().Solve()) {
Console.WriteLine(s);
}
} catch (Exception e) {
Console.WriteLine(e);
if (args?.Any() != true)
throw e;
}
if (args?.Any() == true)
Console.ReadKey();
}
}
class Program {
public List<int> ScanInts(int count) =>
Enumerable.Range(0, count).Select(_ => ScanInt).ToList();
public List<int> ScanInts(long count) => ScanInts((int)count);
public List<long>
ScanLongs(int count) => Enumerable.Range(0, count).Select(_ => Scan).ToList();
public List<long> ScanLongs(long count) => ScanLongs((int)count);
public int ScanInt => int.Parse(Str);
public long Scan => long.Parse(Str);
public double ScanDouble => (double)Scan;
StringBuilder sb = new StringBuilder();
public string Str => ScanStr();
public string ScanStr() {
sb.Clear();
int r = 0;
bool? b = null;
do {
r = Console.Read();
b = IsBreak(r);
} while (b == true);
if (b == null)
throw new Exception("input error: unexpected end of stream");
do {
sb.Append((char)r);
r = Console.Read();
b = IsBreak(r);
} while (b == false);
return sb.ToString();
}
bool? IsBreak(int c) {
switch (c) {
case -1:
return null;
case (int)' ':
case (int)'\n':
case (int)'\r':
return true;
default:
return false;
}
}
public IEnumerable<int> Loop(int count) => Enumerable.Range(0, count);
public IEnumerable<int> Loop(int from,
int to) => Enumerable.Range(from, to - from + 1);
public IEnumerable<long> Loop(long count) => Loop(0, count - 1);
public IEnumerable<long> Loop(long from, long to) {
for (long i = from; i <= to; i++)
yield return i;
}
public string YesNo(bool isYes) => isYes ? "Yes" : "No";
public HashSet<T> ToHashSet<T>(IEnumerable<T> ts) => new HashSet<T>(ts);
public class M {
public int a;
public int b;
}
public IEnumerable<string> Solve() {
var h = ScanInt;
var n = ScanInt;
var ms = new List<M>();
foreach (var i in Loop(n)) {
ms.Add(new M() { a = ScanInt, b = ScanInt });
}
// var r = new Random();
// foreach (var i in Loop(1000))
//{
// ms.Add(new M() { a = r.Next(), b = r.Next() });
//}
var dict = new Dictionary<long, long>();
dict.Add(0, 0);
var res = 0L;
for (int key = 0; key < 10001; key++) {
if (dict.ContainsKey(key) == false)
continue;
var value = dict[key];
if (key >= h) {
res = dict.Values.OrderBy(x => x).First();
break;
}
foreach (var m in ms) {
var newKey = Math.Min(10000, key + m.a);
var newValue = value + m.b;
var val = 0L;
if (dict.TryGetValue(newKey, out val)) {
if (val > newValue)
dict[newKey] = newValue;
} else {
dict.Add(newKey, newValue);
}
}
dict.Remove(key);
}
yield return res.ToString();
}
}
}
|
[["-", 0, 1, 0, 11, 12, 204, 206, 207, 0, 70], ["-", 0, 11, 12, 204, 206, 207, 0, 28, 0, 22], ["-", 0, 1, 0, 11, 12, 204, 206, 207, 0, 73], ["+", 63, 214, 205, 213, 63, 214, 205, 214, 0, 131], ["+", 63, 214, 205, 213, 63, 214, 205, 214, 141, 22], ["+", 12, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["+", 12, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 12, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["+", 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], ["+", 12, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25]]
| 8
| 906
| 16
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
// using System.Numerics;
using System.Runtime.CompilerServices;
using System.Diagnostics;
using ll=System.Int64;
using static Contest_F.Lib_IO;
using static Contest_F.Lib_Minifunc;
public static class Contest_F
{
public static void Main() {
checked{
long n, d,a;
Lib_IO.rm(out n, out d,out a);
P<ll,ll>[] xhl;
rl(n,out xhl);
Array.Sort(xhl,(x,y)=>x.A.CompareTo(y.A));
BinaryIndexedTree bit = new BinaryIndexedTree(n+1);
ll ans = 0;
for (int i = 0; i < n; i++)
{
ll v = ceiling(xhl[i].B-bit.Sum(i)*a,a);
if(v==0)continue;
ans += v;
ll idx = BS(xhl,xhl[i].A+2*d);
bit.Add(i,v);
bit.Add(idx,-v);
}
Lib_IO.wm(ans);
}
}
public class BinaryIndexedTree {
private long[] data;
public BinaryIndexedTree(long sz) { data = new long[++sz]; }
public long Sum(long k) {
long ret = 0;
for(++k; k > 0; k -= k & -k) ret += data[k];
return (ret);
}
public void Add(long k, long x) { for(++k; k < data.Length; k += k & -k) data[k] += x; }
}
public static long BS<T>(P<T,T>[] seq, T value) where T : IComparable<T> {
int left = -1;
int right = seq.Length;
while (right - left > 1) {
int mid = left + (right - left) / 2;
if (0<seq[mid].A.CompareTo(value)) right = mid;
else left = mid;
}
return right;
}
#region BaseModule
public static class Lib_Minifunc{
[MethodImpl(256)] public static void swap1<T>(ref T a, ref T b) { T t = a; a = b; b = t; }
[MethodImpl(256)] public static void swap2<T>(ref T a, ref T b) where T : IComparable { if (a.CompareTo(b)==1) swap1(ref a, ref b); } // b の方が小さければ交換
[MethodImpl(256)] public static bool chmin<T>(ref T a, T b) where T : IComparable { if (a.CompareTo(b)== 1) { a = b; return true; } return false; } // b の方が小さければ a を更新
[MethodImpl(256)] public static bool chmax<T>(ref T a, T b) where T : IComparable { if (a.CompareTo(b)==-1) { a = b; return true; } return false; } // b の方が大きければ a を更新
[MethodImpl(256)] public static bool inside(long i, long n) => (0<=i&&i<n);
[MethodImpl(256)] public static bool inside(long x, long y, long w, long h) => (inside(x,w)&&inside(y,h));
[MethodImpl(256)] public static T min<T>(params T[] a) where T : IComparable => a.Min();
[MethodImpl(256)] public static T max<T>(params T[] a) where T : IComparable => a.Max();
[MethodImpl(256)] public static long mod(long a, long m=MOD1) { var v = a%m; return (v<0?v+m:v); }
[MethodImpl(256)] public static long ceiling(long a, long b) => (a%b==0||a*b<0?a/b:a/b+1); // 整数商の切り上げ
[MethodImpl(256)] public static P<T,U> initp<T,U>(T a,U b) => new P<T,U>(a,b);
[MethodImpl(256)] public static P<T,U,V> initp<T,U,V>(T a,U b,V c) => new P<T,U,V>(a,b,c);
[MethodImpl(256)] public static P<T,U,V,W> initp<T,U,V,W>(T a,U b,V c,W d) => new P<T,U,V,W>(a,b,c,d);
public static T[][] initm<T>(long len1,long len2,T val) where T : struct { var m = new T[len1][]; for (int i=0;i<m.Length;i++) m[i] = Enumerable.Repeat(val,(int)len2).ToArray(); return m; }
public static T[][][] initm<T>(long len1,long len2,long len3,T val) where T : struct { var m = new T[len1][][]; for (int i=0;i<m.Length;i++) m[i] = initm(len2,len3,val); return m; }
public const long MOD1 = 1000000007; // 10^9+7
public const double EPS1 = 1e-8;
public const long INF1 = 1000000000000000; // 10^15
}
public struct P<T,U>
{
public T A; public U B;
public P(T a,U b) { A = a; B = b; }
public static implicit operator KeyValuePair<T,U>(P<T,U> a) => new KeyValuePair<T,U>(a.A,a.B);
public static implicit operator P<T,U>(KeyValuePair<T,U> a) => new P<T,U>(a.Key,a.Value);
}
public struct P<T,U,V>
{
public T A; public U B; public V C;
public P(T a,U b,V c) { A = a; B = b; C = c; }
}
public struct P<T,U,V,W>
{
public T A; public U B; public V C; public W D;
public P(T a,U b,V c,W d) { A = a; B = b; C = c; D = d; }
}
public static class Lib_IO
{
class Prt : System.IO.StreamWriter
{
public override IFormatProvider FormatProvider { get { return System.Globalization.CultureInfo.InvariantCulture; } }
public Prt(System.IO.Stream s) : base(s,new UTF8Encoding(false,true)) {}
public Prt(System.IO.Stream s,Encoding e) : base(s,e) {}
}
static Prt sw = new Prt(Console.OpenStandardOutput());
static char[] sp = new char[] {' '};
[MethodImpl(256)] static bool eq<T,U>() => typeof(T).Equals(typeof(U));
[MethodImpl(256)] static T ct<T,U>(U a) => (T)Convert.ChangeType(a,typeof(T));
[MethodImpl(256)] static T cv<T>(string s) =>
eq<T,int>() ? ct<T,int>(int.Parse(s))
: eq<T,long>() ? ct<T,long>(long.Parse(s))
: eq<T,double>() ? ct<T,double>(double.Parse(s,System.Globalization.CultureInfo.InvariantCulture))
: eq<T,char>() ? ct<T,char>(s[0])
: ct<T,string>(s);
public static string[] rm<T>(out T a) {
var z = Console.ReadLine().Split(sp,StringSplitOptions.RemoveEmptyEntries);
a = cv<T>(z[0]);
return z;
}
public static string[] rm<T,U>(out T a,out U b) {
var z = rm<T>(out a);
b = cv<U>(z[1]);
return z;
}
public static string[] rm<T,U,V>(out T a,out U b,out V c) {
var z = rm<T,U>(out a,out b);
c = cv<V>(z[2]);
return z;
}
public static string[] rm<T,U,V,W>(out T a,out U b,out V c,out W d) {
var z = rm<T,U,V>(out a,out b,out c);
d = cv<W>(z[3]);
return z;
}
public static string[] rm<T,U,V,W,X>(out T a,out U b,out V c,out W d,out X e) {
var z = rm<T,U,V,W>(out a,out b,out c,out d);
e = cv<X>(z[4]);
return z;
}
public static string[] rm<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 z = rm<T,U,V,W,X>(out a,out b,out c,out d,out e);
f = cv<Y>(z[5]);
return z;
}
public static string[] ra<T>(out T[] a) {
var z = Console.ReadLine().Split(sp,StringSplitOptions.RemoveEmptyEntries);
a = z.Select(cv<T>).ToArray();
return z;
}
public static string[][] rl<T>(long n,out T[] a) {
a = new T[n];
var y = new string[n][];
for(int i=0;i<n;i++) y[i] = rm(out a[i]);
return y;
}
public static string[][] rl<T,U>(long n,out P<T,U>[] a) {
a = new P<T,U>[n];
var y = new string[n][];
for(int i=0;i<n;i++) {
T o; U p;
y[i] = rm(out o,out p);
a[i] = new P<T,U>(o,p);
}
return y;
}
public static string[][] rl<T,U,V>(long n,out P<T,U,V>[] a) {
a = new P<T,U,V>[n];
var y = new string[n][];
for(int i=0;i<n;i++) {
T o; U p; V q;
y[i] = rm(out o,out p,out q);
a[i] = new P<T,U,V>(o,p,q);
}
return y;
}
public static string[][] rl<T,U,V,W>(long n,out P<T,U,V,W>[] a) {
a = new P<T,U,V,W>[n];
var y = new string[n][];
for(int i=0;i<n;i++) {
T o; U p; V q; W r;
y[i] = rm(out o,out p,out q,out r);
a[i] = new P<T,U,V,W>(o,p,q,r);
}
return y;
}
public static string[][] rx<T>(long n,out T[][] a) {
a = new T[n][];
var y = new string[n][];
for(int i=0;i<n;i++) y[i] = ra(out a[i]);
return y;
}
static void wwp(Action act){
sw.AutoFlush = false;
Console.SetOut(sw);
act();
Console.Out.Flush();
sw.AutoFlush = true;
Console.SetOut(sw);
}
[MethodImpl(256)] static string wfm(Type t) =>t.Equals(typeof(double)) ? "{0:F10}" : "{0}";
public static void wm(params object[] a) {
wwp(()=>{
for(int i=0;i<a.Length;i++) {
var f = wfm(a[i].GetType()) + ((i<a.Length-1) ? " " : Environment.NewLine);
Console.Write(f,a[i]);
}
});
}
public static void wa<T>(IList<T> a) {
wwp(()=>{
var f = wfm(typeof(T));
var g = f + " ";
var h = f + Environment.NewLine;
for(int i=0;i<a.Count;i++) Console.Write(((i<a.Count-1) ? g : h),a[i]);
});
}
public static void wl<T>(IList<T> a) {
wwp(()=>{
var f = wfm(typeof(T)) + Environment.NewLine;
foreach(T x in a) Console.Write(f,x);
});
}
}
#endregion
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
// using System.Numerics;
using System.Runtime.CompilerServices;
using System.Diagnostics;
using ll=System.Int64;
using static Contest_F.Lib_IO;
using static Contest_F.Lib_Minifunc;
public static class Contest_F
{
public static void Main() {
checked{
long n, d,a;
Lib_IO.rm(out n, out d,out a);
P<ll,ll>[] xhl;
rl(n,out xhl);
Array.Sort(xhl,(x,y)=>x.A.CompareTo(y.A));
BinaryIndexedTree bit = new BinaryIndexedTree(n+1);
ll ans = 0;
for (int i = 0; i < n; i++)
{
ll v = ceiling(xhl[i].B-bit.Sum(i)*a,a);
if(v<=0)continue;
ans += v;
ll idx = BS(xhl,xhl[i].A+2*d);
bit.Add(i,v);
bit.Add(idx,-v);
}
Lib_IO.wm(ans);
}
}
public class BinaryIndexedTree {
private long[] data;
public BinaryIndexedTree(long sz) { data = new long[++sz]; }
public long Sum(long k) {
long ret = 0;
for(++k; k > 0; k -= k & -k) ret += data[k];
return (ret);
}
public void Add(long k, long x) { for(++k; k < data.Length; k += k & -k) data[k] += x; }
}
public static long BS<T>(P<T,T>[] seq, T value) where T : IComparable<T> {
int left = -1;
int right = seq.Length;
while (right - left > 1) {
int mid = left + (right - left) / 2;
if (0<seq[mid].A.CompareTo(value)) right = mid;
else left = mid;
}
return right;
}
#region BaseModule
public static class Lib_Minifunc{
[MethodImpl(256)] public static void swap1<T>(ref T a, ref T b) { T t = a; a = b; b = t; }
[MethodImpl(256)] public static void swap2<T>(ref T a, ref T b) where T : IComparable { if (a.CompareTo(b)==1) swap1(ref a, ref b); } // b の方が小さければ交換
[MethodImpl(256)] public static bool chmin<T>(ref T a, T b) where T : IComparable { if (a.CompareTo(b)== 1) { a = b; return true; } return false; } // b の方が小さければ a を更新
[MethodImpl(256)] public static bool chmax<T>(ref T a, T b) where T : IComparable { if (a.CompareTo(b)==-1) { a = b; return true; } return false; } // b の方が大きければ a を更新
[MethodImpl(256)] public static bool inside(long i, long n) => (0<=i&&i<n);
[MethodImpl(256)] public static bool inside(long x, long y, long w, long h) => (inside(x,w)&&inside(y,h));
[MethodImpl(256)] public static T min<T>(params T[] a) where T : IComparable => a.Min();
[MethodImpl(256)] public static T max<T>(params T[] a) where T : IComparable => a.Max();
[MethodImpl(256)] public static long mod(long a, long m=MOD1) { var v = a%m; return (v<0?v+(m<0?-m:m):v); }
[MethodImpl(256)] public static long ceiling(long a, long b) => (a%b==0||(a<0&&0<b)||(0<a&&b<0)?a/b:a/b+1); // 整数商の切り上げ
[MethodImpl(256)] public static P<T,U> initp<T,U>(T a,U b) => new P<T,U>(a,b);
[MethodImpl(256)] public static P<T,U,V> initp<T,U,V>(T a,U b,V c) => new P<T,U,V>(a,b,c);
[MethodImpl(256)] public static P<T,U,V,W> initp<T,U,V,W>(T a,U b,V c,W d) => new P<T,U,V,W>(a,b,c,d);
public static T[][] initm<T>(long len1,long len2,T val) where T : struct { var m = new T[len1][]; for (int i=0;i<m.Length;i++) m[i] = Enumerable.Repeat(val,(int)len2).ToArray(); return m; }
public static T[][][] initm<T>(long len1,long len2,long len3,T val) where T : struct { var m = new T[len1][][]; for (int i=0;i<m.Length;i++) m[i] = initm(len2,len3,val); return m; }
public const long MOD1 = 1000000007; // 10^9+7
public const double EPS1 = 1e-8;
public const long INF1 = 1000000000000000; // 10^15
}
public struct P<T,U>
{
public T A; public U B;
public P(T a,U b) { A = a; B = b; }
public static implicit operator KeyValuePair<T,U>(P<T,U> a) => new KeyValuePair<T,U>(a.A,a.B);
public static implicit operator P<T,U>(KeyValuePair<T,U> a) => new P<T,U>(a.Key,a.Value);
}
public struct P<T,U,V>
{
public T A; public U B; public V C;
public P(T a,U b,V c) { A = a; B = b; C = c; }
}
public struct P<T,U,V,W>
{
public T A; public U B; public V C; public W D;
public P(T a,U b,V c,W d) { A = a; B = b; C = c; D = d; }
}
public static class Lib_IO
{
class Prt : System.IO.StreamWriter
{
public override IFormatProvider FormatProvider { get { return System.Globalization.CultureInfo.InvariantCulture; } }
public Prt(System.IO.Stream s) : base(s,new UTF8Encoding(false,true)) {}
public Prt(System.IO.Stream s,Encoding e) : base(s,e) {}
}
static Prt sw = new Prt(Console.OpenStandardOutput());
static char[] sp = new char[] {' '};
[MethodImpl(256)] static bool eq<T,U>() => typeof(T).Equals(typeof(U));
[MethodImpl(256)] static T ct<T,U>(U a) => (T)Convert.ChangeType(a,typeof(T));
[MethodImpl(256)] static T cv<T>(string s) =>
eq<T,int>() ? ct<T,int>(int.Parse(s))
: eq<T,long>() ? ct<T,long>(long.Parse(s))
: eq<T,double>() ? ct<T,double>(double.Parse(s,System.Globalization.CultureInfo.InvariantCulture))
: eq<T,char>() ? ct<T,char>(s[0])
: ct<T,string>(s);
public static string[] rm<T>(out T a) {
var z = Console.ReadLine().Split(sp,StringSplitOptions.RemoveEmptyEntries);
a = cv<T>(z[0]);
return z;
}
public static string[] rm<T,U>(out T a,out U b) {
var z = rm<T>(out a);
b = cv<U>(z[1]);
return z;
}
public static string[] rm<T,U,V>(out T a,out U b,out V c) {
var z = rm<T,U>(out a,out b);
c = cv<V>(z[2]);
return z;
}
public static string[] rm<T,U,V,W>(out T a,out U b,out V c,out W d) {
var z = rm<T,U,V>(out a,out b,out c);
d = cv<W>(z[3]);
return z;
}
public static string[] rm<T,U,V,W,X>(out T a,out U b,out V c,out W d,out X e) {
var z = rm<T,U,V,W>(out a,out b,out c,out d);
e = cv<X>(z[4]);
return z;
}
public static string[] rm<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 z = rm<T,U,V,W,X>(out a,out b,out c,out d,out e);
f = cv<Y>(z[5]);
return z;
}
public static string[] ra<T>(out T[] a) {
var z = Console.ReadLine().Split(sp,StringSplitOptions.RemoveEmptyEntries);
a = z.Select(cv<T>).ToArray();
return z;
}
public static string[][] rl<T>(long n,out T[] a) {
a = new T[n];
var y = new string[n][];
for(int i=0;i<n;i++) y[i] = rm(out a[i]);
return y;
}
public static string[][] rl<T,U>(long n,out P<T,U>[] a) {
a = new P<T,U>[n];
var y = new string[n][];
for(int i=0;i<n;i++) {
T o; U p;
y[i] = rm(out o,out p);
a[i] = new P<T,U>(o,p);
}
return y;
}
public static string[][] rl<T,U,V>(long n,out P<T,U,V>[] a) {
a = new P<T,U,V>[n];
var y = new string[n][];
for(int i=0;i<n;i++) {
T o; U p; V q;
y[i] = rm(out o,out p,out q);
a[i] = new P<T,U,V>(o,p,q);
}
return y;
}
public static string[][] rl<T,U,V,W>(long n,out P<T,U,V,W>[] a) {
a = new P<T,U,V,W>[n];
var y = new string[n][];
for(int i=0;i<n;i++) {
T o; U p; V q; W r;
y[i] = rm(out o,out p,out q,out r);
a[i] = new P<T,U,V,W>(o,p,q,r);
}
return y;
}
public static string[][] rx<T>(long n,out T[][] a) {
a = new T[n][];
var y = new string[n][];
for(int i=0;i<n;i++) y[i] = ra(out a[i]);
return y;
}
static void wwp(Action act){
sw.AutoFlush = false;
Console.SetOut(sw);
act();
Console.Out.Flush();
sw.AutoFlush = true;
Console.SetOut(sw);
}
[MethodImpl(256)] static string wfm(Type t) =>t.Equals(typeof(double)) ? "{0:F10}" : "{0}";
public static void wm(params object[] a) {
wwp(()=>{
for(int i=0;i<a.Length;i++) {
var f = wfm(a[i].GetType()) + ((i<a.Length-1) ? " " : Environment.NewLine);
Console.Write(f,a[i]);
}
});
}
public static void wa<T>(IList<T> a) {
wwp(()=>{
var f = wfm(typeof(T));
var g = f + " ";
var h = f + Environment.NewLine;
for(int i=0;i<a.Count;i++) Console.Write(((i<a.Count-1) ? g : h),a[i]);
});
}
public static void wl<T>(IList<T> a) {
wwp(()=>{
var f = wfm(typeof(T)) + Environment.NewLine;
foreach(T x in a) Console.Write(f,x);
});
}
}
#endregion
}
|
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 19], ["+", 0, 23, 0, 41, 64, 16, 12, 23, 0, 24], ["+", 64, 16, 12, 23, 0, 41, 15, 16, 17, 18], ["+", 64, 16, 12, 23, 0, 41, 15, 16, 12, 203], ["+", 0, 41, 64, 16, 12, 23, 0, 41, 0, 101], ["+", 64, 16, 12, 23, 0, 41, 64, 241, 0, 33], ["+", 64, 16, 12, 23, 0, 41, 64, 241, 0, 22], ["+", 0, 41, 64, 16, 12, 23, 0, 41, 0, 102], ["+", 0, 41, 64, 16, 12, 23, 0, 41, 75, 22], ["+", 0, 23, 0, 41, 64, 16, 12, 23, 0, 25], ["+", 0, 41, 15, 16, 31, 16, 12, 23, 0, 24], ["-", 0, 41, 15, 16, 12, 16, 31, 16, 17, 48], ["+", 31, 16, 12, 23, 0, 16, 31, 16, 17, 18], ["+", 31, 16, 12, 23, 0, 16, 31, 16, 12, 203], ["+", 15, 16, 31, 16, 12, 23, 0, 16, 17, 98], ["+", 31, 16, 12, 23, 0, 16, 12, 16, 31, 203], ["+", 31, 16, 12, 23, 0, 16, 12, 16, 17, 18], ["+", 0, 41, 15, 16, 31, 16, 12, 23, 0, 25], ["+", 8, 306, 0, 23, 0, 41, 15, 16, 17, 106], ["+", 0, 23, 0, 41, 15, 16, 12, 23, 0, 24], ["+", 15, 16, 12, 23, 0, 16, 31, 16, 31, 203], ["+", 15, 16, 12, 23, 0, 16, 31, 16, 17, 18], ["+", 15, 16, 12, 23, 0, 16, 31, 16, 12, 22], ["+", 0, 41, 15, 16, 12, 23, 0, 16, 17, 98], ["+", 15, 16, 12, 23, 0, 16, 12, 16, 31, 22], ["+", 0, 23, 0, 41, 15, 16, 12, 23, 0, 25]]
| 8
| 3,037
| 27
|
using System;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split();
int N = int.Parse(str[0]);
int D = int.Parse(str[1]);
int A = int.Parse(str[2]);
int[][] B = new int [N][];
for (var i = 0; i < N; i++) {
string[] str2 = Console.ReadLine().Split();
B[i] = new int[2] { int.Parse(str2[0]), int.Parse(str2[1]) };
}
Array.Sort(B, (x, y) => x[0] - y[0]);
long ans = 0;
var list = new List<long[]>();
list.Add(new long[2] { B[0][0] + D, B[0][1] });
int a1 = 0;
long m1 = B[0][1];
ans += (B[0][1] - 1) / A + 1;
m1 = ((B[0][1] - 1) / A + 1) * A;
// Console.Error.WriteLine(ans+" "+m1);
for (var i = 1; i < N; i++) {
while (a1 < list.Count) {
if (list[a1][0] < B[i][0] - D) {
m1 -= list[a1][1];
a1++;
} else {
break;
}
}
// Console.Error.WriteLine(m1);
if (B[i][1] > m1) {
long c1 = ((B[i][1] - m1 - 1) / A + 1) * A;
ans += c1 / A;
m1 += c1;
list.Add(new long[2] { B[i][0] + D, c1 });
}
// Console.Error.WriteLine(ans+" "+m1);
}
Console.WriteLine(ans);
}
}
|
using System;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split();
int N = int.Parse(str[0]);
int D = int.Parse(str[1]);
int A = int.Parse(str[2]);
int[][] B = new int [N][];
for (var i = 0; i < N; i++) {
string[] str2 = Console.ReadLine().Split();
B[i] = new int[2] { int.Parse(str2[0]), int.Parse(str2[1]) };
}
Array.Sort(B, (x, y) => x[0] - y[0]);
long ans = 0;
var list = new List<long[]>();
list.Add(new long[2] { B[0][0] + D, ((B[0][1] - 1) / A + 1) * A });
int a1 = 0;
long m1 = B[0][1];
ans += (B[0][1] - 1) / A + 1;
m1 = ((B[0][1] - 1) / A + 1) * A;
// Console.Error.WriteLine(ans+" "+m1);
for (var i = 1; i < N; i++) {
while (a1 < list.Count) {
if (list[a1][0] < B[i][0] - D) {
m1 -= list[a1][1];
a1++;
} else {
break;
}
}
// Console.Error.WriteLine(m1);
if (B[i][1] > m1) {
long c1 = ((B[i][1] - m1 - 1) / A + 1) * A;
ans += c1 / A;
m1 += c1;
list.Add(new long[2] { B[i][0] + D, c1 });
}
// Console.Error.WriteLine(ans+" "+m1);
}
Console.WriteLine(ans);
}
}
|
[["+", 0, 227, 0, 229, 0, 16, 31, 23, 0, 24], ["+", 31, 23, 0, 16, 31, 16, 31, 23, 0, 24], ["+", 0, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 16, 31, 16, 31, 23, 0, 16, 12, 203], ["+", 31, 23, 0, 16, 31, 16, 31, 23, 0, 25], ["+", 0, 16, 31, 23, 0, 16, 31, 16, 17, 85], ["+", 0, 16, 31, 23, 0, 16, 31, 16, 12, 22], ["+", 0, 229, 0, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 229, 0, 16, 31, 23, 0, 16, 12, 203], ["+", 0, 227, 0, 229, 0, 16, 31, 23, 0, 25], ["+", 0, 28, 0, 227, 0, 229, 0, 16, 17, 48], ["+", 0, 28, 0, 227, 0, 229, 0, 16, 12, 22]]
| 8
| 433
| 12
|
using System;
using System.Collections.Generic;
using System.Linq;
// namespaceの値をコンテスト名にして運用
namespace ABC152A {
class Input {
/// <summary>
/// 1行の入力を取得する
/// </summary>
/// <returns>文字列</returns>
public string String() { return Console.ReadLine(); }
/// <summary>
/// 複数行の入力を取得
/// </summary>
/// <returns>文字列の配列</returns>
public string[] ArrayString(int rowNumber) {
string[] s = new string[rowNumber];
for (int i = 0; i < rowNumber; i++) {
s[i] = String();
}
return s;
}
/// <summary>
/// 1行の入力を取得
/// </summary>
/// <returns>int型の値</returns>
public int Int() { return int.Parse(String()); }
/// <summary>
/// 1行の入力を取得
/// </summary>
/// <returns>int型の配列</returns>
public int[] ArrayInt() { return Split().Select(int.Parse).ToArray(); }
/// <summary>
/// 複数行の入力を取得
/// </summary>
/// <param name="rowNumber">行数</param>
/// <returns>int型の配列</returns>
public int[] ArrayInt(int rowNumber) {
int[] ints = new int[rowNumber];
for (int i = 0; i < rowNumber; i++) {
ints[i] = Int();
}
return ints;
}
/// <summary>
/// 1行の入力を取得
/// </summary>
/// <returns>long型の値</returns>
public long Long() { return long.Parse(String()); }
/// <summary>
/// 2つの整数が1行に書かれている入力を、2つのlongで受け取る
/// </summary>
/// <param name="A"></param>
/// <param name="B"></param>
public void Longs(ref long A, ref long B) {
var longs = ArrayLong();
A = longs[0];
B = longs[1];
}
/// <summary>
/// 3つの整数が1行に書かれている入力を、3つのlongで受け取る
/// </summary>
/// <param name="A"></param>
/// <param name="B"></param>
/// <param name="C"></param>
public void Longs(ref long A, ref long B, ref long C) {
var longs = ArrayLong();
A = longs[0];
B = longs[1];
C = longs[2];
}
/// <summary>
/// 4つの整数が1行に書かれている入力を、4つのlongで受け取る
/// </summary>
/// <param name="A"></param>
/// <param name="B"></param>
/// <param name="C"></param>
/// <param name="D"></param>
public void Longs(ref long A, ref long B, ref long C, ref long D) {
var longs = ArrayLong();
A = longs[0];
B = longs[1];
C = longs[2];
D = longs[3];
}
/// <summary>
/// 2つの整数が複数行に書かれている入力を、2つのlong[]で受け取る
/// </summary>
/// <param name="rowNumber"></param>
/// <param name="A"></param>
/// <param name="B"></param>
public void LongsArray(long rowNumber, ref long[] A, ref long[] B) {
A = new long[rowNumber];
B = new long[rowNumber];
for (int i = 0; i < rowNumber; i++) {
var l = ArrayLong();
A[i] = l[0];
B[i] = l[1];
}
}
/// <summary>
/// 3つの整数が複数行に書かれている入力を、2つのlong[]で受け取る
/// </summary>
/// <param name="rowNumber"></param>
/// <param name="A"></param>
/// <param name="B"></param>
/// <param name="C"></param>
public void LongsArray(long rowNumber, ref long[] A, ref long[] B,
ref long[] C) {
A = new long[rowNumber];
B = new long[rowNumber];
C = new long[rowNumber];
for (int i = 0; i < rowNumber; i++) {
var l = ArrayLong();
A[i] = l[0];
B[i] = l[1];
C[i] = l[2];
}
}
/// <summary>
/// 1行の入力を取得
/// </summary>
/// <returns>long型の配列</returns>
public long[] ArrayLong() { return Split().Select(long.Parse).ToArray(); }
public long[] ArrayLong(int rowNumber) {
long[] longs = new long[rowNumber];
for (int i = 0; i < rowNumber; i++) {
longs[i] = Long();
}
return longs;
}
/// <summary>
/// 1行の入力を取得
/// </summary>
/// <returns>double型の値</returns>
public double Double() { return double.Parse(String()); }
/// <summary>
/// 1行の入力を取得
/// </summary>
/// <returns>double型の配列</returns>
public double[] ArrayDouble() {
return Split().Select(double.Parse).ToArray();
}
private IEnumerable<string> Split() { return String().Split(' '); }
}
class Program {
static void Main(string[] args) {
Solver solver = new Solver();
solver.Solve();
}
}
class Solver {
public Solver() {
Input input = new Input();
long n = 0;
long m = 0;
input.Longs(ref n, ref m);
Console.WriteLine(n == m ? "Yes" : "No");
}
public void Solve() { Console.WriteLine(0); }
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
// namespaceの値をコンテスト名にして運用
namespace ABC152A {
class Input {
/// <summary>
/// 1行の入力を取得する
/// </summary>
/// <returns>文字列</returns>
public string String() { return Console.ReadLine(); }
/// <summary>
/// 複数行の入力を取得
/// </summary>
/// <returns>文字列の配列</returns>
public string[] ArrayString(int rowNumber) {
string[] s = new string[rowNumber];
for (int i = 0; i < rowNumber; i++) {
s[i] = String();
}
return s;
}
/// <summary>
/// 1行の入力を取得
/// </summary>
/// <returns>int型の値</returns>
public int Int() { return int.Parse(String()); }
/// <summary>
/// 1行の入力を取得
/// </summary>
/// <returns>int型の配列</returns>
public int[] ArrayInt() { return Split().Select(int.Parse).ToArray(); }
/// <summary>
/// 複数行の入力を取得
/// </summary>
/// <param name="rowNumber">行数</param>
/// <returns>int型の配列</returns>
public int[] ArrayInt(int rowNumber) {
int[] ints = new int[rowNumber];
for (int i = 0; i < rowNumber; i++) {
ints[i] = Int();
}
return ints;
}
/// <summary>
/// 1行の入力を取得
/// </summary>
/// <returns>long型の値</returns>
public long Long() { return long.Parse(String()); }
/// <summary>
/// 2つの整数が1行に書かれている入力を、2つのlongで受け取る
/// </summary>
/// <param name="A"></param>
/// <param name="B"></param>
public void Longs(ref long A, ref long B) {
var longs = ArrayLong();
A = longs[0];
B = longs[1];
}
/// <summary>
/// 3つの整数が1行に書かれている入力を、3つのlongで受け取る
/// </summary>
/// <param name="A"></param>
/// <param name="B"></param>
/// <param name="C"></param>
public void Longs(ref long A, ref long B, ref long C) {
var longs = ArrayLong();
A = longs[0];
B = longs[1];
C = longs[2];
}
/// <summary>
/// 4つの整数が1行に書かれている入力を、4つのlongで受け取る
/// </summary>
/// <param name="A"></param>
/// <param name="B"></param>
/// <param name="C"></param>
/// <param name="D"></param>
public void Longs(ref long A, ref long B, ref long C, ref long D) {
var longs = ArrayLong();
A = longs[0];
B = longs[1];
C = longs[2];
D = longs[3];
}
/// <summary>
/// 2つの整数が複数行に書かれている入力を、2つのlong[]で受け取る
/// </summary>
/// <param name="rowNumber"></param>
/// <param name="A"></param>
/// <param name="B"></param>
public void LongsArray(long rowNumber, ref long[] A, ref long[] B) {
A = new long[rowNumber];
B = new long[rowNumber];
for (int i = 0; i < rowNumber; i++) {
var l = ArrayLong();
A[i] = l[0];
B[i] = l[1];
}
}
/// <summary>
/// 3つの整数が複数行に書かれている入力を、2つのlong[]で受け取る
/// </summary>
/// <param name="rowNumber"></param>
/// <param name="A"></param>
/// <param name="B"></param>
/// <param name="C"></param>
public void LongsArray(long rowNumber, ref long[] A, ref long[] B,
ref long[] C) {
A = new long[rowNumber];
B = new long[rowNumber];
C = new long[rowNumber];
for (int i = 0; i < rowNumber; i++) {
var l = ArrayLong();
A[i] = l[0];
B[i] = l[1];
C[i] = l[2];
}
}
/// <summary>
/// 1行の入力を取得
/// </summary>
/// <returns>long型の配列</returns>
public long[] ArrayLong() { return Split().Select(long.Parse).ToArray(); }
public long[] ArrayLong(int rowNumber) {
long[] longs = new long[rowNumber];
for (int i = 0; i < rowNumber; i++) {
longs[i] = Long();
}
return longs;
}
/// <summary>
/// 1行の入力を取得
/// </summary>
/// <returns>double型の値</returns>
public double Double() { return double.Parse(String()); }
/// <summary>
/// 1行の入力を取得
/// </summary>
/// <returns>double型の配列</returns>
public double[] ArrayDouble() {
return Split().Select(double.Parse).ToArray();
}
private IEnumerable<string> Split() { return String().Split(' '); }
}
class Program {
static void Main(string[] args) {
Solver solver = new Solver();
solver.Solve();
}
}
class Solver {
public Solver() {
Input input = new Input();
long n = 0;
long m = 0;
input.Longs(ref n, ref m);
Console.WriteLine(n == m ? "Yes" : "No");
}
public void Solve() {}
}
}
|
[["-", 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, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 825
| 7
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using System.Numerics;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
// 解答はココに書く
int[] m = cin.ReadIntArray(2);
Console.WriteLine(m[0] == m[1]);
Console.ReadLine();
}
}
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;
}
}
class Mod {
public int N { get; }
private readonly List<long> fac = new List<long>() { 1, 1 };
private readonly List<long> inv = new List<long>() { 0, 1 };
private readonly List<long> facInv = new List<long>() { 1, 1 };
/// <summary>
/// コンストラクタでmod N のNの値を決める
/// </summary>
/// <param name="n"></param>
public Mod(int n) { N = n; }
/// <summary>
/// 四則演算は下で
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public long Add(long a, long b) => (a % N + b % N + N) % N;
public long Sub(long a, long b) => Add(a, -b);
public long Mul(long a, long b) => (a % N * b % N + N) % N;
public long Div(long a, long b) => Mul(a, Inv(b));
public long Sum(params long[] args) => args.Aggregate(Add);
public long Inv(long a) {
if (a < inv.Count)
return inv[(int)a];
long b = N, x = 1, y = 0, tmp;
while (b != 0) {
var q = a / b;
tmp = y;
y = x - q * y;
x = tmp;
tmp = b;
b = a - q * b;
a = tmp;
}
return (x % N + N) % N;
}
public long Pow(long a, long n) {
var result = 1L;
while (n > 0) {
if ((n & 1) == 1)
result = Mul(result, a);
a = Mul(a, a);
n >>= 1;
}
return result;
}
public void InitSeq(int n) {
for (var i = fac.Count; i <= n; i++) {
fac.Add(fac[i - 1] * i % N);
inv.Add(N - inv[N % i] * (N / i) % N);
facInv.Add(facInv[i - 1] * inv[i] % N);
}
}
public long Fac(int n) {
InitSeq(n);
return fac[n];
}
public long Per(int n, int k) {
if (n < k || n < 0 || k < 0)
return 0;
InitSeq(n);
return fac[n] * facInv[n - k] % N;
}
public long Com(int n, int k) {
if (n < k || n < 0 || k < 0)
return 0;
InitSeq(n);
return fac[n] * (facInv[k] * facInv[n - k] % N) % N;
}
}
}
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using System.Numerics;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
Console.ReadLine();
}
public void Solve(ConsoleInput cin) {
// 解答はココに書く
int[] m = cin.ReadIntArray(2);
Console.WriteLine(m[0] == m[1] ? "Yes" : "No");
}
}
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;
}
}
class Mod {
public int N { get; }
private readonly List<long> fac = new List<long>() { 1, 1 };
private readonly List<long> inv = new List<long>() { 0, 1 };
private readonly List<long> facInv = new List<long>() { 1, 1 };
/// <summary>
/// コンストラクタでmod N のNの値を決める
/// </summary>
/// <param name="n"></param>
public Mod(int n) { N = n; }
/// <summary>
/// 四則演算は下で
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public long Add(long a, long b) => (a % N + b % N + N) % N;
public long Sub(long a, long b) => Add(a, -b);
public long Mul(long a, long b) => (a % N * b % N + N) % N;
public long Div(long a, long b) => Mul(a, Inv(b));
public long Sum(params long[] args) => args.Aggregate(Add);
public long Inv(long a) {
if (a < inv.Count)
return inv[(int)a];
long b = N, x = 1, y = 0, tmp;
while (b != 0) {
var q = a / b;
tmp = y;
y = x - q * y;
x = tmp;
tmp = b;
b = a - q * b;
a = tmp;
}
return (x % N + N) % N;
}
public long Pow(long a, long n) {
var result = 1L;
while (n > 0) {
if ((n & 1) == 1)
result = Mul(result, a);
a = Mul(a, a);
n >>= 1;
}
return result;
}
public void InitSeq(int n) {
for (var i = fac.Count; i <= n; i++) {
fac.Add(fac[i - 1] * i % N);
inv.Add(N - inv[N % i] * (N / i) % N);
facInv.Add(facInv[i - 1] * inv[i] % N);
}
}
public long Fac(int n) {
InitSeq(n);
return fac[n];
}
public long Per(int n, int k) {
if (n < k || n < 0 || k < 0)
return 0;
InitSeq(n);
return fac[n] * facInv[n - k] % N;
}
public long Com(int n, int k) {
if (n < k || n < 0 || k < 0)
return 0;
InitSeq(n);
return fac[n] * (facInv[k] * facInv[n - k] % N) % N;
}
}
}
|
[["+", 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, 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, 213, 3, 4, 0, 28, 0, 41, 0, 101], ["+", 3, 4, 0, 28, 0, 41, 64, 5, 0, 62], ["+", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 102], ["+", 3, 4, 0, 28, 0, 41, 75, 5, 0, 62], ["+", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222]]
| 8
| 1,037
| 20
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
var N = cin.ReadInt;
var M = cin.ReadInt;
if (N >= 1 && N <= 100) {
if (M >= 0 && M <= N) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
int N = cin.ReadInt;
int M = cin.ReadInt;
if (M == N) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 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, 20], ["-", 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, 19], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["-", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 64, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["-", 64, 196, 0, 57, 15, 16, 31, 16, 17, 20], ["-", 64, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["-", 0, 57, 64, 196, 0, 57, 15, 16, 17, 98], ["-", 64, 196, 0, 57, 15, 16, 12, 16, 17, 19], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["-", 0, 57, 64, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 483
| 22
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
// 解答はココに書く
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
int n = cin.ReadInt;
int m = cin.ReadInt;
if (n == m) {
WriteLine("Yes");
} else {
WriteLine("No");
}
// 解答はココに書く
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
[["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 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, 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], ["+", 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, 213, 63, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 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, 213, 63, 22], ["+", 75, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 75, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46], ["+", 0, 235, 8, 201, 0, 195, 8, 196, 0, 46]]
| 8
| 425
| 39
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ComparingStrings {
class Program {
static void Main(string[] args) {
var input = Console.ReadLine().Split(' ');
int leftString = int.Parse(input[0]);
int rightString = int.Parse(input[1]);
List<int> leftStringList = new List<int>();
List<int> rightStringList = new List<int>();
for (int i = 0; i < rightString; i++) {
leftStringList.Add(leftString);
}
for (int i = 0; i < leftString; i++) {
rightStringList.Add(rightString);
}
if (leftStringList[0] > rightStringList[0]) {
string outputPrint = string.Join("", rightStringList.ToArray());
Console.WriteLine(outputPrint);
}
if (rightStringList[0] > leftStringList[0]) {
string outputPrint = string.Join("", leftStringList.ToArray());
Console.WriteLine(outputPrint);
} else {
string outputPrint = string.Join("", leftStringList.ToArray());
Console.WriteLine(outputPrint);
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ComparingStrings {
class Program {
static void Main(string[] args) {
var input = Console.ReadLine().Split(' ');
int leftString = int.Parse(input[0]);
int rightString = int.Parse(input[1]);
List<int> leftStringList = new List<int>();
List<int> rightStringList = new List<int>();
for (int i = 0; i < rightString; i++) {
leftStringList.Add(leftString);
}
for (int i = 0; i < leftString; i++) {
rightStringList.Add(rightString);
}
if (leftStringList[0] > rightStringList[0]) {
string outputPrint = string.Join("", rightStringList.ToArray());
Console.WriteLine(outputPrint);
}
if (rightStringList[0] > leftStringList[0]) {
string outputPrint = string.Join("", leftStringList.ToArray());
Console.WriteLine(outputPrint);
}
if (rightStringList[0] == leftStringList[0]) {
string outputPrint = string.Join("", leftStringList.ToArray());
Console.WriteLine(outputPrint);
}
}
}
}
|
[["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 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, 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, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 204, 205, 22], ["+", 0, 57, 15, 16, 12, 204, 206, 207, 0, 70], ["+", 15, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 57, 15, 16, 12, 204, 206, 207, 0, 73], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25]]
| 8
| 253
| 13
|
using System;
using System.Linq;
class Program {
public static void Main() {
int[] input =
Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
int a, b;
if (input[0] == input[1]) {
a = input[0];
b = input[0];
} else if (input[0] > input[1]) {
a = input[0];
b = input[1];
} else {
a = input[1];
b = input[0];
}
for (int i = 0; i < b; i++)
Console.Write(a);
}
}
|
using System;
using System.Linq;
class Program {
public static void Main() {
int[] input =
Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
int num, time;
if (input[0] == input[1]) {
num = input[0];
time = input[0];
} else if (input[0] < input[1]) {
num = input[0];
time = input[1];
} else {
num = input[1];
time = input[0];
}
for (int i = 1; i <= time; i++)
Console.Write(num);
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 57, 75, 57, 15, 16, 17, 47], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 18], ["-", 75, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 75, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 75, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 75, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["-", 8, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 8, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 154
| 26
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int a = int.Parse(input[0]);
int b = int.Parse(input[1]);
string str = (a > b) ? b.ToString() : a.ToString();
int count = (a > b) ? a : b;
for (int i = 0; i < count; i++) {
str += count;
}
Console.WriteLine(str);
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int a = int.Parse(input[0]);
int b = int.Parse(input[1]);
string str = (a > b) ? b.ToString() : a.ToString();
int count = (a > b) ? a : b;
string ans = "";
for (int i = 0; i < count; i++) {
ans += str;
}
Console.WriteLine(ans);
}
}
|
[["+", 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, 5, 0, 62], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 0, 7, 8, 196, 0, 1, 0, 11, 12, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 12, 22], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 135
| 12
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
int a = cin.ReadInt;
int b = cin.ReadInt;
string String;
if (a <= b)
String = new string((char)a, b);
else
String = new string((char)b, a);
WriteLine(String);
// 解答はココに書く
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
var a = cin.ReadInt;
var b = cin.ReadInt;
string String = "";
if (a <= b)
String = string.Concat(Enumerable.Repeat(a.ToString(), b));
else
String = string.Concat(Enumerable.Repeat(b.ToString(), a));
WriteLine(String);
// 解答はココに書く
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 5, 0, 62], ["-", 0, 57, 64, 1, 0, 11, 12, 230, 0, 228], ["+", 64, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["+", 64, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 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], ["-", 12, 230, 3, 4, 0, 28, 0, 74, 39, 199], ["-", 12, 230, 3, 4, 0, 28, 0, 74, 0, 25], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25], ["-", 0, 57, 75, 1, 0, 11, 12, 230, 0, 228], ["+", 75, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["+", 75, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 75, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["-", 12, 230, 3, 4, 0, 28, 0, 74, 51, 22]]
| 8
| 480
| 33
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
var a = cin.ReadInt;
var b = cin.ReadInt;
if (a < b) {
Console.WriteLine($"{a}{a}{a}{a}");
} else {
Console.WriteLine($"{b}{b}{b}{b}");
}
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
var a = cin.ReadInt;
var b = cin.ReadInt;
if (a < b) {
for (int i = 1; i <= b; i++) {
Console.Write($"{a}");
}
} else {
for (int i = 1; i <= a; i++) {
Console.Write($"{b}");
}
}
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
[["+", 8, 196, 0, 57, 64, 196, 0, 7, 0, 88], ["+", 8, 196, 0, 57, 64, 196, 0, 7, 0, 24], ["+", 0, 57, 64, 196, 0, 7, 10, 198, 39, 199], ["+", 64, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 7, 0, 35], ["+", 0, 57, 64, 196, 0, 7, 15, 16, 31, 22], ["+", 0, 57, 64, 196, 0, 7, 15, 16, 17, 19], ["+", 0, 57, 64, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 57, 64, 196, 0, 7, 26, 223, 0, 22], ["+", 0, 57, 64, 196, 0, 7, 26, 223, 0, 29], ["+", 8, 196, 0, 57, 64, 196, 0, 7, 0, 25], ["+", 0, 57, 64, 196, 0, 7, 8, 196, 0, 45], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 3, 4, 0, 28, 0, 283, 0, 284, 0, 45], ["-", 3, 4, 0, 28, 0, 283, 0, 284, 0, 22], ["-", 3, 4, 0, 28, 0, 283, 0, 284, 0, 46], ["+", 0, 57, 64, 196, 0, 7, 8, 196, 0, 46], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 8, 196, 0, 57, 75, 196, 0, 7, 0, 88], ["+", 8, 196, 0, 57, 75, 196, 0, 7, 0, 24], ["+", 0, 57, 75, 196, 0, 7, 10, 198, 39, 199], ["+", 75, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 57, 75, 196, 0, 7, 0, 35], ["+", 0, 57, 75, 196, 0, 7, 15, 16, 31, 22], ["+", 0, 57, 75, 196, 0, 7, 15, 16, 17, 19], ["+", 0, 57, 75, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 57, 75, 196, 0, 7, 26, 223, 0, 22], ["+", 0, 57, 75, 196, 0, 7, 26, 223, 0, 29], ["+", 8, 196, 0, 57, 75, 196, 0, 7, 0, 25], ["-", 75, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 0, 57, 75, 196, 0, 7, 8, 196, 0, 46]]
| 8
| 489
| 54
|
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
public class Test152_b {
/// <summary>
/// https://atcoder.jp/contests/abc152/tasks/abc152_b
/// </summary>
public static void Main() {
string[] ss = Console.ReadLine().Split(
new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
int a = int.Parse(ss[0]);
int b = int.Parse(ss[1]);
//整数 a を b 回繰り返してできる文字列と
//整数 b を a 回繰り返してできる文字列と
StringBuilder sbA = new StringBuilder();
StringBuilder sbB = new StringBuilder();
for (int i = 0; i < a; i++) {
sbA.Append(a.ToString());
}
for (int i = 0; i < a; i++) {
sbB.Append(b.ToString());
}
// 辞書順で小さい方を答えてください。
if (string.Compare(sbA.ToString(), sbB.ToString()) < 0) {
Console.WriteLine(sbA.ToString());
} else {
Console.WriteLine(sbB.ToString());
}
}
}
|
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
public class Test152_b {
/// <summary>
/// https://atcoder.jp/contests/abc152/tasks/abc152_b
/// </summary>
public static void Main() {
string[] ss = Console.ReadLine().Split(
new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
int a = int.Parse(ss[0]);
int b = int.Parse(ss[1]);
//整数 a を b 回繰り返してできる文字列と
StringBuilder sbA = new StringBuilder();
for (int i = 0; i < b; i++) {
sbA.Append(a.ToString());
}
StringBuilder sbB = new StringBuilder();
//整数 b を a 回繰り返してできる文字列と
for (int i = 0; i < a; i++) {
sbB.Append(b.ToString());
}
// 辞書順で小さい方を答えてください。
if (string.Compare(sbA.ToString(), sbB.ToString()) < 0) {
Console.WriteLine(sbA.ToString());
} else {
Console.WriteLine(sbB.ToString());
}
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 22], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 198, 0, 200, 0, 212, 0, 230, 0, 228], ["-", 0, 198, 0, 200, 0, 212, 0, 230, 39, 22], ["-", 0, 200, 0, 212, 0, 230, 3, 4, 0, 24], ["-", 0, 200, 0, 212, 0, 230, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 230, 0, 228], ["+", 0, 198, 0, 200, 0, 212, 0, 230, 39, 22], ["+", 0, 200, 0, 212, 0, 230, 3, 4, 0, 24], ["+", 0, 200, 0, 212, 0, 230, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35]]
| 8
| 223
| 18
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static ConsoleApp.Util;
using static System.Math;
namespace ConsoleApp {
class Program {
static void Main(string[] args) {
var arr = ReadLine().Split().Select(long.Parse).ToArray();
long n = arr[0];
long k = arr[1];
long[] p = ReadLine().Split().Select(long.Parse).ToArray();
long maxExp2 = 0;
// 0-K-1までの期待値の合計を出す
for (long i = 0; i < k; i++) {
maxExp2 += p[i] + 1;
}
for (long i = 0; i < n - k; i++) {
var tmp = maxExp2;
tmp -= p[i] + 1;
tmp += p[i + k] + 1;
if (tmp > maxExp2)
maxExp2 = tmp;
}
WriteLine((double)(maxExp2 / 2.0));
}
}
static class Util {
public static void ChMin(ref long a, long b) {
if (a > b) {
a = b;
}
}
public static void ChMax(ref long a, long b) {
if (a < b) {
a = b;
}
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static ConsoleApp.Util;
using static System.Math;
namespace ConsoleApp {
class Program {
static void Main(string[] args) {
var arr = ReadLine().Split().Select(long.Parse).ToArray();
long n = arr[0];
long k = arr[1];
long[] p = ReadLine().Split().Select(long.Parse).ToArray();
long maxExp2 = 0;
// 0-K-1までの期待値の合計を出す
for (long i = 0; i < k; i++) {
maxExp2 += p[i] + 1;
}
var sum = maxExp2;
for (long i = 0; i < n - k; i++) {
sum -= p[i] + 1;
sum += p[i + k] + 1;
if (sum > maxExp2)
maxExp2 = sum;
}
WriteLine((double)(maxExp2 / 2.0));
}
}
static class Util {
public static void ChMin(ref long a, long b) {
if (a > b) {
a = b;
}
}
public static void ChMax(ref long a, long b) {
if (a < b) {
a = b;
}
}
}
}
|
[["+", 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], ["-", 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, 196, 0, 7, 8, 196, 0, 197, 0, 35], ["-", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 8, 196, 0, 57, 64, 1, 0, 11, 12, 22], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 12, 22]]
| 8
| 267
| 18
|
using System;
class Program {
static void Main(string[] args) {
// int n = int.Parse(Console.ReadLine());
string[] input = Console.ReadLine().Split(' ');
int n = int.Parse(input[0]);
int k = int.Parse(input[1]);
string[] input2 = Console.ReadLine().Split(' ');
int cnt = n - k + 1;
long max = 0;
long tmpSum = 0;
for (int i = 0; i < n; i++) {
tmpSum += int.Parse(input2[i]);
if (i >= k) {
tmpSum -= int.Parse(input2[i - k]);
if (max < tmpSum)
max = tmpSum;
}
}
double ans = (max + k) / 2d;
Console.WriteLine(ans);
}
}
|
using System;
class Program {
static void Main(string[] args) {
// int n = int.Parse(Console.ReadLine());
string[] input = Console.ReadLine().Split(' ');
int n = int.Parse(input[0]);
int k = int.Parse(input[1]);
string[] input2 = Console.ReadLine().Split(' ');
long max = 0;
long tmpSum = 0;
for (int i = 0; i < n; i++) {
tmpSum += int.Parse(input2[i]);
if (i >= k) {
tmpSum -= int.Parse(input2[i - k]);
}
if (max < tmpSum)
max = tmpSum;
}
double ans = (max + k) / 2d;
Console.WriteLine(ans);
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 200, 0, 212, 0, 16, 31, 16, 31, 22], ["-", 0, 200, 0, 212, 0, 16, 31, 16, 17, 33], ["-", 0, 200, 0, 212, 0, 16, 31, 16, 12, 22], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 178
| 11
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace AtCoder {
struct mint : IEquatable<mint> {
// static uint mod = 998244353;
static uint mod = 1000000007;
uint _v;
public mint(long v) : this((uint)(v % mod + mod)) {}
private mint(uint v) { _v = v < mod ? v : (v - mod); }
public static void SetMod(uint p) { mod = p; }
public static mint operator +(mint lhs, mint rhs) {
return new mint(lhs._v + rhs._v);
}
public static mint operator -(mint lhs, mint rhs) {
return new mint(lhs._v + mod - rhs._v);
}
public static mint operator *(mint lhs, mint rhs) {
return new mint((uint)((ulong)lhs._v * rhs._v % mod));
}
public static mint operator /(mint lhs, mint rhs) { return lhs * rhs.Inv(); }
public static mint operator ^(mint x, int n) { return Pow(x, n); }
public static bool operator ==(mint l, mint r) { return l._v == r._v; }
public static bool operator !=(mint l, mint r) { return !(l == r); }
public static bool operator<(mint l, mint r) { return l._v < r._v; }
public static bool operator>(mint l, mint r) { return l._v > r._v; }
public static mint Pow(mint x, int n) {
var r = new mint(1);
while (n > 0) {
if ((n & 1) > 0)
r *= x;
x *= x;
n >>= 1;
}
return r;
}
public mint Pow(int n) { return Pow(this, n); }
public mint Inv() { return Pow((int)mod - 2); }
public bool Equals(mint o) { return this == o; }
public override bool Equals(object obj) {
if (obj is mint)
return this == (mint)obj;
else
return false;
}
public override int GetHashCode() { return _v.GetHashCode(); }
public override string ToString() { return _v.ToString(); }
public static implicit operator mint(int i) { return new mint(i); }
public static implicit operator mint(long i) { return new mint(i); }
private static mint[] _fact;
public static void SetFact(int n) {
_fact = new mint[n + 1];
_fact[0] = 1;
for (int i = 1; i < n + 1; i++) {
_fact[i] = _fact[i - 1] * i;
}
}
public static mint Fact(int n) {
if (_fact == null || _fact.Length <= n) {
SetFact(n * 2);
}
return _fact[n];
}
public static mint Combination(int n, int r) {
return Fact(n) / (Fact(n - r) * Fact(r));
}
}
static class Extensions {
public static int LowerBound<T>(this IList<T> list, T value,
IComparer<T> comp = null) {
if (comp == null)
comp = Comparer<T>.Default;
var l = 0;
var r = list.Count;
while (l < r) {
var m = (l + r) / 2;
var c = comp.Compare(value, list[m]);
if (c > 0)
l = m + 1;
else
r = m;
}
return l;
}
public static int UpperBound<T>(this IList<T> list, T value,
IComparer<T> comp = null) {
if (comp == null)
comp = Comparer<T>.Default;
var l = 0;
var r = list.Count;
while (l < r) {
var m = (l + r) / 2;
var c = comp.Compare(value, list[m]);
if (c >= 0)
l = m + 1;
else
r = m;
}
return r;
}
}
class Program {
static int ReadInt() { return int.Parse(Console.ReadLine()); }
static long ReadLong() { return long.Parse(Console.ReadLine()); }
static int[] ReadIntArray() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
static int[] ReadIntArray(int n) {
var a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = ReadInt();
}
return a;
}
static long[] ReadLongArray() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
}
static long[] ReadLongArray(int n) {
var a = new long[n];
for (int i = 0; i < n; i++) {
a[i] = ReadLong();
}
return a;
}
static List<T> ReadObjects<T>(int n, Func<int[], T> creator) {
var l = new List<T>(n);
for (int i = 0; i < n; i++) {
var a = ReadIntArray();
l.Add(creator(a));
}
return l;
}
static int[,] ReadMatrix(int n, int m) {
var r = new int[n, m];
for (int i = 0; i < n; i++) {
var a = ReadIntArray();
for (int j = 0; j < m; j++) {
r[i, j] = a[j];
}
}
return r;
}
public static int[] ZAlgotithm(string s) {
var len = s.Length;
var a = new int[len];
a[0] = len;
var i = 1;
var j = 0;
while (i < len) {
while (i + j < len && s[j] == s[i + j])
j++;
a[i] = j;
if (j == 0) {
i++;
continue;
}
var k = 1;
while (i + k < len && k + a[k] < j) {
a[i + k] = a[k];
k++;
}
i += k;
j -= k;
}
return a;
}
public class MaxHeap<T> : IEnumerable<T> {
private List<T> _list;
private Comparer<T> _comp;
public int Count {
get { return _list.Count; }
}
public MaxHeap() : this(0) {}
public MaxHeap(int capacity, Comparison<T> comp = null) {
_list = new List<T>(capacity);
if (comp == null) {
_comp = Comparer<T>.Default;
} else {
_comp = Comparer<T>.Create(comp);
}
}
public void Push(T elem) { Upheap(elem); }
public T Pop() { return Downheap(); }
public T Peek() { return _list[0]; }
private void Swap(int i, int j) {
var a = _list[j];
_list[j] = _list[i];
_list[i] = a;
}
private void Upheap(T elem) {
_list.Add(elem);
var i = _list.Count - 1;
while (true) {
if (i == 0)
return;
var j = (i - 1) / 2;
var e = _list[i];
var p = _list[j];
var c = _comp.Compare(e, p);
if (c > 0) {
Swap(i, j);
i = j;
continue;
} else {
break;
}
}
}
private T Downheap() {
var result = _list[0];
var last = _list.Count - 1;
Swap(0, last);
_list.RemoveAt(last);
if (_list.Count == 0)
return result;
var i = 0;
while (true) {
if (i == _list.Count - 1)
return result;
var p = _list[i];
var j = i * 2 + 1;
if (j >= _list.Count)
return result;
if (j + 1 < _list.Count && _comp.Compare(_list[j], _list[j + 1]) < 0) {
j++;
}
if (_comp.Compare(_list[i], _list[j]) < 0) {
Swap(i, j);
i = j;
} else {
return result;
}
}
}
public MaxHeap<T> Copy(Comparison<T> comp = null) {
var c = new MaxHeap<T>(0, comp);
c._list = _list.ToList();
return c;
}
public MaxHeap(List<T> list) {
_list = list;
_comp = Comparer<T>.Default;
}
public List<T> GetList() { return _list; }
public IEnumerator<T> GetEnumerator() { return _list.GetEnumerator(); }
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
}
public class MinHeap<T> : IEnumerable<T> {
private List<T> _list;
private Comparer<T> _comp;
public int Count {
get { return _list.Count; }
}
public MinHeap() : this(0) {}
public MinHeap(int capacity, Comparison<T> comp = null) {
_list = new List<T>(capacity);
if (comp == null) {
_comp = Comparer<T>.Default;
} else {
_comp = Comparer<T>.Create(comp);
}
}
public void Push(T elem) { Upheap(elem); }
public T Pop() { return Downheap(); }
public T Peek() { return _list[0]; }
private void Swap(int i, int j) {
var a = _list[j];
_list[j] = _list[i];
_list[i] = a;
}
private void Upheap(T elem) {
_list.Add(elem);
var i = _list.Count - 1;
while (true) {
if (i == 0)
return;
var j = (i - 1) / 2;
var e = _list[i];
var p = _list[j];
var c = _comp.Compare(e, p);
if (c < 0) {
Swap(i, j);
i = j;
continue;
} else {
break;
}
}
}
private T Downheap() {
var result = _list[0];
var last = _list.Count - 1;
Swap(0, last);
_list.RemoveAt(last);
if (_list.Count == 0)
return result;
var i = 0;
while (true) {
if (i == _list.Count - 1)
return result;
var p = _list[i];
var j = i * 2 + 1;
if (j >= _list.Count)
return result;
if (j + 1 < _list.Count && _comp.Compare(_list[j], _list[j + 1]) > 0) {
j++;
}
if (_comp.Compare(_list[i], _list[j]) > 0) {
Swap(i, j);
i = j;
} else {
return result;
}
}
}
public MinHeap<T> Copy(Comparison<T> comp = null) {
var c = new MinHeap<T>(0, comp);
c._list = _list.ToList();
return c;
}
public MinHeap(List<T> list) {
_list = list;
_comp = Comparer<T>.Default;
}
public List<T> GetList() { return _list; }
public IEnumerator<T> GetEnumerator() { return _list.GetEnumerator(); }
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
}
class InputLine {
private string[] _inputs;
private int _index = 0;
InputLine(string input) {
_inputs = input.Split();
_index = 0;
}
public static InputLine Read() { return new InputLine(Console.ReadLine()); }
public int NextInt() { return int.Parse(_inputs[_index++]); }
public long NextLong() { return long.Parse(_inputs[_index++]); }
public double NextDouble() { return double.Parse(_inputs[_index++]); }
}
public static int GCD(int x, int y) {
var a = Math.Max(x, y);
var b = x + y - a;
while (b != 0) {
var c = b;
b = a % b;
a = c;
}
return a;
}
public static long GCD(long x, long y) {
var a = Math.Max(x, y);
var b = x + y - a;
while (b != 0) {
var c = b;
b = a % b;
a = c;
}
return a;
}
public static long LCM(long x, long y) {
var gcd = GCD(x, y);
return x * y / gcd;
}
static long ModPower(long x, long y, long mod) {
var bytes = BitConverter.GetBytes(y);
var bits = new System.Collections.BitArray(bytes);
var max2 = 0;
for (int i = bits.Length - 1; i >= 0; i--) {
if (bits[i]) {
max2 = i;
break;
}
}
long result = 1;
for (int i = max2; i >= 0; i--) {
result = (result * result) % mod;
if (bits[i]) {
result = (result * x) % mod;
}
}
return result;
}
static long ModFact(long n, long mod) {
long result = 1;
for (int i = 1; i <= n; i++) {
result = result * i % mod;
}
return result;
}
static long ModAdd(long x, long y, long mod) {
return ((x % mod) + (y % mod)) % mod;
}
static long ModMul(long x, long y, long mod) {
return ((x % mod) * (y % mod)) % mod;
}
static long ModDiv(long x, long y, long mod) {
//フェルマーの小定理より、a^(-1) = a^(p-2)
return ModMul(x, ModPower(y, mod - 2, mod), mod);
}
static long ModComb(long n, long r, long mod) {
long numerator = 1;
for (int i = 0; i < r; i++) {
numerator = ModMul(numerator, n - i, mod);
}
long denominator = ModFact(r, mod);
return ModDiv(numerator, denominator, mod);
}
class Graph {
private int _size;
private List<int>[] _edges;
public Graph(int size) {
_size = size;
_edges = new List<int>[size];
}
public List<int> this[int i] {
get {
if (_edges[i] == null)
_edges[i] = new List<int>();
return _edges[i];
}
}
}
class Graph<T> {
private int _size;
private List<T>[] _edges;
public Graph(int size) {
_size = size;
_edges = new List<T>[size];
}
public List<T> this[int i] {
get {
if (_edges[i] == null)
_edges[i] = new List<T>();
return _edges[i];
}
}
}
static Graph<T> NewGraph<T>(int size, T template) {
return new Graph<T>(size);
}
static List<T> NewList<T>(T template) { return new List<T>(); }
static T[] NewArray<T>(int size, T template) { return new T[size]; }
static long p1097 = 1000000007;
static void Main(string[] args) {
//↓
var nk = ReadIntArray();
var n = nk[0];
var k = nk[1];
var ps = ReadIntArray();
var es = new double[n];
for (int i = 0; i < n; i++) {
var p = ps[i];
es[i] = (double)(p + 1) / 2;
}
var ss = new double[n];
double max = 0;
double sum = 0;
for (int i = 0; i < n; i++) {
var e = es[i];
sum += e;
if (i < k)
continue;
sum -= es[i - k];
max = Math.Max(max, sum);
}
Console.WriteLine(max);
//↑
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace AtCoder {
struct mint : IEquatable<mint> {
// static uint mod = 998244353;
static uint mod = 1000000007;
uint _v;
public mint(long v) : this((uint)(v % mod + mod)) {}
private mint(uint v) { _v = v < mod ? v : (v - mod); }
public static void SetMod(uint p) { mod = p; }
public static mint operator +(mint lhs, mint rhs) {
return new mint(lhs._v + rhs._v);
}
public static mint operator -(mint lhs, mint rhs) {
return new mint(lhs._v + mod - rhs._v);
}
public static mint operator *(mint lhs, mint rhs) {
return new mint((uint)((ulong)lhs._v * rhs._v % mod));
}
public static mint operator /(mint lhs, mint rhs) { return lhs * rhs.Inv(); }
public static mint operator ^(mint x, int n) { return Pow(x, n); }
public static bool operator ==(mint l, mint r) { return l._v == r._v; }
public static bool operator !=(mint l, mint r) { return !(l == r); }
public static bool operator<(mint l, mint r) { return l._v < r._v; }
public static bool operator>(mint l, mint r) { return l._v > r._v; }
public static mint Pow(mint x, int n) {
var r = new mint(1);
while (n > 0) {
if ((n & 1) > 0)
r *= x;
x *= x;
n >>= 1;
}
return r;
}
public mint Pow(int n) { return Pow(this, n); }
public mint Inv() { return Pow((int)mod - 2); }
public bool Equals(mint o) { return this == o; }
public override bool Equals(object obj) {
if (obj is mint)
return this == (mint)obj;
else
return false;
}
public override int GetHashCode() { return _v.GetHashCode(); }
public override string ToString() { return _v.ToString(); }
public static implicit operator mint(int i) { return new mint(i); }
public static implicit operator mint(long i) { return new mint(i); }
private static mint[] _fact;
public static void SetFact(int n) {
_fact = new mint[n + 1];
_fact[0] = 1;
for (int i = 1; i < n + 1; i++) {
_fact[i] = _fact[i - 1] * i;
}
}
public static mint Fact(int n) {
if (_fact == null || _fact.Length <= n) {
SetFact(n * 2);
}
return _fact[n];
}
public static mint Combination(int n, int r) {
return Fact(n) / (Fact(n - r) * Fact(r));
}
}
static class Extensions {
public static int LowerBound<T>(this IList<T> list, T value,
IComparer<T> comp = null) {
if (comp == null)
comp = Comparer<T>.Default;
var l = 0;
var r = list.Count;
while (l < r) {
var m = (l + r) / 2;
var c = comp.Compare(value, list[m]);
if (c > 0)
l = m + 1;
else
r = m;
}
return l;
}
public static int UpperBound<T>(this IList<T> list, T value,
IComparer<T> comp = null) {
if (comp == null)
comp = Comparer<T>.Default;
var l = 0;
var r = list.Count;
while (l < r) {
var m = (l + r) / 2;
var c = comp.Compare(value, list[m]);
if (c >= 0)
l = m + 1;
else
r = m;
}
return r;
}
}
class Program {
static int ReadInt() { return int.Parse(Console.ReadLine()); }
static long ReadLong() { return long.Parse(Console.ReadLine()); }
static int[] ReadIntArray() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
static int[] ReadIntArray(int n) {
var a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = ReadInt();
}
return a;
}
static long[] ReadLongArray() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
}
static long[] ReadLongArray(int n) {
var a = new long[n];
for (int i = 0; i < n; i++) {
a[i] = ReadLong();
}
return a;
}
static List<T> ReadObjects<T>(int n, Func<int[], T> creator) {
var l = new List<T>(n);
for (int i = 0; i < n; i++) {
var a = ReadIntArray();
l.Add(creator(a));
}
return l;
}
static int[,] ReadMatrix(int n, int m) {
var r = new int[n, m];
for (int i = 0; i < n; i++) {
var a = ReadIntArray();
for (int j = 0; j < m; j++) {
r[i, j] = a[j];
}
}
return r;
}
public static int[] ZAlgotithm(string s) {
var len = s.Length;
var a = new int[len];
a[0] = len;
var i = 1;
var j = 0;
while (i < len) {
while (i + j < len && s[j] == s[i + j])
j++;
a[i] = j;
if (j == 0) {
i++;
continue;
}
var k = 1;
while (i + k < len && k + a[k] < j) {
a[i + k] = a[k];
k++;
}
i += k;
j -= k;
}
return a;
}
public class MaxHeap<T> : IEnumerable<T> {
private List<T> _list;
private Comparer<T> _comp;
public int Count {
get { return _list.Count; }
}
public MaxHeap() : this(0) {}
public MaxHeap(int capacity, Comparison<T> comp = null) {
_list = new List<T>(capacity);
if (comp == null) {
_comp = Comparer<T>.Default;
} else {
_comp = Comparer<T>.Create(comp);
}
}
public void Push(T elem) { Upheap(elem); }
public T Pop() { return Downheap(); }
public T Peek() { return _list[0]; }
private void Swap(int i, int j) {
var a = _list[j];
_list[j] = _list[i];
_list[i] = a;
}
private void Upheap(T elem) {
_list.Add(elem);
var i = _list.Count - 1;
while (true) {
if (i == 0)
return;
var j = (i - 1) / 2;
var e = _list[i];
var p = _list[j];
var c = _comp.Compare(e, p);
if (c > 0) {
Swap(i, j);
i = j;
continue;
} else {
break;
}
}
}
private T Downheap() {
var result = _list[0];
var last = _list.Count - 1;
Swap(0, last);
_list.RemoveAt(last);
if (_list.Count == 0)
return result;
var i = 0;
while (true) {
if (i == _list.Count - 1)
return result;
var p = _list[i];
var j = i * 2 + 1;
if (j >= _list.Count)
return result;
if (j + 1 < _list.Count && _comp.Compare(_list[j], _list[j + 1]) < 0) {
j++;
}
if (_comp.Compare(_list[i], _list[j]) < 0) {
Swap(i, j);
i = j;
} else {
return result;
}
}
}
public MaxHeap<T> Copy(Comparison<T> comp = null) {
var c = new MaxHeap<T>(0, comp);
c._list = _list.ToList();
return c;
}
public MaxHeap(List<T> list) {
_list = list;
_comp = Comparer<T>.Default;
}
public List<T> GetList() { return _list; }
public IEnumerator<T> GetEnumerator() { return _list.GetEnumerator(); }
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
}
public class MinHeap<T> : IEnumerable<T> {
private List<T> _list;
private Comparer<T> _comp;
public int Count {
get { return _list.Count; }
}
public MinHeap() : this(0) {}
public MinHeap(int capacity, Comparison<T> comp = null) {
_list = new List<T>(capacity);
if (comp == null) {
_comp = Comparer<T>.Default;
} else {
_comp = Comparer<T>.Create(comp);
}
}
public void Push(T elem) { Upheap(elem); }
public T Pop() { return Downheap(); }
public T Peek() { return _list[0]; }
private void Swap(int i, int j) {
var a = _list[j];
_list[j] = _list[i];
_list[i] = a;
}
private void Upheap(T elem) {
_list.Add(elem);
var i = _list.Count - 1;
while (true) {
if (i == 0)
return;
var j = (i - 1) / 2;
var e = _list[i];
var p = _list[j];
var c = _comp.Compare(e, p);
if (c < 0) {
Swap(i, j);
i = j;
continue;
} else {
break;
}
}
}
private T Downheap() {
var result = _list[0];
var last = _list.Count - 1;
Swap(0, last);
_list.RemoveAt(last);
if (_list.Count == 0)
return result;
var i = 0;
while (true) {
if (i == _list.Count - 1)
return result;
var p = _list[i];
var j = i * 2 + 1;
if (j >= _list.Count)
return result;
if (j + 1 < _list.Count && _comp.Compare(_list[j], _list[j + 1]) > 0) {
j++;
}
if (_comp.Compare(_list[i], _list[j]) > 0) {
Swap(i, j);
i = j;
} else {
return result;
}
}
}
public MinHeap<T> Copy(Comparison<T> comp = null) {
var c = new MinHeap<T>(0, comp);
c._list = _list.ToList();
return c;
}
public MinHeap(List<T> list) {
_list = list;
_comp = Comparer<T>.Default;
}
public List<T> GetList() { return _list; }
public IEnumerator<T> GetEnumerator() { return _list.GetEnumerator(); }
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
}
class InputLine {
private string[] _inputs;
private int _index = 0;
InputLine(string input) {
_inputs = input.Split();
_index = 0;
}
public static InputLine Read() { return new InputLine(Console.ReadLine()); }
public int NextInt() { return int.Parse(_inputs[_index++]); }
public long NextLong() { return long.Parse(_inputs[_index++]); }
public double NextDouble() { return double.Parse(_inputs[_index++]); }
}
public static int GCD(int x, int y) {
var a = Math.Max(x, y);
var b = x + y - a;
while (b != 0) {
var c = b;
b = a % b;
a = c;
}
return a;
}
public static long GCD(long x, long y) {
var a = Math.Max(x, y);
var b = x + y - a;
while (b != 0) {
var c = b;
b = a % b;
a = c;
}
return a;
}
public static long LCM(long x, long y) {
var gcd = GCD(x, y);
return x * y / gcd;
}
static long ModPower(long x, long y, long mod) {
var bytes = BitConverter.GetBytes(y);
var bits = new System.Collections.BitArray(bytes);
var max2 = 0;
for (int i = bits.Length - 1; i >= 0; i--) {
if (bits[i]) {
max2 = i;
break;
}
}
long result = 1;
for (int i = max2; i >= 0; i--) {
result = (result * result) % mod;
if (bits[i]) {
result = (result * x) % mod;
}
}
return result;
}
static long ModFact(long n, long mod) {
long result = 1;
for (int i = 1; i <= n; i++) {
result = result * i % mod;
}
return result;
}
static long ModAdd(long x, long y, long mod) {
return ((x % mod) + (y % mod)) % mod;
}
static long ModMul(long x, long y, long mod) {
return ((x % mod) * (y % mod)) % mod;
}
static long ModDiv(long x, long y, long mod) {
//フェルマーの小定理より、a^(-1) = a^(p-2)
return ModMul(x, ModPower(y, mod - 2, mod), mod);
}
static long ModComb(long n, long r, long mod) {
long numerator = 1;
for (int i = 0; i < r; i++) {
numerator = ModMul(numerator, n - i, mod);
}
long denominator = ModFact(r, mod);
return ModDiv(numerator, denominator, mod);
}
class Graph {
private int _size;
private List<int>[] _edges;
public Graph(int size) {
_size = size;
_edges = new List<int>[size];
}
public List<int> this[int i] {
get {
if (_edges[i] == null)
_edges[i] = new List<int>();
return _edges[i];
}
}
}
class Graph<T> {
private int _size;
private List<T>[] _edges;
public Graph(int size) {
_size = size;
_edges = new List<T>[size];
}
public List<T> this[int i] {
get {
if (_edges[i] == null)
_edges[i] = new List<T>();
return _edges[i];
}
}
}
static Graph<T> NewGraph<T>(int size, T template) {
return new Graph<T>(size);
}
static List<T> NewList<T>(T template) { return new List<T>(); }
static T[] NewArray<T>(int size, T template) { return new T[size]; }
static long p1097 = 1000000007;
static void Main(string[] args) {
//↓
var nk = ReadIntArray();
var n = nk[0];
var k = nk[1];
var ps = ReadIntArray();
var es = new double[n];
for (int i = 0; i < n; i++) {
var p = ps[i];
es[i] = (double)(p + 1) / 2;
}
var ss = new double[n];
double max = 0;
double sum = 0;
for (int i = 0; i < n; i++) {
var e = es[i];
sum += e;
if (i < k - 1)
continue;
if (i > k - 1)
sum -= es[i - k];
max = Math.Max(max, sum);
}
Console.WriteLine(max);
//↑
}
}
}
|
[["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 33], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 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], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25]]
| 8
| 3,569
| 10
|
using System;
using System.Linq;
class Program {
static void Main() {
var kn = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }),
number => int.Parse(number));
var p = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }),
number => int.Parse(number));
var k = kn[0];
var n = kn[1];
var maxSum = 0;
var maxIndex = 0;
var end = k - n + 1;
for (var i = 0; i < end; ++i) {
var sum = 0;
if (i == 0) {
for (var j = 0; j < n; ++j) {
sum += p[i + j];
}
} else {
sum = maxSum - p[i - 1] + p[i + n - 1];
}
if (sum > maxSum) {
maxSum = sum;
maxIndex = i;
}
}
var expectations = p.Skip(maxIndex).Take(n).Select(number => {
var expectation = 0.0;
for (var i = 1; i <= number; ++i) {
expectation += i * (1.0 / (double)number);
}
return expectation;
});
Console.WriteLine(Math.Round(expectations.Sum(), 8));
}
}
|
using System;
using System.Linq;
class Program {
static void Main() {
var kn = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }),
number => int.Parse(number));
var p = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }),
number => int.Parse(number));
var k = kn[0];
var n = kn[1];
var maxSum = 0;
var lastSum = 0;
var maxIndex = 0;
var end = k - n + 1;
for (var i = 0; i < end; ++i) {
var sum = 0;
if (i == 0) {
for (var j = 0; j < n; ++j) {
sum += p[i + j];
}
} else {
sum = lastSum - p[i - 1] + p[i + n - 1];
}
if (sum > maxSum) {
maxSum = sum;
maxIndex = i;
}
lastSum = sum;
}
var expectations = p.Skip(maxIndex).Take(n).Select(number => {
var expectation = 0.0;
for (var i = 1; i <= number; ++i) {
expectation += i * (1.0 / (double)number);
}
return expectation;
});
Console.WriteLine(Math.Round(expectations.Sum(), 8));
}
}
|
[["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 0, 1, 0, 11, 12, 16, 31, 16, 31, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 12, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35]]
| 8
| 295
| 11
|
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
namespace Practice {
class Program {
static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
private const int MOD = 1000000007;
private const int MAX = 1000001;
static long[] fac = new long[MAX];
static long[] finv = new long[MAX];
static long[] inv = new long[MAX];
static void Solve() {
var n = Input.NextInt();
var k = Input.NextInt();
var p = Input.NextInt(n);
var q = new int[n];
for (int i = 0; i < n; ++i) {
q[i] = p[i] == 1 ? 1 : 1 + p[i];
}
var sum = new int[n + 1];
for (int i = 0; i < n; ++i) {
sum[i + 1] = sum[i] + q[i];
}
int max = 0;
for (int i = 0; i + k < sum.Length; ++i) {
int tmpmax = sum[i + k] - sum[i];
if (tmpmax > max) {
max = tmpmax;
}
}
var ans = (double)max / 2;
Console.WriteLine(ans);
}
#region よく使う便利関数
private static Dictionary<long, int> Factorize(long n) {
var dic = new Dictionary<long, int>();
for (long i = 2; i * i <= n; ++i) {
while (n % i == 0) {
if (!dic.ContainsKey(i)) {
dic.Add(i, 0);
}
dic[i]++;
n /= i;
}
}
if (n != 1) {
dic.Add(n, 1);
}
return dic;
}
static void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
static long COM(long n, long k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
static class Input {
static char[] separator = { ' ' };
public static bool IsEof { get; set; }
static Queue<string> q { get; set; }
static Input() {
IsEof = false;
q = new Queue<string>();
}
/// <summary>
/// 入力予約
/// </summary>
/// <param name="items"></param>
public static void SetText(IEnumerable<string> items) {
foreach (var item in items) {
SetText(item);
}
}
/// <summary>
/// 入力予約
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static bool SetText(string s) {
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
q.Enqueue(elem);
}
return true;
}
/// <summary>
/// 内部queueに入力からの値をsplitして格納する
/// </summary>
/// <returns></returns>
static bool read() {
var s = Console.ReadLine();
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
q.Enqueue(elem);
}
if (!q.Any())
return read();
return true;
}
/// <summary>
/// 次のstringを一つ読み込む
/// </summary>
/// <returns></returns>
public static string Next() {
if (!q.Any()) {
if (!read()) {
IsEof = true;
return "";
}
}
return q.Dequeue();
}
public static int NextInt() => int.Parse(Next());
public static long NextLong() => long.Parse(Next());
public static double NextDouble() => double.Parse(Next());
public static List<string>
Next(int n) => Enumerable.Range(0, n).Select(_ => Next()).ToList();
public static List<int>
NextInt(int n) => Next(n).Select(x => int.Parse(x)).ToList();
public static List<long>
NextLong(int n) => Next(n).Select(x => long.Parse(x)).ToList();
public static List<double>
NextDouble(int n) => Next(n).Select(x => double.Parse(x)).ToList();
public static List<string>
NextLine() => Console.ReadLine()
.Trim()
.Split(separator, StringSplitOptions.RemoveEmptyEntries)
.ToList();
public static List<int>
NextIntLine() => NextLine().Select(x => int.Parse(x)).ToList();
public static List<long>
NextLongLine() => NextLine().Select(x => long.Parse(x)).ToList();
public static List<double>
NextDoubleLine() => NextLine().Select(x => double.Parse(x)).ToList();
}
private static bool isPrime(long x) {
if (x == 2) {
return true;
}
if (x < 2 || x % 2 == 0) {
return false;
}
long i = 3;
while (i * i <= x) {
if (x % i == 0) {
return false;
}
i = i + 2;
}
return true;
}
private static long lcm(long x, long y) { return x / gcd(x, y) * y; }
private static long gcd(long x, long y) { return y > 0 ? gcd(y, x % y) : x; }
private static long pow(long x, long n) {
if (n == 0) {
return 1;
}
long res = pow(x * x % MOD, n / 2);
if (n % 2 == 1) {
res = res * x % MOD;
}
return res;
}
private static void Swap<T>(ref T x, ref T y) {
T t = x;
x = y;
y = t;
}
/// <summary>
/// 指定した値以上の先頭のインデクスを返す
/// </summary>
/// <typeparam name="T">比較する値の型</typeparam>
/// <param name="arr">対象の配列(※ソート済みであること)</param>
/// <param name="start">開始インデクス [inclusive]</param>
/// <param name="end">終了インデクス [exclusive]</param>
/// <param name="value">検索する値</param>
/// <param name="comparer">比較関数(インターフェイス)</param>
/// <returns>指定した値以上の先頭のインデクス</returns>
public static int LowerBound<T>(IReadOnlyList<T> arr, int start, int end,
T value, IComparer<T> comparer) {
int low = start;
int high = end;
int mid;
while (low < high) {
mid = ((high - low) >> 1) + low;
if (comparer.Compare(arr[mid], value) < 0)
low = mid + 1;
else
high = mid;
}
return low;
}
//引数省略のオーバーロード
public static int LowerBound<T>(IReadOnlyList<T> arr, T value)
where T : IComparable {
return LowerBound(arr, 0, arr.Count, value, Comparer<T>.Default);
}
/// <summary>
/// 指定した値より大きい先頭のインデクスを返す
/// </summary>
/// <typeparam name="T">比較する値の型</typeparam>
/// <param name="arr">対象の配列(※ソート済みであること)</param>
/// <param name="start">開始インデクス [inclusive]</param>
/// <param name="end">終了インデクス [exclusive]</param>
/// <param name="value">検索する値</param>
/// <param name="comparer">比較関数(インターフェイス)</param>
/// <returns>指定した値より大きい先頭のインデクス</returns>
public static int UpperBound<T>(IReadOnlyList<T> arr, int start, int end,
T value, IComparer<T> comparer) {
int low = start;
int high = end;
int mid;
while (low < high) {
mid = ((high - low) >> 1) + low;
if (comparer.Compare(arr[mid], value) <= 0)
low = mid + 1;
else
high = mid;
}
return low;
}
//引数省略のオーバーロード
public static int UpperBound<T>(IReadOnlyList<T> arr, T value) {
return UpperBound(arr, 0, arr.Count, value, Comparer<T>.Default);
}
#endregion
}
public class DisjointSet {
private int[] rank;
private int[] p;
private int[] size;
public DisjointSet(int n) {
rank = new int[n];
p = new int[n];
size = new int[n];
for (int i = 0; i < n; ++i) {
MakeSet(i);
}
}
public void MakeSet(int x) {
p[x] = x;
rank[x] = 0;
size[x] = 1;
}
public bool IsSame(int x, int y) { return FindSet(x) == FindSet(y); }
public void Unite(int x, int y) { Link(FindSet(x), FindSet(y)); }
public void Link(int x, int y) {
if (rank[x] > rank[y]) {
p[y] = x;
size[x] += size[y];
size[y] = 0;
} else {
p[x] = y;
size[y] += size[x];
size[x] = 0;
if (rank[x] == rank[y]) {
rank[y]++;
}
}
}
public int FindSet(int x) {
if (x != p[x]) {
p[x] = FindSet(p[x]);
}
return p[x];
}
public int Size(int x) {
int root = FindSet(x);
return size[root];
}
}
public class PriorityQueue<T>
where T : IComparable {
private IComparer<T> _comparer = null;
private int _type = 0;
private T[] _heap;
private int _sz = 0;
private int _count = 0;
/// <summary>
/// Priority Queue with custom comparer
/// </summary>
public PriorityQueue(int maxSize, IComparer<T> comparer) {
_heap = new T[maxSize];
_comparer = comparer;
}
/// <summary>
/// Priority queue
/// </summary>
/// <param name="maxSize">max size</param>
/// <param name="type">0: asc, 1:desc</param>
public PriorityQueue(int maxSize, int type = 0) {
_heap = new T[maxSize];
_type = type;
}
private int Compare(T x, T y) {
if (_comparer != null)
return _comparer.Compare(x, y);
return _type == 0 ? x.CompareTo(y) : y.CompareTo(x);
}
public void Push(T x) {
_count++;
// node number
var i = _sz++;
while (i > 0) {
// parent node number
var p = (i - 1) / 2;
if (Compare(_heap[p], x) <= 0)
break;
_heap[i] = _heap[p];
i = p;
}
_heap[i] = x;
}
public T Pop() {
_count--;
T ret = _heap[0];
T x = _heap[--_sz];
int i = 0;
while (i * 2 + 1 < _sz) {
// children
int a = i * 2 + 1;
int b = i * 2 + 2;
if (b < _sz && Compare(_heap[b], _heap[a]) < 0)
a = b;
if (Compare(_heap[a], x) >= 0)
break;
_heap[i] = _heap[a];
i = a;
}
_heap[i] = x;
return ret;
}
public int Count() { return _count; }
public T Peek() { return _heap[0]; }
public bool Contains(T x) {
for (int i = 0; i < _sz; i++)
if (x.Equals(_heap[i]))
return true;
return false;
}
public void Clear() {
while (this.Count() > 0)
this.Pop();
}
public IEnumerator<T> GetEnumerator() {
var ret = new List<T>();
while (this.Count() > 0) {
ret.Add(this.Pop());
}
foreach (var r in ret) {
this.Push(r);
yield return r;
}
}
public T[] ToArray() {
T[] array = new T[_sz];
int i = 0;
foreach (var r in this) {
array[i++] = r;
}
return array;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
namespace Practice {
class Program {
static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
private const int MOD = 1000000007;
private const int MAX = 1000001;
static long[] fac = new long[MAX];
static long[] finv = new long[MAX];
static long[] inv = new long[MAX];
static void Solve() {
var n = Input.NextInt();
var k = Input.NextInt();
var p = Input.NextInt(n);
var q = new int[n];
for (int i = 0; i < n; ++i) {
q[i] = 1 + p[i];
}
var sum = new int[n + 1];
for (int i = 0; i < n; ++i) {
sum[i + 1] = sum[i] + q[i];
}
int max = 0;
for (int i = 0; i + k < sum.Length; ++i) {
int tmpmax = sum[i + k] - sum[i];
if (tmpmax > max) {
max = tmpmax;
}
}
var ans = (double)max / 2;
Console.WriteLine(ans);
}
#region よく使う便利関数
private static Dictionary<long, int> Factorize(long n) {
var dic = new Dictionary<long, int>();
for (long i = 2; i * i <= n; ++i) {
while (n % i == 0) {
if (!dic.ContainsKey(i)) {
dic.Add(i, 0);
}
dic[i]++;
n /= i;
}
}
if (n != 1) {
dic.Add(n, 1);
}
return dic;
}
static void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
static long COM(long n, long k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
static class Input {
static char[] separator = { ' ' };
public static bool IsEof { get; set; }
static Queue<string> q { get; set; }
static Input() {
IsEof = false;
q = new Queue<string>();
}
/// <summary>
/// 入力予約
/// </summary>
/// <param name="items"></param>
public static void SetText(IEnumerable<string> items) {
foreach (var item in items) {
SetText(item);
}
}
/// <summary>
/// 入力予約
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static bool SetText(string s) {
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
q.Enqueue(elem);
}
return true;
}
/// <summary>
/// 内部queueに入力からの値をsplitして格納する
/// </summary>
/// <returns></returns>
static bool read() {
var s = Console.ReadLine();
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
q.Enqueue(elem);
}
if (!q.Any())
return read();
return true;
}
/// <summary>
/// 次のstringを一つ読み込む
/// </summary>
/// <returns></returns>
public static string Next() {
if (!q.Any()) {
if (!read()) {
IsEof = true;
return "";
}
}
return q.Dequeue();
}
public static int NextInt() => int.Parse(Next());
public static long NextLong() => long.Parse(Next());
public static double NextDouble() => double.Parse(Next());
public static List<string>
Next(int n) => Enumerable.Range(0, n).Select(_ => Next()).ToList();
public static List<int>
NextInt(int n) => Next(n).Select(x => int.Parse(x)).ToList();
public static List<long>
NextLong(int n) => Next(n).Select(x => long.Parse(x)).ToList();
public static List<double>
NextDouble(int n) => Next(n).Select(x => double.Parse(x)).ToList();
public static List<string>
NextLine() => Console.ReadLine()
.Trim()
.Split(separator, StringSplitOptions.RemoveEmptyEntries)
.ToList();
public static List<int>
NextIntLine() => NextLine().Select(x => int.Parse(x)).ToList();
public static List<long>
NextLongLine() => NextLine().Select(x => long.Parse(x)).ToList();
public static List<double>
NextDoubleLine() => NextLine().Select(x => double.Parse(x)).ToList();
}
private static bool isPrime(long x) {
if (x == 2) {
return true;
}
if (x < 2 || x % 2 == 0) {
return false;
}
long i = 3;
while (i * i <= x) {
if (x % i == 0) {
return false;
}
i = i + 2;
}
return true;
}
private static long lcm(long x, long y) { return x / gcd(x, y) * y; }
private static long gcd(long x, long y) { return y > 0 ? gcd(y, x % y) : x; }
private static long pow(long x, long n) {
if (n == 0) {
return 1;
}
long res = pow(x * x % MOD, n / 2);
if (n % 2 == 1) {
res = res * x % MOD;
}
return res;
}
private static void Swap<T>(ref T x, ref T y) {
T t = x;
x = y;
y = t;
}
/// <summary>
/// 指定した値以上の先頭のインデクスを返す
/// </summary>
/// <typeparam name="T">比較する値の型</typeparam>
/// <param name="arr">対象の配列(※ソート済みであること)</param>
/// <param name="start">開始インデクス [inclusive]</param>
/// <param name="end">終了インデクス [exclusive]</param>
/// <param name="value">検索する値</param>
/// <param name="comparer">比較関数(インターフェイス)</param>
/// <returns>指定した値以上の先頭のインデクス</returns>
public static int LowerBound<T>(IReadOnlyList<T> arr, int start, int end,
T value, IComparer<T> comparer) {
int low = start;
int high = end;
int mid;
while (low < high) {
mid = ((high - low) >> 1) + low;
if (comparer.Compare(arr[mid], value) < 0)
low = mid + 1;
else
high = mid;
}
return low;
}
//引数省略のオーバーロード
public static int LowerBound<T>(IReadOnlyList<T> arr, T value)
where T : IComparable {
return LowerBound(arr, 0, arr.Count, value, Comparer<T>.Default);
}
/// <summary>
/// 指定した値より大きい先頭のインデクスを返す
/// </summary>
/// <typeparam name="T">比較する値の型</typeparam>
/// <param name="arr">対象の配列(※ソート済みであること)</param>
/// <param name="start">開始インデクス [inclusive]</param>
/// <param name="end">終了インデクス [exclusive]</param>
/// <param name="value">検索する値</param>
/// <param name="comparer">比較関数(インターフェイス)</param>
/// <returns>指定した値より大きい先頭のインデクス</returns>
public static int UpperBound<T>(IReadOnlyList<T> arr, int start, int end,
T value, IComparer<T> comparer) {
int low = start;
int high = end;
int mid;
while (low < high) {
mid = ((high - low) >> 1) + low;
if (comparer.Compare(arr[mid], value) <= 0)
low = mid + 1;
else
high = mid;
}
return low;
}
//引数省略のオーバーロード
public static int UpperBound<T>(IReadOnlyList<T> arr, T value) {
return UpperBound(arr, 0, arr.Count, value, Comparer<T>.Default);
}
#endregion
}
public class DisjointSet {
private int[] rank;
private int[] p;
private int[] size;
public DisjointSet(int n) {
rank = new int[n];
p = new int[n];
size = new int[n];
for (int i = 0; i < n; ++i) {
MakeSet(i);
}
}
public void MakeSet(int x) {
p[x] = x;
rank[x] = 0;
size[x] = 1;
}
public bool IsSame(int x, int y) { return FindSet(x) == FindSet(y); }
public void Unite(int x, int y) { Link(FindSet(x), FindSet(y)); }
public void Link(int x, int y) {
if (rank[x] > rank[y]) {
p[y] = x;
size[x] += size[y];
size[y] = 0;
} else {
p[x] = y;
size[y] += size[x];
size[x] = 0;
if (rank[x] == rank[y]) {
rank[y]++;
}
}
}
public int FindSet(int x) {
if (x != p[x]) {
p[x] = FindSet(p[x]);
}
return p[x];
}
public int Size(int x) {
int root = FindSet(x);
return size[root];
}
}
public class PriorityQueue<T>
where T : IComparable {
private IComparer<T> _comparer = null;
private int _type = 0;
private T[] _heap;
private int _sz = 0;
private int _count = 0;
/// <summary>
/// Priority Queue with custom comparer
/// </summary>
public PriorityQueue(int maxSize, IComparer<T> comparer) {
_heap = new T[maxSize];
_comparer = comparer;
}
/// <summary>
/// Priority queue
/// </summary>
/// <param name="maxSize">max size</param>
/// <param name="type">0: asc, 1:desc</param>
public PriorityQueue(int maxSize, int type = 0) {
_heap = new T[maxSize];
_type = type;
}
private int Compare(T x, T y) {
if (_comparer != null)
return _comparer.Compare(x, y);
return _type == 0 ? x.CompareTo(y) : y.CompareTo(x);
}
public void Push(T x) {
_count++;
// node number
var i = _sz++;
while (i > 0) {
// parent node number
var p = (i - 1) / 2;
if (Compare(_heap[p], x) <= 0)
break;
_heap[i] = _heap[p];
i = p;
}
_heap[i] = x;
}
public T Pop() {
_count--;
T ret = _heap[0];
T x = _heap[--_sz];
int i = 0;
while (i * 2 + 1 < _sz) {
// children
int a = i * 2 + 1;
int b = i * 2 + 2;
if (b < _sz && Compare(_heap[b], _heap[a]) < 0)
a = b;
if (Compare(_heap[a], x) >= 0)
break;
_heap[i] = _heap[a];
i = a;
}
_heap[i] = x;
return ret;
}
public int Count() { return _count; }
public T Peek() { return _heap[0]; }
public bool Contains(T x) {
for (int i = 0; i < _sz; i++)
if (x.Equals(_heap[i]))
return true;
return false;
}
public void Clear() {
while (this.Count() > 0)
this.Pop();
}
public IEnumerator<T> GetEnumerator() {
var ret = new List<T>();
while (this.Count() > 0) {
ret.Add(this.Pop());
}
foreach (var r in ret) {
this.Push(r);
yield return r;
}
}
public T[] ToArray() {
T[] array = new T[_sz];
int i = 0;
foreach (var r in this) {
array[i++] = r;
}
return array;
}
}
}
|
[["-", 0, 11, 12, 41, 15, 16, 31, 204, 205, 22], ["-", 12, 41, 15, 16, 31, 204, 206, 207, 0, 70], ["-", 15, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["-", 12, 41, 15, 16, 31, 204, 206, 207, 0, 73], ["-", 0, 1, 0, 11, 12, 41, 15, 16, 17, 60], ["-", 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], ["-", 0, 1, 0, 11, 12, 41, 75, 16, 31, 203]]
| 8
| 2,561
| 9
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoders {
class Program {
static void Main(string[] args) {
var inputArray = retreiveStringArray();
var inputCount = 1;
// 不正な入力は処理しない
if (inputArray.Length != inputCount) {
Console.WriteLine("invalid input");
return;
}
var N = inputArray[0].Select(x => int.Parse(x.ToString())).ToArray();
var K = retreiveLongArray()[0];
long ans = 0;
// N桁目が0の場合の数
ans += combination(N.Length - 1, K) * (long)Math.Pow(9, K);
// N桁目が1以上nより小さいとき
ans += combination(N.Length - 1, K - 1) * (long)Math.Pow(9, K - 1) *
(N[0] - 1);
// N桁目がnのとき
if (K == 1) { // K=1ならn000000を足しておしまい
ans += 1;
Console.WriteLine(ans);
return;
}
var k = K - 1;
var i = 1;
while (k > 0) {
if (N[i] == 0) {
i++;
continue;
}
var n = N[i];
// N-i桁目が0の場合
ans += combination(N.Length - (i + 1), k) * (long)Math.Pow(9, k);
// N-i桁目が1以上(n-i)(その桁の数値)より小さいとき
ans += combination(N.Length - (i + 1), k - 1) * (long)Math.Pow(9, k - 1) *
(n - 1);
if (k == 1) {
ans += 1;
Console.WriteLine(ans);
return;
}
k--;
i++;
if (i == N.Length) {
break;
}
}
//答えの出力
Console.WriteLine(ans);
}
/// <summary>
/// nこからrこを選ぶ組み合わせの数
/// </summary>
/// <param name="n"></param>
/// <param name="r"></param>
/// <returns></returns>
private static long combination(long n, long r) {
long bunshi = 1;
for (int i = 1; i <= r; i++) {
bunshi = bunshi * (n - r + i);
}
long bunbo = 1;
for (int i = 1; i <= r; i++) {
bunbo = bunbo * (i);
}
//逆元を使って、組み合わせの数を求める
return bunshi / bunbo;
}
/// <summary>
/// スペースで区切られた文字列配列の入力を受け取る
/// </summary>
/// <returns></returns>
private static string[] retreiveStringArray() {
var inputArray = Console.ReadLine().Split(' ');
return inputArray;
}
/// <summary>
/// スペースで区切られた整数配列の入力を受け取る
/// </summary>
/// <returns></returns>
private static long[] retreiveLongArray() {
var inputArray = Console.ReadLine().Split(' ');
var longArray = inputArray.Select(s => long.Parse(s));
return longArray.ToArray();
}
/// <summary>
/// 2組みずつの入力データ(数値)からTuppleListを作成する
/// </summary>
/// <param name="N"></param>
/// <returns></returns>
private static List<Tuple<long, long>> createLongTuppleList(long N) {
var inpList = new List<Tuple<long, long>>();
for (int i = 0; i < N; i++) {
var inp = retreiveLongArray();
var item1 = inp[0];
var item2 = inp[1];
inpList.Add(new Tuple<long, long>(item1, item2));
}
return inpList;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoders {
class Program {
static void Main(string[] args) {
var inputArray = retreiveStringArray();
var inputCount = 1;
// 不正な入力は処理しない
if (inputArray.Length != inputCount) {
Console.WriteLine("invalid input");
return;
}
var N = inputArray[0].Select(x => int.Parse(x.ToString())).ToArray();
var K = retreiveLongArray()[0];
long ans = 0;
// N桁目が0の場合の数
ans += combination(N.Length - 1, K) * (long)Math.Pow(9, K);
// N桁目が1以上nより小さいとき
ans += combination(N.Length - 1, K - 1) * (long)Math.Pow(9, K - 1) *
(N[0] - 1);
// N桁目がnのとき
if (K == 1) { // K=1ならn000000を足しておしまい
ans += 1;
Console.WriteLine(ans);
return;
}
var k = K - 1;
var i = 1;
while (i < N.Length) {
if (N[i] == 0) {
i++;
continue;
}
var n = N[i];
// N-i桁目が0の場合
ans += combination(N.Length - (i + 1), k) * (long)Math.Pow(9, k);
// N-i桁目が1以上(n-i)(その桁の数値)より小さいとき
ans += combination(N.Length - (i + 1), k - 1) * (long)Math.Pow(9, k - 1) *
(n - 1);
if (k == 1) {
ans += 1;
Console.WriteLine(ans);
return;
}
k--;
i++;
}
//答えの出力
Console.WriteLine(ans);
}
/// <summary>
/// nこからrこを選ぶ組み合わせの数
/// </summary>
/// <param name="n"></param>
/// <param name="r"></param>
/// <returns></returns>
private static long combination(long n, long r) {
long bunshi = 1;
for (int i = 1; i <= r; i++) {
bunshi = bunshi * (n - r + i);
}
long bunbo = 1;
for (int i = 1; i <= r; i++) {
bunbo = bunbo * (i);
}
//逆元を使って、組み合わせの数を求める
return bunshi / bunbo;
}
/// <summary>
/// スペースで区切られた文字列配列の入力を受け取る
/// </summary>
/// <returns></returns>
private static string[] retreiveStringArray() {
var inputArray = Console.ReadLine().Split(' ');
return inputArray;
}
/// <summary>
/// スペースで区切られた整数配列の入力を受け取る
/// </summary>
/// <returns></returns>
private static long[] retreiveLongArray() {
var inputArray = Console.ReadLine().Split(' ');
var longArray = inputArray.Select(s => long.Parse(s));
return longArray.ToArray();
}
/// <summary>
/// 2組みずつの入力データ(数値)からTuppleListを作成する
/// </summary>
/// <param name="N"></param>
/// <returns></returns>
private static List<Tuple<long, long>> createLongTuppleList(long N) {
var inpList = new List<Tuple<long, long>>();
for (int i = 0; i < N; i++) {
var inp = retreiveLongArray();
var item1 = inp[0];
var item2 = inp[1];
inpList.Add(new Tuple<long, long>(item1, item2));
}
return inpList;
}
}
}
|
[["-", 0, 195, 8, 196, 0, 52, 15, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 52, 15, 16, 17, 47], ["-", 0, 195, 8, 196, 0, 52, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 18], ["+", 8, 196, 0, 52, 15, 16, 12, 214, 205, 22], ["+", 8, 196, 0, 52, 15, 16, 12, 214, 0, 131], ["+", 8, 196, 0, 52, 15, 16, 12, 214, 141, 22], ["-", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35], ["-", 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, 196, 0, 57, 15, 16, 12, 214, 205, 22], ["-", 8, 196, 0, 57, 15, 16, 12, 214, 0, 131], ["-", 8, 196, 0, 57, 15, 16, 12, 214, 141, 22], ["-", 8, 196, 0, 52, 8, 196, 0, 57, 0, 25], ["-", 0, 52, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["-", 0, 52, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 645
| 20
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
namespace _200523 {
public class Solve {
public static void Main(string[] args) { (new Solve())._E(); }
string n;
int len;
int k;
long ans = 0;
void _E() {
n = Ex.Read;
len = n.Length;
k = Ex.ReadInt;
dfs(0, 0, 1, true);
ans.Cw();
}
void dfs(int i, int now_k, long cou, bool b) {
if (now_k > k) {
return;
}
if (i >= len) {
if (now_k == k) {
ans += cou;
}
return;
}
// 0
dfs(i + 1, now_k, cou, false);
// 1-9
if (b) {
int max = n[i] - '0';
if (max - 1 > 0)
dfs(i + 1, now_k + 1, cou * (max - 1), false);
if (max > 0)
dfs(i + 1, now_k + 1, cou, true);
} else {
dfs(i + 1, now_k + 1, cou * 9, false);
}
}
}
public static class Ex {
public static void Cw(this object s) { Console.WriteLine(s); }
static long Gcd(long m, long n) {
if (n == 0)
return m;
return Gcd(n, m % n);
}
public static List<string> FastSort(this List<string> s) {
s.Sort(StringComparer.Ordinal);
return s.ToList();
}
public static void yesno(this bool b) { (b ? "yes" : "no").Cw(); }
public static void YesNo(this bool b) { (b ? "Yes" : "No").Cw(); }
public static void YESNO(this bool b) { (b ? "YES" : "NO").Cw(); }
public static string Read {
get { return Console.ReadLine().Trim(); }
}
public static int ReadInt {
get { return int.Parse(Read); }
}
public static long ReadLong {
get { return long.Parse(Read); }
}
public static double ReadDouble {
get { return double.Parse(Read); }
}
public static string[] ReadArray() { return Read.Split(' '); }
public static int[] ReadIntArray() {
return Read.Split(' ').Select(int.Parse).ToArray();
}
public static long[] ReadLongArray() {
return Read.Split(' ').Select(long.Parse).ToArray();
}
public static string[] ReadArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public static int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public static 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.Linq;
using System.Collections;
using System.Collections.Generic;
namespace _200523 {
public class Solve {
public static void Main(string[] args) { (new Solve())._E(); }
string n;
int len;
int k;
long ans = 0;
void _E() {
n = Ex.Read;
len = n.Length;
k = Ex.ReadInt;
dfs(0, 0, 1, true);
ans.Cw();
}
void dfs(int i, int now_k, long cou, bool b) {
if (now_k > k) {
return;
}
if (i >= len) {
if (now_k == k) {
ans += cou;
}
return;
}
// 0
dfs(i + 1, now_k, cou, b && n[i] == '0');
// 1-9
if (b) {
int max = n[i] - '0';
if (max - 1 > 0)
dfs(i + 1, now_k + 1, cou * (max - 1), false);
if (max > 0)
dfs(i + 1, now_k + 1, cou, true);
} else {
dfs(i + 1, now_k + 1, cou * 9, false);
}
}
}
public static class Ex {
public static void Cw(this object s) { Console.WriteLine(s); }
static long Gcd(long m, long n) {
if (n == 0)
return m;
return Gcd(n, m % n);
}
public static List<string> FastSort(this List<string> s) {
s.Sort(StringComparer.Ordinal);
return s.ToList();
}
public static void yesno(this bool b) { (b ? "yes" : "no").Cw(); }
public static void YesNo(this bool b) { (b ? "Yes" : "No").Cw(); }
public static void YESNO(this bool b) { (b ? "YES" : "NO").Cw(); }
public static string Read {
get { return Console.ReadLine().Trim(); }
}
public static int ReadInt {
get { return int.Parse(Read); }
}
public static long ReadLong {
get { return long.Parse(Read); }
}
public static double ReadDouble {
get { return double.Parse(Read); }
}
public static string[] ReadArray() { return Read.Split(' '); }
public static int[] ReadIntArray() {
return Read.Split(' ').Select(int.Parse).ToArray();
}
public static long[] ReadLongArray() {
return Read.Split(' ').Select(long.Parse).ToArray();
}
public static string[] ReadArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public static int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public static long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 211, 0, 147], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 98], ["+", 0, 28, 0, 16, 12, 16, 31, 204, 205, 22], ["+", 0, 16, 12, 16, 31, 204, 206, 207, 0, 70], ["+", 12, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 16, 12, 16, 31, 204, 206, 207, 0, 73], ["+", 3, 4, 0, 28, 0, 16, 12, 16, 17, 60], ["+", 0, 28, 0, 16, 12, 16, 12, 252, 0, 104], ["+", 0, 28, 0, 16, 12, 16, 12, 252, 0, 253]]
| 8
| 716
| 11
|
using System.Collections;
using System.Text;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System;
using System.Numerics;
class Program {
#region Reader
// static Vector2Int ReadVec2Int
//{
// get
// {
// string[] s = Console.ReadLine().Split(' ');
// return new Vector2Int(int.Parse(s[0]), int.Parse(s[1]));
// }
//}
// static Vector2Int[] ReadVec2Ints(int n)
//{
// List<Vector2Int> list = new List<Vector2Int>();
// for (int i = 0; i < n; ++i)
// {
// var ab = ReadInts;
// list.Add(new Vector2Int(ab[0], ab[1]));
// }
// return list.ToArray();
//}
// static HashSet<Vector2Int> ReadVec2IntHash(int n)
//{
// HashSet<Vector2Int> hash = new HashSet<Vector2Int>();
// for (int i = 0; i < n; ++i)
// {
// var ab = ReadInts;
// hash.Add(new Vector2Int(ab[0], ab[1]));
// }
// return hash;
//}
static string ReadStr => Console.ReadLine();
static string[] ReadStrs => Console.ReadLine().Split(' ');
static int ReadInt => Convert.ToInt32(Console.ReadLine());
static int[] ReadInts =>
Console.ReadLine().Split(' ').Select(s => Convert.ToInt32(s)).ToArray();
static long ReadLong => Convert.ToInt64(Console.ReadLine());
static long[] ReadLongs =>
Console.ReadLine().Split(' ').Select(s => Convert.ToInt64(s)).ToArray();
static long[,] ReLongMatrix(int r, int c) {
var mat = new long[r, c];
for (int i = 0; i < r; ++i) {
var x = ReadLongs;
for (int j = 0; j < c; ++j) {
mat[i, j] = x[j];
}
}
return mat;
}
static Tuple<string, string>[] ReTupleStr(int n) {
List<Tuple<string, string>> list = new List<Tuple<string, string>>();
for (int i = 0; i < n; ++i) {
var ab = ReadStrs;
list.Add(new Tuple<string, string>(ab[0], ab[1]));
}
return list.ToArray();
}
static Tuple<long, long>[] ReTupleLong(int n) {
List<Tuple<long, long>> list = new List<Tuple<long, long>>();
for (int i = 0; i < n; ++i) {
var ab = ReadLongs;
list.Add(new Tuple<long, long>(ab[0], ab[1]));
}
return list.ToArray();
}
static Tuple<int, int>[] ReadTupleInt(int n) {
List<Tuple<int, int>> list = new List<Tuple<int, int>>();
for (int i = 0; i < n; ++i) {
var ab = ReadInts;
list.Add(new Tuple<int, int>(ab[0], ab[1]));
}
return list.ToArray();
}
static Tuple<double, double>[] ReTupleDouble(int n) {
List<Tuple<double, double>> list = new List<Tuple<double, double>>();
for (int i = 0; i < n; ++i) {
var ab = ReadLongs;
list.Add(new Tuple<double, double>(ab[0], ab[1]));
}
return list.ToArray();
}
static Dictionary<int, HashSet<int>> ReAdjacencyList(int N, int M) {
Dictionary<int, HashSet<int>> dict = new Dictionary<int, HashSet<int>>();
for (int i = 0; i <= N; ++i) {
dict.Add(i, new HashSet<int>());
}
for (int i = 0; i < M; ++i) {
var ab = ReadInts;
dict[ab[0]].Add(ab[1]);
dict[ab[1]].Add(ab[0]);
}
return dict;
}
#endregion
static void Swap<T>(ref T a, ref T b) {
T temp = a;
a = b;
b = temp;
}
static int mod = (int)Pow(10, 9) + 7;
public static long GetInv(long a, long mod = 1000000007) {
return PowerMod(a, mod - 2, mod);
}
public static long Combination(long a, long b, long mod = 1000000007) {
if (b < 0 || b > a)
return 0;
if (b > a / 2)
b = a - b;
long numerator = Factorial(a, mod);
long denominator = (Factorial(b, mod) * Factorial(a - b, mod)) % mod;
return (numerator * GetInv(denominator, mod)) % mod;
}
public static long Factorial(long n, long mod = 1000000007) {
if (n == 0)
return 1;
if (n == 1)
return 1;
long ans = n;
for (int i = 2; i < n; i++) {
ans = (ans * i) % mod;
}
return ans;
}
private static long PowerMod(long a, long n, long mod = 1000000007) {
if (n == 0)
return 1;
if (n == 1)
return a;
long p = PowerMod(a, n / 2, mod);
if (n % 2 == 1)
return ((p * p) % mod * a) % mod;
else
return (p * p) % mod;
}
static void Main() {
string S = ReadStr;
int N = S.Length;
short K = short.Parse(ReadLine());
List<int[]> comb = new List<int[]>();
int cnt = (int)Combination(Max(N - 1, 0), K, mod) * (int)Pow(9, K);
//最も次数が高い数字が異なる
cnt += ((S[0] - '0') - 1) * ((int)Combination(N - 1, K - 1, mod)) *
(int)Pow(9, K - 1);
if (K == 1) {
WriteLine(cnt + 1);
return;
}
//同じとき、次に0ではない数を探す
int index = -1;
for (int i = 1; i < N; i++) {
if (S[i] != '0') {
index = i;
break;
}
}
if (K == 2) {
WriteLine(cnt + Max(N - index - 1, 0) * 9 + (S[index] - '0'));
return;
}
//二番目が異なる
if (index != -1) {
cnt += ((S[index] - '0') - 1) * Max(N - index - 1, 0) * 9;
cnt += (int)Combination(N - index - 1, 2, mod) * 9 * 9;
}
//同じとき
int index2 = -1;
if (index != -1) {
for (int i = index + 1; i < N; i++) {
if (S[i] != '0') {
index2 = i;
break;
}
}
}
if (index2 != -1) {
cnt += Max(N - index2 - 1, 0) * 9 + (S[index2] - '0');
}
WriteLine(cnt);
}
}
|
using System.Collections;
using System.Text;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System;
using System.Numerics;
class Program {
#region Reader
// static Vector2Int ReadVec2Int
//{
// get
// {
// string[] s = Console.ReadLine().Split(' ');
// return new Vector2Int(int.Parse(s[0]), int.Parse(s[1]));
// }
//}
// static Vector2Int[] ReadVec2Ints(int n)
//{
// List<Vector2Int> list = new List<Vector2Int>();
// for (int i = 0; i < n; ++i)
// {
// var ab = ReadInts;
// list.Add(new Vector2Int(ab[0], ab[1]));
// }
// return list.ToArray();
//}
// static HashSet<Vector2Int> ReadVec2IntHash(int n)
//{
// HashSet<Vector2Int> hash = new HashSet<Vector2Int>();
// for (int i = 0; i < n; ++i)
// {
// var ab = ReadInts;
// hash.Add(new Vector2Int(ab[0], ab[1]));
// }
// return hash;
//}
static string ReadStr => Console.ReadLine();
static string[] ReadStrs => Console.ReadLine().Split(' ');
static int ReadInt => Convert.ToInt32(Console.ReadLine());
static int[] ReadInts =>
Console.ReadLine().Split(' ').Select(s => Convert.ToInt32(s)).ToArray();
static long ReadLong => Convert.ToInt64(Console.ReadLine());
static long[] ReadLongs =>
Console.ReadLine().Split(' ').Select(s => Convert.ToInt64(s)).ToArray();
static long[,] ReLongMatrix(int r, int c) {
var mat = new long[r, c];
for (int i = 0; i < r; ++i) {
var x = ReadLongs;
for (int j = 0; j < c; ++j) {
mat[i, j] = x[j];
}
}
return mat;
}
static Tuple<string, string>[] ReTupleStr(int n) {
List<Tuple<string, string>> list = new List<Tuple<string, string>>();
for (int i = 0; i < n; ++i) {
var ab = ReadStrs;
list.Add(new Tuple<string, string>(ab[0], ab[1]));
}
return list.ToArray();
}
static Tuple<long, long>[] ReTupleLong(int n) {
List<Tuple<long, long>> list = new List<Tuple<long, long>>();
for (int i = 0; i < n; ++i) {
var ab = ReadLongs;
list.Add(new Tuple<long, long>(ab[0], ab[1]));
}
return list.ToArray();
}
static Tuple<int, int>[] ReadTupleInt(int n) {
List<Tuple<int, int>> list = new List<Tuple<int, int>>();
for (int i = 0; i < n; ++i) {
var ab = ReadInts;
list.Add(new Tuple<int, int>(ab[0], ab[1]));
}
return list.ToArray();
}
static Tuple<double, double>[] ReTupleDouble(int n) {
List<Tuple<double, double>> list = new List<Tuple<double, double>>();
for (int i = 0; i < n; ++i) {
var ab = ReadLongs;
list.Add(new Tuple<double, double>(ab[0], ab[1]));
}
return list.ToArray();
}
static Dictionary<int, HashSet<int>> ReAdjacencyList(int N, int M) {
Dictionary<int, HashSet<int>> dict = new Dictionary<int, HashSet<int>>();
for (int i = 0; i <= N; ++i) {
dict.Add(i, new HashSet<int>());
}
for (int i = 0; i < M; ++i) {
var ab = ReadInts;
dict[ab[0]].Add(ab[1]);
dict[ab[1]].Add(ab[0]);
}
return dict;
}
#endregion
static void Swap<T>(ref T a, ref T b) {
T temp = a;
a = b;
b = temp;
}
static int mod = (int)Pow(10, 9) + 7;
public static long GetInv(long a, long mod = 1000000007) {
return PowerMod(a, mod - 2, mod);
}
public static long Combination(long a, long b, long mod = 1000000007) {
if (b < 0 || b > a)
return 0;
if (b > a / 2)
b = a - b;
long numerator = Factorial(a, mod);
long denominator = (Factorial(b, mod) * Factorial(a - b, mod)) % mod;
return (numerator * GetInv(denominator, mod)) % mod;
}
public static long Factorial(long n, long mod = 1000000007) {
if (n == 0)
return 1;
if (n == 1)
return 1;
long ans = n;
for (int i = 2; i < n; i++) {
ans = (ans * i) % mod;
}
return ans;
}
private static long PowerMod(long a, long n, long mod = 1000000007) {
if (n == 0)
return 1;
if (n == 1)
return a;
long p = PowerMod(a, n / 2, mod);
if (n % 2 == 1)
return ((p * p) % mod * a) % mod;
else
return (p * p) % mod;
}
static void Main() {
string S = ReadStr;
int N = S.Length;
short K = short.Parse(ReadLine());
int cnt = (int)Combination(Max(N - 1, 0), K, mod) * (int)Pow(9, K);
//最も次数が高い数字が異なる
cnt += ((S[0] - '0') - 1) * ((int)Combination(N - 1, K - 1, mod)) *
(int)Pow(9, K - 1);
if (K == 1) {
WriteLine(cnt + 1);
return;
}
//同じとき、次に0ではない数を探す
int index = -1;
for (int i = 1; i < N; i++) {
if (S[i] != '0') {
index = i;
break;
}
}
if (K == 2) {
if (index != -1)
cnt += Max(N - index - 1, 0) * 9 + (S[index] - '0');
WriteLine(cnt);
return;
}
//二番目が異なる
if (index != -1) {
cnt += ((S[index] - '0') - 1) * Max(N - index - 1, 0) * 9;
cnt += (int)Combination(N - index - 1, 2, mod) * 9 * 9;
}
//同じとき
int index2 = -1;
if (index != -1) {
for (int i = index + 1; i < N; i++) {
if (S[i] != '0') {
index2 = i;
break;
}
}
}
if (index2 != -1) {
cnt += Max(N - index2 - 1, 0) * 9 + (S[index2] - '0');
}
WriteLine(cnt);
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 39, 236, 141, 22], ["-", 0, 197, 0, 198, 39, 236, 237, 238, 0, 18], ["-", 39, 236, 237, 238, 0, 224, 225, 226, 0, 70], ["-", 39, 236, 237, 238, 0, 224, 225, 226, 0, 73], ["-", 0, 197, 0, 198, 39, 236, 237, 238, 0, 47], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 198, 0, 200, 0, 212, 0, 230, 0, 228], ["-", 0, 200, 0, 212, 0, 230, 39, 236, 141, 22], ["-", 0, 212, 0, 230, 39, 236, 237, 238, 0, 18], ["-", 0, 230, 39, 236, 237, 238, 0, 224, 39, 199], ["-", 0, 212, 0, 230, 39, 236, 237, 238, 0, 47], ["-", 0, 200, 0, 212, 0, 230, 3, 4, 0, 24], ["-", 0, 200, 0, 212, 0, 230, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 57, 64, 196, 0, 1, 0, 213, 63, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 79], ["+", 64, 196, 0, 57, 15, 16, 12, 241, 0, 33], ["+", 64, 196, 0, 57, 15, 16, 12, 241, 0, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["-", 3, 4, 0, 28, 0, 16, 31, 16, 17, 72], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 107], ["+", 0, 57, 64, 196, 0, 57, 64, 1, 0, 35], ["+", 0, 57, 64, 196, 0, 1, 0, 213, 63, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 1,489
| 31
|
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atcoder {
public class Program {
static void Main(string[] args) {
var n = Read();
var k = Read().ToInt();
decimal ans = 0;
if (n.Length < k) {
WriteRead(0);
return;
}
if (k == 1) {
ans = k1(n.ToString());
} else if (k == 2) {
ans = k2(n.ToString());
} else if (k == 3) {
ans = 9 * 9 * 9 * Combination(n.Length - 1, 3);
ans += (n[0].ToDecimal() - 1) * Combination((n.Length - 1), 2) * 9 * 9;
ans += k2(Remove(n.ToString().Remove(0, 1)));
}
WriteRead(ans);
}
private static string Remove(string n) {
var tmp = n;
if (string.IsNullOrEmpty(tmp))
return tmp;
bool isDel = true;
while (isDel) {
if (tmp[0] == '0') {
tmp = tmp.ToString().Remove(0, 1);
} else {
isDel = false;
}
}
return tmp;
}
private static decimal k1(string value) {
if (string.IsNullOrEmpty(value))
return 0;
decimal ans = 0;
ans = 9 * (value.Length - 1);
ans += value[0].ToDecimal();
return ans;
}
private static decimal k2(string n) {
if (string.IsNullOrEmpty(n))
return 0;
decimal ans = 0;
ans = 9 * 9 * Combination(n.Length - 1, 2);
ans += (n[0].ToDecimal() - 1) * (n.Length - 1) * 9;
ans += k1(Remove(n.ToString().Remove(0, 1)));
return ans;
}
private static long mod = 1000000007;
public static long ModPow(long x, long n) {
x = x % mod;
if (n == 0) {
return 1;
} else if (n % 2 == 1) {
return (x * ModPow(x, n - 1)) % mod;
} else {
return ModPow((x * x) % mod, n / 2) % mod;
}
}
public static long Combination(long n, long k) {
long x = 1;
for (long i = n - k + 1; i <= n; i++) {
x = x * i % mod;
}
long y = 1;
for (int i = 1; i <= k; i++) {
y = y * i % mod;
}
y = ModPow(y, mod - 2);
return x * y % mod;
}
public static string Read() { return Console.ReadLine(); }
public static string[] ReadSplit() { return Console.ReadLine().Split(' '); }
public static void WriteRead(object str) {
Console.WriteLine(str);
Read();
}
public static void Write(object str) { Console.WriteLine(str); }
}
}
public static class Extentions {
public static int ToInt(this object obj) { return int.Parse(obj.ToString()); }
public static decimal ToDecimal(this object obj) {
return decimal.Parse(obj.ToString());
}
public static double ToDouble(this object obj) {
return double.Parse(obj.ToString());
}
public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key)
where T2 : struct {
T2 value;
if (d.TryGetValue(key, out value)) {
return value;
}
return new T2();
}
}
|
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atcoder {
public class Program {
static void Main(string[] args) {
var n = Read();
var k = Read().ToInt();
decimal ans = 0;
if (n.Length < k) {
WriteRead(0);
return;
}
if (k == 1) {
ans = k1(n.ToString());
} else if (k == 2) {
ans = k2(n.ToString());
} else if (k == 3) {
ans = 9 * 9 * 9 * Combination(n.Length - 1, 3);
ans += (n[0].ToDecimal() - 1) * Combination((n.Length - 1), 2) * 9 * 9;
ans += k2(Remove(n.ToString().Remove(0, 1)));
}
WriteRead(ans);
}
private static string Remove(string n) {
var tmp = n;
if (string.IsNullOrEmpty(tmp))
return tmp;
bool isDel = true;
while (isDel) {
if (tmp.Length == 0)
break;
if (tmp[0] == '0') {
tmp = tmp.ToString().Remove(0, 1);
} else {
isDel = false;
}
}
return tmp;
}
private static decimal k1(string value) {
if (string.IsNullOrEmpty(value))
return 0;
decimal ans = 0;
ans = 9 * (value.Length - 1);
ans += value[0].ToDecimal();
return ans;
}
private static decimal k2(string n) {
if (string.IsNullOrEmpty(n))
return 0;
decimal ans = 0;
ans = 9 * 9 * Combination(n.Length - 1, 2);
ans += (n[0].ToDecimal() - 1) * (n.Length - 1) * 9;
ans += k1(Remove(n.ToString().Remove(0, 1)));
return ans;
}
private static long mod = 1000000007;
public static long ModPow(long x, long n) {
x = x % mod;
if (n == 0) {
return 1;
} else if (n % 2 == 1) {
return (x * ModPow(x, n - 1)) % mod;
} else {
return ModPow((x * x) % mod, n / 2) % mod;
}
}
public static long Combination(long n, long k) {
long x = 1;
for (long i = n - k + 1; i <= n; i++) {
x = x * i % mod;
}
long y = 1;
for (int i = 1; i <= k; i++) {
y = y * i % mod;
}
y = ModPow(y, mod - 2);
return x * y % mod;
}
public static string Read() { return Console.ReadLine(); }
public static string[] ReadSplit() { return Console.ReadLine().Split(' '); }
public static void WriteRead(object str) {
Console.WriteLine(str);
Read();
}
public static void Write(object str) { Console.WriteLine(str); }
}
}
public static class Extentions {
public static int ToInt(this object obj) { return int.Parse(obj.ToString()); }
public static decimal ToDecimal(this object obj) {
return decimal.Parse(obj.ToString());
}
public static double ToDouble(this object obj) {
return double.Parse(obj.ToString());
}
public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key)
where T2 : struct {
T2 value;
if (d.TryGetValue(key, out value)) {
return value;
}
return new T2();
}
}
|
[["+", 8, 196, 0, 57, 15, 16, 31, 214, 0, 131], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 141, 22], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 25], ["+", 0, 52, 8, 196, 0, 57, 64, 93, 0, 94], ["+", 0, 52, 8, 196, 0, 57, 64, 93, 0, 35], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 204, 205, 22]]
| 8
| 823
| 10
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using E = System.Linq.Enumerable;
class Program {
static void Main(string[] args) {
var N = Console.ReadLine();
var K = long.Parse(Console.ReadLine());
Console.WriteLine(AlmostEverywhereZero(N, K));
}
static long AlmostEverywhereZero(String N, long K) {
long ans = 0;
var len = N.Length;
if (K == 1) {
ans += 9 * (len - 1);
ans += N[0].ToInt();
} else if (K == 2) {
ans += (len - 1) * (len - 2) / 2 * 9 * 9;
ans += (len - 1) * 9 * (N[0].ToInt() - 1);
//先頭の数はN[0](つまり、元の先頭)に固定
var NonZeroIndex = len - 1;
for (int i = 1; i < len; i++) {
if (N[i] != '0') {
NonZeroIndex = i;
break;
}
}
ans += AlmostEverywhereZero(N.Substring(NonZeroIndex, len - NonZeroIndex),
1);
} else if (K == 3) {
ans += (len - 1) * (len - 2) * (len - 3) / 6 * 9 * 9 * 9;
ans += (len - 1) * (len - 2) / 2 * 9 * 9 * (N[0].ToInt() - 1);
var NonZeroIndex = len - 1;
for (int i = 1; i < len; i++) {
if (N[i] != '0') {
NonZeroIndex = i;
break;
}
}
ans += AlmostEverywhereZero(N.Substring(NonZeroIndex, len - NonZeroIndex),
2);
}
return ans;
}
}
public static class CharExt {
public static int ToInt(this char self) { return self - '0'; }
}
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();
}
class UnionFind
{
// 親要素のインデックスを保持する
// 親要素が存在しない(自身がルートである)とき、マイナスでグループの要素数を持つ
public long[] Parents { get; set; }
public UnionFind(long n)
{
this.Parents = new long[n];
for (int i = 0; i < n; i++)
{
// 初期状態ではそれぞれが別のグループ(ルートは自分自身)
// ルートなのでマイナスで要素数(1個)を保持する
this.Parents[i] = -1;
}
}
// 要素xのルート要素はどれか
public long Find(long x)
{
// 親がマイナスの場合は自分自身がルート
if (this.Parents[x] < 0)
return x;
// ルートが見つかるまで再帰的に探す
// 見つかったルートにつなぎかえる
this.Parents[x] = Find(this.Parents[x]);
return this.Parents[x];
}
// 要素xの属するグループの要素数を取得する
public long Size(long x)
{
// ルート要素を取得して、サイズを取得して返す
return -this.Parents[this.Find(x)];
}
// 要素x, yが同じグループかどうか判定する
public bool Same(long x, long y)
{
return this.Find(x) == this.Find(y);
}
// 要素x, yが属するグループを同じグループにまとめる
public bool Union(long x, long y)
{
// x, y のルート
x = this.Find(x);
y = this.Find(y);
// すでに同じグループの場合処理しない
if (x == y)
return false;
// 要素数が少ないグループを多いほうに書き換えたい
if (this.Size(x) < this.Size(y))
{
var tmp = x;
x = y;
y = tmp;
}
// まとめる先のグループの要素数を更新
this.Parents[x] += this.Parents[y];
// まとめられるグループのルートの親を書き換え
this.Parents[y] = x;
return true;
}
}
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using E = System.Linq.Enumerable;
class Program {
static void Main(string[] args) {
var N = Console.ReadLine();
var K = long.Parse(Console.ReadLine());
Console.WriteLine(AlmostEverywhereZero(N, K));
}
static long AlmostEverywhereZero(String N, long K) {
long ans = 0;
var len = N.Length;
if (K == 1) {
ans += 9 * (len - 1);
ans += N[0].ToInt();
} else if (K == 2) {
if (len >= 2) {
ans += (len - 1) * (len - 2) / 2 * 9 * 9;
ans += (len - 1) * 9 * (N[0].ToInt() - 1);
//先頭の数はN[0](つまり、元の先頭)に固定
var NonZeroIndex = len - 1;
for (int i = 1; i < len; i++) {
if (N[i] != '0') {
NonZeroIndex = i;
break;
}
}
ans += AlmostEverywhereZero(
N.Substring(NonZeroIndex, len - NonZeroIndex), 1);
}
} else if (K == 3) {
if (len >= 3) {
ans += (len - 1) * (len - 2) * (len - 3) / 6 * 9 * 9 * 9;
ans += ((len - 1) * (len - 2) / 2 * 9 * 9) * (N[0].ToInt() - 1);
var NonZeroIndex = len - 1;
for (int i = 1; i < len; i++) {
if (N[i] != '0') {
NonZeroIndex = i;
break;
}
}
ans += AlmostEverywhereZero(
N.Substring(NonZeroIndex, len - NonZeroIndex), 2);
}
}
return ans;
}
}
public static class CharExt {
public static int ToInt(this char self) { return self - '0'; }
}
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();
}
class UnionFind
{
// 親要素のインデックスを保持する
// 親要素が存在しない(自身がルートである)とき、マイナスでグループの要素数を持つ
public long[] Parents { get; set; }
public UnionFind(long n)
{
this.Parents = new long[n];
for (int i = 0; i < n; i++)
{
// 初期状態ではそれぞれが別のグループ(ルートは自分自身)
// ルートなのでマイナスで要素数(1個)を保持する
this.Parents[i] = -1;
}
}
// 要素xのルート要素はどれか
public long Find(long x)
{
// 親がマイナスの場合は自分自身がルート
if (this.Parents[x] < 0)
return x;
// ルートが見つかるまで再帰的に探す
// 見つかったルートにつなぎかえる
this.Parents[x] = Find(this.Parents[x]);
return this.Parents[x];
}
// 要素xの属するグループの要素数を取得する
public long Size(long x)
{
// ルート要素を取得して、サイズを取得して返す
return -this.Parents[this.Find(x)];
}
// 要素x, yが同じグループかどうか判定する
public bool Same(long x, long y)
{
return this.Find(x) == this.Find(y);
}
// 要素x, yが属するグループを同じグループにまとめる
public bool Union(long x, long y)
{
// x, y のルート
x = this.Find(x);
y = this.Find(y);
// すでに同じグループの場合処理しない
if (x == y)
return false;
// 要素数が少ないグループを多いほうに書き換えたい
if (this.Size(x) < this.Size(y))
{
var tmp = x;
x = y;
y = tmp;
}
// まとめる先のグループの要素数を更新
this.Parents[x] += this.Parents[y];
// まとめられるグループのルートの親を書き換え
this.Parents[y] = x;
return true;
}
}
|
[["+", 0, 57, 75, 57, 64, 196, 0, 57, 0, 121], ["+", 0, 57, 75, 57, 64, 196, 0, 57, 0, 24], ["+", 75, 57, 64, 196, 0, 57, 15, 16, 31, 22], ["+", 75, 57, 64, 196, 0, 57, 15, 16, 17, 20], ["+", 75, 57, 64, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 57, 75, 57, 64, 196, 0, 57, 0, 25], ["+", 75, 57, 64, 196, 0, 57, 64, 196, 0, 45], ["+", 75, 57, 64, 196, 0, 57, 64, 196, 0, 46], ["+", 0, 57, 75, 57, 75, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 57, 75, 57, 75, 57, 0, 25], ["+", 0, 57, 75, 57, 75, 57, 64, 196, 0, 45], ["+", 75, 57, 75, 57, 64, 196, 0, 57, 0, 121], ["+", 75, 57, 75, 57, 64, 196, 0, 57, 0, 24], ["+", 31, 16, 31, 16, 31, 16, 31, 23, 0, 24], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25]]
| 8
| 1,124
| 18
|
using System;
using System.Linq;
namespace PracticeForAtCoder {
class Program {
static void Main(string[] args) {
//ここから
string n = Console.ReadLine();
int k = int.Parse(Console.ReadLine());
int ans = Solve(n, k);
Console.WriteLine(ans);
//ここまで
}
static int ncr(int n, int r) {
int temp = 1;
int bunbo = 1;
for (int i = 1; i <= r; i++) {
temp *= (n - i + 1);
bunbo *= i;
}
return temp / bunbo;
}
static int Ketain(int ketasuu, int k) {
return ncr(ketasuu, k) * (int)Math.Pow(9, k);
}
static int Solve(string n, int k) {
int ans = 0;
int length = n.Length;
if (length < k)
return 0;
if (length > k)
ans += Ketain(length - 1, k);
if (k > 1) {
ans += Ketain(length - 1, k - 1) * (n[0].ToInt() - 1);
ans += Solve(n.Remove(0, 1), k - 1);
}
if (k == 1)
ans += n[0].ToInt();
return ans;
}
}
public static class CharExt {
public static int ToInt(this char self) { return self - '0'; }
}
}
|
using System;
using System.Linq;
namespace PracticeForAtCoder {
class Program {
static void Main(string[] args) {
//ここから
string n = Console.ReadLine();
int k = int.Parse(Console.ReadLine());
int ans = Solve(n, k);
Console.WriteLine(ans);
//ここまで
}
static int ncr(int n, int r) {
int temp = 1;
int bunbo = 1;
for (int i = 1; i <= r; i++) {
temp *= (n - i + 1);
bunbo *= i;
}
return temp / bunbo;
}
static int Ketain(int ketasuu, int k) {
return ncr(ketasuu, k) * (int)Math.Pow(9, k);
}
static int Solve(string n, int k) {
while (n[0] == '0' && n.Length > 1) {
n = n.Remove(0, 1);
}
int ans = 0;
int length = n.Length;
if (length < k)
return 0;
if (length > k)
ans += Ketain(length - 1, k);
if (k > 1) {
ans += Ketain(length - 1, k - 1) * (n[0].ToInt() - 1);
ans += Solve(n.Remove(0, 1), k - 1);
}
if (k == 1)
ans += n[0].ToInt();
return ans;
}
}
public static class CharExt {
public static int ToInt(this char self) { return self - '0'; }
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 52, 0, 89], ["+", 8, 201, 0, 195, 8, 196, 0, 52, 0, 24], ["+", 0, 52, 15, 16, 31, 16, 31, 204, 205, 22], ["+", 15, 16, 31, 16, 31, 204, 206, 207, 0, 70], ["+", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 31, 16, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 52, 15, 16, 31, 16, 17, 60], ["+", 0, 52, 15, 16, 31, 16, 12, 252, 0, 104], ["+", 0, 52, 15, 16, 31, 16, 12, 252, 0, 253], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 98], ["+", 0, 52, 15, 16, 12, 16, 31, 214, 205, 22], ["+", 0, 52, 15, 16, 12, 16, 31, 214, 0, 131], ["+", 0, 52, 15, 16, 12, 16, 31, 214, 141, 22], ["+", 8, 196, 0, 52, 15, 16, 12, 16, 17, 47], ["+", 8, 196, 0, 52, 15, 16, 12, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 52, 0, 25], ["+", 0, 195, 8, 196, 0, 52, 8, 196, 0, 45], ["+", 0, 52, 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, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 52, 8, 196, 0, 46]]
| 8
| 304
| 30
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder {
class Program {
static void Main() {
Solve();
Console.ReadKey();
}
static void Solve() {
var N = GetStr();
var K = GetInt();
var C = N.Length;
var dp = new int [C][][];
for (int i = 0; i < C; i++) {
dp[i] = new int [2][];
for (int j = 0; j < 2; j++) {
dp[i][j] = Enumerable.Repeat(0, K + 1).ToArray();
}
}
dp[0][0][0] = 1;
dp[0][0][1] = int.Parse(N[0].ToString()) - 1;
dp[0][1][0] = 0;
dp[0][1][1] = 1;
var ans0 = Rec(N, dp, C - 1, 0, K);
// var ans1 = Rec(N, dp, C - 1, 1, K);
var ans = ans0 + 1;
Console.WriteLine(ans);
}
static int Rec(string N, int[][][] dp, int i, int j, int k) {
if (i == 0) {
return dp[i][j][k];
}
if (j == 0 && k == 0) {
return Rec(N, dp, i - 1, 0, 0);
} else if (j == 0) //&&k==k
{
if (N[i] == '0') {
return Rec(N, dp, i - 1, 0, k - 1) * 9 + Rec(N, dp, i - 1, 0, k);
} else {
return Rec(N, dp, i - 1, 0, k - 1) * 9 + Rec(N, dp, i - 1, 0, k) +
Rec(N, dp, i - 1, 1, k - 1) * (int.Parse(N[i].ToString()) - 1) +
Rec(N, dp, i - 1, 1, k);
}
} else if (k == 0) //&& j==1
{
return 0;
} else // k==k && j==1
{
if (N[i] != '0') {
return Rec(N, dp, i - 1, 1, k - 1) * (int.Parse(N[i].ToString()) - 1);
} else {
return Rec(N, dp, i - 1, 1, k);
}
}
}
static 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 string GetStr() { return Console.ReadLine(); }
static public int GetInt() { return int.Parse(Console.ReadLine()); }
static public long GetLong() { return long.Parse(Console.ReadLine()); }
static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
static public int[] GetIntArray() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
static public long[] GetLongArray() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
}
static public List<double> GetDoubleList() {
return Console.ReadLine().Split(' ').Select(double.Parse).ToList();
}
static public void WriteObjects<T>(IEnumerable<T> values) {
foreach (var o in values) {
Console.Write(o + " ");
}
}
static bool eq<T, U>() => typeof(T).Equals(typeof(U));
static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
: eq<T, long>() ? ct<T, long>(long.Parse(s))
: eq<T, double>() ? ct<T, double>(double.Parse(s))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
static void Multi<T>(out T a) => a = cv<T>(GetStr());
static void Multi<T, U>(out T a, out U b) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
static void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder {
class Program {
static void Main() {
Solve();
Console.ReadKey();
}
static void Solve() {
var N = GetStr();
var K = GetInt();
var C = N.Length;
var dp = new int [C][][];
for (int i = 0; i < C; i++) {
dp[i] = new int [2][];
for (int j = 0; j < 2; j++) {
dp[i][j] = Enumerable.Repeat(0, K + 1).ToArray();
}
}
dp[0][0][0] = 1;
dp[0][0][1] = int.Parse(N[0].ToString()) - 1;
dp[0][1][0] = 0;
dp[0][1][1] = 1;
var ans0 = Rec(N, dp, C - 1, 0, K);
var ans1 = Rec(N, dp, C - 1, 1, K);
var ans = ans0 + ans1;
Console.WriteLine(ans);
}
static int Rec(string N, int[][][] dp, int i, int j, int k) {
if (i == 0) {
return dp[i][j][k];
}
if (j == 0 && k == 0) {
return Rec(N, dp, i - 1, 0, 0);
} else if (j == 0) //&&k==k
{
if (N[i] == '0') {
return Rec(N, dp, i - 1, 0, k - 1) * 9 + Rec(N, dp, i - 1, 0, k);
} else {
return Rec(N, dp, i - 1, 0, k - 1) * 9 + Rec(N, dp, i - 1, 0, k) +
Rec(N, dp, i - 1, 1, k - 1) * (int.Parse(N[i].ToString()) - 1) +
Rec(N, dp, i - 1, 1, k);
}
} else if (k == 0) //&& j==1
{
return 0;
} else // k==k && j==1
{
if (N[i] != '0') {
return Rec(N, dp, i - 1, 1, k - 1);
} else {
return Rec(N, dp, i - 1, 1, k);
}
}
}
static 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 string GetStr() { return Console.ReadLine(); }
static public int GetInt() { return int.Parse(Console.ReadLine()); }
static public long GetLong() { return long.Parse(Console.ReadLine()); }
static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
static public int[] GetIntArray() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
static public long[] GetLongArray() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
}
static public List<double> GetDoubleList() {
return Console.ReadLine().Split(' ').Select(double.Parse).ToList();
}
static public void WriteObjects<T>(IEnumerable<T> values) {
foreach (var o in values) {
Console.Write(o + " ");
}
}
static bool eq<T, U>() => typeof(T).Equals(typeof(U));
static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
: eq<T, long>() ? ct<T, long>(long.Parse(s))
: eq<T, double>() ? ct<T, double>(double.Parse(s))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
static void Multi<T>(out T a) => a = cv<T>(GetStr());
static void Multi<T, U>(out T a, out U b) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
static void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
}
}
|
[["+", 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, 213, 63, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["+", 0, 212, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 21], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 0, 212, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["-", 31, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["-", 31, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["-", 0, 37, 0, 16, 31, 213, 3, 4, 0, 25], ["-", 0, 57, 64, 196, 0, 37, 0, 16, 17, 48], ["-", 64, 196, 0, 37, 0, 16, 12, 23, 0, 24], ["-", 12, 23, 0, 16, 31, 213, 63, 214, 205, 199], ["-", 12, 23, 0, 16, 31, 213, 63, 214, 0, 131], ["-", 12, 23, 0, 16, 31, 213, 63, 214, 141, 22], ["-", 12, 23, 0, 16, 31, 213, 3, 4, 0, 24], ["-", 0, 28, 0, 213, 63, 214, 205, 204, 205, 22], ["-", 0, 213, 63, 214, 205, 204, 206, 207, 0, 70], ["-", 63, 214, 205, 204, 206, 207, 0, 28, 0, 22], ["-", 0, 213, 63, 214, 205, 204, 206, 207, 0, 73], ["-", 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], ["-", 12, 23, 0, 16, 31, 213, 3, 4, 0, 25]]
| 8
| 1,147
| 38
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder.Abc {
class QuestionE {
public static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
// 整数の入力
string n = Console.ReadLine();
int k = int.Parse(Console.ReadLine());
int first = int.Parse(n.Substring(0, 1));
long result = 0;
if (n.Length < k) {
result = 0;
} else {
result = Test(n, k);
}
Console.WriteLine(result);
Console.Out.Flush();
}
public static long Test(string n, int k) {
int first = int.Parse(n.Substring(0, 1));
if (n.StartsWith("0")) {
// 0始まりは、無視する
return Test(n.Substring(1), k);
}
if (n.Length < k) {
return 0;
}
long result = 0;
if (k == 1) {
//最上位以外は1~9の9個が該当する
//最上位だけ、1~{first-1}個が該当
result = 9 * (n.Length - 1);
result += first;
} else {
// sの最大桁数を使わない場合
//残りのs.Length - 1からk箇所とって、k^10 -1をかければいい
result = nCr(n.Length - 1, k) * (long)(Math.Pow(9, k));
// sの最大桁数を使う場合
//最大桁数が最大値でないなら、残りのs.Length -1
//からk-1箇所取って、(k-1)^10-1をかければいい
result +=
(first - 1) * nCr(n.Length - 1, k - 1) * (long)(Math.Pow(9, k - 1));
//最大桁数が最大値の場合、再起で求める
result += Test(n.Substring(1), k - 1);
}
// Program.Debug.Log($"Test({n},{k}) -> {result}");
return result;
}
public static long nCr(int n, int r) {
// naive: return Factorial(n) / (Factorial(r) * Factorial(n - r));
return nPr(n, r) / Factorial(r);
}
public static long nPr(int n, int r) {
// naive: return Factorial(n) / Factorial(n - r);
return FactorialDivision(n, n - r);
}
private static long FactorialDivision(int topFactorial,
int divisorFactorial) {
long result = 1;
for (int i = topFactorial; i > divisorFactorial; i--)
result *= i;
return result;
}
private static long Factorial(int i) {
if (i <= 1)
return 1;
return i * Factorial(i - 1);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder.Abc {
class QuestionE {
public static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
// 整数の入力
string n = Console.ReadLine();
int k = int.Parse(Console.ReadLine());
int first = int.Parse(n.Substring(0, 1));
long result = 0;
if (n.Length < k) {
result = 0;
} else {
result = Test(n, k);
}
Console.WriteLine(result);
Console.Out.Flush();
}
public static long Test(string n, int k) {
if (n.Length == 0) {
return 0;
}
int first = int.Parse(n.Substring(0, 1));
if (n.StartsWith("0")) {
// 0始まりは、無視する
return Test(n.Substring(1), k);
}
if (n.Length < k) {
return 0;
}
long result = 0;
if (k == 1) {
//最上位以外は1~9の9個が該当する
//最上位だけ、1~{first-1}個が該当
result = 9 * (n.Length - 1);
result += first;
} else {
// sの最大桁数を使わない場合
//残りのs.Length - 1からk箇所とって、k^10 -1をかければいい
result = nCr(n.Length - 1, k) * (long)(Math.Pow(9, k));
// sの最大桁数を使う場合
//最大桁数が最大値でないなら、残りのs.Length -1
//からk-1箇所取って、(k-1)^10-1をかければいい
result +=
(first - 1) * nCr(n.Length - 1, k - 1) * (long)(Math.Pow(9, k - 1));
//最大桁数が最大値の場合、再起で求める
result += Test(n.Substring(1), k - 1);
}
// Program.Debug.Log($"Test({n},{k}) -> {result}");
return result;
}
public static long nCr(int n, int r) {
// naive: return Factorial(n) / (Factorial(r) * Factorial(n - r));
return nPr(n, r) / Factorial(r);
}
public static long nPr(int n, int r) {
// naive: return Factorial(n) / Factorial(n - r);
return FactorialDivision(n, n - r);
}
private static long FactorialDivision(int topFactorial,
int divisorFactorial) {
long result = 1;
for (int i = topFactorial; i > divisorFactorial; i--)
result *= i;
return result;
}
private static long Factorial(int i) {
if (i <= 1)
return 1;
return i * Factorial(i - 1);
}
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 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], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 478
| 13
|
using System;
using System.Linq;
public class AtCoder_154_E {
public static void Main() {
// var exStdIn = new System.IO.StreamReader("input.txt");
// System.Console.SetIn(exStdIn);
char[] n = Console.ReadLine().ToCharArray();
int k = int.Parse(Console.ReadLine());
long[] pow = new long[] { 1, 9, 9 * 9, 9 * 9 * 9 };
if (k > n.Length) {
Console.WriteLine("0");
return;
}
long ans = 0;
for (int i = 0; i < k && i < n.Length; i++) {
int left = int.Parse(n[i].ToString());
if (left == 0) {
k++;
continue;
}
if (i < n.Length - 1) {
// 一番大きい暗いを選ばない
ans += pow[k - i] * nCm(n.Length - i - 1, k - i);
}
if (left > 1) {
if (i == k - 1) {
ans += (left - 1);
} else {
ans += (left - 1) * pow[k - i - 1] * nCm(n.Length - i - 1, k - i - 1);
}
}
}
ans++;
Console.WriteLine(ans);
}
// Copyright (C) 2013 sz-x638 All rights reserved.
// http://zweihander638.blog.fc2.com
public static long nCm(int n, int m) {
if (m == 0)
return 1;
if (n == 0)
return 0;
return n * nCm(n - 1, m - 1) / m;
}
}
|
using System;
using System.Linq;
public class AtCoder_154_E {
public static void Main() {
// var exStdIn = new System.IO.StreamReader("input.txt");
// System.Console.SetIn(exStdIn);
char[] n = Console.ReadLine().ToCharArray();
int k = int.Parse(Console.ReadLine());
long[] pow = new long[] { 1, 9, 9 * 9, 9 * 9 * 9 };
if (k > n.Length) {
Console.WriteLine("0");
return;
}
long ans = 0;
for (int i = 0; i < k && i < n.Length; i++) {
int left = int.Parse(n[i].ToString());
if (left == 0) {
k++;
if (i == n.Length - 1) {
ans--;
}
continue;
}
if (i < n.Length - 1) {
// 一番大きい暗いを選ばない
ans += pow[k - i] * nCm(n.Length - i - 1, k - i);
}
if (left > 1) {
if (i == k - 1) {
ans += (left - 1);
} else {
ans += (left - 1) * pow[k - i - 1] * nCm(n.Length - i - 1, k - i - 1);
}
}
}
ans++;
Console.WriteLine(ans);
}
// Copyright (C) 2013 sz-x638 All rights reserved.
// http://zweihander638.blog.fc2.com
public static long nCm(int n, int m) {
if (m == 0)
return 1;
if (n == 0)
return 0;
return n * nCm(n - 1, m - 1) / m;
}
}
|
[["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 57, 15, 16, 12, 16, 31, 214, 205, 22], ["+", 0, 57, 15, 16, 12, 16, 31, 214, 0, 131], ["+", 0, 57, 15, 16, 12, 16, 31, 214, 141, 22], ["+", 64, 196, 0, 57, 15, 16, 12, 16, 17, 33], ["+", 64, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 68], ["+", 64, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 314
| 15
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;
public class E {
public static void Main() => (new Solver()).Solve();
}
public class Solver {
public void Solve() {
string N = GetString();
int K = GetInt();
int L = N.Length;
int[] num = new int[L];
for (int i = 0; i < L; i++)
num[i] = (int)(N[i] - '0');
long[,,] dp = new long[L, L - K + 1, 2];
if (L - K > 0)
dp[0, 1, 1] = 1;
for (int i = 1; i < num[0]; i++)
dp[0, 0, 1]++;
dp[0, 0, 0] = 1;
for (int i = 1; i < L; i++) {
for (int j = 0; j <= L - K; j++) {
if (j < L - K) {
if (num[i] == 0) {
dp[i, j + 1, 0] += dp[i - 1, j, 0];
dp[i, j + 1, 1] += dp[i - 1, j, 1];
} else {
dp[i, j + 1, 1] += dp[i - 1, j, 0] + dp[i - 1, j, 1];
}
}
for (int l = 1; l < 10; l++) {
if (l < num[i]) {
dp[i, j, 1] += dp[i - 1, j, 0] + dp[i - 1, j, 1];
} else if (l == num[i]) {
dp[i, j, 0] += dp[i - 1, j, 0];
dp[i, j, 1] += dp[i - 1, j, 1];
} else {
dp[i, j, 1] += dp[i - 1, j, 1];
}
}
}
}
WriteLine(dp[L - 1, L - K, 0] + dp[L - 1, L - K, 1]);
}
}
public static class MyIO {
private static string[] args = null;
private static int num = -1;
private static int used = -1;
private static string getArg() {
if (used == num) {
args = Console.ReadLine().Split(' ');
num = args.Length;
used = 0;
}
return args[used++];
}
public static int GetInt() => int.Parse(getArg());
public static long GetLong() => long.Parse(getArg());
public static double GetDouble() => double.Parse(getArg());
public static decimal GetDecimal() => decimal.Parse(getArg());
public static string GetString() => getArg();
public static char GetChar() => getArg()[0];
public static int[] GetInts(long N) =>
Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
public static long[] GetLongs(long N) =>
Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
public static double[] GetDoubles(long N) =>
Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
public static decimal[] GetDecimals(long N) =>
Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
public static string[] GetStrings(long N) =>
Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}
public static class MyUtil {
public static void chmax<T>(ref T x, T y)
where T : IComparable<T> {
if (x.CompareTo(y) < 0)
x = y;
}
public static void chmin<T>(ref T x, T y)
where T : IComparable<T> {
if (x.CompareTo(y) > 0)
x = y;
}
public static void swap<T>(ref T x, ref T y) {
T tmp = x;
x = y;
y = tmp;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;
public class E {
public static void Main() => (new Solver()).Solve();
}
public class Solver {
public void Solve() {
string N = GetString();
int K = GetInt();
int L = N.Length;
if (L < K) {
WriteLine(0);
return;
}
int[] num = new int[L];
for (int i = 0; i < L; i++)
num[i] = (int)(N[i] - '0');
long[,,] dp = new long[L, L - K + 1, 2];
if (L - K > 0)
dp[0, 1, 1] = 1;
for (int i = 1; i < num[0]; i++)
dp[0, 0, 1]++;
dp[0, 0, 0] = 1;
for (int i = 1; i < L; i++) {
for (int j = 0; j <= L - K; j++) {
if (j < L - K) {
if (num[i] == 0) {
dp[i, j + 1, 0] += dp[i - 1, j, 0];
dp[i, j + 1, 1] += dp[i - 1, j, 1];
} else {
dp[i, j + 1, 1] += dp[i - 1, j, 0] + dp[i - 1, j, 1];
}
}
for (int l = 1; l < 10; l++) {
if (l < num[i]) {
dp[i, j, 1] += dp[i - 1, j, 0] + dp[i - 1, j, 1];
} else if (l == num[i]) {
dp[i, j, 0] += dp[i - 1, j, 0];
dp[i, j, 1] += dp[i - 1, j, 1];
} else {
dp[i, j, 1] += dp[i - 1, j, 1];
}
}
}
}
WriteLine(dp[L - 1, L - K, 0] + dp[L - 1, L - K, 1]);
}
}
public static class MyIO {
private static string[] args = null;
private static int num = -1;
private static int used = -1;
private static string getArg() {
if (used == num) {
args = Console.ReadLine().Split(' ');
num = args.Length;
used = 0;
}
return args[used++];
}
public static int GetInt() => int.Parse(getArg());
public static long GetLong() => long.Parse(getArg());
public static double GetDouble() => double.Parse(getArg());
public static decimal GetDecimal() => decimal.Parse(getArg());
public static string GetString() => getArg();
public static char GetChar() => getArg()[0];
public static int[] GetInts(long N) =>
Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
public static long[] GetLongs(long N) =>
Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
public static double[] GetDoubles(long N) =>
Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
public static decimal[] GetDecimals(long N) =>
Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
public static string[] GetStrings(long N) =>
Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}
public static class MyUtil {
public static void chmax<T>(ref T x, T y)
where T : IComparable<T> {
if (x.CompareTo(y) < 0)
x = y;
}
public static void chmin<T>(ref T x, T y)
where T : IComparable<T> {
if (x.CompareTo(y) > 0)
x = y;
}
public static void swap<T>(ref T x, ref T y) {
T tmp = x;
x = y;
y = tmp;
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 213, 63, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 985
| 15
|
using System;
using System.Linq;
public class Test {
public static void Main() {
// my code goes here
var c = Console.ReadLine().Split().Select(b => int.Parse(b)).ToArray();
int h = c[0];
int a = c[1];
int ans = h / a + 1;
Console.WriteLine(ans);
}
}
|
using System;
using System.Linq;
public class Test {
public static void Main() {
// my code goes here
var c = Console.ReadLine().Split().Select(b => int.Parse(b)).ToArray();
int h = c[0];
int a = c[1];
int ans = h / a;
if (h % a != 0) {
ans++;
}
Console.WriteLine(ans);
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 79], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 29], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 83
| 15
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
var inp = Inputer.IntArray1Line();
var H = (inp[0] / inp[1]) + 1;
Console.Write(H);
}
}
/// <summary>
/// 素数かどうか判定する
/// </summary>
static class IsPrime {
/// <summary>
/// 素数かどうか判定
/// </summary>
/// <param name="num"></param>
/// <returns></returns>
public static bool Is(int num) {
if (num < 2)
return false;
else if (num == 2)
return true;
else if (num % 2 == 0)
return false;
double sqrtNum = Math.Sqrt(num);
for (int i = 3; i <= sqrtNum; i += 2) {
if (num % i == 0) {
return false;
}
}
return true;
}
}
/// <summary>
/// 入力受付
/// </summary>
static class Inputer {
/// <summary>
/// A B C の複数整数からなる1行を受け取る
/// </summary>
/// <returns></returns>
public static int[] IntArray1Line() {
return Console.ReadLine().Split().Select(int.Parse).ToArray();
}
/// <summary>
/// 整数N のような1つの整数からなる入力を受け取る
/// </summary>
/// <returns></returns>
public static int Int1Char() { return int.Parse(Console.ReadLine()); }
public static double Double1Char() {
return double.Parse(Console.ReadLine());
}
/// <summary>
/// 大きい整数N のような1つの整数からなる入力を受け取る
/// </summary>
/// <returns></returns>
public static long Long1Char() { return long.Parse(Console.ReadLine()); }
public static List<int> MultLineInt(int Linenum) {
var L = new List<int>();
for (int i = 0; i < Linenum; i++) {
L.Add(int.Parse(Console.ReadLine()));
}
return L;
}
public static long[] LongArray1Line() {
return Console.ReadLine().Split().Select(long.Parse).ToArray();
}
public static Char[] CharArray() { return Console.ReadLine().ToCharArray(); }
}
/// <summary>
/// 順列を出すやつ
/// </summary>
/// <typeparam name="T"></typeparam>
static class Permutation<T> {
private static void Search(List<T[]> perms, Stack<T> stack, T[] a) {
int N = a.Length;
if (N == 0) {
perms.Add(stack.Reverse().ToArray());
} else {
var b = new T[N - 1];
Array.Copy(a, 1, b, 0, N - 1);
for (int i = 0; i < a.Length; ++i) {
stack.Push(a[i]);
Search(perms, stack, b);
if (i < b.Length) {
b[i] = a[i];
}
stack.Pop();
}
}
}
public static IEnumerable<T[]> All(IEnumerable<T> src) {
var perms = new List<T[]>();
Search(perms, new Stack<T>(), src.ToArray());
return perms;
}
}
/// <summary>
/// 素因数分解
/// </summary>
static class PrimeFactors {
public static IEnumerable<long> PrimeFactor(long n) {
long i = 2;
long tmp = n;
while (i * i <= n) {
if (tmp % i == 0) {
tmp /= i;
yield return i;
} else {
i++;
}
}
if (tmp != 1)
yield return tmp; //最後の素数も返す
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
var inp = Inputer.IntArray1Line();
var chousei = 1;
if (inp[0] % inp[1] == 0) {
chousei = 0;
}
var H = (inp[0] / inp[1]) + chousei;
Console.Write(H);
}
}
/// <summary>
/// 素数かどうか判定する
/// </summary>
static class IsPrime {
/// <summary>
/// 素数かどうか判定
/// </summary>
/// <param name="num"></param>
/// <returns></returns>
public static bool Is(int num) {
if (num < 2)
return false;
else if (num == 2)
return true;
else if (num % 2 == 0)
return false;
double sqrtNum = Math.Sqrt(num);
for (int i = 3; i <= sqrtNum; i += 2) {
if (num % i == 0) {
return false;
}
}
return true;
}
}
/// <summary>
/// 入力受付
/// </summary>
static class Inputer {
/// <summary>
/// A B C の複数整数からなる1行を受け取る
/// </summary>
/// <returns></returns>
public static int[] IntArray1Line() {
return Console.ReadLine().Split().Select(int.Parse).ToArray();
}
/// <summary>
/// 整数N のような1つの整数からなる入力を受け取る
/// </summary>
/// <returns></returns>
public static int Int1Char() { return int.Parse(Console.ReadLine()); }
public static double Double1Char() {
return double.Parse(Console.ReadLine());
}
/// <summary>
/// 大きい整数N のような1つの整数からなる入力を受け取る
/// </summary>
/// <returns></returns>
public static long Long1Char() { return long.Parse(Console.ReadLine()); }
public static List<int> MultLineInt(int Linenum) {
var L = new List<int>();
for (int i = 0; i < Linenum; i++) {
L.Add(int.Parse(Console.ReadLine()));
}
return L;
}
public static long[] LongArray1Line() {
return Console.ReadLine().Split().Select(long.Parse).ToArray();
}
public static Char[] CharArray() { return Console.ReadLine().ToCharArray(); }
}
/// <summary>
/// 順列を出すやつ
/// </summary>
/// <typeparam name="T"></typeparam>
static class Permutation<T> {
private static void Search(List<T[]> perms, Stack<T> stack, T[] a) {
int N = a.Length;
if (N == 0) {
perms.Add(stack.Reverse().ToArray());
} else {
var b = new T[N - 1];
Array.Copy(a, 1, b, 0, N - 1);
for (int i = 0; i < a.Length; ++i) {
stack.Push(a[i]);
Search(perms, stack, b);
if (i < b.Length) {
b[i] = a[i];
}
stack.Pop();
}
}
}
public static IEnumerable<T[]> All(IEnumerable<T> src) {
var perms = new List<T[]>();
Search(perms, new Stack<T>(), src.ToArray());
return perms;
}
}
/// <summary>
/// 素因数分解
/// </summary>
static class PrimeFactors {
public static IEnumerable<long> PrimeFactor(long n) {
long i = 2;
long tmp = n;
while (i * i <= n) {
if (tmp % i == 0) {
tmp /= i;
yield return i;
} else {
i++;
}
}
if (tmp != 1)
yield return tmp; //最後の素数も返す
}
}
}
|
[["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 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, 16, 31, 204, 205, 22], ["+", 15, 16, 31, 16, 31, 204, 206, 207, 0, 70], ["+", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 31, 16, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["+", 0, 57, 15, 16, 31, 16, 12, 204, 205, 22], ["+", 15, 16, 31, 16, 12, 204, 206, 207, 0, 70], ["+", 31, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 31, 16, 12, 204, 206, 207, 0, 73], ["+", 0, 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, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22]]
| 8
| 686
| 27
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using static exMath;
using static exReadLine;
class Program {
static void Main(string[] args) {
int H, A;
intReadLine(out H, out A);
WriteLine(1 + (H / A));
}
}
static class exReadLine {
public static void intReadLine(out int a) { a = int.Parse(ReadLine()); }
public static void intReadLine(out int a, out int b) {
int[] input = ReadLine().Split().Select(int.Parse).ToArray();
a = input[0];
b = input[1];
}
public static void intReadLine(out int a, out int b, out int c) {
int[] input = ReadLine().Split().Select(int.Parse).ToArray();
a = input[0];
b = input[1];
c = input[2];
}
public static void intReadLine(out int a, out int b, out int c, out int d) {
int[] input = ReadLine().Split().Select(int.Parse).ToArray();
a = input[0];
b = input[1];
c = input[2];
d = input[3];
}
public static void longReadLine(out long a) { a = long.Parse(ReadLine()); }
public static void longReadLine(out long a, out long b) {
long[] input = ReadLine().Split().Select(long.Parse).ToArray();
a = input[0];
b = input[1];
}
public static void longReadLine(out long a, out long b, out long c) {
long[] input = ReadLine().Split().Select(long.Parse).ToArray();
a = input[0];
b = input[1];
c = input[2];
}
public static void longReadLine(out long a, out long b, out long c,
out long d) {
long[] input = ReadLine().Split().Select(long.Parse).ToArray();
a = input[0];
b = input[1];
c = input[2];
d = input[3];
}
}
static class exMath {
// 最大公約数
public static int Gcd(int a, int b) {
if (a < b)
return Gcd(b, a);
while (b != 0) {
var r = a % b;
a = b;
b = r;
}
return a;
}
public static long Gcd(long a, long b) {
if (a < b)
return Gcd(b, a);
while (b != 0) {
var r = a % b;
a = b;
b = r;
}
return a;
}
// 最小公倍数
public static long Lcm(int a, int b) { return BigMul(a, b) / Gcd(a, b); }
public static long Lcm(long a, long b) { return a * b / Gcd(a, b); }
}
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using static exMath;
using static exReadLine;
class Program {
static void Main(string[] args) {
int H, A;
intReadLine(out H, out A);
if (H % A == 0) {
WriteLine(H / A);
} else {
WriteLine(1 + (H / A));
}
}
}
static class exReadLine {
public static void intReadLine(out int a) { a = int.Parse(ReadLine()); }
public static void intReadLine(out int a, out int b) {
int[] input = ReadLine().Split().Select(int.Parse).ToArray();
a = input[0];
b = input[1];
}
public static void intReadLine(out int a, out int b, out int c) {
int[] input = ReadLine().Split().Select(int.Parse).ToArray();
a = input[0];
b = input[1];
c = input[2];
}
public static void intReadLine(out int a, out int b, out int c, out int d) {
int[] input = ReadLine().Split().Select(int.Parse).ToArray();
a = input[0];
b = input[1];
c = input[2];
d = input[3];
}
public static void longReadLine(out long a) { a = long.Parse(ReadLine()); }
public static void longReadLine(out long a, out long b) {
long[] input = ReadLine().Split().Select(long.Parse).ToArray();
a = input[0];
b = input[1];
}
public static void longReadLine(out long a, out long b, out long c) {
long[] input = ReadLine().Split().Select(long.Parse).ToArray();
a = input[0];
b = input[1];
c = input[2];
}
public static void longReadLine(out long a, out long b, out long c,
out long d) {
long[] input = ReadLine().Split().Select(long.Parse).ToArray();
a = input[0];
b = input[1];
c = input[2];
d = input[3];
}
}
static class exMath {
// 最大公約数
public static int Gcd(int a, int b) {
if (a < b)
return Gcd(b, a);
while (b != 0) {
var r = a % b;
a = b;
b = r;
}
return a;
}
public static long Gcd(long a, long b) {
if (a < b)
return Gcd(b, a);
while (b != 0) {
var r = a % b;
a = b;
b = r;
}
return a;
}
// 最小公倍数
public static long Lcm(int a, int b) { return BigMul(a, b) / Gcd(a, b); }
public static long Lcm(long a, long b) { return a * b / Gcd(a, b); }
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 213, 63, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 85], ["+", 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, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 679
| 20
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
//入力
long[] inputLongArray =
Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
if (inputLongArray.Where(x => x % 2 == 0)
.Any(x => x % 3 != 0 && x % 5 != 0)) {
Console.WriteLine("DENIED");
} else {
Console.WriteLine("APPROVED");
}
// 文字列の入力
// string s = Console.ReadLine();
// 整数の入力
/*long n = long.Parse(Console.ReadLine());
// 文字列配列の入力
string[] inputStrArray = Console.ReadLine().Split(' ');
// 整数配列の入力
long[] inputLongArray = Console.ReadLine().Split(' ').Select(i =>
long.Parse(i)).ToArray();
*/
//処理
//出力
Console.Out.Flush();
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
//入力
long n = long.Parse(Console.ReadLine());
long[] inputLongArray =
Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
if (inputLongArray.Where(x => x % 2 == 0)
.Any(x => x % 3 != 0 && x % 5 != 0)) {
Console.WriteLine("DENIED");
} else {
Console.WriteLine("APPROVED");
}
// 文字列の入力
// string s = Console.ReadLine();
// 整数の入力
/*long n = long.Parse(Console.ReadLine());
// 文字列配列の入力
string[] inputStrArray = Console.ReadLine().Split(' ');
// 整数配列の入力
long[] inputLongArray = Console.ReadLine().Split(' ').Select(i =>
long.Parse(i)).ToArray();
*/
//処理
//出力
Console.Out.Flush();
}
}
|
[["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199]]
| 8
| 163
| 14
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TOPSIC {
partial class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
//入力値をスペース区切りで配列に格納
string[] inputStr = Console.ReadLine().Split(' ');
//入力値の個数
int inputCount = inputStr.Length;
//入力値をintにした配列
int[] A = new int[inputStr.Length];
//入力値をintに変換
for (int i = 0; i < inputCount; i++) {
A[i] = int.Parse(inputStr[i]);
}
for (int i = 0; i < inputCount; i++) {
if (A[i] % 2 == 0) {
if (A[i] % 3 != 0 && A[i] % 5 != 0) {
Console.WriteLine("DENIED");
return;
}
}
}
Console.WriteLine("APPROVE");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TOPSIC {
partial class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
//入力値をスペース区切りで配列に格納
string[] inputStr = Console.ReadLine().Split(' ');
//入力値をintにした配列
int[] A = new int[N];
//入力値をintに変換
for (int i = 0; i < N; i++) {
A[i] = int.Parse(inputStr[i]);
}
for (int i = 0; i < N; i++) {
if (A[i] % 2 == 0) {
if (A[i] % 3 != 0 && A[i] % 5 != 0) {
Console.WriteLine("DENIED");
return;
}
}
}
Console.WriteLine("APPROVED");
}
}
}
|
[["-", 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, 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], ["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 0, 227, 39, 224, 225, 226, 0, 214, 205, 22], ["-", 0, 227, 39, 224, 225, 226, 0, 214, 0, 131], ["-", 0, 227, 39, 224, 225, 226, 0, 214, 141, 22], ["+", 0, 212, 0, 227, 39, 224, 225, 226, 0, 22], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 205
| 17
|
using System;
using System.Linq;
public class Program {
public static void Main() {
if (0 == Console.ReadLine()
.Split()
.Select(int.Parse)
.Where(x => x % 2 == 0)
.Where(x => !(x % 3 == 0) && !(x % 5 == 0))
.Count()) {
Console.WriteLine("APPROVED");
return;
}
Console.WriteLine("DENIED");
}
}
|
using System;
using System.Linq;
public class Program {
public static void Main() {
Console.ReadLine();
if (0 == Console.ReadLine()
.Split()
.Select(int.Parse)
.Where(x => x % 2 == 0)
.Where(x => (!(x % 3 == 0)) && (!(x % 5 == 0)))
.Count()) {
Console.WriteLine("APPROVED");
return;
}
Console.WriteLine("DENIED");
}
}
|
[["+", 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], ["+", 0, 28, 0, 218, 8, 16, 31, 23, 0, 24], ["+", 8, 16, 31, 23, 0, 241, 0, 23, 0, 25], ["+", 0, 28, 0, 218, 8, 16, 12, 23, 0, 24], ["+", 8, 16, 12, 23, 0, 241, 0, 23, 0, 25]]
| 8
| 102
| 10
|
using System;
using System.Linq;
using System.Runtime.CompilerServices;
namespace AtCoderBeginnerContest155 {
class Program {
static void Main(string[] args) {
var number = ReadInt();
var numbers = ReadIntArray();
for (var i = 0; i < number; i++) {
if (numbers[i] % 2 == 0 && (numbers[i] % 3 != 0 || numbers[i] % 5 != 0)) {
Console.WriteLine("DENIED");
return;
}
}
Console.WriteLine("APPROVED");
}
public static int ReadInt() => int.Parse(Console.ReadLine());
public static int[] ReadIntArray() =>
Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
public static long ReadLong() => long.Parse(Console.ReadLine());
public static long[] ReadLongArray() =>
Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
public static string ReadString() => Console.ReadLine();
public static string[] ReadStringArray() => Console.ReadLine().Split();
}
}
|
using System;
using System.Linq;
namespace AtCoderBeginnerContest155 {
class Program {
static void Main(string[] args) {
var number = ReadInt();
var numbers = ReadIntArray();
for (var i = 0; i < number; i++) {
if (numbers[i] % 2 == 0 && numbers[i] % 3 != 0 && numbers[i] % 5 != 0) {
Console.Write("DENIED");
return;
}
}
Console.Write("APPROVED");
}
public static int ReadInt() => int.Parse(Console.ReadLine());
public static int[] ReadIntArray() =>
Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
public static long ReadLong() => long.Parse(Console.ReadLine());
public static long[] ReadLongArray() =>
Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
public static string ReadString() => Console.ReadLine();
public static string[] ReadStringArray() => Console.ReadLine().Split();
}
}
|
[["-", 36, 36, 36, 36, 0, 208, 0, 231, 0, 233], ["-", 0, 208, 0, 231, 141, 232, 234, 232, 234, 22], ["-", 0, 208, 0, 231, 141, 232, 234, 232, 0, 131], ["-", 0, 208, 0, 231, 141, 232, 234, 232, 141, 22], ["-", 36, 36, 0, 208, 0, 231, 141, 232, 0, 131], ["-", 36, 36, 0, 208, 0, 231, 141, 232, 141, 22], ["-", 36, 36, 36, 36, 0, 208, 0, 231, 0, 35], ["-", 8, 196, 0, 57, 15, 16, 12, 23, 0, 24], ["-", 0, 57, 15, 16, 12, 23, 0, 16, 17, 106], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22]]
| 8
| 255
| 15
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder_20190707_1 {
class Program {
static void Main(string[] args) {
string N = Console.ReadLine();
string[] a = Console.ReadLine().Split(' ');
int[] An = new int[a.Length];
for (int i = 0; i < a.Length; i++) {
An[i] = int.Parse(a[i]);
}
for (int i = 0; i < An.Length; i++) {
if (An[i] % 2 == 0) {
if (An[i] % 3 != 0 && An[i] % 5 != 0) {
Console.WriteLine("DENIED");
}
}
}
Console.WriteLine("APPROVED");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder_20190707_1 {
class Program {
static void Main(string[] args) {
string N = Console.ReadLine();
string[] a = Console.ReadLine().Split(' ');
int[] An = new int[a.Length];
bool isDenied = false;
for (int i = 0; i < a.Length; i++) {
An[i] = int.Parse(a[i]);
}
for (int i = 0; i < An.Length; i++) {
if (An[i] % 2 == 0) {
if (An[i] % 3 != 0 && An[i] % 5 != 0) {
isDenied = true;
}
}
}
if (isDenied) {
Console.WriteLine("DENIED");
} else {
Console.WriteLine("APPROVED");
}
}
}
}
|
[["+", 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, 211, 0, 147], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 64, 196, 0, 1, 0, 11, 12, 211, 0, 146], ["+", 64, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 15, 22], ["-", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46], ["-", 0, 7, 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
| 190
| 22
|
using System;
namespace atcorderpractice {
class Mainclass {
public static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
int[] a = new int[n];
string[] input = Console.ReadLine().Split(' ');
for (int i = 0; i < n; i++) {
a[i] = int.Parse(input[i]);
}
bool judge = false;
for (int i = 0; i < n; i++) {
if (a[i] % 2 == 0) {
if (a[i] % 3 == 0 || a[i] % 5 == 0) {
judge = true;
} else {
judge = false;
break;
}
}
}
if (judge == true) {
Console.WriteLine("APPROVED");
} else {
Console.WriteLine("DENIED");
}
}
}
}
|
using System;
namespace atcorderpractice {
class Mainclass {
public static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
int[] a = new int[n];
string[] input = Console.ReadLine().Split(' ');
for (int i = 0; i < n; i++) {
a[i] = int.Parse(input[i]);
}
bool judge = true;
for (int i = 0; i < n; i++) {
if (a[i] % 2 == 0) {
if (judge == false) {
break;
}
if (a[i] % 3 == 0 || a[i] % 5 == 0) {
judge = true;
} else {
judge = false;
break;
}
}
}
if (judge == true) {
Console.WriteLine("APPROVED");
} else {
Console.WriteLine("DENIED");
}
}
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 211, 0, 147], ["+", 0, 198, 0, 200, 0, 212, 0, 211, 0, 146], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 60], ["+", 64, 196, 0, 57, 15, 16, 12, 211, 0, 147], ["+", 64, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 64, 196, 0, 57, 64, 196, 0, 93, 0, 35], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 195
| 12
|
using System;
using System.Linq;
class C {
static void Main() => Console.WriteLine(
string.Join("\n", new int [int.Parse(Console.ReadLine())]
.Select(_ => Console.ReadLine())
.GroupBy(x => x)
.GroupBy(g => g.Count(), g => g.Key)
.OrderBy(g => -g.Key)
.First()));
}
|
using System;
using System.Linq;
class C {
static void Main() => Console.WriteLine(
string.Join("\n", new int [int.Parse(Console.ReadLine())]
.Select(_ => Console.ReadLine())
.GroupBy(x => x)
.GroupBy(g => g.Count(), g => g.Key)
.OrderBy(g => -g.Key)
.First()
.OrderBy(x => x)));
}
|
[["+", 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]]
| 8
| 96
| 7
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class B {
static void Main() {
int[] intRecord =
Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
var N = intRecord[0];
var M = intRecord[1];
var answer = string.Empty;
if (N >= M) {
answer = M.ToString();
for (int i = 1; i < N; i++) {
answer += M;
}
} else {
answer = N.ToString();
for (int i = 1; i < N; i++) {
answer += N;
}
}
Console.WriteLine(answer);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class B {
static void Main() {
int[] intRecord =
Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
var N = intRecord[0];
var M = intRecord[1];
var answer = string.Empty;
if (N >= M) {
answer = M.ToString();
for (int i = 1; i < N; i++) {
answer += M.ToString();
}
} else {
answer = N.ToString();
for (int i = 1; i < M; i++) {
answer += N.ToString();
}
}
Console.WriteLine(answer);
}
}
|
[["+", 0, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["-", 0, 57, 75, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 57, 75, 196, 0, 7, 15, 16, 12, 22]]
| 8
| 162
| 10
|
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 pi = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
var count = 1;
for (var i = 1; i < n; i++) {
if (pi[i] < pi[i - 1])
count++;
}
Console.WriteLine(count);
}
}
}
|
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 pi = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
var count = 0;
var min = n;
for (var i = 0; i < n; i++) {
var val = pi[i];
if (val <= min) {
count++;
min = val;
}
}
Console.WriteLine(count);
}
}
}
|
[["-", 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], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 196, 0, 7, 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, 18], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 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, 19], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 180
| 17
|
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 pi = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
var count = 1;
for (var i = 1; i < n; i++) {
if (pi[i] < pi[i - 1])
count++;
}
Console.WriteLine(count);
}
}
}
|
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 pi = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
var count = 1;
var minIndex = 0;
for (var i = 1; i < n; i++) {
if (pi[i] <= pi[minIndex]) {
count++;
minIndex = i;
}
}
Console.WriteLine(count);
}
}
}
|
[["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 19], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 15, 16, 12, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 180
| 17
|
using System;
class C {
public static void Main() {
int N = int.Parse(Console.ReadLine());
int c = 0;
int[] Ar = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
for (int i = 0; i < Ar.Length; i++) {
if (Ar[i] <= Ar[0])
c++;
}
Console.WriteLine(c);
}
}
|
using System;
class C {
public static void Main() {
int N = int.Parse(Console.ReadLine());
int c = 0;
int[] Ar = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
for (int i = 0; i < N; i++) {
if (Ar[i] <= Ar[0]) {
c++;
Ar[0] = Ar[i];
}
}
Console.WriteLine(c);
}
}
|
[["-", 8, 196, 0, 7, 15, 16, 12, 214, 205, 22], ["-", 8, 196, 0, 7, 15, 16, 12, 214, 0, 131], ["-", 8, 196, 0, 7, 15, 16, 12, 214, 141, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 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, 203], ["+", 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, 204, 205, 22], ["+", 0, 1, 0, 11, 12, 204, 206, 207, 0, 70], ["+", 0, 11, 12, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 1, 0, 11, 12, 204, 206, 207, 0, 73], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 101
| 16
|
using System;
class Program {
static void Main(string[] args) {
long N = long.Parse(Console.ReadLine());
long[] P = new long[N];
string[] str = Console.ReadLine().Split(' ');
for (int i = 0; i < P.Length; i++) {
P[i] = long.Parse(str[i]);
}
long ans = 0;
long min = P[0];
for (int i = 0; i < N; i++) {
bool flag = true;
if (P[i] > N - i) {
flag = false;
}
if (min < P[i]) {
flag = false;
min = P[i];
}
if (flag) {
ans++;
}
}
Console.WriteLine(ans);
}
}
|
using System;
class Program {
static void Main(string[] args) {
long N = long.Parse(Console.ReadLine());
long[] P = new long[N];
string[] str = Console.ReadLine().Split(' ');
for (int i = 0; i < P.Length; i++) {
P[i] = long.Parse(str[i]);
}
long ans = 0;
long min = P[0];
for (int i = 0; i < N; i++) {
bool flag = true;
if (min < P[i]) {
flag = false;
}
if (flag) {
ans++;
min = P[i];
}
}
Console.WriteLine(ans);
}
}
|
[["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 18], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 33], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 12, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 18], ["-", 8, 196, 0, 57, 15, 16, 12, 204, 205, 22], ["-", 0, 57, 15, 16, 12, 204, 206, 207, 0, 70], ["-", 15, 16, 12, 204, 206, 207, 0, 28, 0, 22], ["-", 0, 57, 15, 16, 12, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 15, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 64, 196, 0, 1, 0, 11, 12, 211, 0, 147], ["+", 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, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 15, 22], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 0, 57, 64, 196, 0, 1, 0, 223, 0, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 223, 0, 29]]
| 8
| 183
| 27
|
using System;
using System.Linq;
public class Program {
static void Main() {
int n = int.Parse(Console.ReadLine());
int[] p = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
int max = p[0];
int ans = 1;
for (int i = 1; i < n; i++) {
if (p[i] <= max) {
ans++;
} else
max = p[i];
}
Console.WriteLine(ans);
}
}
|
using System;
using System.Linq;
public class Program {
static void Main() {
int n = int.Parse(Console.ReadLine());
int[] p = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
int min = p[0];
int ans = 1;
for (int i = 1; i < n; i++) {
if (p[i] <= min) {
ans++;
}
min = Math.Min(min, p[i]);
}
Console.WriteLine(ans);
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["-", 8, 196, 0, 57, 75, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 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
| 119
| 14
|
using System;
using System.Linq;
class LowElements {
static void Main(string[] args) {
var input = int.Parse(Console.ReadLine());
var number = Console.ReadLine().Split(' ');
int[] intArray = number.Select(int.Parse).ToArray();
int count = 1;
for (var i = 1; i < input; i++) {
if (intArray[i - 1] >= intArray[i]) {
count++;
}
}
Console.WriteLine(count);
}
}
|
using System;
using System.Linq;
class LowElements {
static void Main(string[] args) {
var input = int.Parse(Console.ReadLine());
var number = Console.ReadLine().Split(' ');
int[] intArray = number.Select(int.Parse).ToArray();
int count = 1;
int min = intArray[0];
for (var i = 1; i < input; i++) {
if (intArray[i - 1] >= intArray[i] && min >= intArray[i]) {
count++;
min = intArray[i];
}
}
Console.WriteLine(count);
}
}
|
[["+", 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, 204, 205, 22], ["+", 0, 200, 0, 212, 0, 204, 206, 207, 0, 70], ["+", 0, 212, 0, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 200, 0, 212, 0, 204, 206, 207, 0, 73], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 15, 16, 31, 16, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 20], ["+", 0, 57, 15, 16, 31, 16, 12, 204, 205, 22], ["+", 15, 16, 31, 16, 12, 204, 206, 207, 0, 70], ["+", 31, 16, 12, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 64, 196, 0, 1, 0, 11, 12, 204, 205, 22], ["+", 0, 1, 0, 11, 12, 204, 206, 207, 0, 70], ["+", 0, 11, 12, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 1, 0, 11, 12, 204, 206, 207, 0, 73]]
| 8
| 118
| 22
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
// 解答はココに書く
var N = cin.ReadInt;
if (N > 200000) {
Error.WriteLine("Error");
}
var P = cin.ReadIntArray(N);
int num = 0;
int pmin = 0;
for (int i = 0; i < N; i++) {
if (P[pmin] > P[i]) {
pmin = i;
num++;
}
}
WriteLine(num);
/* ex2
var N = cin.ReadInt;
var M = cin.ReadInt;
var str = "";
if (N >= M)
{
for (int i = 0; i < N; i++)
{
str += M.ToString();
}
}
else
{
for (int i = 0; i < M; i++)
{
str += N.ToString();
}
}
WriteLine("{0}", str);
*/
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
// 解答はココに書く
var N = cin.ReadInt;
var P = cin.ReadIntArray(N);
int num = 0;
int pmin = 0;
for (int i = 0; i < N; i++) {
if (P[pmin] >= P[i]) {
pmin = i;
num++;
}
}
WriteLine(num);
/* ex2
var N = cin.ReadInt;
var M = cin.ReadInt;
var str = "";
if (N >= M)
{
for (int i = 0; i < N; i++)
{
str += M.ToString();
}
}
else
{
for (int i = 0; i < M; i++)
{
str += N.ToString();
}
}
WriteLine("{0}", str);
*/
}
}
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, 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], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["-", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 20]]
| 8
| 512
| 19
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
var N = cin.ReadInt;
var P = cin.ReadIntArray(N);
var count = 0;
for (int i = 0; i < N; i++) {
bool isOk = true;
for (int k = 0; k < i; k++) {
if (P[i] < P[k]) {
isOk = false;
}
}
if (isOk)
count++;
}
WriteLine(count);
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
var N = cin.ReadInt;
var P = cin.ReadIntArray(N);
var count = 0;
int min = P[0];
for (int i = 0; i < N; i++) {
bool isOk = true;
if (min < P[i]) {
isOk = false;
} else
min = P[i];
if (isOk)
count++;
}
WriteLine(count);
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
[["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 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, 204, 205, 22], ["+", 0, 200, 0, 212, 0, 204, 206, 207, 0, 70], ["+", 0, 212, 0, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 200, 0, 212, 0, 204, 206, 207, 0, 73], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 88], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 24], ["-", 0, 7, 8, 196, 0, 7, 10, 198, 39, 199], ["-", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 35], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 31, 22], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 17, 18], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 12, 22], ["-", 0, 7, 8, 196, 0, 7, 26, 223, 0, 22], ["-", 0, 7, 8, 196, 0, 7, 26, 223, 0, 29], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 25], ["-", 0, 7, 8, 196, 0, 7, 8, 196, 0, 45], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 18], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 18], ["-", 8, 196, 0, 57, 15, 16, 12, 204, 205, 22], ["-", 0, 57, 15, 16, 12, 204, 206, 207, 0, 70], ["-", 15, 16, 12, 204, 206, 207, 0, 28, 0, 22], ["-", 0, 57, 15, 16, 12, 204, 206, 207, 0, 73], ["-", 0, 7, 8, 196, 0, 7, 8, 196, 0, 46], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["+", 8, 196, 0, 57, 75, 1, 0, 11, 31, 22], ["+", 0, 57, 75, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 75, 1, 0, 11, 12, 204, 205, 22], ["+", 75, 1, 0, 11, 12, 204, 206, 207, 0, 70], ["+", 0, 11, 12, 204, 206, 207, 0, 28, 0, 22], ["+", 75, 1, 0, 11, 12, 204, 206, 207, 0, 73], ["+", 0, 7, 8, 196, 0, 57, 75, 1, 0, 35]]
| 8
| 513
| 39
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC152 {
class C {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
int[] p = Console.ReadLine().Split().Select(int.Parse).ToArray();
int ans = 1;
int min = p[0];
for (int i = 1; i < n; i++) {
if (min < p[i]) {
min = p[i];
} else {
ans++;
}
}
Console.WriteLine(ans);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC152 {
class C {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
int[] p = Console.ReadLine().Split().Select(int.Parse).ToArray();
int ans = 1;
int min = p[0];
for (int i = 1; i < n; i++) {
if (min < p[i]) {
} else {
ans++;
min = p[i];
}
}
Console.WriteLine(ans);
}
}
}
|
[["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 57, 75, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 57, 75, 196, 0, 1, 0, 223, 0, 29], ["+", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["-", 0, 7, 8, 196, 0, 57, 75, 196, 0, 45], ["-", 0, 57, 75, 196, 0, 1, 0, 223, 0, 22], ["-", 0, 57, 75, 196, 0, 1, 0, 223, 0, 29]]
| 8
| 146
| 12
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace AtCoder {
class Program {
static void Main(string[] args) {
//[summary]C - Low Elements
int N = int.Parse(Console.ReadLine());
var P = ReadLine();
int ans = 1;
bool isReset = false;
for (int i = 1; i < N; i++) {
if (P[i - 1] >= P[i]) {
ans++;
}
}
Console.WriteLine(ans);
}
static List<int> ReadLine() {
var line = Console.ReadLine();
var arr = line.Split(' ');
return arr.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 - Low Elements
int N = int.Parse(Console.ReadLine());
var P = ReadLine();
int ans = 0;
int min = int.MaxValue;
for (int i = 0; i < N; i++) {
if (P[i] <= min) {
min = P[i];
ans++;
}
}
Console.WriteLine(ans);
}
static List<int> ReadLine() {
var line = Console.ReadLine();
var arr = line.Split(' ');
return arr.Select(x => int.Parse(x)).ToList();
}
}
}
|
[["-", 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, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 195, 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, 214, 205, 199], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 0, 131], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 141, 22], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 20], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 19], ["+", 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, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35]]
| 8
| 158
| 24
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Console;
namespace CPLib {
class Atria {
static void Main(string[] args) {
int n = int.Parse(ReadLine());
int[] p = ReadLine().Split(' ').Select(int.Parse).ToArray();
int ans = 1;
for (int i = 0; i < n - 1; i++) {
if (p[i] >= p[i + 1]) {
ans++;
}
}
WriteLine(ans);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Console;
namespace CPLib {
class Atria {
static void Main(string[] args) {
int n = int.Parse(ReadLine());
int[] p = ReadLine().Split(' ').Select(int.Parse).ToArray();
int ans = 1;
int now = p[0];
for (int i = 1; i < n; i++) {
if (p[i] <= now) {
now = p[i];
ans++;
}
}
WriteLine(ans);
}
}
}
|
[["+", 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, 204, 205, 22], ["+", 0, 200, 0, 212, 0, 204, 206, 207, 0, 70], ["+", 0, 212, 0, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 200, 0, 212, 0, 204, 206, 207, 0, 73], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 20], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 19], ["+", 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, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 17, 72], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35]]
| 8
| 142
| 24
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class MainClass {
public const long Giri = 1000000007;
public static void Main(string[] args) {
var n = Console.ReadLine().ToInt();
var p = Input().ToInt();
int wa = 0;
int q = 200000;
for (int i = 0; i < n; i++) {
if (i == 0) {
wa++;
continue;
}
if (p[i - 1] >= p[i])
wa++;
}
Console.WriteLine(wa);
}
static long GCD(long a, long b) {
var v = new[] { a, b };
while (v[1] != 0) {
v = new[] { v[1], v[0] % v[1] };
}
return v[0];
}
public static string[] Input() { return Console.ReadLine().Split(' '); }
public static int Clamp(int val, int max, int min = 0) {
return Math.Min(max, Math.Max(min, val));
}
}
public static class Smarter {
public static int ToInt(this string str) { return int.Parse(str); }
public static long ToLong(this string str) { return long.Parse(str); }
public static int[] ToInt(this string[] str) {
var r = new int[str.Length];
for (int i = 0; i < str.Length; i++)
r[i] = str[i].ToInt();
return r;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class MainClass {
public const long Giri = 1000000007;
public static void Main(string[] args) {
var n = Console.ReadLine().ToInt();
var p = Input().ToInt();
int wa = 0;
int min = 999999;
for (int i = 0; i < n; i++) {
if (p[i] <= min) {
min = Math.Min(min, p[i]);
wa++;
}
}
Console.WriteLine(wa);
}
static long GCD(long a, long b) {
var v = new[] { a, b };
while (v[1] != 0) {
v = new[] { v[1], v[0] % v[1] };
}
return v[0];
}
public static string[] Input() { return Console.ReadLine().Split(' '); }
public static int Clamp(int val, int max, int min = 0) {
return Math.Min(max, Math.Max(min, val));
}
}
public static class Smarter {
public static int ToInt(this string str) { return int.Parse(str); }
public static long ToLong(this string str) { return long.Parse(str); }
public static int[] ToInt(this string[] str) {
var r = new int[str.Length];
for (int i = 0; i < str.Length; i++)
r[i] = str[i].ToInt();
return r;
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 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, 60], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 0, 57, 64, 196, 0, 1, 0, 223, 0, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 223, 0, 29], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 8, 196, 0, 57, 64, 196, 0, 116, 0, 117], ["-", 8, 196, 0, 57, 64, 196, 0, 116, 0, 35], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 20], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 19], ["+", 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, 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, 11, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 356
| 34
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC152_C {
class Program {
static void Main(string[] args) {
var n = int.Parse(Console.ReadLine());
var p = Console.ReadLine().Split().Select(int.Parse).ToArray();
var ans = 0;
var cm = int.MaxValue;
var list = new List<int>();
for (int i = 0; i < n; i++) {
if (cm >= p[i]) {
ans++;
cm = p[i];
} else {
cm = p[i];
}
}
Console.WriteLine(ans);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC152_C {
class Program {
static void Main(string[] args) {
var n = int.Parse(Console.ReadLine());
var p = Console.ReadLine().Split().Select(int.Parse).ToArray();
var ans = 0;
var cm = int.MaxValue;
var list = new List<int>();
for (int i = 0; i < n; i++) {
if (cm >= p[i]) {
ans++;
cm = p[i];
}
}
Console.WriteLine(ans);
}
}
}
|
[["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["-", 0, 7, 8, 196, 0, 57, 75, 196, 0, 45], ["-", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["-", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 75, 196, 0, 1, 0, 11, 12, 204, 205, 22], ["-", 0, 1, 0, 11, 12, 204, 206, 207, 0, 70], ["-", 0, 11, 12, 204, 206, 207, 0, 28, 0, 22], ["-", 0, 1, 0, 11, 12, 204, 206, 207, 0, 73], ["-", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["-", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46]]
| 8
| 161
| 10
|
using System;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using System.Text;
class DandA {
static void Main(string[] args) {
int n = ReadLineInt();
int[] frontArr = new int[n];
int[] endArr = new int[n];
int[] rtnArr = new int[n];
int cnt = 0;
for (int i = 0; i < n; i++) {
if ((i + 1) % 10 == 0) {
continue;
}
string wk = (i + 1).ToString();
wk = wk.Substring(0, 1) + wk.Substring(wk.Length - 1, 1);
if (myTable.ContainsKey(wk)) {
myTable[wk]++;
} else {
myTable.Add(wk, 1);
}
}
foreach (KeyValuePair<string, int> item in myTable) {
if (item.Key.Substring(0, 1) ==
item.Key.Substring(item.Key.Length - 1, 1)) {
cnt += item.Value * item.Value;
} else {
cnt += item.Value * myTable[item.Key.Substring(item.Key.Length - 1, 1) +
item.Key.Substring(0, 1)];
}
}
Console.WriteLine(cnt);
}
static string Alphabet =
"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
static string[] strAry = new string[] { "L", "R", "U", "D" };
static int[] intArray = new int[10];
static List<int> intList = new List<int>();
static Dictionary<string, int> myTable = new Dictionary<string, int>();
static HashSet<int>[] rtnArrAb = null;
static HashSet<int>[] rtnArrCd = null;
static int iRtn;
static int[] rdx = null;
static int[][] lrArr = null;
static int[] pArr = null;
static private string ReadLineStr() { return Console.ReadLine(); }
static private int ReadLineInt() { return int.Parse(Console.ReadLine()); }
static private long ReadLineLong() { return long.Parse(Console.ReadLine()); }
static private double ReadLineDouble() {
return double.Parse(Console.ReadLine());
}
static private string[] ReadLineStrArray() {
return Console.ReadLine().Trim().Split();
}
static private int[] ReadLineIntArray() {
return Console.ReadLine()
.Trim()
.Split()
.Select(a => int.Parse(a))
.ToArray();
}
static private long[] ReadLineLongArray() {
return Console.ReadLine()
.Trim()
.Split()
.Select(a => long.Parse(a))
.ToArray();
}
static private double[] ReadLineDoubleArray() {
return Console.ReadLine()
.Trim()
.Split()
.Select(a => double.Parse(a))
.ToArray();
}
static private decimal[] ReadLineDecimalArray() {
return Console.ReadLine()
.Trim()
.Split()
.Select(a => decimal.Parse(a))
.ToArray();
}
static private List<int> ReadLineIntList() {
return Console.ReadLine().Trim().Split().Select(a => int.Parse(a)).ToList();
}
static private List<long> ReadLineLongList() {
return Console.ReadLine()
.Trim()
.Split()
.Select(a => long.Parse(a))
.ToList();
}
static private string[][] ReadMLineStrArray(int arg) {
return new int [arg].Select(_ => Console.ReadLine().Split()).ToArray();
}
static private int[][] ReadMLineIntArray(int arg) {
return new int [arg]
.Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray())
.ToArray();
}
static private bool IsPrime(int num) {
if (num < 2)
return false;
if (num == 2)
return true;
else if (num % 2 == 0)
return false;
double sqrtNum = Math.Sqrt(num);
for (int i = 3; i <= sqrtNum; i += 2) {
if (num % i == 0)
return false;
}
return true;
}
static private string IntToNString(int x, int n) {
var nstring = "";
var numbers = new string[] { "0", "1", "2", "3", "4", "5", "6", "7",
"8", "9", "a", "b", "c", "d", "e", "f" };
int r = 1;
int q = x;
while (q > 0) {
r = q % n;
nstring += numbers[r];
q = q / n;
}
return string.Join("", nstring.Reverse());
}
/* 最大公約数 */
static private long Gcd(long m, long n) {
long temp;
while (m % n != 0) {
temp = n;
n = m % n;
m = temp;
}
return n;
}
}
|
using System;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using System.Text;
class DandA {
static void Main(string[] args) {
int n = ReadLineInt();
int[] frontArr = new int[n];
int[] endArr = new int[n];
int[] rtnArr = new int[n];
int cnt = 0;
for (int i = 0; i < n; i++) {
if ((i + 1) % 10 == 0) {
continue;
}
string wk = (i + 1).ToString();
wk = wk.Substring(0, 1) + wk.Substring(wk.Length - 1, 1);
if (myTable.ContainsKey(wk)) {
myTable[wk]++;
} else {
myTable.Add(wk, 1);
}
}
foreach (KeyValuePair<string, int> item in myTable) {
if (item.Key.Substring(0, 1) ==
item.Key.Substring(item.Key.Length - 1, 1)) {
cnt += item.Value * item.Value;
} else {
if (myTable.ContainsKey(item.Key.Substring(item.Key.Length - 1, 1) +
item.Key.Substring(0, 1))) {
cnt +=
item.Value * myTable[item.Key.Substring(item.Key.Length - 1, 1) +
item.Key.Substring(0, 1)];
}
}
}
Console.WriteLine(cnt);
}
static string Alphabet =
"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
static string[] strAry = new string[] { "L", "R", "U", "D" };
static int[] intArray = new int[10];
static List<int> intList = new List<int>();
static Dictionary<string, int> myTable = new Dictionary<string, int>();
static HashSet<int>[] rtnArrAb = null;
static HashSet<int>[] rtnArrCd = null;
static int iRtn;
static int[] rdx = null;
static int[][] lrArr = null;
static int[] pArr = null;
static private string ReadLineStr() { return Console.ReadLine(); }
static private int ReadLineInt() { return int.Parse(Console.ReadLine()); }
static private long ReadLineLong() { return long.Parse(Console.ReadLine()); }
static private double ReadLineDouble() {
return double.Parse(Console.ReadLine());
}
static private string[] ReadLineStrArray() {
return Console.ReadLine().Trim().Split();
}
static private int[] ReadLineIntArray() {
return Console.ReadLine()
.Trim()
.Split()
.Select(a => int.Parse(a))
.ToArray();
}
static private long[] ReadLineLongArray() {
return Console.ReadLine()
.Trim()
.Split()
.Select(a => long.Parse(a))
.ToArray();
}
static private double[] ReadLineDoubleArray() {
return Console.ReadLine()
.Trim()
.Split()
.Select(a => double.Parse(a))
.ToArray();
}
static private decimal[] ReadLineDecimalArray() {
return Console.ReadLine()
.Trim()
.Split()
.Select(a => decimal.Parse(a))
.ToArray();
}
static private List<int> ReadLineIntList() {
return Console.ReadLine().Trim().Split().Select(a => int.Parse(a)).ToList();
}
static private List<long> ReadLineLongList() {
return Console.ReadLine()
.Trim()
.Split()
.Select(a => long.Parse(a))
.ToList();
}
static private string[][] ReadMLineStrArray(int arg) {
return new int [arg].Select(_ => Console.ReadLine().Split()).ToArray();
}
static private int[][] ReadMLineIntArray(int arg) {
return new int [arg]
.Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray())
.ToArray();
}
static private bool IsPrime(int num) {
if (num < 2)
return false;
if (num == 2)
return true;
else if (num % 2 == 0)
return false;
double sqrtNum = Math.Sqrt(num);
for (int i = 3; i <= sqrtNum; i += 2) {
if (num % i == 0)
return false;
}
return true;
}
static private string IntToNString(int x, int n) {
var nstring = "";
var numbers = new string[] { "0", "1", "2", "3", "4", "5", "6", "7",
"8", "9", "a", "b", "c", "d", "e", "f" };
int r = 1;
int q = x;
while (q > 0) {
r = q % n;
nstring += numbers[r];
q = q / n;
}
return string.Join("", nstring.Reverse());
}
/* 最大公約数 */
static private long Gcd(long m, long n) {
long temp;
while (m % n != 0) {
temp = n;
n = m % n;
m = temp;
}
return n;
}
}
|
[["+", 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, 213, 63, 214, 205, 22], ["+", 75, 196, 0, 57, 15, 213, 63, 214, 0, 131], ["+", 75, 196, 0, 57, 15, 213, 63, 214, 141, 22], ["+", 75, 196, 0, 57, 15, 213, 3, 4, 0, 24], ["+", 0, 16, 31, 213, 63, 214, 205, 214, 205, 22], ["+", 0, 16, 31, 213, 63, 214, 205, 214, 0, 131], ["+", 0, 16, 31, 213, 63, 214, 205, 214, 141, 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], ["+", 0, 28, 0, 16, 31, 214, 205, 214, 205, 22], ["+", 0, 28, 0, 16, 31, 214, 205, 214, 0, 131], ["+", 0, 28, 0, 16, 31, 214, 205, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 16, 31, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 16, 31, 214, 141, 22], ["+", 31, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 31, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 0, 28, 0, 16, 31, 213, 3, 4, 0, 21], ["+", 0, 16, 31, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 28, 0, 16, 31, 213, 3, 4, 0, 25], ["+", 15, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 0, 16, 12, 213, 63, 214, 205, 214, 205, 22], ["+", 0, 16, 12, 213, 63, 214, 205, 214, 0, 131], ["+", 0, 16, 12, 213, 63, 214, 205, 214, 141, 22], ["+", 0, 28, 0, 16, 12, 213, 63, 214, 0, 131], ["+", 0, 28, 0, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 28, 0, 16, 12, 213, 3, 4, 0, 24], ["+", 0, 16, 12, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 28, 0, 16, 12, 213, 3, 4, 0, 21], ["+", 0, 28, 0, 16, 12, 213, 3, 4, 0, 25], ["+", 75, 196, 0, 57, 15, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 25], ["+", 0, 57, 75, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 75, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 1,129
| 37
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
public class Hello {
public static void Main() {
int reader = int.Parse(ReadLine());
int[,] map = new int[10, 10];
for (int i = 1; i <= reader; i++) {
int tempi = i;
while (tempi >= 10) {
tempi /= 10;
}
int end = i % 10;
int fir = tempi;
map[fir, end]++;
}
long ans = 0;
for (int i = 1; i <= 9; i++) {
for (int j = 1; j <= 9; j++) {
ans += map[i, j] * map[j, i];
Write(map[i, j]);
Write(" ");
}
WriteLine();
}
WriteLine(ans);
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
public class Hello {
public static void Main() {
int reader = int.Parse(ReadLine());
int[,] map = new int[10, 10];
for (int i = 1; i <= reader; i++) {
int tempi = i;
while (tempi >= 10) {
tempi /= 10;
}
int end = i % 10;
int fir = tempi;
map[fir, end]++;
}
long ans = 0;
for (int i = 1; i <= 9; i++) {
for (int j = 1; j <= 9; j++) {
ans += map[i, j] * map[j, i];
}
}
WriteLine(ans);
}
}
|
[["-", 0, 7, 8, 196, 0, 1, 0, 213, 63, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 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, 22], ["-", 3, 4, 0, 28, 0, 204, 206, 207, 0, 21], ["-", 3, 4, 0, 28, 0, 204, 206, 207, 0, 73], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 198
| 21
|
using System.Collections.Generic;
using System;
public class Hello {
public static void Main() {
var d = new Dictionary<string, int>();
var n = int.Parse(Console.ReadLine().Trim());
for (int i = 1; i <= n; i++) {
var its = i.ToString();
var k = "" + its[0] + its[its.Length - 1];
if (d.ContainsKey(k))
d[k]++;
else
d[k] = 1;
}
getAns(n, d);
}
static void getAns(int n, Dictionary<string, int> d) {
var ans = 0;
foreach (var x in d)
if (x.Key[x.Key.Length - 1] != '0') {
var nk = "" + x.Key[x.Key.Length - 1] + x.Key[0];
ans += x.Value * d[nk];
}
Console.WriteLine(ans);
}
}
|
using System.Collections.Generic;
using System;
public class Hello {
public static void Main() {
var d = new Dictionary<string, int>();
var n = int.Parse(Console.ReadLine().Trim());
for (int i = 1; i <= n; i++) {
var its = i.ToString();
var k = "" + its[0] + its[its.Length - 1];
if (d.ContainsKey(k))
d[k]++;
else
d[k] = 1;
}
getAns(n, d);
}
static void getAns(int n, Dictionary<string, int> d) {
var ans = 0;
foreach (var x in d)
if (x.Key[x.Key.Length - 1] != '0') {
var nk = "" + x.Key[x.Key.Length - 1] + x.Key[0];
if (d.ContainsKey(nk))
ans += x.Value * d[nk];
}
Console.WriteLine(ans);
}
}
|
[["+", 0, 210, 8, 57, 64, 196, 0, 57, 0, 121], ["+", 0, 210, 8, 57, 64, 196, 0, 57, 0, 24], ["+", 64, 196, 0, 57, 15, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 57, 15, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 57, 15, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 57, 15, 213, 3, 4, 0, 24], ["+", 0, 57, 15, 213, 3, 4, 0, 28, 0, 22], ["+", 64, 196, 0, 57, 15, 213, 3, 4, 0, 25], ["+", 0, 210, 8, 57, 64, 196, 0, 57, 0, 25]]
| 8
| 223
| 9
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
// using System.Numerics;
using System.Runtime.CompilerServices;
using System.Diagnostics;
using ll=System.Int64;
using static Contest_D.Lib_IO;
using static Contest_D.Lib_Minifunc;
public class Contest_D
{
public static void Main() {
checked{
long n;
Lib_IO.rm(out n);
ll[][] m = initm(10,10,0L);
for (int j = 1; j <= n; j++)
{
string s = j.ToString();
m[int.Parse(s[0].ToString())][int.Parse(s[s.Length-1].ToString())]++;
}
ll ans = 0;
for (int i = 0; i <= 9; i++)
{
for (int j = 0; j <= 9; j++)
{
ans+=m[i][j];
}
}
Lib_IO.wm(ans);
}
}
#region BaseModule
public static class Lib_Minifunc{
[MethodImpl(256)] public static void swap1<T>(ref T a, ref T b) { T t = a; a = b; b = t; }
[MethodImpl(256)] public static void swap2<T>(ref T a, ref T b) where T : IComparable { if (a.CompareTo(b)==1) swap1(ref a, ref b); } // b の方が小さければ交換
[MethodImpl(256)] public static bool chmin<T>(ref T a, T b) where T : IComparable { if (a.CompareTo(b)== 1) { a = b; return true; } return false; } // b の方が小さければ a を更新
[MethodImpl(256)] public static bool chmax<T>(ref T a, T b) where T : IComparable { if (a.CompareTo(b)==-1) { a = b; return true; } return false; } // b の方が大きければ a を更新
[MethodImpl(256)] public static bool inside(long i, long n) => (0<=i&&i<n);
[MethodImpl(256)] public static bool inside(long x, long y, long w, long h) => (inside(x,w)&&inside(y,h));
[MethodImpl(256)] public static T min<T>(params T[] a) where T : IComparable => a.Min();
[MethodImpl(256)] public static T max<T>(params T[] a) where T : IComparable => a.Max();
[MethodImpl(256)] public static long mod(long a, long m=MOD1) { var v = a%m; return (v<0?v+m:v); }
[MethodImpl(256)] public static long ceiling(long a, long b) => (a%b==0?a/b:a/b+1); // 整数商の切り上げ
[MethodImpl(256)] public static P<T,U> initp<T,U>(T a,U b) => new P<T,U>(a,b);
[MethodImpl(256)] public static P<T,U,V> initp<T,U,V>(T a,U b,V c) => new P<T,U,V>(a,b,c);
[MethodImpl(256)] public static P<T,U,V,W> initp<T,U,V,W>(T a,U b,V c,W d) => new P<T,U,V,W>(a,b,c,d);
public static T[][] initm<T>(long len1,long len2,T val) where T : struct { var m = new T[len1][]; for (int i=0;i<m.Length;i++) m[i] = Enumerable.Repeat(val,(int)len2).ToArray(); return m; }
public static T[][][] initm<T>(long len1,long len2,long len3,T val) where T : struct { var m = new T[len1][][]; for (int i=0;i<m.Length;i++) m[i] = initm(len2,len3,val); return m; }
public const long MOD1 = 1000000007; // 10^9+7
public const double EPS1 = 1e-8;
public const long INF1 = 1000000000000000; // 10^15
}
public struct P<T,U>
{
public T A; public U B;
public P(T a,U b) { A = a; B = b; }
public static implicit operator KeyValuePair<T,U>(P<T,U> a) => new KeyValuePair<T,U>(a.A,a.B);
public static implicit operator P<T,U>(KeyValuePair<T,U> a) => new P<T,U>(a.Key,a.Value);
}
public struct P<T,U,V>
{
public T A; public U B; public V C;
public P(T a,U b,V c) { A = a; B = b; C = c; }
}
public struct P<T,U,V,W>
{
public T A; public U B; public V C; public W D;
public P(T a,U b,V c,W d) { A = a; B = b; C = c; D = d; }
}
public static class Lib_IO
{
class Prt : System.IO.StreamWriter
{
public override IFormatProvider FormatProvider { get { return System.Globalization.CultureInfo.InvariantCulture; } }
public Prt(System.IO.Stream s) : base(s,new UTF8Encoding(false,true)) {}
public Prt(System.IO.Stream s,Encoding e) : base(s,e) {}
}
static Prt sw = new Prt(Console.OpenStandardOutput());
static char[] sp = new char[] {' '};
[MethodImpl(256)] static bool eq<T,U>() => typeof(T).Equals(typeof(U));
[MethodImpl(256)] static T ct<T,U>(U a) => (T)Convert.ChangeType(a,typeof(T));
[MethodImpl(256)] static T cv<T>(string s) =>
eq<T,int>() ? ct<T,int>(int.Parse(s))
: eq<T,long>() ? ct<T,long>(long.Parse(s))
: eq<T,double>() ? ct<T,double>(double.Parse(s,System.Globalization.CultureInfo.InvariantCulture))
: eq<T,char>() ? ct<T,char>(s[0])
: ct<T,string>(s);
public static string[] rm<T>(out T a) {
var z = Console.ReadLine().Split(sp,StringSplitOptions.RemoveEmptyEntries);
a = cv<T>(z[0]);
return z;
}
public static string[] rm<T,U>(out T a,out U b) {
var z = rm<T>(out a);
b = cv<U>(z[1]);
return z;
}
public static string[] rm<T,U,V>(out T a,out U b,out V c) {
var z = rm<T,U>(out a,out b);
c = cv<V>(z[2]);
return z;
}
public static string[] rm<T,U,V,W>(out T a,out U b,out V c,out W d) {
var z = rm<T,U,V>(out a,out b,out c);
d = cv<W>(z[3]);
return z;
}
public static string[] rm<T,U,V,W,X>(out T a,out U b,out V c,out W d,out X e) {
var z = rm<T,U,V,W>(out a,out b,out c,out d);
e = cv<X>(z[4]);
return z;
}
public static string[] rm<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 z = rm<T,U,V,W,X>(out a,out b,out c,out d,out e);
f = cv<Y>(z[5]);
return z;
}
public static string[] ra<T>(out T[] a) {
var z = Console.ReadLine().Split(sp,StringSplitOptions.RemoveEmptyEntries);
a = z.Select(cv<T>).ToArray();
return z;
}
public static string[][] rl<T>(long n,out T[] a) {
a = new T[n];
var y = new string[n][];
for(int i=0;i<n;i++) y[i] = rm(out a[i]);
return y;
}
public static string[][] rl<T,U>(long n,out P<T,U>[] a) {
a = new P<T,U>[n];
var y = new string[n][];
for(int i=0;i<n;i++) {
T o; U p;
y[i] = rm(out o,out p);
a[i] = new P<T,U>(o,p);
}
return y;
}
public static string[][] rl<T,U,V>(long n,out P<T,U,V>[] a) {
a = new P<T,U,V>[n];
var y = new string[n][];
for(int i=0;i<n;i++) {
T o; U p; V q;
y[i] = rm(out o,out p,out q);
a[i] = new P<T,U,V>(o,p,q);
}
return y;
}
public static string[][] rl<T,U,V,W>(long n,out P<T,U,V,W>[] a) {
a = new P<T,U,V,W>[n];
var y = new string[n][];
for(int i=0;i<n;i++) {
T o; U p; V q; W r;
y[i] = rm(out o,out p,out q,out r);
a[i] = new P<T,U,V,W>(o,p,q,r);
}
return y;
}
public static string[][] rx<T>(long n,out T[][] a) {
a = new T[n][];
var y = new string[n][];
for(int i=0;i<n;i++) y[i] = ra(out a[i]);
return y;
}
static void wwp(Action act){
sw.AutoFlush = false;
Console.SetOut(sw);
act();
Console.Out.Flush();
sw.AutoFlush = true;
Console.SetOut(sw);
}
[MethodImpl(256)] static string wfm(Type t) =>t.Equals(typeof(double)) ? "{0:F10}" : "{0}";
public static void wm(params object[] a) {
wwp(()=>{
for(int i=0;i<a.Length;i++) {
var f = wfm(a[i].GetType()) + ((i<a.Length-1) ? " " : Environment.NewLine);
Console.Write(f,a[i]);
}
});
}
public static void wa<T>(IList<T> a) {
wwp(()=>{
var f = wfm(typeof(T));
var g = f + " ";
var h = f + Environment.NewLine;
for(int i=0;i<a.Count;i++) Console.Write(((i<a.Count-1) ? g : h),a[i]);
});
}
public static void wl<T>(IList<T> a) {
wwp(()=>{
var f = wfm(typeof(T)) + Environment.NewLine;
foreach(T x in a) Console.Write(f,x);
});
}
}
#endregion
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
// using System.Numerics;
using System.Runtime.CompilerServices;
using System.Diagnostics;
using ll=System.Int64;
using static Contest_D.Lib_IO;
using static Contest_D.Lib_Minifunc;
public class Contest_D
{
public static void Main() {
checked{
long n;
Lib_IO.rm(out n);
ll[][] m = initm(10,10,0L);
for (int j = 1; j <= n; j++)
{
string s = j.ToString();
m[int.Parse(s[0].ToString())][int.Parse(s[s.Length-1].ToString())]++;
}
ll ans = 0;
for (int i = 0; i <= 9; i++)
{
for (int j = 0; j <= 9; j++)
{
ans+=m[i][j]*m[j][i];
}
}
Lib_IO.wm(ans);
}
}
#region BaseModule
public static class Lib_Minifunc{
[MethodImpl(256)] public static void swap1<T>(ref T a, ref T b) { T t = a; a = b; b = t; }
[MethodImpl(256)] public static void swap2<T>(ref T a, ref T b) where T : IComparable { if (a.CompareTo(b)==1) swap1(ref a, ref b); } // b の方が小さければ交換
[MethodImpl(256)] public static bool chmin<T>(ref T a, T b) where T : IComparable { if (a.CompareTo(b)== 1) { a = b; return true; } return false; } // b の方が小さければ a を更新
[MethodImpl(256)] public static bool chmax<T>(ref T a, T b) where T : IComparable { if (a.CompareTo(b)==-1) { a = b; return true; } return false; } // b の方が大きければ a を更新
[MethodImpl(256)] public static bool inside(long i, long n) => (0<=i&&i<n);
[MethodImpl(256)] public static bool inside(long x, long y, long w, long h) => (inside(x,w)&&inside(y,h));
[MethodImpl(256)] public static T min<T>(params T[] a) where T : IComparable => a.Min();
[MethodImpl(256)] public static T max<T>(params T[] a) where T : IComparable => a.Max();
[MethodImpl(256)] public static long mod(long a, long m=MOD1) { var v = a%m; return (v<0?v+m:v); }
[MethodImpl(256)] public static long ceiling(long a, long b) => (a%b==0?a/b:a/b+1); // 整数商の切り上げ
[MethodImpl(256)] public static P<T,U> initp<T,U>(T a,U b) => new P<T,U>(a,b);
[MethodImpl(256)] public static P<T,U,V> initp<T,U,V>(T a,U b,V c) => new P<T,U,V>(a,b,c);
[MethodImpl(256)] public static P<T,U,V,W> initp<T,U,V,W>(T a,U b,V c,W d) => new P<T,U,V,W>(a,b,c,d);
public static T[][] initm<T>(long len1,long len2,T val) where T : struct { var m = new T[len1][]; for (int i=0;i<m.Length;i++) m[i] = Enumerable.Repeat(val,(int)len2).ToArray(); return m; }
public static T[][][] initm<T>(long len1,long len2,long len3,T val) where T : struct { var m = new T[len1][][]; for (int i=0;i<m.Length;i++) m[i] = initm(len2,len3,val); return m; }
public const long MOD1 = 1000000007; // 10^9+7
public const double EPS1 = 1e-8;
public const long INF1 = 1000000000000000; // 10^15
}
public struct P<T,U>
{
public T A; public U B;
public P(T a,U b) { A = a; B = b; }
public static implicit operator KeyValuePair<T,U>(P<T,U> a) => new KeyValuePair<T,U>(a.A,a.B);
public static implicit operator P<T,U>(KeyValuePair<T,U> a) => new P<T,U>(a.Key,a.Value);
}
public struct P<T,U,V>
{
public T A; public U B; public V C;
public P(T a,U b,V c) { A = a; B = b; C = c; }
}
public struct P<T,U,V,W>
{
public T A; public U B; public V C; public W D;
public P(T a,U b,V c,W d) { A = a; B = b; C = c; D = d; }
}
public static class Lib_IO
{
class Prt : System.IO.StreamWriter
{
public override IFormatProvider FormatProvider { get { return System.Globalization.CultureInfo.InvariantCulture; } }
public Prt(System.IO.Stream s) : base(s,new UTF8Encoding(false,true)) {}
public Prt(System.IO.Stream s,Encoding e) : base(s,e) {}
}
static Prt sw = new Prt(Console.OpenStandardOutput());
static char[] sp = new char[] {' '};
[MethodImpl(256)] static bool eq<T,U>() => typeof(T).Equals(typeof(U));
[MethodImpl(256)] static T ct<T,U>(U a) => (T)Convert.ChangeType(a,typeof(T));
[MethodImpl(256)] static T cv<T>(string s) =>
eq<T,int>() ? ct<T,int>(int.Parse(s))
: eq<T,long>() ? ct<T,long>(long.Parse(s))
: eq<T,double>() ? ct<T,double>(double.Parse(s,System.Globalization.CultureInfo.InvariantCulture))
: eq<T,char>() ? ct<T,char>(s[0])
: ct<T,string>(s);
public static string[] rm<T>(out T a) {
var z = Console.ReadLine().Split(sp,StringSplitOptions.RemoveEmptyEntries);
a = cv<T>(z[0]);
return z;
}
public static string[] rm<T,U>(out T a,out U b) {
var z = rm<T>(out a);
b = cv<U>(z[1]);
return z;
}
public static string[] rm<T,U,V>(out T a,out U b,out V c) {
var z = rm<T,U>(out a,out b);
c = cv<V>(z[2]);
return z;
}
public static string[] rm<T,U,V,W>(out T a,out U b,out V c,out W d) {
var z = rm<T,U,V>(out a,out b,out c);
d = cv<W>(z[3]);
return z;
}
public static string[] rm<T,U,V,W,X>(out T a,out U b,out V c,out W d,out X e) {
var z = rm<T,U,V,W>(out a,out b,out c,out d);
e = cv<X>(z[4]);
return z;
}
public static string[] rm<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 z = rm<T,U,V,W,X>(out a,out b,out c,out d,out e);
f = cv<Y>(z[5]);
return z;
}
public static string[] ra<T>(out T[] a) {
var z = Console.ReadLine().Split(sp,StringSplitOptions.RemoveEmptyEntries);
a = z.Select(cv<T>).ToArray();
return z;
}
public static string[][] rl<T>(long n,out T[] a) {
a = new T[n];
var y = new string[n][];
for(int i=0;i<n;i++) y[i] = rm(out a[i]);
return y;
}
public static string[][] rl<T,U>(long n,out P<T,U>[] a) {
a = new P<T,U>[n];
var y = new string[n][];
for(int i=0;i<n;i++) {
T o; U p;
y[i] = rm(out o,out p);
a[i] = new P<T,U>(o,p);
}
return y;
}
public static string[][] rl<T,U,V>(long n,out P<T,U,V>[] a) {
a = new P<T,U,V>[n];
var y = new string[n][];
for(int i=0;i<n;i++) {
T o; U p; V q;
y[i] = rm(out o,out p,out q);
a[i] = new P<T,U,V>(o,p,q);
}
return y;
}
public static string[][] rl<T,U,V,W>(long n,out P<T,U,V,W>[] a) {
a = new P<T,U,V,W>[n];
var y = new string[n][];
for(int i=0;i<n;i++) {
T o; U p; V q; W r;
y[i] = rm(out o,out p,out q,out r);
a[i] = new P<T,U,V,W>(o,p,q,r);
}
return y;
}
public static string[][] rx<T>(long n,out T[][] a) {
a = new T[n][];
var y = new string[n][];
for(int i=0;i<n;i++) y[i] = ra(out a[i]);
return y;
}
static void wwp(Action act){
sw.AutoFlush = false;
Console.SetOut(sw);
act();
Console.Out.Flush();
sw.AutoFlush = true;
Console.SetOut(sw);
}
[MethodImpl(256)] static string wfm(Type t) =>t.Equals(typeof(double)) ? "{0:F10}" : "{0}";
public static void wm(params object[] a) {
wwp(()=>{
for(int i=0;i<a.Length;i++) {
var f = wfm(a[i].GetType()) + ((i<a.Length-1) ? " " : Environment.NewLine);
Console.Write(f,a[i]);
}
});
}
public static void wa<T>(IList<T> a) {
wwp(()=>{
var f = wfm(typeof(T));
var g = f + " ";
var h = f + Environment.NewLine;
for(int i=0;i<a.Count;i++) Console.Write(((i<a.Count-1) ? g : h),a[i]);
});
}
public static void wl<T>(IList<T> a) {
wwp(()=>{
var f = wfm(typeof(T)) + Environment.NewLine;
foreach(T x in a) Console.Write(f,x);
});
}
}
#endregion
}
|
[["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 0, 11, 12, 16, 12, 204, 205, 204, 205, 22], ["+", 12, 16, 12, 204, 205, 204, 206, 207, 0, 70], ["+", 12, 204, 205, 204, 206, 207, 0, 28, 0, 22], ["+", 12, 16, 12, 204, 205, 204, 206, 207, 0, 73], ["+", 0, 11, 12, 16, 12, 204, 206, 207, 0, 70], ["+", 12, 16, 12, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 11, 12, 16, 12, 204, 206, 207, 0, 73]]
| 8
| 2,796
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using System.IO;
class readint {
public readint(out int i) { i = int.Parse(Console.ReadLine()); }
public readint(out int a, out int b) {
int[] sp = Console.ReadLine().Split().Select(int.Parse).ToArray();
a = sp[0];
b = sp[1];
}
public readint(out int a, out int b, out int c) {
int[] sp = Console.ReadLine().Split().Select(int.Parse).ToArray();
a = sp[0];
b = sp[1];
c = sp[2];
}
public readint(out int a, out int b, out int c, out int d) {
int[] sp = Console.ReadLine().Split().Select(int.Parse).ToArray();
a = sp[0];
b = sp[1];
c = sp[2];
d = sp[3];
}
}
class readlong {
public readlong(out long i) { i = long.Parse(Console.ReadLine()); }
public readlong(out long a, out long b) {
long[] sp = Console.ReadLine().Split().Select(long.Parse).ToArray();
a = sp[0];
b = sp[1];
}
public readlong(out long a, out long b, out long c) {
long[] sp = Console.ReadLine().Split().Select(long.Parse).ToArray();
a = sp[0];
b = sp[1];
c = sp[2];
}
public readlong(out long a, out long b, out long c, out long d) {
long[] sp = Console.ReadLine().Split().Select(long.Parse).ToArray();
a = sp[0];
b = sp[1];
c = sp[2];
d = sp[3];
}
}
class Util {
public static int[] readintarr() {
return Console.ReadLine().Split().Select(int.Parse).ToArray();
}
public static long[] readlongarr() {
return Console.ReadLine().Split().Select(long.Parse).ToArray();
}
/// <summary>
/// 2引数の最大公約数を返します。longです。
/// </summary>
/// <param name="a">long 引数1</param>
/// <param name="b">long 引数2</param>
/// <returns></returns>
public static long GCD(long a, long b) {
if (a < b)
swap(ref a, ref b);
if (a % b == 0)
return b;
return GCD(b, a % b);
}
/// <summary>
/// 2引数の最大公約数を返します。intです。
/// </summary>
/// <param name="a">int 引数1</param>
/// <param name="b">int 引数2</param>
/// <returns></returns>
public static int GCD(int a, int b) {
// if (a < b)
// swap(ref a, ref b);
if (a % b == 0)
return b;
return GCD(b, a % b);
}
/// <summary>
/// 2つの変数の中身を交換する。型はなんでもいい
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="a"></param>
/// <param name="b"></param>
public static void swap<T>(ref T a, ref T b) {
T temp = b;
b = a;
a = temp;
}
/// <summary>
/// 2引数の最大公約数を返します。
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public static long LCM(long a, long b) { return a * b / GCD(a, b); }
/// <summary>
/// 2引数の最大公約数を返します。
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public static long LCM(int a, int b) { return Math.BigMul(a, b) / GCD(a, b); }
public static int M = (int)(Math.Pow(10, 9)) + 7;
private static int[] factorial_modM;
/// <summary>
/// 2引数の積 mod Mを求める。Mは10億7。
/// 変えられるよ。
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public static int Multiple_modM(int a, int b) {
return (int)(Math.BigMul(a, b) % M);
}
/// <summary>
/// n! modMを求めるための準備を行う。引数は最大値。
/// </summary>
/// <param name="n"></param>
public static void factorial_modM_Prepare(int n) {
factorial_modM = new int[n + 1];
factorial_modM[0] = 1;
for (int i = 1; i <= n; ++i) {
factorial_modM[i] = Multiple_modM(factorial_modM[i - 1], i);
}
}
/// <summary>
/// n! mod M を返す。やる前にfactorial_modM_Prepare(n)を実行しといてね。
/// </summary>
/// <param name="n"></param>
/// <returns></returns>
public static int Factorial(int n) { return factorial_modM[n]; }
public static 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 = Multiple_modM(p1, p1);
return ((m % 2) == 0) ? p2 : Multiple_modM(p2, a);
}
}
/// <summary>
/// a / m Mod M を求める。
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public static int Div(int a, int b) {
return Multiple_modM(a, Pow(b, M - 2));
}
/// <summary>
/// nCr mod M を求める。やる前にfactorial_modM_Prepare(n)を実行しといてね。
/// </summary>
/// <param name="n"></param>
/// <param name="r"></param>
/// <returns></returns>
public static int nCr_modM(int n, int r) {
if (r < 0)
return 0;
if (n < r) {
return 0;
}
if (n == r) {
return 1;
}
int res = Factorial(n);
res = Div(res, Factorial(r));
res = Div(res, Factorial(n - r));
return res;
}
}
/// <summary>
/// Union-Find木を定義する。コンストラクタの指定は、頂点の番号。
/// おすすめとしては、UnionFind<T>[] で宣言してしまう。
/// </summary>
/// <typeparam name="T">int固定でいいよね。</typeparam>
class UnionFind<T> {
public int tree_height;
public UnionFind<T> parent;
public T item { get; private set; }
public UnionFind(T item) {
tree_height = 0;
parent = this;
}
/// <summary>
/// 一番上の親を探す。
/// 探しながら繋がり方を最適化している。
/// UnionFindの頂点そのものを返すので、==での比較が可能。
/// </summary>
/// <returns></returns>
public UnionFind<T> FindAdam() {
if (parent == this)
return this;
else {
UnionFind<T> ParentOfParent = parent.FindAdam();
parent = ParentOfParent; //縦長な構成をつなぎ直している
return ParentOfParent;
}
}
/// <summary>
/// unionfind2つを一つにつなぐ。
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
public static void Unite(UnionFind<T> a, UnionFind<T> b) {
UnionFind<T> ParentOfA = a.FindAdam();
UnionFind<T> ParentOfB = b.FindAdam();
if (ParentOfA.tree_height < ParentOfB.tree_height) {
ParentOfA.parent = ParentOfB;
ParentOfB.tree_height =
Math.Max(ParentOfA.tree_height + 1, ParentOfB.tree_height);
} else {
ParentOfB.parent = ParentOfA;
ParentOfA.tree_height =
Math.Max(ParentOfB.tree_height + 1, ParentOfA.tree_height);
}
}
}
// Treap 平衡二分木
class Treap<T>
where T : IComparable {
private class Node {
private static Random g_rand = new Random();
private readonly int m_rank = g_rand.Next();
private readonly T m_value;
private Node m_lch;
private Node m_rch;
private int m_count;
public Node(T value) {
m_value = value;
m_count = 1;
}
private static int Count(Node node) {
return (node != null) ? node.m_count : 0;
}
private Node Update() {
m_count = Count(m_lch) + Count(m_rch) + 1;
return this;
}
public static Node Merge(Node a, Node b) {
if (a == null) {
return b;
}
if (b == null) {
return a;
}
if (a.m_rank < b.m_rank) {
a.m_rch = Merge(a.m_rch, b);
return a.Update();
} else {
b.m_lch = Merge(a, b.m_lch);
return b.Update();
}
}
public static Tuple<Node, Node> Split(Node t, int k) {
if (t == null) {
return new Tuple<Node, Node>(null, null);
}
if (k <= Count(t.m_lch)) {
var pair = Split(t.m_lch, k);
t.m_lch = pair.Item2;
return new Tuple<Node, Node>(pair.Item1, t.Update());
} else {
var pair = Split(t.m_rch, k - Count(t.m_lch) - 1);
t.m_rch = pair.Item1;
return new Tuple<Node, Node>(t.Update(), pair.Item2);
}
}
public int FindIndex(T value) {
int L = Count(m_lch);
if (value.CompareTo(m_value) < 0) {
return (m_lch != null) ? m_lch.FindIndex(value) : 0;
} else if (value.CompareTo(m_value) > 0) {
return (m_rch != null) ? m_rch.FindIndex(value) + L + 1 : L + 1;
} else {
return L;
}
}
public T this[int i] {
get {
int L = Count(m_lch);
if (i < L) {
return m_lch[i];
} else if (i > L) {
return m_rch[i - L - 1];
} else {
return m_value;
}
}
}
}
private Node node;
public void Insert(T value) {
if (node != null) {
int k = node.FindIndex(value);
var pair = Node.Split(node, k);
node = Node.Merge(Node.Merge(pair.Item1, new Node(value)), pair.Item2);
} else {
node = new Node(value);
}
}
public int FindIndex(T value) { return node.FindIndex(value); }
public T this[int i] {
get { return node[i]; }
}
}
static class Permutation<T> {
private static void Search(List<T[]> perms, Stack<T> stack, T[] a) {
int N = a.Length;
if (N == 0) {
perms.Add(stack.Reverse().ToArray());
} else {
var b = new T[N - 1];
Array.Copy(a, 1, b, 0, N - 1);
for (int i = 0; i < a.Length; ++i) {
stack.Push(a[i]);
Search(perms, stack, b);
if (i < b.Length) {
b[i] = a[i];
}
stack.Pop();
}
}
}
public static IEnumerable<T[]> All(IEnumerable<T> src) {
var perms = new List<T[]>();
Search(perms, new Stack<T>(), src.ToArray());
return perms;
}
}
namespace CompLib.Collections {
#region PriorityQueue
/// <summary>
/// 指定した型のインスタンスを最も価値が低い順に取り出すことが可能な可変サイズのコレクションを表します.
/// </summary>
/// <typeparam name="T">優先度付きキュー内の要素の型を指定します.</typeparam>
/// <remarks>内部的にはバイナリヒープによって実装されています.</remarks>
public class PriorityQueue<T> {
readonly List<T> heap = new List<T>();
readonly Comparison<T> cmp;
/// <summary>
/// デフォルトの比較子を使用してインスタンスを初期化します.
/// </summary>
/// <remarks>この操作は O(1) で実行されます.</remarks>
public PriorityQueue() { cmp = Comparer<T>.Default.Compare; }
/// <summary>
/// デリゲートで表されるような比較関数を使用してインスタンスを初期化します.
/// </summary>
/// <param name="comparison"></param>
/// <remarks>この操作は O(1) で実行されます.</remarks>
public PriorityQueue(Comparison<T> comparison) { cmp = comparison; }
/// <summary>
/// 指定された比較子を使用してインスタンスを初期化します.
/// </summary>
/// <param name="comparer"></param>
/// <remarks>この操作は O(1) で実行されます.</remarks>
public PriorityQueue(IComparer<T> comparer) { cmp = comparer.Compare; }
/// <summary>
/// 優先度付きキューに要素を追加します.
/// </summary>
/// <param name="item">優先度付きキューに追加される要素</param>
/// <remarks>最悪計算量 O(log N) で実行されます.</remarks>
public void Enqueue(T item) {
var pos = heap.Count;
heap.Add(item);
while (pos > 0) {
var par = (pos - 1) / 2;
if (cmp(heap[par], item) <= 0)
break;
heap[pos] = heap[par];
pos = par;
}
heap[pos] = item;
}
/// <summary>
/// 優先度付きキューから最も価値が低い要素を削除し,返します.
/// </summary>
/// <returns>優先度付きキューから削除された要素.</returns>
/// <remarks>最悪計算量 O(log N) で実行されます.</remarks>
public T Dequeue() {
var ret = heap[0];
var pos = 0;
var x = heap[heap.Count - 1];
while (pos * 2 + 1 < heap.Count - 1) {
var lch = pos * 2 + 1;
var rch = pos * 2 + 2;
if (rch < heap.Count - 1 && cmp(heap[rch], heap[lch]) < 0)
lch = rch;
if (cmp(heap[lch], x) >= 0)
break;
heap[pos] = heap[lch];
pos = lch;
}
heap[pos] = x;
heap.RemoveAt(heap.Count - 1);
return ret;
}
/// <summary>
/// 優先度付きキューに含まれる最も価値が低い要素を削除せずに返します.
/// </summary>
/// <returns>優先度付きキューに含まれる最も価値が低い要素.</returns>
/// <remarks>この操作は O(1) で実行されます.</remarks>
public T Peek() { return heap[0]; }
/// <summary>
/// 優先度付きキュー内の要素の数を取得します.
/// </summary>
/// <returns>優先度付キュー内にある要素の数</returns>
/// <remarks>最悪計算量 O(1) で実行されます.</remarks>
public int Count {
get { return heap.Count; }
}
/// <summary>
/// 優先度付きキュー内に要素が存在するかどうかを O(1) で判定します.
/// </summary>
/// <returns>優先度付キュー内にある要素が存在するならば
/// true,そうでなければ false.</returns> <remarks>この操作は O(1)
/// で実行されます.</remarks>
public bool Any() { return heap.Count > 0; }
/// <summary>
/// 優先度付きキューに含まれる要素を昇順に並べて返します.
/// </summary>
/// <remarks>この操作は計算量 O(N log N)で実行されます.</remarks>
public T[] Items {
get {
var ret = heap.ToArray();
Array.Sort(ret, cmp);
return ret;
}
}
}
#endregion
}
/// <summary>
/// SEGTREEは1-BASE運用でございます
/// よろしくおねがいします
/// </summary>
/// <typeparam name="T"></typeparam>
class Segtree<T> {
int n; //高さ
T[] tree; //本体
Func<T, T, T> f; //更新関数。a -> b -> ab使ったなにか
T exnum; //初期値
int count;
/// <summary>
/// !!!WARNING!!! 1-BASEです。
/// </summary>
/// <param name="m">最大値。200001とか入れておくとよい</param>
/// <param name="f">2引数の関数</param>
/// <param
/// name="ex">葉に書いてある値の初期値。fの関数に影響を与えない数値、零元とかにしておくべき。バグり散らかす。</param>
public Segtree(int m, Func<T, T, T> f, T ex) {
this.count = 0;
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) {
this.count = 0;
for (int i = 0; i < m; ++i)
tree[i + n - 1] = ini;
all_update();
}
/// <summary>
/// j番目の値をxにする。計算し直さないので、
/// 入れ替えた後はall_update();を使おう
/// </summary>
/// <param name="j">番目</param>
/// <param name="x">更新後の値</param>
public void assign_without_update(int j, T x) { tree[j + n - 1] = x; }
/// <summary>
/// j番目の値をxにする。計算し直すので、ちょっと計算時間がかかる
/// </summary>
/// <param name="j">番目</param>
/// <param name="x">更新後の値</param>
public void update(int j, T x) // j番目を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]);
}
this.count++;
}
/// <summary>
/// 木を全部計算し直す。多分NlogN。違うかも知れないから
/// よかったら教えて
/// </summary>
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]; }
/// <summary>
/// j番目を消す。
/// </summary>
/// <param name="j"></param>
public void delete (int j) {
int i = j + n - 1;
tree[i] = exnum;
int moved = 0;
while (true) {
tree[i + 1] = tree[i];
T check = tree[i];
moved++;
if (moved + j + 2 > count) {
break;
}
}
all_update();
}
// [s, t)
/// <summary>
/// s番目からt番目までの結果を返す。
/// これも当然のように1-BASE.
/// </summary>
/// <param name="s"></param>
/// <param name="t"></param>
/// <returns></returns>
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 ABC {
// long[] sp = Console.ReadLine().Split().Select(long
// .Parse).ToArray(); int[] sp =
// Console.ReadLine().Split().Select(int.Parse).ToArray(); int N =
// int.Parse(Console.ReadLine());
// CompLib.Collections.PriorityQueue<?>
public static void Main() {
;
int N;
new readint(out N);
long output = 0;
long[,] arr = new long[10, 10];
for (int ue = 0; ue < 10; ue++) {
for (int shita = 0; shita < 10; shita++) {
arr[ue, shita] = makenumber(N, ue, shita);
}
}
for (int ue = 0; ue < 10; ue++) {
for (int shita = 0; shita < 10; shita++) {
output += arr[ue, shita] * arr[shita, ue];
}
}
Console.WriteLine(output);
}
public static int makenumber(int N, int ue, int shita) {
//一番上と下の桁は固定
// 1桁からN.length桁まである
int n_length = ("" + N).Length;
if (ue == 0)
return 0;
int output = 0;
// 1桁
if (ue == shita)
output++;
// 2桁以上、N_length桁未満
for (int keta = 2; keta < n_length; keta++) {
int yoyuu_keta = keta - 2;
output += (int)Math.Pow(10, yoyuu_keta);
}
// N_length桁
int yoyuu = n_length - 2;
if (yoyuu != 0) {
string temp = "";
for (int i = 0; i < yoyuu; i++) {
temp += "0";
}
int limit = (int)Math.Pow(10, temp.Length);
for (int i = 0; i < limit; i++) {
string d = ("" + ue) + temp + ("" + shita);
if (int.Parse(d) <= N) {
output++;
} else {
break;
}
temp = tempup(temp, temp.Length - 1);
if (temp.Contains("#"))
break;
}
} else {
if (int.Parse(("" + ue) + shita) <= N)
output++;
}
return output;
}
public static string ketalimit = "";
public static string tempup(string temp, int keta) {
if (ketalimit == "")
for (int i = 0; i < temp.Length; i++) {
ketalimit += "9";
}
if (ketalimit == temp) {
return "#";
}
if (temp[keta] != '9') {
int tempketa = int.Parse(temp[keta].ToString());
tempketa++;
return temp.Substring(0, keta) + (tempketa) + temp.Substring(keta + 1);
} else {
return tempup(temp.Substring(0, temp.Length - 1), (keta - 1)) + "0";
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using System.IO;
class readint {
public readint(out int i) { i = int.Parse(Console.ReadLine()); }
public readint(out int a, out int b) {
int[] sp = Console.ReadLine().Split().Select(int.Parse).ToArray();
a = sp[0];
b = sp[1];
}
public readint(out int a, out int b, out int c) {
int[] sp = Console.ReadLine().Split().Select(int.Parse).ToArray();
a = sp[0];
b = sp[1];
c = sp[2];
}
public readint(out int a, out int b, out int c, out int d) {
int[] sp = Console.ReadLine().Split().Select(int.Parse).ToArray();
a = sp[0];
b = sp[1];
c = sp[2];
d = sp[3];
}
}
class readlong {
public readlong(out long i) { i = long.Parse(Console.ReadLine()); }
public readlong(out long a, out long b) {
long[] sp = Console.ReadLine().Split().Select(long.Parse).ToArray();
a = sp[0];
b = sp[1];
}
public readlong(out long a, out long b, out long c) {
long[] sp = Console.ReadLine().Split().Select(long.Parse).ToArray();
a = sp[0];
b = sp[1];
c = sp[2];
}
public readlong(out long a, out long b, out long c, out long d) {
long[] sp = Console.ReadLine().Split().Select(long.Parse).ToArray();
a = sp[0];
b = sp[1];
c = sp[2];
d = sp[3];
}
}
class Util {
public static int[] readintarr() {
return Console.ReadLine().Split().Select(int.Parse).ToArray();
}
public static long[] readlongarr() {
return Console.ReadLine().Split().Select(long.Parse).ToArray();
}
/// <summary>
/// 2引数の最大公約数を返します。longです。
/// </summary>
/// <param name="a">long 引数1</param>
/// <param name="b">long 引数2</param>
/// <returns></returns>
public static long GCD(long a, long b) {
if (a < b)
swap(ref a, ref b);
if (a % b == 0)
return b;
return GCD(b, a % b);
}
/// <summary>
/// 2引数の最大公約数を返します。intです。
/// </summary>
/// <param name="a">int 引数1</param>
/// <param name="b">int 引数2</param>
/// <returns></returns>
public static int GCD(int a, int b) {
// if (a < b)
// swap(ref a, ref b);
if (a % b == 0)
return b;
return GCD(b, a % b);
}
/// <summary>
/// 2つの変数の中身を交換する。型はなんでもいい
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="a"></param>
/// <param name="b"></param>
public static void swap<T>(ref T a, ref T b) {
T temp = b;
b = a;
a = temp;
}
/// <summary>
/// 2引数の最大公約数を返します。
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public static long LCM(long a, long b) { return a * b / GCD(a, b); }
/// <summary>
/// 2引数の最大公約数を返します。
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public static long LCM(int a, int b) { return Math.BigMul(a, b) / GCD(a, b); }
public static int M = (int)(Math.Pow(10, 9)) + 7;
private static int[] factorial_modM;
/// <summary>
/// 2引数の積 mod Mを求める。Mは10億7。
/// 変えられるよ。
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public static int Multiple_modM(int a, int b) {
return (int)(Math.BigMul(a, b) % M);
}
/// <summary>
/// n! modMを求めるための準備を行う。引数は最大値。
/// </summary>
/// <param name="n"></param>
public static void factorial_modM_Prepare(int n) {
factorial_modM = new int[n + 1];
factorial_modM[0] = 1;
for (int i = 1; i <= n; ++i) {
factorial_modM[i] = Multiple_modM(factorial_modM[i - 1], i);
}
}
/// <summary>
/// n! mod M を返す。やる前にfactorial_modM_Prepare(n)を実行しといてね。
/// </summary>
/// <param name="n"></param>
/// <returns></returns>
public static int Factorial(int n) { return factorial_modM[n]; }
public static 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 = Multiple_modM(p1, p1);
return ((m % 2) == 0) ? p2 : Multiple_modM(p2, a);
}
}
/// <summary>
/// a / m Mod M を求める。
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public static int Div(int a, int b) {
return Multiple_modM(a, Pow(b, M - 2));
}
/// <summary>
/// nCr mod M を求める。やる前にfactorial_modM_Prepare(n)を実行しといてね。
/// </summary>
/// <param name="n"></param>
/// <param name="r"></param>
/// <returns></returns>
public static int nCr_modM(int n, int r) {
if (r < 0)
return 0;
if (n < r) {
return 0;
}
if (n == r) {
return 1;
}
int res = Factorial(n);
res = Div(res, Factorial(r));
res = Div(res, Factorial(n - r));
return res;
}
}
/// <summary>
/// Union-Find木を定義する。コンストラクタの指定は、頂点の番号。
/// おすすめとしては、UnionFind<T>[] で宣言してしまう。
/// </summary>
/// <typeparam name="T">int固定でいいよね。</typeparam>
class UnionFind<T> {
public int tree_height;
public UnionFind<T> parent;
public T item { get; private set; }
public UnionFind(T item) {
tree_height = 0;
parent = this;
}
/// <summary>
/// 一番上の親を探す。
/// 探しながら繋がり方を最適化している。
/// UnionFindの頂点そのものを返すので、==での比較が可能。
/// </summary>
/// <returns></returns>
public UnionFind<T> FindAdam() {
if (parent == this)
return this;
else {
UnionFind<T> ParentOfParent = parent.FindAdam();
parent = ParentOfParent; //縦長な構成をつなぎ直している
return ParentOfParent;
}
}
/// <summary>
/// unionfind2つを一つにつなぐ。
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
public static void Unite(UnionFind<T> a, UnionFind<T> b) {
UnionFind<T> ParentOfA = a.FindAdam();
UnionFind<T> ParentOfB = b.FindAdam();
if (ParentOfA.tree_height < ParentOfB.tree_height) {
ParentOfA.parent = ParentOfB;
ParentOfB.tree_height =
Math.Max(ParentOfA.tree_height + 1, ParentOfB.tree_height);
} else {
ParentOfB.parent = ParentOfA;
ParentOfA.tree_height =
Math.Max(ParentOfB.tree_height + 1, ParentOfA.tree_height);
}
}
}
// Treap 平衡二分木
class Treap<T>
where T : IComparable {
private class Node {
private static Random g_rand = new Random();
private readonly int m_rank = g_rand.Next();
private readonly T m_value;
private Node m_lch;
private Node m_rch;
private int m_count;
public Node(T value) {
m_value = value;
m_count = 1;
}
private static int Count(Node node) {
return (node != null) ? node.m_count : 0;
}
private Node Update() {
m_count = Count(m_lch) + Count(m_rch) + 1;
return this;
}
public static Node Merge(Node a, Node b) {
if (a == null) {
return b;
}
if (b == null) {
return a;
}
if (a.m_rank < b.m_rank) {
a.m_rch = Merge(a.m_rch, b);
return a.Update();
} else {
b.m_lch = Merge(a, b.m_lch);
return b.Update();
}
}
public static Tuple<Node, Node> Split(Node t, int k) {
if (t == null) {
return new Tuple<Node, Node>(null, null);
}
if (k <= Count(t.m_lch)) {
var pair = Split(t.m_lch, k);
t.m_lch = pair.Item2;
return new Tuple<Node, Node>(pair.Item1, t.Update());
} else {
var pair = Split(t.m_rch, k - Count(t.m_lch) - 1);
t.m_rch = pair.Item1;
return new Tuple<Node, Node>(t.Update(), pair.Item2);
}
}
public int FindIndex(T value) {
int L = Count(m_lch);
if (value.CompareTo(m_value) < 0) {
return (m_lch != null) ? m_lch.FindIndex(value) : 0;
} else if (value.CompareTo(m_value) > 0) {
return (m_rch != null) ? m_rch.FindIndex(value) + L + 1 : L + 1;
} else {
return L;
}
}
public T this[int i] {
get {
int L = Count(m_lch);
if (i < L) {
return m_lch[i];
} else if (i > L) {
return m_rch[i - L - 1];
} else {
return m_value;
}
}
}
}
private Node node;
public void Insert(T value) {
if (node != null) {
int k = node.FindIndex(value);
var pair = Node.Split(node, k);
node = Node.Merge(Node.Merge(pair.Item1, new Node(value)), pair.Item2);
} else {
node = new Node(value);
}
}
public int FindIndex(T value) { return node.FindIndex(value); }
public T this[int i] {
get { return node[i]; }
}
}
static class Permutation<T> {
private static void Search(List<T[]> perms, Stack<T> stack, T[] a) {
int N = a.Length;
if (N == 0) {
perms.Add(stack.Reverse().ToArray());
} else {
var b = new T[N - 1];
Array.Copy(a, 1, b, 0, N - 1);
for (int i = 0; i < a.Length; ++i) {
stack.Push(a[i]);
Search(perms, stack, b);
if (i < b.Length) {
b[i] = a[i];
}
stack.Pop();
}
}
}
public static IEnumerable<T[]> All(IEnumerable<T> src) {
var perms = new List<T[]>();
Search(perms, new Stack<T>(), src.ToArray());
return perms;
}
}
namespace CompLib.Collections {
#region PriorityQueue
/// <summary>
/// 指定した型のインスタンスを最も価値が低い順に取り出すことが可能な可変サイズのコレクションを表します.
/// </summary>
/// <typeparam name="T">優先度付きキュー内の要素の型を指定します.</typeparam>
/// <remarks>内部的にはバイナリヒープによって実装されています.</remarks>
public class PriorityQueue<T> {
readonly List<T> heap = new List<T>();
readonly Comparison<T> cmp;
/// <summary>
/// デフォルトの比較子を使用してインスタンスを初期化します.
/// </summary>
/// <remarks>この操作は O(1) で実行されます.</remarks>
public PriorityQueue() { cmp = Comparer<T>.Default.Compare; }
/// <summary>
/// デリゲートで表されるような比較関数を使用してインスタンスを初期化します.
/// </summary>
/// <param name="comparison"></param>
/// <remarks>この操作は O(1) で実行されます.</remarks>
public PriorityQueue(Comparison<T> comparison) { cmp = comparison; }
/// <summary>
/// 指定された比較子を使用してインスタンスを初期化します.
/// </summary>
/// <param name="comparer"></param>
/// <remarks>この操作は O(1) で実行されます.</remarks>
public PriorityQueue(IComparer<T> comparer) { cmp = comparer.Compare; }
/// <summary>
/// 優先度付きキューに要素を追加します.
/// </summary>
/// <param name="item">優先度付きキューに追加される要素</param>
/// <remarks>最悪計算量 O(log N) で実行されます.</remarks>
public void Enqueue(T item) {
var pos = heap.Count;
heap.Add(item);
while (pos > 0) {
var par = (pos - 1) / 2;
if (cmp(heap[par], item) <= 0)
break;
heap[pos] = heap[par];
pos = par;
}
heap[pos] = item;
}
/// <summary>
/// 優先度付きキューから最も価値が低い要素を削除し,返します.
/// </summary>
/// <returns>優先度付きキューから削除された要素.</returns>
/// <remarks>最悪計算量 O(log N) で実行されます.</remarks>
public T Dequeue() {
var ret = heap[0];
var pos = 0;
var x = heap[heap.Count - 1];
while (pos * 2 + 1 < heap.Count - 1) {
var lch = pos * 2 + 1;
var rch = pos * 2 + 2;
if (rch < heap.Count - 1 && cmp(heap[rch], heap[lch]) < 0)
lch = rch;
if (cmp(heap[lch], x) >= 0)
break;
heap[pos] = heap[lch];
pos = lch;
}
heap[pos] = x;
heap.RemoveAt(heap.Count - 1);
return ret;
}
/// <summary>
/// 優先度付きキューに含まれる最も価値が低い要素を削除せずに返します.
/// </summary>
/// <returns>優先度付きキューに含まれる最も価値が低い要素.</returns>
/// <remarks>この操作は O(1) で実行されます.</remarks>
public T Peek() { return heap[0]; }
/// <summary>
/// 優先度付きキュー内の要素の数を取得します.
/// </summary>
/// <returns>優先度付キュー内にある要素の数</returns>
/// <remarks>最悪計算量 O(1) で実行されます.</remarks>
public int Count {
get { return heap.Count; }
}
/// <summary>
/// 優先度付きキュー内に要素が存在するかどうかを O(1) で判定します.
/// </summary>
/// <returns>優先度付キュー内にある要素が存在するならば
/// true,そうでなければ false.</returns> <remarks>この操作は O(1)
/// で実行されます.</remarks>
public bool Any() { return heap.Count > 0; }
/// <summary>
/// 優先度付きキューに含まれる要素を昇順に並べて返します.
/// </summary>
/// <remarks>この操作は計算量 O(N log N)で実行されます.</remarks>
public T[] Items {
get {
var ret = heap.ToArray();
Array.Sort(ret, cmp);
return ret;
}
}
}
#endregion
}
/// <summary>
/// SEGTREEは1-BASE運用でございます
/// よろしくおねがいします
/// </summary>
/// <typeparam name="T"></typeparam>
class Segtree<T> {
int n; //高さ
T[] tree; //本体
Func<T, T, T> f; //更新関数。a -> b -> ab使ったなにか
T exnum; //初期値
int count;
/// <summary>
/// !!!WARNING!!! 1-BASEです。
/// </summary>
/// <param name="m">最大値。200001とか入れておくとよい</param>
/// <param name="f">2引数の関数</param>
/// <param
/// name="ex">葉に書いてある値の初期値。fの関数に影響を与えない数値、零元とかにしておくべき。バグり散らかす。</param>
public Segtree(int m, Func<T, T, T> f, T ex) {
this.count = 0;
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) {
this.count = 0;
for (int i = 0; i < m; ++i)
tree[i + n - 1] = ini;
all_update();
}
/// <summary>
/// j番目の値をxにする。計算し直さないので、
/// 入れ替えた後はall_update();を使おう
/// </summary>
/// <param name="j">番目</param>
/// <param name="x">更新後の値</param>
public void assign_without_update(int j, T x) { tree[j + n - 1] = x; }
/// <summary>
/// j番目の値をxにする。計算し直すので、ちょっと計算時間がかかる
/// </summary>
/// <param name="j">番目</param>
/// <param name="x">更新後の値</param>
public void update(int j, T x) // j番目を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]);
}
this.count++;
}
/// <summary>
/// 木を全部計算し直す。多分NlogN。違うかも知れないから
/// よかったら教えて
/// </summary>
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]; }
/// <summary>
/// j番目を消す。
/// </summary>
/// <param name="j"></param>
public void delete (int j) {
int i = j + n - 1;
tree[i] = exnum;
int moved = 0;
while (true) {
tree[i + 1] = tree[i];
T check = tree[i];
moved++;
if (moved + j + 2 > count) {
break;
}
}
all_update();
}
// [s, t)
/// <summary>
/// s番目からt番目までの結果を返す。
/// これも当然のように1-BASE.
/// </summary>
/// <param name="s"></param>
/// <param name="t"></param>
/// <returns></returns>
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 ABC {
// long[] sp = Console.ReadLine().Split().Select(long
// .Parse).ToArray(); int[] sp =
// Console.ReadLine().Split().Select(int.Parse).ToArray(); int N =
// int.Parse(Console.ReadLine());
// CompLib.Collections.PriorityQueue<?>
public static void Main() {
;
int N;
new readint(out N);
long output = 0;
long[,] arr = new long[10, 10];
for (int ue = 0; ue < 10; ue++) {
for (int shita = 0; shita < 10; shita++) {
arr[ue, shita] = makenumber(N, ue, shita);
}
}
for (int ue = 0; ue < 10; ue++) {
for (int shita = 0; shita < 10; shita++) {
output += arr[ue, shita] * arr[shita, ue];
}
}
Console.WriteLine(output);
}
public static int makenumber(int N, int ue, int shita) {
//一番上と下の桁は固定
// 1桁からN.length桁まである
int n_length = ("" + N).Length;
if (ue == 0)
return 0;
int output = 0;
// 1桁
if (ue == shita) {
if (ue <= N)
output++;
} // 2桁以上、N_length桁未満
for (int keta = 2; keta < n_length; keta++) {
int yoyuu_keta = keta - 2;
output += (int)Math.Pow(10, yoyuu_keta);
}
// N_length桁
int yoyuu = n_length - 2;
if (yoyuu != 0) {
string temp = "";
for (int i = 0; i < yoyuu; i++) {
temp += "0";
}
int limit = (int)Math.Pow(10, temp.Length);
for (int i = 0; i < limit; i++) {
string d = ("" + ue) + temp + ("" + shita);
if (int.Parse(d) <= N) {
output++;
} else {
break;
}
temp = tempup(temp, temp.Length - 1);
if (temp.Contains("#"))
break;
}
} else {
if (int.Parse(("" + ue) + shita) <= N)
output++;
}
return output;
}
public static string ketalimit = "";
public static string tempup(string temp, int keta) {
if (ketalimit == "")
for (int i = 0; i < temp.Length; i++) {
ketalimit += "9";
}
if (ketalimit == temp) {
return "#";
}
if (temp[keta] != '9') {
int tempketa = int.Parse(temp[keta].ToString());
tempketa++;
return temp.Substring(0, keta) + (tempketa) + temp.Substring(keta + 1);
} else {
return tempup(temp.Substring(0, temp.Length - 1), (keta - 1)) + "0";
}
}
}
|
[["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 19], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 3,740
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
namespace AtTest.ABC_152 {
class D {
static void Main(string[] args) {
var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush =
false };
SetOut(sw);
Method(args);
Out.Flush();
}
static void Method(string[] args) {
int n = ReadInt();
var dict = new Dictionary<int, long>();
for (int i = 1; i <= n; i++) {
int tail = i % 10;
int tmp = i;
while (tmp >= 10)
tmp /= 10;
int head = tmp;
int val = head * 10 + tail;
if (dict.ContainsKey(val)) {
dict[val]++;
} else {
dict.Add(val, 1);
}
}
long res = 0;
for (int i = 1; i <= 9; i++) {
for (int j = 1; j <= 9; j++) {
res += dict[i * 10 + j] * dict[j * 10 + i];
}
}
WriteLine(res);
}
private static string Read() { return ReadLine(); }
private static char[] ReadChars() {
return Array.ConvertAll(Read().Split(), a => a[0]);
}
private static int ReadInt() { return int.Parse(Read()); }
private static long ReadLong() { return long.Parse(Read()); }
private static double ReadDouble() { return double.Parse(Read()); }
private static int[] ReadInts() {
return Array.ConvertAll(Read().Split(), int.Parse);
}
private static long[] ReadLongs() {
return Array.ConvertAll(Read().Split(), long.Parse);
}
private static double[] ReadDoubles() {
return Array.ConvertAll(Read().Split(), double.Parse);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
namespace AtTest.ABC_152 {
class D {
static void Main(string[] args) {
var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush =
false };
SetOut(sw);
Method(args);
Out.Flush();
}
static void Method(string[] args) {
int n = ReadInt();
var dict = new Dictionary<int, long>();
for (int i = 1; i <= n; i++) {
int tail = i % 10;
int tmp = i;
while (tmp >= 10)
tmp /= 10;
int head = tmp;
int val = head * 10 + tail;
if (dict.ContainsKey(val)) {
dict[val]++;
} else {
dict.Add(val, 1);
}
}
long res = 0;
for (int i = 1; i <= 9; i++) {
for (int j = 1; j <= 9; j++) {
int a = i * 10 + j;
int b = j * 10 + i;
if (dict.ContainsKey(a) && dict.ContainsKey(b)) {
res += dict[a] * dict[b];
}
}
}
WriteLine(res);
}
private static string Read() { return ReadLine(); }
private static char[] ReadChars() {
return Array.ConvertAll(Read().Split(), a => a[0]);
}
private static int ReadInt() { return int.Parse(Read()); }
private static long ReadLong() { return long.Parse(Read()); }
private static double ReadDouble() { return double.Parse(Read()); }
private static int[] ReadInts() {
return Array.ConvertAll(Read().Split(), int.Parse);
}
private static long[] ReadLongs() {
return Array.ConvertAll(Read().Split(), long.Parse);
}
private static double[] ReadDoubles() {
return Array.ConvertAll(Read().Split(), double.Parse);
}
}
}
|
[["-", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["-", 0, 1, 0, 11, 12, 16, 31, 204, 205, 22], ["-", 0, 11, 12, 16, 31, 204, 206, 207, 0, 70], ["+", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 11, 12, 16, 31, 204, 206, 207, 0, 73], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 17, 48], ["-", 0, 1, 0, 11, 12, 16, 12, 204, 205, 22], ["-", 0, 11, 12, 16, 12, 204, 206, 207, 0, 70], ["+", 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, 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], ["+", 15, 16, 31, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 57, 15, 16, 31, 213, 3, 4, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 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], ["+", 15, 16, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 57, 15, 16, 12, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 0, 1, 0, 11, 12, 16, 31, 204, 205, 22], ["+", 0, 11, 12, 16, 31, 204, 206, 207, 0, 70], ["+", 12, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 11, 12, 16, 31, 204, 206, 207, 0, 73], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 0, 1, 0, 11, 12, 16, 12, 204, 205, 22], ["+", 0, 11, 12, 16, 12, 204, 206, 207, 0, 70], ["+", 12, 16, 12, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 445
| 44
|
using System.Linq;
using System.Text;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Numerics;
namespace AtCoder {
class Program {
const int BiggestMod = 1000000007;
public static void Main() {
var args = new int[2];
args[0] = int.Parse(Console.ReadLine());
args[1] = int.Parse(Console.ReadLine());
Console.WriteLine((args.Max() - 1) / int.Parse(Console.ReadLine()));
}
}
}
|
using System.Linq;
using System.Text;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Numerics;
namespace AtCoder {
class Program {
const int BiggestMod = 1000000007;
public static void Main() {
var args = new int[2];
args[0] = int.Parse(Console.ReadLine());
args[1] = int.Parse(Console.ReadLine());
Console.WriteLine(1 + ((int.Parse(Console.ReadLine()) - 1) / (args.Max())));
}
}
}
|
[["+", 0, 213, 3, 4, 0, 28, 0, 16, 31, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["-", 31, 23, 0, 16, 31, 213, 63, 214, 205, 22], ["+", 0, 16, 12, 23, 0, 16, 31, 23, 0, 24], ["+", 31, 23, 0, 16, 31, 213, 63, 214, 205, 199], ["+", 31, 23, 0, 16, 31, 213, 63, 214, 0, 131], ["+", 31, 23, 0, 16, 31, 213, 63, 214, 141, 22], ["+", 31, 23, 0, 16, 31, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["-", 31, 23, 0, 16, 31, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25], ["-", 0, 28, 0, 16, 12, 213, 63, 214, 205, 199], ["-", 0, 28, 0, 16, 12, 213, 63, 214, 0, 131], ["-", 0, 28, 0, 16, 12, 213, 63, 214, 141, 22], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["+", 0, 16, 12, 23, 0, 213, 63, 214, 205, 22], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 0, 16, 12, 23, 0, 213, 63, 214, 141, 22], ["+", 0, 16, 12, 23, 0, 213, 3, 4, 0, 25]]
| 8
| 129
| 20
|
using System;
using System.Linq;
class Program {
public static void Main() {
int a = int.Parse(Console.ReadLine());
int b = int.Parse(Console.ReadLine());
int big;
if (a > b) {
big = a;
} else {
big = b;
}
int n = int.Parse(Console.ReadLine());
Console.WriteLine(n / big + 1);
}
}
|
using System;
using System.Linq;
class Program {
public static void Main() {
int a = int.Parse(Console.ReadLine());
int b = int.Parse(Console.ReadLine());
int big;
if (a > b) {
big = a;
} else {
big = b;
}
int n = int.Parse(Console.ReadLine());
if (n % big == 0)
Console.WriteLine(n / big);
else
Console.WriteLine(n / big + 1);
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 205, 22], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 0, 131], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 141, 22], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 85], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95]]
| 8
| 95
| 18
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder {
static class Program {
static void Main() {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
int N = GetInt();
Dictionary<string, int> dic = new Dictionary<string, int>();
for (int i = 0; i < N; i++) {
var temp = GetStr();
if (dic.ContainsKey(temp)) {
dic[temp]++;
} else {
dic.Add(temp, 1);
}
}
var num = dic.Values.Max();
var a = dic.Where(d => d.Value == num).Select(s => s.Key).FastSort();
for (int i = 0; i < a.Count(); i++) {
Console.WriteLine(a[i]);
}
// Console.WriteLine(ans);
Console.Out.Flush();
Console.ReadKey();
}
static public string GetStr() { return Console.ReadLine().Trim(); }
static public char GetChar() { return Console.ReadLine().Trim()[0]; }
static public int GetInt() { return int.Parse(Console.ReadLine().Trim()); }
static public long GetLong() { return long.Parse(Console.ReadLine().Trim()); }
static public double GetDouble() {
return double.Parse(Console.ReadLine().Trim());
}
static public string[] GetStrArray() {
return Console.ReadLine().Trim().Split(' ');
}
static public int[] GetIntArray() {
return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
}
static public long[] GetLongArray() {
return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
}
static public char[] GetCharArray() {
return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray();
}
static public Double[] GetDoubleArray() {
return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();
}
static public void WriteObjects<T>(IList<T> values) {
var num = values.Count;
for (int i = 0; i < num; i++) {
Console.Write(values[i]);
if (i < num - 1) {
Console.Write(" ");
}
}
Console.WriteLine();
}
static public List<string> FastSort(this IEnumerable<string> s) {
s.ToList().Sort(StringComparer.Ordinal);
return s.ToList();
}
static string yesno(this bool b) { return b ? "yes" : "no"; }
static string YesNo(this bool b) { return b ? "Yes" : "No"; }
static string YESNO(this bool b) { return b ? "YES" : "NO"; }
static bool eq<T, U>() => typeof(T).Equals(typeof(U));
static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
: eq<T, long>() ? ct<T, long>(long.Parse(s))
: eq<T, double>() ? ct<T, double>(double.Parse(s))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
static void Multi<T>(out T a) => a = cv<T>(GetStr());
static void Multi<T, U>(out T a, out U b) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
static void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
static void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
}
static void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d,
out X e) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
}
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder {
static class Program {
static void Main() {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
int N = GetInt();
Dictionary<string, int> dic = new Dictionary<string, int>();
for (int i = 0; i < N; i++) {
var temp = GetStr();
if (dic.ContainsKey(temp)) {
dic[temp]++;
} else {
dic.Add(temp, 1);
}
}
var num = dic.Values.Max();
var a =
dic.Where(d => d.Value == num).Select(s => s.Key).ToList().FastSort();
for (int i = 0; i < a.Count(); i++) {
Console.WriteLine(a[i]);
}
// Console.WriteLine(ans);
Console.Out.Flush();
Console.ReadKey();
}
static public string GetStr() { return Console.ReadLine().Trim(); }
static public char GetChar() { return Console.ReadLine().Trim()[0]; }
static public int GetInt() { return int.Parse(Console.ReadLine().Trim()); }
static public long GetLong() { return long.Parse(Console.ReadLine().Trim()); }
static public double GetDouble() {
return double.Parse(Console.ReadLine().Trim());
}
static public string[] GetStrArray() {
return Console.ReadLine().Trim().Split(' ');
}
static public int[] GetIntArray() {
return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
}
static public long[] GetLongArray() {
return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
}
static public char[] GetCharArray() {
return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray();
}
static public Double[] GetDoubleArray() {
return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();
}
static public void WriteObjects<T>(IList<T> values) {
var num = values.Count;
for (int i = 0; i < num; i++) {
Console.Write(values[i]);
if (i < num - 1) {
Console.Write(" ");
}
}
Console.WriteLine();
}
static public List<string> FastSort(this List<string> s) {
s.Sort(StringComparer.Ordinal);
return s.ToList();
}
static string yesno(this bool b) { return b ? "yes" : "no"; }
static string YesNo(this bool b) { return b ? "Yes" : "No"; }
static string YESNO(this bool b) { return b ? "YES" : "NO"; }
static bool eq<T, U>() => typeof(T).Equals(typeof(U));
static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
: eq<T, long>() ? ct<T, long>(long.Parse(s))
: eq<T, double>() ? ct<T, double>(double.Parse(s))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
static void Multi<T>(out T a) => a = cv<T>(GetStr());
static void Multi<T, U>(out T a, out U b) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
static void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
static void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
}
static void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d,
out X e) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
}
}
}
|
[["+", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["+", 0, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["-", 0, 195, 54, 55, 0, 220, 39, 236, 141, 22], ["+", 0, 195, 54, 55, 0, 220, 39, 236, 141, 22], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["-", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["-", 0, 213, 63, 214, 205, 213, 3, 4, 0, 25]]
| 8
| 1,214
| 10
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Threading;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using static util;
using P = pair<int, int>;
class Program {
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
var solver = new Solver(sw);
// var t = new Thread(solver.solve, 1 << 26); // 64 MB
// t.Start();
// t.Join();
solver.solve();
sw.Flush();
}
}
class Solver {
StreamWriter sw;
Scan sc;
void Prt(string a) => sw.WriteLine(a);
void Prt<T>(IEnumerable<T> a) => Prt(string.Join(" ", a));
void Prt(params object[] a) => Prt(string.Join(" ", a));
public Solver(StreamWriter sw) {
this.sw = sw;
this.sc = new Scan();
}
public void solve() {
int n = sc.Int;
var dic = new Dictionary<string, int>();
for (int i = 0; i < n; i++) {
var s = sc.Str;
if (!dic.ContainsKey(s)) {
dic.Add(s, 0);
}
++dic[s];
}
int max = dic.Max(x => x.Value);
var ans = new List<string>();
foreach (var item in dic) {
if (item.Value == max) {
ans.Add(item.Key);
}
}
// ans.Sort();
foreach (var item in ans) {
Prt(item);
}
}
}
class pair<T, U> : IComparable<pair<T, U>> {
public T v1;
public U v2;
public pair() : this(default(T), default(U)) {}
public pair(T v1, U v2) {
this.v1 = v1;
this.v2 = v2;
}
public int CompareTo(pair<T, U> a) {
int c = Comparer<T>.Default.Compare(v1, a.v1);
return c != 0 ? c : Comparer<U>.Default.Compare(v2, a.v2);
}
public override string ToString() => v1 + " " + v2;
public void Deconstruct(out T a, out U b) {
a = v1;
b = v2;
}
}
static class util {
public static readonly int M = 1000000007;
// public static readonly int M = 998244353;
public static readonly long LM = 1L << 60;
public static readonly double eps = 1e-11;
public static void DBG(string a) => Console.Error.WriteLine(a);
public static void DBG<T>(IEnumerable<T> a) => DBG(string.Join(" ", a));
public static void DBG(params object[] a) => DBG(string.Join(" ", a));
public static void Assert(params bool[] conds) {
foreach (var cond in conds)
if (!cond)
throw new Exception();
}
public static pair<T, U> make_pair<T, U>(T v1, U v2) => new pair<T, U>(v1,
v2);
public static int CompareList<T>(IList<T> a, IList<T> b)
where T : IComparable<T> {
for (int i = 0; i < a.Count && i < b.Count; i++)
if (a[i].CompareTo(b[i]) != 0)
return a[i].CompareTo(b[i]);
return a.Count.CompareTo(b.Count);
}
public static bool inside(int i, int j, int h, int w) => i >= 0 && i < h
&& j >= 0 && j < w;
static readonly int[] dd = { 0, 1, 0, -1 };
// static readonly string dstring = "RDLU";
public static P[] adjacents(int i,
int j) => Enumerable.Range(0, dd.Length)
.Select(k => new P(i + dd[k],
j + dd[k ^ 1]))
.ToArray();
public static P[] adjacents(int i, int j, int h, int w) =>
Enumerable.Range(0, dd.Length)
.Select(k => new P(i + dd[k], j + dd[k ^ 1]))
.Where(p => inside(p.v1, p.v2, h, w))
.ToArray();
public static P[] adjacents(this P p) => adjacents(p.v1, p.v2);
public static P[] adjacents(this P p, int h, int w) => adjacents(p.v1, p.v2,
h, w);
public static Dictionary<T, int>
compress<T>(this IEnumerable<T> a) => a.Distinct()
.OrderBy(v => v)
.Select((v, i) => new { v, i })
.ToDictionary(p => p.v, p => p.i);
public static Dictionary<T, int> compress<T>(params IEnumerable<T>[] a) =>
compress(a.Aggregate(Enumerable.Union));
public static T[] inv<T>(this Dictionary<T, int> dic) {
var res = new T[dic.Count];
foreach (var item in dic)
res[item.Value] = item.Key;
return res;
}
public static void swap<T>(ref T a, ref T b)
where T : struct {
var t = a;
a = b;
b = t;
}
public static void swap<T>(this IList<T> a, int i, int j)
where T : struct {
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;
}
public static void Deconstruct<T>(this IList<T> v, out T a) { a = v[0]; }
public static void Deconstruct<T>(this IList<T> v, out T a, out T b) {
a = v[0];
b = v[1];
}
public static void Deconstruct<T>(this IList<T> v, out T a, out T b,
out T c) {
a = v[0];
b = v[1];
c = v[2];
}
public static void Deconstruct<T>(this IList<T> v, out T a, out T b, out T c,
out T d) {
a = v[0];
b = v[1];
c = v[2];
d = v[3];
}
public static void Deconstruct<T>(this IList<T> v, out T a, out T b, out T c,
out T d, out T e) {
a = v[0];
b = v[1];
c = v[2];
d = v[3];
e = v[4];
}
}
class Scan {
StreamReader sr;
public Scan() { sr = new StreamReader(Console.OpenStandardInput()); }
public Scan(string path) { sr = new StreamReader(path); }
public int Int => int.Parse(Str);
public long Long => long.Parse(Str);
public double Double => double.Parse(Str);
public string Str => sr.ReadLine().Trim();
public pair<T, U> Pair<T, U>() {
T a;
U b;
Multi(out a, out b);
return new pair<T, U>(a, b);
}
public P P => Pair<int, int>();
public int[] IntArr => StrArr.Select(int.Parse).ToArray();
public long[] LongArr => StrArr.Select(long.Parse).ToArray();
public double[] DoubleArr => StrArr.Select(double.Parse).ToArray();
public string[] StrArr =>
Str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
bool eq<T, U>() => typeof(T).Equals(typeof(U));
T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
: eq<T, long>() ? ct<T, long>(long.Parse(s))
: eq<T, double>() ? ct<T, double>(double.Parse(s))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
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]);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Threading;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using static util;
using P = pair<int, int>;
class Program {
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
var solver = new Solver(sw);
// var t = new Thread(solver.solve, 1 << 26); // 64 MB
// t.Start();
// t.Join();
solver.solve();
sw.Flush();
}
}
class Solver {
StreamWriter sw;
Scan sc;
void Prt(string a) => sw.WriteLine(a);
void Prt<T>(IEnumerable<T> a) => Prt(string.Join(" ", a));
void Prt(params object[] a) => Prt(string.Join(" ", a));
public Solver(StreamWriter sw) {
this.sw = sw;
this.sc = new Scan();
}
public void solve() {
int n = sc.Int;
var dic = new SortedDictionary<string, int>(StringComparer.Ordinal);
for (int i = 0; i < n; i++) {
var s = sc.Str;
if (!dic.ContainsKey(s)) {
dic.Add(s, 0);
}
++dic[s];
}
int max = dic.Max(x => x.Value);
foreach (var item in dic) {
if (item.Value == max) {
Prt(item.Key);
}
}
}
}
class pair<T, U> : IComparable<pair<T, U>> {
public T v1;
public U v2;
public pair() : this(default(T), default(U)) {}
public pair(T v1, U v2) {
this.v1 = v1;
this.v2 = v2;
}
public int CompareTo(pair<T, U> a) {
int c = Comparer<T>.Default.Compare(v1, a.v1);
return c != 0 ? c : Comparer<U>.Default.Compare(v2, a.v2);
}
public override string ToString() => v1 + " " + v2;
public void Deconstruct(out T a, out U b) {
a = v1;
b = v2;
}
}
static class util {
public static readonly int M = 1000000007;
// public static readonly int M = 998244353;
public static readonly long LM = 1L << 60;
public static readonly double eps = 1e-11;
public static void DBG(string a) => Console.Error.WriteLine(a);
public static void DBG<T>(IEnumerable<T> a) => DBG(string.Join(" ", a));
public static void DBG(params object[] a) => DBG(string.Join(" ", a));
public static void Assert(params bool[] conds) {
foreach (var cond in conds)
if (!cond)
throw new Exception();
}
public static pair<T, U> make_pair<T, U>(T v1, U v2) => new pair<T, U>(v1,
v2);
public static int CompareList<T>(IList<T> a, IList<T> b)
where T : IComparable<T> {
for (int i = 0; i < a.Count && i < b.Count; i++)
if (a[i].CompareTo(b[i]) != 0)
return a[i].CompareTo(b[i]);
return a.Count.CompareTo(b.Count);
}
public static bool inside(int i, int j, int h, int w) => i >= 0 && i < h
&& j >= 0 && j < w;
static readonly int[] dd = { 0, 1, 0, -1 };
// static readonly string dstring = "RDLU";
public static P[] adjacents(int i,
int j) => Enumerable.Range(0, dd.Length)
.Select(k => new P(i + dd[k],
j + dd[k ^ 1]))
.ToArray();
public static P[] adjacents(int i, int j, int h, int w) =>
Enumerable.Range(0, dd.Length)
.Select(k => new P(i + dd[k], j + dd[k ^ 1]))
.Where(p => inside(p.v1, p.v2, h, w))
.ToArray();
public static P[] adjacents(this P p) => adjacents(p.v1, p.v2);
public static P[] adjacents(this P p, int h, int w) => adjacents(p.v1, p.v2,
h, w);
public static Dictionary<T, int>
compress<T>(this IEnumerable<T> a) => a.Distinct()
.OrderBy(v => v)
.Select((v, i) => new { v, i })
.ToDictionary(p => p.v, p => p.i);
public static Dictionary<T, int> compress<T>(params IEnumerable<T>[] a) =>
compress(a.Aggregate(Enumerable.Union));
public static T[] inv<T>(this Dictionary<T, int> dic) {
var res = new T[dic.Count];
foreach (var item in dic)
res[item.Value] = item.Key;
return res;
}
public static void swap<T>(ref T a, ref T b)
where T : struct {
var t = a;
a = b;
b = t;
}
public static void swap<T>(this IList<T> a, int i, int j)
where T : struct {
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;
}
public static void Deconstruct<T>(this IList<T> v, out T a) { a = v[0]; }
public static void Deconstruct<T>(this IList<T> v, out T a, out T b) {
a = v[0];
b = v[1];
}
public static void Deconstruct<T>(this IList<T> v, out T a, out T b,
out T c) {
a = v[0];
b = v[1];
c = v[2];
}
public static void Deconstruct<T>(this IList<T> v, out T a, out T b, out T c,
out T d) {
a = v[0];
b = v[1];
c = v[2];
d = v[3];
}
public static void Deconstruct<T>(this IList<T> v, out T a, out T b, out T c,
out T d, out T e) {
a = v[0];
b = v[1];
c = v[2];
d = v[3];
e = v[4];
}
}
class Scan {
StreamReader sr;
public Scan() { sr = new StreamReader(Console.OpenStandardInput()); }
public Scan(string path) { sr = new StreamReader(path); }
public int Int => int.Parse(Str);
public long Long => long.Parse(Str);
public double Double => double.Parse(Str);
public string Str => sr.ReadLine().Trim();
public pair<T, U> Pair<T, U>() {
T a;
U b;
Multi(out a, out b);
return new pair<T, U>(a, b);
}
public P P => Pair<int, int>();
public int[] IntArr => StrArr.Select(int.Parse).ToArray();
public long[] LongArr => StrArr.Select(long.Parse).ToArray();
public double[] DoubleArr => StrArr.Select(double.Parse).ToArray();
public string[] StrArr =>
Str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
bool eq<T, U>() => typeof(T).Equals(typeof(U));
T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
: eq<T, long>() ? ct<T, long>(long.Parse(s))
: eq<T, double>() ? ct<T, double>(double.Parse(s))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
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]);
}
}
|
[["-", 0, 200, 0, 212, 0, 230, 39, 236, 141, 22], ["+", 0, 200, 0, 212, 0, 230, 39, 236, 141, 22], ["+", 0, 230, 3, 4, 0, 28, 0, 214, 205, 22], ["+", 0, 230, 3, 4, 0, 28, 0, 214, 0, 131], ["+", 0, 230, 3, 4, 0, 28, 0, 214, 141, 22], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 198, 0, 200, 0, 212, 0, 230, 0, 228], ["-", 0, 212, 0, 230, 39, 236, 237, 238, 0, 18], ["-", 0, 212, 0, 230, 39, 236, 237, 238, 0, 199], ["-", 0, 212, 0, 230, 39, 236, 237, 238, 0, 47], ["-", 0, 200, 0, 212, 0, 230, 3, 4, 0, 24], ["-", 0, 200, 0, 212, 0, 230, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 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], ["+", 0, 57, 64, 196, 0, 1, 0, 213, 63, 22], ["-", 0, 210, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 8, 201, 0, 195, 8, 196, 0, 210, 0, 266], ["-", 8, 201, 0, 195, 8, 196, 0, 210, 0, 24], ["-", 0, 195, 8, 196, 0, 210, 39, 216, 0, 217], ["-", 8, 201, 0, 195, 8, 196, 0, 210, 31, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 210, 0, 267], ["-", 8, 201, 0, 195, 8, 196, 0, 210, 12, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 210, 0, 25], ["-", 0, 195, 8, 196, 0, 210, 8, 196, 0, 45], ["-", 0, 210, 8, 196, 0, 1, 0, 213, 63, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 210, 8, 196, 0, 1, 0, 35]]
| 8
| 2,303
| 34
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
namespace AtTest.ABC_155 {
class C {
static void Main(string[] args) {
var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush =
false };
SetOut(sw);
Method(args);
Out.Flush();
}
static void Method(string[] args) {
int n = ReadInt();
var dict = new Dictionary<string, int>();
int cnt = 0;
for (int i = 0; i < n; i++) {
string s = Read();
if (dict.ContainsKey(s)) {
dict[s]++;
} else {
dict.Add(s, 1);
}
cnt = Max(cnt, dict[s]);
}
List<string> res = new List<string>();
foreach (string key in dict.Keys) {
if (dict[key] == cnt) {
res.Add(key);
}
}
string[] array = res.ToArray();
Array.Sort(array);
for (int i = 0; i < n; i++) {
WriteLine(array[i]);
}
}
private static string Read() { return ReadLine(); }
private static char[] ReadChars() {
return Array.ConvertAll(Read().Split(), a => a[0]);
}
private static int ReadInt() { return int.Parse(Read()); }
private static long ReadLong() { return long.Parse(Read()); }
private static double ReadDouble() { return double.Parse(Read()); }
private static int[] ReadInts() {
return Array.ConvertAll(Read().Split(), int.Parse);
}
private static long[] ReadLongs() {
return Array.ConvertAll(Read().Split(), long.Parse);
}
private static double[] ReadDoubles() {
return Array.ConvertAll(Read().Split(), double.Parse);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
namespace AtTest.ABC_155 {
class C {
static void Main(string[] args) {
var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush =
false };
SetOut(sw);
Method(args);
Out.Flush();
}
static void Method(string[] args) {
int n = ReadInt();
var dict = new Dictionary<string, int>();
int cnt = 0;
for (int i = 0; i < n; i++) {
string s = Read();
if (dict.ContainsKey(s)) {
dict[s]++;
} else {
dict.Add(s, 1);
}
cnt = Max(cnt, dict[s]);
}
List<string> res = new List<string>();
foreach (string key in dict.Keys) {
if (dict[key] == cnt) {
res.Add(key);
}
}
res.Sort(StringComparer.Ordinal);
for (int i = 0; i < res.Count; i++) {
WriteLine(res[i]);
}
}
private static string Read() { return ReadLine(); }
private static char[] ReadChars() {
return Array.ConvertAll(Read().Split(), a => a[0]);
}
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);
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 0, 197, 0, 198, 39, 224, 225, 226, 0, 70], ["-", 0, 197, 0, 198, 39, 224, 225, 226, 0, 73], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 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, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 214, 205, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 214, 0, 131], ["+", 0, 213, 3, 4, 0, 28, 0, 214, 141, 22], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 8, 196, 0, 7, 15, 16, 12, 214, 205, 22], ["+", 8, 196, 0, 7, 15, 16, 12, 214, 0, 131], ["+", 8, 196, 0, 7, 15, 16, 12, 214, 141, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 204, 205, 22]]
| 8
| 456
| 21
|
using Complib.Generic;
using CompLib.Util;
using System;
using System.Collections.Generic;
public class Program {
long N;
long K;
long[] A;
List<long> plus, minus;
public void Solve() {
var sc = new Scanner();
N = sc.NextInt();
K = sc.NextLong();
A = sc.LongArray();
plus = new List<long>();
minus = new List<long>();
foreach (var i in A) {
if (i >= 0)
plus.Add(i);
else
minus.Add(i);
}
plus.Sort();
minus.Sort((a, b) => -a.CompareTo(b));
// にぶたん
// med以下がk個以下
long ok = long.MinValue / 2;
long ng = long.MaxValue / 2;
while (ng - ok > 1) {
long med = (ok + ng) / 2;
if (C(med)) {
ok = med;
} else {
ng = med;
}
}
Console.WriteLine(ok);
}
// n以下がk個以下か
bool C(long n) {
long cnt = 0;
if (n >= 0) {
cnt += (long)plus.Count * minus.Count;
for (int i = 0; i < plus.Count; i++) {
int ok = -1;
int ng = i;
while (ng - ok > 1) {
int med = (ok + ng) / 2;
if ((long)plus[i] * plus[med] < n) {
ok = med;
} else {
ng = med;
}
}
cnt += ng;
}
for (int i = 0; i < minus.Count; i++) {
int ok = -1;
int ng = i;
while (ng - ok > 1) {
int med = (ok + ng) / 2;
if ((long)minus[i] * minus[med] < n) {
ok = med;
} else {
ng = med;
}
}
cnt += ng;
}
} else {
for (int i = 0; i < plus.Count; i++) {
int ng = -1;
int ok = minus.Count;
while (ok - ng > 1) {
int med = (ok + ng) / 2;
if ((long)plus[i] * minus[med] < n) {
ok = med;
} else {
ng = med;
}
}
cnt += minus.Count - ok;
}
}
return cnt < K;
}
public static void Main(string[] args) => new Program().Solve();
}
namespace Complib.Generic {
using System.Collections.Generic;
class HashMap<K, V> : Dictionary<K, V> {
public V this[K key] {
set { base[key] = value; }
get {
V o;
return TryGetValue(key, out o) ? o : base[key] = default(V);
}
}
}
}
namespace CompLib.Util {
using System;
using System.Linq;
class Scanner {
private int _index;
private string[] _line;
const char separator = ' ';
public Scanner() {
_index = 0;
_line = new string[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 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();
}
}
|
using Complib.Generic;
using CompLib.Util;
using System;
using System.Collections.Generic;
public class Program {
long N;
long K;
long[] A;
List<long> plus, minus;
public void Solve() {
var sc = new Scanner();
N = sc.NextInt();
K = sc.NextLong();
A = sc.LongArray();
plus = new List<long>();
minus = new List<long>();
foreach (var i in A) {
if (i >= 0)
plus.Add(i);
else
minus.Add(i);
}
plus.Sort();
minus.Sort((a, b) => -a.CompareTo(b));
// にぶたん
// med以下がk個以下
long ng = long.MinValue / 2;
long ok = long.MaxValue / 2;
while (ok - ng > 1) {
long med = (ok + ng) / 2;
if (C(med)) {
ok = med;
} else {
ng = med;
}
}
Console.WriteLine(ok);
}
// n以下がk個以下か
bool C(long n) {
long cnt = 0;
if (n >= 0) {
cnt += (long)plus.Count * minus.Count;
for (int i = 0; i < plus.Count; i++) {
int ok = -1;
int ng = i;
while (ng - ok > 1) {
int med = (ok + ng) / 2;
if ((long)plus[i] * plus[med] <= n) {
ok = med;
} else {
ng = med;
}
}
cnt += ng;
}
for (int i = 0; i < minus.Count; i++) {
int ok = -1;
int ng = i;
while (ng - ok > 1) {
int med = (ok + ng) / 2;
if ((long)minus[i] * minus[med] <= n) {
ok = med;
} else {
ng = med;
}
}
cnt += ng;
}
} else {
for (int i = 0; i < plus.Count; i++) {
int ng = -1;
int ok = minus.Count;
while (ok - ng > 1) {
int med = (ok + ng) / 2;
if ((long)plus[i] * minus[med] <= n) {
ok = med;
} else {
ng = med;
}
}
cnt += minus.Count - ok;
}
}
return cnt >= K;
}
public static void Main(string[] args) => new Program().Solve();
}
namespace Complib.Generic {
using System.Collections.Generic;
class HashMap<K, V> : Dictionary<K, V> {
public V this[K key] {
set { base[key] = value; }
get {
V o;
return TryGetValue(key, out o) ? o : base[key] = default(V);
}
}
}
}
namespace CompLib.Util {
using System;
using System.Linq;
class Scanner {
private int _index;
private string[] _line;
const char separator = ' ';
public Scanner() {
_index = 0;
_line = new string[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 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();
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 8, 196, 0, 52, 15, 16, 31, 16, 31, 22], ["-", 8, 196, 0, 52, 15, 16, 31, 16, 17, 33], ["+", 8, 196, 0, 52, 15, 16, 31, 16, 17, 33], ["+", 8, 196, 0, 52, 15, 16, 31, 16, 12, 22], ["-", 0, 52, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 17, 19], ["-", 0, 195, 8, 196, 0, 37, 0, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 37, 0, 16, 17, 20]]
| 8
| 891
| 16
|
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;
using System.Text;
using static System.Math;
class MainClass {
public static void Main(string[] args) {
var n = LnStr();
var N = n.Length;
var price = new int[N];
for (int i = 0; i < N; i++) {
price[i] = int.Parse(n[i].ToString());
}
var dp = new int [N + 1][];
for (int i = 0; i < dp.Length; i++) {
dp[i] = new int[2];
}
for (int i = 0; i < N; i++) {
dp[i + 1][0] = Min(dp[i][0] + price[i], dp[i][1] + 10 - price[i]);
dp[i + 1][1] = Min(dp[i][0] + price[i] + 1, dp[i][1] + 10 - price[i] - 1);
}
print(Min(dp[N][0], dp[N][1]));
}
public static long PowLite(long n, long p, int mod = (int)1e9 + 7) {
long ans = 1;
long now = n;
for (; p > 0; p >>= 1) {
if ((p & 1) == 1) {
ans *= now;
ans %= mod;
}
now *= now;
now %= mod;
}
return ans;
}
public static void print(object obj) { Console.WriteLine(obj); }
public static long Gcd(long a, long b) {
if (a > b) {
var r = a % b;
if (r == 0)
return b;
else
return Gcd(b, r);
} else {
var r = b % a;
if (r == 0)
return a;
else
return Gcd(a, r);
}
}
public static int Gcd(int a, int b) {
if (a > b) {
var r = a % b;
if (r == 0)
return b;
else
return Gcd(b, r);
} else {
var r = b % a;
if (r == 0)
return a;
else
return Gcd(a, r);
}
}
public static int[] LnInts() {
var vs = Console.ReadLine().Trim().Split(
new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
var ins = new int[vs.Length];
for (int i = 0; i < vs.Length; i++)
ins[i] = int.Parse(vs[i]);
return ins;
}
public static int LnInt() {
var vs = Console.ReadLine().Trim();
return int.Parse(vs);
}
public static long[] LnLngs() {
var vs = Console.ReadLine().Trim().Split(
new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
var ins = new long[vs.Length];
for (int i = 0; i < vs.Length; i++)
ins[i] = long.Parse(vs[i]);
return ins;
}
public static long LnLng() {
var vs = Console.ReadLine().Trim();
return long.Parse(vs);
}
public static string[] LnStrs() {
var vs = Console.ReadLine().Trim().Split(
new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
return vs;
}
public static string LnStr() {
var vs = Console.ReadLine().Trim();
return vs;
}
public static List<T[]> AllPermutation<T>(params T[] array)
where T : IComparable {
var a = new List<T>(array).ToArray();
var res = new List<T[]>();
res.Add(new List<T>(a).ToArray());
var n = a.Length;
var next = true;
while (next) {
next = false;
int i;
for (i = n - 2; i >= 0; i--) {
if (a[i].CompareTo(a[i + 1]) < 0)
break;
}
if (i < 0)
break;
var j = n;
do {
j--;
} while (a[i].CompareTo(a[j]) > 0);
if (a[i].CompareTo(a[j]) < 0) {
var tmp = a[i];
a[i] = a[j];
a[j] = tmp;
Array.Reverse(a, i + 1, n - i - 1);
res.Add(new List<T>(a).ToArray());
next = true;
}
}
return res;
}
}
|
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;
using System.Text;
using static System.Math;
class MainClass {
public static void Main(string[] args) {
var n = LnStr();
var N = n.Length;
var price = new int[N];
for (int i = 0; i < N; i++) {
price[i] = int.Parse(n[i].ToString());
}
var dp = new int [N + 1][];
for (int i = 0; i < dp.Length; i++) {
dp[i] = new int[2];
}
dp[0][1] = 1;
for (int i = 0; i < N; i++) {
dp[i + 1][0] = Min(dp[i][0] + price[i], dp[i][1] + 10 - price[i]);
dp[i + 1][1] = Min(dp[i][0] + price[i] + 1, dp[i][1] + 10 - price[i] - 1);
}
print(dp[N][0]);
}
public static long PowLite(long n, long p, int mod = (int)1e9 + 7) {
long ans = 1;
long now = n;
for (; p > 0; p >>= 1) {
if ((p & 1) == 1) {
ans *= now;
ans %= mod;
}
now *= now;
now %= mod;
}
return ans;
}
public static void print(object obj) { Console.WriteLine(obj); }
public static long Gcd(long a, long b) {
if (a > b) {
var r = a % b;
if (r == 0)
return b;
else
return Gcd(b, r);
} else {
var r = b % a;
if (r == 0)
return a;
else
return Gcd(a, r);
}
}
public static int Gcd(int a, int b) {
if (a > b) {
var r = a % b;
if (r == 0)
return b;
else
return Gcd(b, r);
} else {
var r = b % a;
if (r == 0)
return a;
else
return Gcd(a, r);
}
}
public static int[] LnInts() {
var vs = Console.ReadLine().Trim().Split(
new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
var ins = new int[vs.Length];
for (int i = 0; i < vs.Length; i++)
ins[i] = int.Parse(vs[i]);
return ins;
}
public static int LnInt() {
var vs = Console.ReadLine().Trim();
return int.Parse(vs);
}
public static long[] LnLngs() {
var vs = Console.ReadLine().Trim().Split(
new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
var ins = new long[vs.Length];
for (int i = 0; i < vs.Length; i++)
ins[i] = long.Parse(vs[i]);
return ins;
}
public static long LnLng() {
var vs = Console.ReadLine().Trim();
return long.Parse(vs);
}
public static string[] LnStrs() {
var vs = Console.ReadLine().Trim().Split(
new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
return vs;
}
public static string LnStr() {
var vs = Console.ReadLine().Trim();
return vs;
}
public static List<T[]> AllPermutation<T>(params T[] array)
where T : IComparable {
var a = new List<T>(array).ToArray();
var res = new List<T[]>();
res.Add(new List<T>(a).ToArray());
var n = a.Length;
var next = true;
while (next) {
next = false;
int i;
for (i = n - 2; i >= 0; i--) {
if (a[i].CompareTo(a[i + 1]) < 0)
break;
}
if (i < 0)
break;
var j = n;
do {
j--;
} while (a[i].CompareTo(a[j]) > 0);
if (a[i].CompareTo(a[j]) < 0) {
var tmp = a[i];
a[i] = a[j];
a[j] = tmp;
Array.Reverse(a, i + 1, n - i - 1);
res.Add(new List<T>(a).ToArray());
next = true;
}
}
return res;
}
}
|
[["+", 0, 1, 0, 11, 31, 204, 205, 204, 205, 22], ["+", 0, 11, 31, 204, 205, 204, 206, 207, 0, 70], ["+", 31, 204, 205, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 11, 31, 204, 205, 204, 206, 207, 0, 73], ["+", 0, 1, 0, 11, 31, 204, 206, 207, 0, 70], ["+", 0, 11, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 1, 0, 11, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 195, 8, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["-", 0, 213, 3, 4, 0, 28, 0, 213, 63, 22], ["-", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["-", 3, 4, 0, 28, 0, 204, 206, 207, 0, 73], ["-", 3, 4, 0, 28, 0, 213, 3, 4, 0, 21], ["-", 3, 4, 0, 28, 0, 204, 205, 204, 205, 22], ["-", 0, 28, 0, 204, 205, 204, 206, 207, 0, 70], ["-", 0, 204, 205, 204, 206, 207, 0, 28, 0, 22], ["-", 0, 28, 0, 204, 205, 204, 206, 207, 0, 73], ["-", 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, 213, 3, 4, 0, 25]]
| 8
| 1,063
| 21
|
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>
/// ABC155 E
/// </summary>
public class QuestionF : AtCoderQuestionBase {
public override IEnumerable<object> Solve(TextReader inputStream) {
var n = inputStream.ReadLine().ToCharArray();
var billCount = 0;
var kuriagari = 0;
for (int i = n.Length - 1; i >= 0; i--) {
var digit = (n[i] - '0') + kuriagari;
if (digit >= 6) {
kuriagari = 1;
billCount += 10 - digit;
} else if (digit == 5) {
var nextDigit = n[i - 1] - '0';
if (i > 0 && nextDigit >= 5) {
kuriagari = 1;
billCount += 10 - digit;
} else {
kuriagari = 0;
billCount += digit;
}
} else {
kuriagari = 0;
billCount += digit;
}
}
if (kuriagari >= 1) {
billCount += kuriagari;
}
yield return billCount;
}
}
}
namespace Yorukatsu025 {
class Program {
static void Main(string[] args) {
IAtCoderQuestion question = new QuestionF(); // 問題に合わせて書き換え
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>
/// ABC155 E
/// </summary>
public class QuestionF : AtCoderQuestionBase {
public override IEnumerable<object> Solve(TextReader inputStream) {
var n = inputStream.ReadLine().ToCharArray();
var billCount = 0;
var kuriagari = 0;
for (int i = n.Length - 1; i >= 0; i--) {
var digit = (n[i] - '0') + kuriagari;
if (digit >= 6) {
kuriagari = 1;
billCount += 10 - digit;
} else if (digit == 5) {
if (i > 0 && n[i - 1] - '0' >= 5) {
kuriagari = 1;
billCount += 10 - digit;
} else {
kuriagari = 0;
billCount += digit;
}
} else {
kuriagari = 0;
billCount += digit;
}
}
if (kuriagari >= 1) {
billCount += kuriagari;
}
yield return billCount;
}
}
}
namespace Yorukatsu025 {
class Program {
static void Main(string[] args) {
IAtCoderQuestion question = new QuestionF(); // 問題に合わせて書き換え
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
|
[["-", 64, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 64, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 57, 75, 57, 64, 196, 0, 57, 0, 121], ["+", 0, 57, 75, 57, 64, 196, 0, 57, 0, 24], ["+", 64, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 64, 196, 0, 57, 15, 16, 31, 16, 17, 47], ["+", 64, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 75, 57, 64, 196, 0, 57, 15, 16, 17, 98], ["-", 0, 57, 75, 57, 64, 196, 0, 197, 0, 35], ["-", 0, 57, 75, 57, 64, 196, 0, 57, 0, 121], ["-", 0, 57, 75, 57, 64, 196, 0, 57, 0, 24], ["-", 64, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["-", 64, 196, 0, 57, 15, 16, 31, 16, 17, 47], ["-", 64, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["-", 75, 57, 64, 196, 0, 57, 15, 16, 17, 98], ["-", 64, 196, 0, 57, 15, 16, 12, 16, 31, 22]]
| 8
| 617
| 17
|
using System;
public class a {
static void Main() {
var s = Console.ReadLine().Split();
var t = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
var u = Console.ReadLine();
if (s[0] == u[0].ToString()) {
t[0] -= 1;
} else {
t[1] -= 1;
}
Console.WriteLine("{0} {1}", t[0], t[1]);
}
}
|
using System;
public class a {
static void Main() {
var s = Console.ReadLine().Split();
var t = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
var u = Console.ReadLine();
if (s[0] == u) {
t[0] -= 1;
} else {
t[1] -= 1;
}
Console.WriteLine("{0} {1}", t[0], t[1]);
}
}
|
[["-", 12, 213, 63, 214, 205, 204, 206, 207, 0, 70], ["-", 63, 214, 205, 204, 206, 207, 0, 28, 0, 203], ["-", 12, 213, 63, 214, 205, 204, 206, 207, 0, 73], ["-", 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], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25]]
| 8
| 113
| 7
|
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atcoder {
public class Program {
static void Main(string[] args) {
var r1 = ReadSplit();
var r2 = ReadSplit();
var S = r1[0];
var T = r1[1];
var A = r2[0].ToInt();
var B = r2[1].ToInt();
var U = Read();
if (S == U) {
Write(A - 1);
} else {
Write(B - 1);
}
}
public static string Read() { return Console.ReadLine(); }
public static string[] ReadSplit() { return Console.ReadLine().Split(' '); }
public static void Write(object str) { Console.WriteLine(str); }
}
}
public static class Extentions {
public static int ToInt(this object obj) { return int.Parse(obj.ToString()); }
public static decimal ToDecimal(this object obj) {
return decimal.Parse(obj.ToString());
}
public static double ToDouble(this object obj) {
return double.Parse(obj.ToString());
}
}
|
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atcoder {
public class Program {
static void Main(string[] args) {
var r1 = ReadSplit();
var r2 = ReadSplit();
var S = r1[0];
var T = r1[1];
var A = r2[0].ToInt();
var B = r2[1].ToInt();
var U = Read();
if (S == U) {
Write((A - 1).ToString() + " " + B.ToString());
} else {
Write(A.ToString() + " " + (B - 1).ToString());
}
Read();
}
public static string Read() { return Console.ReadLine(); }
public static string[] ReadSplit() { return Console.ReadLine().Split(' '); }
public static void Write(object str) { Console.WriteLine(str); }
}
}
public static class Extentions {
public static int ToInt(this object obj) { return int.Parse(obj.ToString()); }
public static decimal ToDecimal(this object obj) {
return decimal.Parse(obj.ToString());
}
public static double ToDouble(this object obj) {
return double.Parse(obj.ToString());
}
}
|
[["+", 31, 16, 31, 213, 63, 214, 205, 23, 0, 24], ["+", 31, 16, 31, 213, 63, 214, 205, 23, 0, 25], ["+", 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, 25], ["+", 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, 28, 0, 16, 12, 213, 63, 214, 205, 22], ["+", 0, 28, 0, 16, 12, 213, 63, 214, 0, 131], ["+", 0, 28, 0, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 28, 0, 16, 12, 213, 3, 4, 0, 24], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 75, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 16, 31, 16, 31, 213, 63, 214, 205, 22], ["+", 0, 28, 0, 16, 12, 213, 3, 4, 0, 25], ["+", 75, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 1, 0, 213, 63, 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
| 269
| 36
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace A___Remaining_Balls {
class Program {
static void Main(string[] args) {
string[] input1 = Console.ReadLine().Split(' ');
string s = input1[0];
string t = input1[1];
int[] input2 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int a = input2[0];
int b = input2[0];
string u = Console.ReadLine();
if (u == s) {
a--;
} else {
b--;
}
Console.WriteLine(a + " " + b);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace A___Remaining_Balls {
class Program {
static void Main(string[] args) {
string[] input1 = Console.ReadLine().Split(' ');
string s = input1[0];
string t = input1[1];
int[] input2 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int a = input2[0];
int b = input2[1];
string u = Console.ReadLine();
if (u == s) {
a--;
} else {
b--;
}
Console.WriteLine(a + " " + b);
Console.ReadKey();
}
}
}
|
[["-", 0, 212, 0, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 212, 0, 204, 206, 207, 0, 28, 0, 203], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24]]
| 8
| 159
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CF {
class Program {
static void Main(string[] args) {
// var c = Console.ReadLine().Split().Select(int.Parse).ToList();
var n = int.Parse(Console.ReadLine());
var s = Console.ReadLine();
var br = 0;
for (int i = 0; i < n - 2; i++) {
if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
br++;
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CF {
class Program {
static void Main(string[] args) {
// var c = Console.ReadLine().Split().Select(int.Parse).ToList();
var n = int.Parse(Console.ReadLine());
var s = Console.ReadLine();
var br = 0;
for (int i = 0; i < n - 2; i++) {
if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
br++;
}
Console.WriteLine(br);
}
}
}
|
[["+", 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]]
| 8
| 122
| 7
|
using System;
using System.Collections.Generic;
using System.Linq;
// namespaceの値をコンテスト名にして運用
namespace ABC150B {
class Input {
/// <summary>
/// 1行の入力を取得する
/// </summary>
/// <returns>文字列</returns>
public string String() { return Console.ReadLine(); }
/// <summary>
/// 複数行の入力を取得
/// </summary>
/// <returns>文字列の配列</returns>
public string[] ArrayString(int rowNumber) {
string[] s = new string[rowNumber];
for (int i = 0; i < rowNumber; i++) {
s[i] = String();
}
return s;
}
/// <summary>
/// 1行の入力を取得
/// </summary>
/// <returns>int型の値</returns>
public int Int() { return int.Parse(String()); }
/// <summary>
/// 1行の入力を取得
/// </summary>
/// <returns>int型の配列</returns>
public int[] ArrayInt() { return Split().Select(int.Parse).ToArray(); }
/// <summary>
/// 複数行の入力を取得
/// </summary>
/// <param name="rowNumber">行数</param>
/// <returns>int型の配列</returns>
public int[] ArrayInt(int rowNumber) {
int[] ints = new int[rowNumber];
for (int i = 0; i < rowNumber; i++) {
ints[i] = Int();
}
return ints;
}
/// <summary>
/// 1行の入力を取得
/// </summary>
/// <returns>long型の値</returns>
public long Long() { return long.Parse(String()); }
/// <summary>
/// 2つの整数が1行に書かれている入力を、2つのlongで受け取る
/// </summary>
/// <param name="A"></param>
/// <param name="B"></param>
public void Longs(ref long A, ref long B) {
var longs = ArrayLong();
A = longs[0];
B = longs[1];
}
/// <summary>
/// 3つの整数が1行に書かれている入力を、3つのlongで受け取る
/// </summary>
/// <param name="A"></param>
/// <param name="B"></param>
/// <param name="C"></param>
public void Longs(ref long A, ref long B, ref long C) {
var longs = ArrayLong();
A = longs[0];
B = longs[1];
C = longs[2];
}
/// <summary>
/// 4つの整数が1行に書かれている入力を、4つのlongで受け取る
/// </summary>
/// <param name="A"></param>
/// <param name="B"></param>
/// <param name="C"></param>
/// <param name="D"></param>
public void Longs(ref long A, ref long B, ref long C, ref long D) {
var longs = ArrayLong();
A = longs[0];
B = longs[1];
C = longs[2];
D = longs[3];
}
/// <summary>
/// 2つの整数が複数行に書かれている入力を、2つのlong[]で受け取る
/// </summary>
/// <param name="rowNumber"></param>
/// <param name="A"></param>
/// <param name="B"></param>
public void LongsArray(long rowNumber, ref long[] A, ref long[] B) {
A = new long[rowNumber];
B = new long[rowNumber];
for (int i = 0; i < rowNumber; i++) {
var l = ArrayLong();
A[i] = l[0];
B[i] = l[1];
}
}
/// <summary>
/// 3つの整数が複数行に書かれている入力を、2つのlong[]で受け取る
/// </summary>
/// <param name="rowNumber"></param>
/// <param name="A"></param>
/// <param name="B"></param>
/// <param name="C"></param>
public void LongsArray(long rowNumber, ref long[] A, ref long[] B,
ref long[] C) {
A = new long[rowNumber];
B = new long[rowNumber];
C = new long[rowNumber];
for (int i = 0; i < rowNumber; i++) {
var l = ArrayLong();
A[i] = l[0];
B[i] = l[1];
C[i] = l[2];
}
}
/// <summary>
/// 1行の入力を取得
/// </summary>
/// <returns>long型の配列</returns>
public long[] ArrayLong() { return Split().Select(long.Parse).ToArray(); }
public long[] ArrayLong(int rowNumber) {
long[] longs = new long[rowNumber];
for (int i = 0; i < rowNumber; i++) {
longs[i] = Long();
}
return longs;
}
/// <summary>
/// 1行の入力を取得
/// </summary>
/// <returns>double型の値</returns>
public double Double() { return double.Parse(String()); }
/// <summary>
/// 1行の入力を取得
/// </summary>
/// <returns>double型の配列</returns>
public double[] ArrayDouble() {
return Split().Select(double.Parse).ToArray();
}
private IEnumerable<string> Split() { return String().Split(' '); }
}
class Program {
static void Main(string[] args) {
Solver solver = new Solver();
solver.Solve();
}
}
class Solver {
public Solver() {
Input input = new Input();
N = input.Long();
S = input.String();
}
private long N;
private string S;
public void Solve() {
int ans = 0;
char cur = '-';
for (int i = 0; i < N; i++) {
if (cur == '-' && S[i] == 'A') {
cur = 'A';
continue;
}
if (cur == 'A' && S[i] == 'B') {
cur = 'B';
continue;
}
if (cur == 'B' && S[i] == 'C') {
ans++;
}
cur = '-';
}
Console.WriteLine(ans);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
// namespaceの値をコンテスト名にして運用
namespace ABC150B {
class Input {
/// <summary>
/// 1行の入力を取得する
/// </summary>
/// <returns>文字列</returns>
public string String() { return Console.ReadLine(); }
/// <summary>
/// 複数行の入力を取得
/// </summary>
/// <returns>文字列の配列</returns>
public string[] ArrayString(int rowNumber) {
string[] s = new string[rowNumber];
for (int i = 0; i < rowNumber; i++) {
s[i] = String();
}
return s;
}
/// <summary>
/// 1行の入力を取得
/// </summary>
/// <returns>int型の値</returns>
public int Int() { return int.Parse(String()); }
/// <summary>
/// 1行の入力を取得
/// </summary>
/// <returns>int型の配列</returns>
public int[] ArrayInt() { return Split().Select(int.Parse).ToArray(); }
/// <summary>
/// 複数行の入力を取得
/// </summary>
/// <param name="rowNumber">行数</param>
/// <returns>int型の配列</returns>
public int[] ArrayInt(int rowNumber) {
int[] ints = new int[rowNumber];
for (int i = 0; i < rowNumber; i++) {
ints[i] = Int();
}
return ints;
}
/// <summary>
/// 1行の入力を取得
/// </summary>
/// <returns>long型の値</returns>
public long Long() { return long.Parse(String()); }
/// <summary>
/// 2つの整数が1行に書かれている入力を、2つのlongで受け取る
/// </summary>
/// <param name="A"></param>
/// <param name="B"></param>
public void Longs(ref long A, ref long B) {
var longs = ArrayLong();
A = longs[0];
B = longs[1];
}
/// <summary>
/// 3つの整数が1行に書かれている入力を、3つのlongで受け取る
/// </summary>
/// <param name="A"></param>
/// <param name="B"></param>
/// <param name="C"></param>
public void Longs(ref long A, ref long B, ref long C) {
var longs = ArrayLong();
A = longs[0];
B = longs[1];
C = longs[2];
}
/// <summary>
/// 4つの整数が1行に書かれている入力を、4つのlongで受け取る
/// </summary>
/// <param name="A"></param>
/// <param name="B"></param>
/// <param name="C"></param>
/// <param name="D"></param>
public void Longs(ref long A, ref long B, ref long C, ref long D) {
var longs = ArrayLong();
A = longs[0];
B = longs[1];
C = longs[2];
D = longs[3];
}
/// <summary>
/// 2つの整数が複数行に書かれている入力を、2つのlong[]で受け取る
/// </summary>
/// <param name="rowNumber"></param>
/// <param name="A"></param>
/// <param name="B"></param>
public void LongsArray(long rowNumber, ref long[] A, ref long[] B) {
A = new long[rowNumber];
B = new long[rowNumber];
for (int i = 0; i < rowNumber; i++) {
var l = ArrayLong();
A[i] = l[0];
B[i] = l[1];
}
}
/// <summary>
/// 3つの整数が複数行に書かれている入力を、2つのlong[]で受け取る
/// </summary>
/// <param name="rowNumber"></param>
/// <param name="A"></param>
/// <param name="B"></param>
/// <param name="C"></param>
public void LongsArray(long rowNumber, ref long[] A, ref long[] B,
ref long[] C) {
A = new long[rowNumber];
B = new long[rowNumber];
C = new long[rowNumber];
for (int i = 0; i < rowNumber; i++) {
var l = ArrayLong();
A[i] = l[0];
B[i] = l[1];
C[i] = l[2];
}
}
/// <summary>
/// 1行の入力を取得
/// </summary>
/// <returns>long型の配列</returns>
public long[] ArrayLong() { return Split().Select(long.Parse).ToArray(); }
public long[] ArrayLong(int rowNumber) {
long[] longs = new long[rowNumber];
for (int i = 0; i < rowNumber; i++) {
longs[i] = Long();
}
return longs;
}
/// <summary>
/// 1行の入力を取得
/// </summary>
/// <returns>double型の値</returns>
public double Double() { return double.Parse(String()); }
/// <summary>
/// 1行の入力を取得
/// </summary>
/// <returns>double型の配列</returns>
public double[] ArrayDouble() {
return Split().Select(double.Parse).ToArray();
}
private IEnumerable<string> Split() { return String().Split(' '); }
}
class Program {
static void Main(string[] args) {
Solver solver = new Solver();
solver.Solve();
}
}
class Solver {
public Solver() {
Input input = new Input();
N = input.Long();
S = input.String();
}
private long N;
private string S;
public void Solve() {
int ans = 0;
char cur = '-';
for (int i = 0; i < N; i++) {
if (cur == 'B' && S[i] == 'C') {
ans++;
}
if (cur == 'A' && S[i] == 'B') {
cur = 'B';
continue;
}
if (S[i] == 'A') {
cur = 'A';
continue;
}
cur = '-';
}
Console.WriteLine(ans);
}
}
}
|
[["-", 0, 57, 15, 16, 31, 16, 12, 252, 0, 253], ["+", 0, 57, 15, 16, 31, 16, 12, 252, 0, 253], ["-", 0, 57, 15, 16, 12, 16, 12, 252, 0, 253], ["+", 0, 57, 15, 16, 12, 16, 12, 252, 0, 253], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 64, 196, 0, 1, 0, 11, 12, 252, 0, 104], ["-", 64, 196, 0, 1, 0, 11, 12, 252, 0, 253], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 8, 196, 0, 57, 64, 196, 0, 116, 0, 117], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 29], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["-", 0, 57, 15, 16, 31, 16, 12, 252, 0, 104], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 8, 196, 0, 57, 15, 16, 12, 252, 0, 253], ["-", 0, 57, 64, 196, 0, 1, 0, 223, 0, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 223, 0, 29], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 64, 196, 0, 1, 0, 11, 12, 252, 0, 104], ["+", 64, 196, 0, 1, 0, 11, 12, 252, 0, 253], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 116, 0, 117]]
| 8
| 921
| 30
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.