結果

問題 No.4 おもりと天秤
ユーザー tentententen
提出日時 2020-11-18 16:53:52
言語 Java19
(openjdk 21)
結果
AC  
実行時間 162 ms / 5,000 ms
コード長 674 bytes
コンパイル時間 2,068 ms
コンパイル使用メモリ 71,780 KB
実行使用メモリ 58,196 KB
最終ジャッジ日時 2023-09-30 15:07:02
合計ジャッジ時間 6,473 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,952 KB
testcase_01 AC 125 ms
55,760 KB
testcase_02 AC 129 ms
55,732 KB
testcase_03 AC 129 ms
55,740 KB
testcase_04 AC 130 ms
55,848 KB
testcase_05 AC 160 ms
56,144 KB
testcase_06 AC 126 ms
55,912 KB
testcase_07 AC 160 ms
58,196 KB
testcase_08 AC 158 ms
56,148 KB
testcase_09 AC 161 ms
56,380 KB
testcase_10 AC 161 ms
55,868 KB
testcase_11 AC 127 ms
55,728 KB
testcase_12 AC 127 ms
55,916 KB
testcase_13 AC 126 ms
55,444 KB
testcase_14 AC 127 ms
55,764 KB
testcase_15 AC 128 ms
55,924 KB
testcase_16 AC 127 ms
56,000 KB
testcase_17 AC 126 ms
56,048 KB
testcase_18 AC 159 ms
55,912 KB
testcase_19 AC 159 ms
55,748 KB
testcase_20 AC 161 ms
56,148 KB
testcase_21 AC 161 ms
55,920 KB
testcase_22 AC 162 ms
56,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        boolean[] isPossible = new boolean[n * 100 + 1];
        isPossible[0] = true;
        int total = 0;
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            total += x;
            for (int j = i * 100; j >= 0 ; j--) {
                isPossible[j + x] |= isPossible[j];
            }
        }
        if (total % 2 == 1 || !isPossible[total / 2]) { 
            System.out.println("impossible");
        } else {
            System.out.println("possible");
        }
    }
}
0