結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
57,800 KB
testcase_01 AC 130 ms
57,344 KB
testcase_02 AC 155 ms
57,400 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 130 ms
57,432 KB
testcase_07 WA -
testcase_08 AC 160 ms
57,640 KB
testcase_09 AC 161 ms
57,540 KB
testcase_10 WA -
testcase_11 AC 132 ms
57,516 KB
testcase_12 AC 129 ms
57,304 KB
testcase_13 AC 130 ms
57,344 KB
testcase_14 AC 131 ms
57,532 KB
testcase_15 AC 132 ms
57,460 KB
testcase_16 WA -
testcase_17 AC 134 ms
57,628 KB
testcase_18 AC 161 ms
57,512 KB
testcase_19 AC 167 ms
57,432 KB
testcase_20 AC 162 ms
57,616 KB
testcase_21 AC 161 ms
57,504 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 = 1; i < 10001; i++) w[i] = false;
        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