結果
問題 | No.150 "良問"(良問とは言っていない |
ユーザー | バカらっく |
提出日時 | 2019-10-21 01:52:48 |
言語 | Kotlin (1.9.23) |
結果 |
AC
|
実行時間 | 427 ms / 5,000 ms |
コード長 | 935 bytes |
コンパイル時間 | 13,350 ms |
コンパイル使用メモリ | 422,144 KB |
実行使用メモリ | 56,904 KB |
最終ジャッジ日時 | 2023-09-15 14:56:42 |
合計ジャッジ時間 | 22,319 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 378 ms
56,392 KB |
testcase_01 | AC | 303 ms
52,944 KB |
testcase_02 | AC | 300 ms
53,092 KB |
testcase_03 | AC | 302 ms
53,500 KB |
testcase_04 | AC | 302 ms
52,960 KB |
testcase_05 | AC | 311 ms
53,128 KB |
testcase_06 | AC | 427 ms
56,788 KB |
testcase_07 | AC | 300 ms
53,020 KB |
testcase_08 | AC | 308 ms
53,004 KB |
testcase_09 | AC | 305 ms
53,264 KB |
testcase_10 | AC | 386 ms
56,380 KB |
testcase_11 | AC | 385 ms
56,628 KB |
testcase_12 | AC | 369 ms
56,312 KB |
testcase_13 | AC | 385 ms
56,788 KB |
testcase_14 | AC | 391 ms
56,888 KB |
testcase_15 | AC | 397 ms
56,612 KB |
testcase_16 | AC | 325 ms
53,164 KB |
testcase_17 | AC | 335 ms
55,312 KB |
testcase_18 | AC | 402 ms
56,408 KB |
testcase_19 | AC | 408 ms
56,868 KB |
testcase_20 | AC | 397 ms
56,904 KB |
コンパイルメッセージ
Main.kt:1:10: warning: parameter 'arr' is never used fun main(arr:Array<String>) { ^ Main.kt:20:73: warning: unnecessary non-null assertion (!!) on a non-null receiver of type Int return listGood.indices.map { listGood[it] + listProbrem[it] }.min()!! ^
ソースコード
fun main(arr:Array<String>) { val inputCount = readLine()!!.toInt() (1..inputCount).forEach { println(getAns(readLine()!!)) } } fun getAns(input:String):Int { val listGood = mutableListOf<Int>() val listProbrem = mutableListOf<Int>() for(i in (0..input.length - 11)) { listGood.add(convCount("good", input.substring((i until i + 4)))) listProbrem.add(convCount("problem", input.substring(i + 4 until i + 11))) } for(i in (1..listGood.lastIndex)) { listGood[i] = Math.min(listGood[i], listGood[i - 1]) } for(i in (0..listProbrem.lastIndex - 1).reversed()) { listProbrem[i] = Math.min(listProbrem[i], listProbrem[i + 1]) } return listGood.indices.map { listGood[it] + listProbrem[it] }.min()!! } fun convCount(original:String, require:String):Int { val ans = original.withIndex().map { if(it.value == require[it.index]) 0 else 1 }.sum() return ans }