diff --git a/atcoder/ABC/WA/abc229_d/.idea/.gitignore b/atcoder/ABC/WA/abc229_d/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/atcoder/ABC/WA/abc229_d/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/atcoder/ABC/WA/abc229_d/.idea/libraries/KotlinJavaRuntime.xml b/atcoder/ABC/WA/abc229_d/.idea/libraries/KotlinJavaRuntime.xml new file mode 100644 index 0000000..9fbfb0d --- /dev/null +++ b/atcoder/ABC/WA/abc229_d/.idea/libraries/KotlinJavaRuntime.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/atcoder/ABC/WA/abc229_d/.idea/misc.xml b/atcoder/ABC/WA/abc229_d/.idea/misc.xml new file mode 100644 index 0000000..07115cd --- /dev/null +++ b/atcoder/ABC/WA/abc229_d/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/atcoder/ABC/WA/abc229_d/.idea/modules.xml b/atcoder/ABC/WA/abc229_d/.idea/modules.xml new file mode 100644 index 0000000..618b8a8 --- /dev/null +++ b/atcoder/ABC/WA/abc229_d/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/atcoder/ABC/WA/abc229_d/.idea/vcs.xml b/atcoder/ABC/WA/abc229_d/.idea/vcs.xml new file mode 100644 index 0000000..c2365ab --- /dev/null +++ b/atcoder/ABC/WA/abc229_d/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/atcoder/ABC/WA/abc229_d/abc229_d.iml b/atcoder/ABC/WA/abc229_d/abc229_d.iml new file mode 100644 index 0000000..245d342 --- /dev/null +++ b/atcoder/ABC/WA/abc229_d/abc229_d.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/atcoder/ABC/WA/abc229_d/out/production/abc229_d/META-INF/abc229_d.kotlin_module b/atcoder/ABC/WA/abc229_d/out/production/abc229_d/META-INF/abc229_d.kotlin_module new file mode 100644 index 0000000..3be8cd0 Binary files /dev/null and b/atcoder/ABC/WA/abc229_d/out/production/abc229_d/META-INF/abc229_d.kotlin_module differ diff --git a/atcoder/ABC/WA/abc229_d/src/main.kt b/atcoder/ABC/WA/abc229_d/src/main.kt new file mode 100644 index 0000000..dde287d --- /dev/null +++ b/atcoder/ABC/WA/abc229_d/src/main.kt @@ -0,0 +1,114 @@ +import java.io.PrintWriter +import kotlin.math.max +import kotlin.math.min + +fun next() = readLine()!! +fun nextInt() = next().toInt() + +@JvmField val _writer = PrintWriter(System.out, false) +fun main() { _writer.solve(); _writer.flush() } +fun PrintWriter.solve() { + val s = next() + val k = nextInt() + + val ml = mutableListOf() + for (i in s.indices) { + if (s[i] == '.') { + ml.add(i) + } + } + + val num = min(ml.size, k) + + val l = ml.combinationWithoutRepetition(num) + + var ans = 0 + for (i in l) { + var tmpS = s.toCharArray() + for (j in i) { + tmpS[j] = 'X' + } + + var isFound = false + var cnt = 0 + for (i in tmpS.indices) { + if (tmpS[i] == 'X') { + isFound = true + cnt++ + } + else if (isFound) { + ans = max(cnt, ans) + isFound = false + cnt = 0 + } + } + ans = max(cnt, ans) + } + + println(ans) +} + + +fun next_combination() : Boolean { + val l = listOf(0,1,2) + val l2 = l.iterator() + l2. +} + + +//template bool next_combination(const T first, const T last, int k) { +// const T subset = first + k; +// // empty container | k = 0 | k == n +// if (first == last || first == subset || last == subset) { +// return false; +// } +// T src = subset; +// while (first != src) { +// src--; +// if (*src < *(last - 1)) { +// T dest = subset; +// while (*src >= *dest) { +// dest++; +// } +// iter_swap(src, dest); +// rotate(src + 1, dest + 1, last); +// rotate(subset, subset + (last - dest) - 1, last); +// return true; +// } +// } +// // restore +// rotate(first, subset, last); +// return false; +//} + + + +private fun pcSequenceFactory( + selecteds: List = emptyList(), + filter: (options: List, i: Int) -> List +): (options: List, k: Int) -> Sequence> = + { options, k -> + sequence { + if (k == 0) { + yield(selecteds) + return@sequence + } + + options.forEachIndexed { i, option -> + pcSequenceFactory(selecteds + option, filter).let { + it(filter(options, i), k - 1) + }.forEach { + yield(it) + } + } + } + } + +/** 重複なしの組み合わせ */ +fun List.combinationWithoutRepetition(k: Int): Sequence> { + require(k in 0..size) { "引数 k は 0 以上かつ $size 以下でなければなりません。k: $k" } + + return pcSequenceFactory { options, i -> + options.drop(i + 1) + }(this, k) +} diff --git a/atcoder/ABC/abc229_a/.idea/.gitignore b/atcoder/ABC/abc229_a/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/atcoder/ABC/abc229_a/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/atcoder/ABC/abc229_a/.idea/libraries/KotlinJavaRuntime.xml b/atcoder/ABC/abc229_a/.idea/libraries/KotlinJavaRuntime.xml new file mode 100644 index 0000000..9fbfb0d --- /dev/null +++ b/atcoder/ABC/abc229_a/.idea/libraries/KotlinJavaRuntime.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/atcoder/ABC/abc229_a/.idea/misc.xml b/atcoder/ABC/abc229_a/.idea/misc.xml new file mode 100644 index 0000000..07115cd --- /dev/null +++ b/atcoder/ABC/abc229_a/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/atcoder/ABC/abc229_a/.idea/modules.xml b/atcoder/ABC/abc229_a/.idea/modules.xml new file mode 100644 index 0000000..390ff63 --- /dev/null +++ b/atcoder/ABC/abc229_a/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/atcoder/ABC/abc229_a/.idea/vcs.xml b/atcoder/ABC/abc229_a/.idea/vcs.xml new file mode 100644 index 0000000..c2365ab --- /dev/null +++ b/atcoder/ABC/abc229_a/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/atcoder/ABC/abc229_a/abc229_a.iml b/atcoder/ABC/abc229_a/abc229_a.iml new file mode 100644 index 0000000..245d342 --- /dev/null +++ b/atcoder/ABC/abc229_a/abc229_a.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/atcoder/ABC/abc229_a/src/main.kt b/atcoder/ABC/abc229_a/src/main.kt new file mode 100644 index 0000000..28653c6 --- /dev/null +++ b/atcoder/ABC/abc229_a/src/main.kt @@ -0,0 +1,16 @@ +import java.io.PrintWriter +fun next() = readLine()!! + +@JvmField val _writer = PrintWriter(System.out, false) +fun main() { _writer.solve(); _writer.flush() } +fun PrintWriter.solve() { + val s1 = next() + val s2 = next() + + var ans = true + if ((s1 == "#." && s2 == ".#") || (s1 == ".#" && s2 == "#.")) { + ans = false + } + + println(if (ans) "Yes" else "No") +} \ No newline at end of file diff --git a/atcoder/ABC/abc229_b/.idea/.gitignore b/atcoder/ABC/abc229_b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/atcoder/ABC/abc229_b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/atcoder/ABC/abc229_b/.idea/libraries/KotlinJavaRuntime.xml b/atcoder/ABC/abc229_b/.idea/libraries/KotlinJavaRuntime.xml new file mode 100644 index 0000000..9fbfb0d --- /dev/null +++ b/atcoder/ABC/abc229_b/.idea/libraries/KotlinJavaRuntime.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/atcoder/ABC/abc229_b/.idea/misc.xml b/atcoder/ABC/abc229_b/.idea/misc.xml new file mode 100644 index 0000000..07115cd --- /dev/null +++ b/atcoder/ABC/abc229_b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/atcoder/ABC/abc229_b/.idea/modules.xml b/atcoder/ABC/abc229_b/.idea/modules.xml new file mode 100644 index 0000000..a39068a --- /dev/null +++ b/atcoder/ABC/abc229_b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/atcoder/ABC/abc229_b/.idea/vcs.xml b/atcoder/ABC/abc229_b/.idea/vcs.xml new file mode 100644 index 0000000..c2365ab --- /dev/null +++ b/atcoder/ABC/abc229_b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/atcoder/ABC/abc229_b/abc229_b.iml b/atcoder/ABC/abc229_b/abc229_b.iml new file mode 100644 index 0000000..245d342 --- /dev/null +++ b/atcoder/ABC/abc229_b/abc229_b.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/atcoder/ABC/abc229_b/out/production/abc229_b/META-INF/abc229_b.kotlin_module b/atcoder/ABC/abc229_b/out/production/abc229_b/META-INF/abc229_b.kotlin_module new file mode 100644 index 0000000..3be8cd0 Binary files /dev/null and b/atcoder/ABC/abc229_b/out/production/abc229_b/META-INF/abc229_b.kotlin_module differ diff --git a/atcoder/ABC/abc229_b/src/main.kt b/atcoder/ABC/abc229_b/src/main.kt new file mode 100644 index 0000000..7d2ef36 --- /dev/null +++ b/atcoder/ABC/abc229_b/src/main.kt @@ -0,0 +1,25 @@ +import java.io.PrintWriter +fun next() = readLine()!! +fun nextLongList() = next().split(" ").map{ it.toLong() } + +@JvmField val _writer = PrintWriter(System.out, false) +fun main() { _writer.solve(); _writer.flush() } +fun PrintWriter.solve() { + var (a, b) = nextLongList() + + var ans = true + while(a != 0L && b != 0L) { + val tmpA = a % 10L + val tmpB = b % 10L + + if (tmpA + tmpB >= 10L) { + ans = false + break + } + + a /= 10L + b /= 10L + } + + println(if (ans) "Easy" else "Hard") +} \ No newline at end of file diff --git a/atcoder/ABC/abc229_c/.idea/.gitignore b/atcoder/ABC/abc229_c/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/atcoder/ABC/abc229_c/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/atcoder/ABC/abc229_c/.idea/libraries/KotlinJavaRuntime.xml b/atcoder/ABC/abc229_c/.idea/libraries/KotlinJavaRuntime.xml new file mode 100644 index 0000000..9fbfb0d --- /dev/null +++ b/atcoder/ABC/abc229_c/.idea/libraries/KotlinJavaRuntime.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/atcoder/ABC/abc229_c/.idea/misc.xml b/atcoder/ABC/abc229_c/.idea/misc.xml new file mode 100644 index 0000000..07115cd --- /dev/null +++ b/atcoder/ABC/abc229_c/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/atcoder/ABC/abc229_c/.idea/modules.xml b/atcoder/ABC/abc229_c/.idea/modules.xml new file mode 100644 index 0000000..3a6fc57 --- /dev/null +++ b/atcoder/ABC/abc229_c/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/atcoder/ABC/abc229_c/.idea/vcs.xml b/atcoder/ABC/abc229_c/.idea/vcs.xml new file mode 100644 index 0000000..c2365ab --- /dev/null +++ b/atcoder/ABC/abc229_c/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/atcoder/ABC/abc229_c/abc229_c.iml b/atcoder/ABC/abc229_c/abc229_c.iml new file mode 100644 index 0000000..245d342 --- /dev/null +++ b/atcoder/ABC/abc229_c/abc229_c.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/atcoder/ABC/abc229_c/out/production/abc229_c/META-INF/abc229_c.kotlin_module b/atcoder/ABC/abc229_c/out/production/abc229_c/META-INF/abc229_c.kotlin_module new file mode 100644 index 0000000..3be8cd0 Binary files /dev/null and b/atcoder/ABC/abc229_c/out/production/abc229_c/META-INF/abc229_c.kotlin_module differ diff --git a/atcoder/ABC/abc229_c/src/main.kt b/atcoder/ABC/abc229_c/src/main.kt new file mode 100644 index 0000000..1f54218 --- /dev/null +++ b/atcoder/ABC/abc229_c/src/main.kt @@ -0,0 +1,33 @@ +import java.io.PrintWriter +import java.util.PriorityQueue +import kotlin.math.min + +fun next() = readLine()!! +fun nextLongList() = next().split(" ").map{ it.toLong() } + +@JvmField val _writer = PrintWriter(System.out, false) +@kotlin.ExperimentalStdlibApi +fun main() { _writer.solve(); _writer.flush() } +@kotlin.ExperimentalStdlibApi +fun PrintWriter.solve() { + val (n, w) = nextLongList() + + val que = PriorityQueue>() {i1, i2 -> + return@PriorityQueue (i2.first - i1.first).toInt() + } + repeat(n.toInt()) { + val (a, b) = nextLongList() + que.add(a to b) + } + + var g = 0L + var cnt = 0L + while (g < w && que.isNotEmpty()) { + val tmp = que.poll() + val m = min(tmp.second, w - g) + cnt += (tmp.first * m) + g += m + } + + println(cnt) +} \ No newline at end of file diff --git a/atcoder/ABC/abc230_b/.idea/workspace.xml b/atcoder/ABC/abc230_b/.idea/workspace.xml new file mode 100644 index 0000000..c48cc46 --- /dev/null +++ b/atcoder/ABC/abc230_b/.idea/workspace.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1646614259510 + + + + \ No newline at end of file