結果
問題 | No.1279 Array Battle |
ユーザー | rutilicus |
提出日時 | 2020-11-07 21:09:15 |
言語 | Kotlin (1.9.23) |
結果 |
AC
|
実行時間 | 303 ms / 2,000 ms |
コード長 | 896 bytes |
コンパイル時間 | 15,235 ms |
コンパイル使用メモリ | 426,472 KB |
実行使用メモリ | 53,200 KB |
最終ジャッジ日時 | 2023-09-29 20:53:20 |
合計ジャッジ時間 | 19,489 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 272 ms
52,968 KB |
testcase_01 | AC | 273 ms
52,976 KB |
testcase_02 | AC | 276 ms
53,000 KB |
testcase_03 | AC | 275 ms
53,060 KB |
testcase_04 | AC | 277 ms
53,100 KB |
testcase_05 | AC | 271 ms
52,824 KB |
testcase_06 | AC | 272 ms
52,888 KB |
testcase_07 | AC | 269 ms
52,820 KB |
testcase_08 | AC | 273 ms
52,940 KB |
testcase_09 | AC | 275 ms
52,760 KB |
testcase_10 | AC | 269 ms
52,892 KB |
testcase_11 | AC | 270 ms
53,076 KB |
testcase_12 | AC | 282 ms
52,852 KB |
testcase_13 | AC | 288 ms
53,200 KB |
testcase_14 | AC | 281 ms
52,972 KB |
testcase_15 | AC | 295 ms
52,876 KB |
testcase_16 | AC | 295 ms
53,148 KB |
testcase_17 | AC | 303 ms
52,880 KB |
testcase_18 | AC | 297 ms
53,112 KB |
testcase_19 | AC | 294 ms
52,892 KB |
コンパイルメッセージ
Main.kt:33:13: warning: 'appendln(Int): kotlin.text.StringBuilder /* = java.lang.StringBuilder */' is deprecated. Use appendLine instead. Note that the new method always appends the line feed character '\n' regardless of the system line separator. builder.appendln(maxCnt) ^
ソースコード
import kotlin.math.max fun main() { val builder = StringBuilder() val n = readInputLine().toInt() val aArr = readInputLine().split(" ").map { it.toInt() }.toIntArray() val bArr = readInputLine().split(" ").map { it.toInt() }.toIntArray() var max = 0 var maxCnt = 0 fun dfs(phase: Int, taken: Int, score: Int) { if (phase == n) { if (score > max) { max = score maxCnt = 1 } else if (score == max) { maxCnt++ } return } for (i in 0 until n) { if (taken and (1 shl i) == 0) { dfs(phase + 1, taken or (1 shl i), score + max(0, aArr[i] - bArr[phase])) } } } dfs(0, 0, 0) builder.appendln(maxCnt) print(builder.toString()) } fun readInputLine(): String { return readLine()!! }