結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-04-06 12:35:01 |
| 言語 | Kotlin (2.1.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 564 bytes |
| コンパイル時間 | 11,887 ms |
| コンパイル使用メモリ | 434,912 KB |
| 実行使用メモリ | 114,084 KB |
| 最終ジャッジ日時 | 2024-11-20 17:46:34 |
| 合計ジャッジ時間 | 64,844 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 15 TLE * 8 |
ソースコード
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) true
else (index + 1 until W.size).any { search(it, currentSum) }
}
if (search(0, 0)) {
println("possible")
} else {
println("impossible")
}
}