結果
問題 |
No.1279 Array Battle
|
ユーザー |
![]() |
提出日時 | 2020-11-07 21:09:15 |
言語 | Kotlin (2.1.0) |
結果 |
AC
|
実行時間 | 318 ms / 2,000 ms |
コード長 | 896 bytes |
コンパイル時間 | 12,513 ms |
コンパイル使用メモリ | 440,816 KB |
実行使用メモリ | 57,128 KB |
最終ジャッジ日時 | 2024-07-22 14:49:47 |
合計ジャッジ時間 | 19,526 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
コンパイルメッセージ
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()!! }