-
Notifications
You must be signed in to change notification settings - Fork 0
/
6a.kt
30 lines (28 loc) · 854 Bytes
/
6a.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import kotlin.io.path.Path
import kotlin.io.path.readLines
import kotlin.math.*
fun <T> debug(container: Iterable<T>) {
container.forEach { element ->
print("$element ")
}
println()
}
fun main() {
val fileName = "6.in"
val input = Path(fileName).readLines()
val times = input[0].split(": ")[1].split(' ').filter { it.isNotBlank() }.map { it.toLong() }.toMutableList()
val distances = input[1].split(": ")[1].split(' ').filter{ it.isNotBlank() }.map { it.toLong() }.toMutableList()
var result = 1
for (i in 0..times.size-1) {
val time = times[i]
val dist = distances[i]
var options = 0
for (t in 0..time) {
val rem_time = time - t
val total_dist = 1L * rem_time * t
if (total_dist >= dist) options++
}
result *= options
}
println(result)
}