結果
| 問題 | No.4 おもりと天秤 | 
| コンテスト | |
| ユーザー |  tenten | 
| 提出日時 | 2020-11-18 16:53:52 | 
| 言語 | Java (openjdk 23) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 146 ms / 5,000 ms | 
| コード長 | 674 bytes | 
| コンパイル時間 | 2,155 ms | 
| コンパイル使用メモリ | 74,500 KB | 
| 実行使用メモリ | 54,260 KB | 
| 最終ジャッジ日時 | 2024-07-23 09:06:47 | 
| 合計ジャッジ時間 | 5,906 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 23 | 
ソースコード
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");
        }
    }
}
            
            
            
        