結果
| 問題 |
No.33 アメーバがたくさん
|
| コンテスト | |
| ユーザー |
バカらっく
|
| 提出日時 | 2019-09-07 13:31:13 |
| 言語 | Kotlin (2.1.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,045 bytes |
| コンパイル時間 | 17,441 ms |
| コンパイル使用メモリ | 457,716 KB |
| 実行使用メモリ | 55,456 KB |
| 最終ジャッジ日時 | 2024-06-26 09:00:11 |
| 合計ジャッジ時間 | 21,984 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 8 WA * 3 |
コンパイルメッセージ
Main.kt:3:10: warning: parameter 'arr' is never used
fun main(arr:Array<String>) {
^
Main.kt:4:10: warning: variable 'amebaCount' is never used
val (amebaCount, move, totalTime) = readLine()!!.split(" ").map { it.toInt() }
^
Main.kt:6:45: warning: unnecessary non-null assertion (!!) on a non-null receiver of type Ameba
val minPos = amebaList.minBy { it.from }!!.from
^
ソースコード
import java.util.*
fun main(arr:Array<String>) {
val (amebaCount, move, totalTime) = readLine()!!.split(" ").map { it.toInt() }
val amebaList = readLine()!!.split(" ").map { Ameba(it.toLong() - move.toLong() * totalTime, it.toLong() + move.toLong() * totalTime) }.sortedBy { it.from }.toMutableList()
val minPos = amebaList.minBy { it.from }!!.from
val amebaMap = mutableMapOf<Long, MutableList<Ameba>>()
amebaList.map { (it.from - minPos) % move }.distinct().forEach { amebaMap[it] = mutableListOf() }
var ans = 0.toLong()
amebaMap.forEach {
val key = it.key
val list = amebaList.filter { (it.from - minPos) % move == key }.sortedBy { it.from }.toMutableList()
for(i in list.lastIndex downTo 1) {
if(list[i-1].to > list[i].from) {
list[i-1] = Ameba(list[i-1].from, list[i].to)
list.removeAt(i)
}
}
ans += list.map { (it.to - it.from) / move + 1 }.sum()
}
println(ans)
}
class Ameba(var from:Long, var to:Long)
バカらっく