結果

問題 No.4 おもりと天秤
ユーザー komkomhkomkomh
提出日時 2019-04-05 08:39:25
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 540 bytes
コンパイル時間 12,439 ms
コンパイル使用メモリ 422,088 KB
実行使用メモリ 57,304 KB
最終ジャッジ日時 2023-08-13 01:34:38
合計ジャッジ時間 21,201 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 304 ms
56,868 KB
testcase_01 AC 284 ms
52,840 KB
testcase_02 AC 300 ms
57,256 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 311 ms
56,932 KB
testcase_06 AC 304 ms
56,916 KB
testcase_07 AC 308 ms
56,812 KB
testcase_08 AC 287 ms
52,800 KB
testcase_09 AC 310 ms
56,868 KB
testcase_10 WA -
testcase_11 AC 308 ms
57,156 KB
testcase_12 AC 304 ms
57,152 KB
testcase_13 AC 305 ms
56,776 KB
testcase_14 AC 306 ms
56,916 KB
testcase_15 AC 307 ms
56,860 KB
testcase_16 WA -
testcase_17 AC 305 ms
56,924 KB
testcase_18 AC 312 ms
56,948 KB
testcase_19 AC 310 ms
56,860 KB
testcase_20 AC 314 ms
56,812 KB
testcase_21 AC 312 ms
56,852 KB
testcase_22 AC 313 ms
56,716 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