結果

問題 No.4 おもりと天秤
ユーザー komkomhkomkomh
提出日時 2019-04-05 08:39:25
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 540 bytes
コンパイル時間 12,190 ms
コンパイル使用メモリ 431,984 KB
実行使用メモリ 60,456 KB
最終ジャッジ日時 2024-04-30 20:08:44
合計ジャッジ時間 17,553 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 281 ms
60,412 KB
testcase_01 AC 271 ms
56,936 KB
testcase_02 AC 279 ms
60,360 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 290 ms
60,308 KB
testcase_06 AC 296 ms
60,292 KB
testcase_07 AC 306 ms
60,452 KB
testcase_08 AC 290 ms
56,980 KB
testcase_09 AC 298 ms
60,448 KB
testcase_10 WA -
testcase_11 AC 308 ms
60,372 KB
testcase_12 AC 293 ms
60,256 KB
testcase_13 AC 297 ms
60,256 KB
testcase_14 AC 284 ms
60,308 KB
testcase_15 AC 283 ms
60,256 KB
testcase_16 WA -
testcase_17 AC 288 ms
60,368 KB
testcase_18 AC 309 ms
60,408 KB
testcase_19 AC 282 ms
60,368 KB
testcase_20 AC 290 ms
60,348 KB
testcase_21 AC 287 ms
60,348 KB
testcase_22 AC 296 ms
60,456 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:4:9: warning: variable 'N' is never used
    val N: Int = readLine()!!.toInt()
        ^

ソースコード

diff #

package yukicoder

fun main() {
    val N: Int = 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
    val sortedW = W.sortedDescending()
    var sumW = 0
    for (currentW in sortedW) {
        if (sumW + currentW <= halfW) {
            sumW += currentW
        }
    }
    if (halfW == sumW) {
        println("possible")
    } else {
        println("impossible")
    }
}
0