結果
問題 |
No.4 おもりと天秤
|
ユーザー |
|
提出日時 | 2019-04-06 12:37:14 |
言語 | Kotlin (2.1.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 663 bytes |
コンパイル時間 | 12,049 ms |
コンパイル使用メモリ | 432,024 KB |
実行使用メモリ | 135,900 KB |
最終ジャッジ日時 | 2024-11-20 17:47:24 |
合計ジャッジ時間 | 26,214 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 TLE * 1 |
ソースコード
package yukicoder fun main() { readLine()!!.toInt() val W: List<Int> = readLine()!!.split(" ").map(String::toInt) val sum: Int = W.sum() if (sum % 2 != 0) { println("impossible") return } val halfW = sum / 2 fun search(index: Int, sum: Int): Boolean { val currentSum = sum + W[index] return if (currentSum > halfW) { false } else if (currentSum == halfW) { true } else { (index + 1 until W.size).any { search(it, currentSum) } } } if (search(0, 0)) { println("possible") } else { println("impossible") } }