結果

問題 No.4 おもりと天秤
ユーザー DAZYDAZY
提出日時 2017-05-24 15:10:37
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 686 bytes
コンパイル時間 3,340 ms
コンパイル使用メモリ 74,856 KB
実行使用メモリ 57,852 KB
最終ジャッジ日時 2023-10-19 19:59:52
合計ジャッジ時間 7,538 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
57,176 KB
testcase_01 AC 128 ms
57,380 KB
testcase_02 AC 149 ms
57,180 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 129 ms
57,516 KB
testcase_07 WA -
testcase_08 AC 154 ms
57,572 KB
testcase_09 AC 159 ms
57,644 KB
testcase_10 WA -
testcase_11 AC 130 ms
57,348 KB
testcase_12 AC 130 ms
57,400 KB
testcase_13 AC 130 ms
57,456 KB
testcase_14 AC 129 ms
57,436 KB
testcase_15 AC 130 ms
57,336 KB
testcase_16 WA -
testcase_17 AC 132 ms
57,532 KB
testcase_18 AC 164 ms
57,468 KB
testcase_19 AC 159 ms
57,528 KB
testcase_20 AC 157 ms
57,560 KB
testcase_21 AC 158 ms
57,648 KB
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No4 {
    public static void main (String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int t, sum = 0;
        //インデックスのおもさを作り出せるかどうか
        boolean[] w = new boolean[10001];
        w[0] = true;
        for (int i = 0; i < N; i++) {
            t = scan.nextInt();
            sum += t;
            for (int j = 10000 - t; j >= 0; j--) w[j+t] = w[j];
        }
        //二等分できないとき、または半分のおもさにできない場合 impossible
        System.out.println((sum & 1)==1 || !w[sum/2] ? "impossible" : "possible");
    }
}
0