結果
| 問題 |
No.30 たこやき工場
|
| コンテスト | |
| ユーザー |
バカらっく
|
| 提出日時 | 2019-09-05 16:08:40 |
| 言語 | Kotlin (2.1.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 978 bytes |
| コンパイル時間 | 12,869 ms |
| コンパイル使用メモリ | 455,704 KB |
| 実行使用メモリ | 98,748 KB |
| 最終ジャッジ日時 | 2024-06-11 18:35:36 |
| 合計ジャッジ時間 | 23,028 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 TLE * 1 -- * 6 |
コンパイルメッセージ
Main.kt:3:10: warning: parameter 'arr' is never used
fun main(arr:Array<String>) {
^
ソースコード
import java.util.*
fun main(arr:Array<String>) {
val zairyoCount = readLine()!!.toInt()
val seizouCount = readLine()!!.toInt()
val need = Array<Int>(zairyoCount + 1, {0})
val seizou = mutableMapOf<Int, MutableMap<Int, Int>>()
(1..seizouCount).forEach {
val (zairyo, value, dekiru) = readLine()!!.split(" ").map { it.toInt() }
if(!seizou.containsKey(dekiru)) {
seizou[dekiru] = mutableMapOf()
}
seizou[dekiru]!![zairyo] = value
}
val queue = LinkedList<Task>()
queue.push(Task(zairyoCount, 1))
while (queue.isNotEmpty()) {
val task = queue.pop()
seizou[task.target]?.also {
it.forEach {
queue.push(Task(it.key, it.value * task.value))
}
} ?: run {
need[task.target] = need[task.target] + task.value
}
}
need.drop(1).dropLast(1).forEach { println(it) }
}
data class Task(val target:Int, val value:Int)
バカらっく