結果
| 問題 | No.4 おもりと天秤 | 
| コンテスト | |
| ユーザー |  fal_rnd | 
| 提出日時 | 2017-01-20 22:08:50 | 
| 言語 | Java (openjdk 23) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 150 ms / 5,000 ms | 
| コード長 | 541 bytes | 
| コンパイル時間 | 4,391 ms | 
| コンパイル使用メモリ | 74,924 KB | 
| 実行使用メモリ | 41,904 KB | 
| 最終ジャッジ日時 | 2024-06-26 10:08:40 | 
| 合計ジャッジ時間 | 8,627 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 23 | 
ソースコード
package src;
import java.util.*;
public class A{
	static Scanner s = new Scanner(System.in);
	public static void main(String[] args) {
		int sum=0;
		int[] in = new int[s.nextInt()];
		for(int i=0;i<in.length;i++)
			sum+=(in[i]=s.nextInt());
		if(sum%2!=0) {
			System.out.println("impossible");
			return;
		}
		Arrays.sort(in);
		boolean[] dp = new boolean[10001];
		dp[0]=true;
		for(int i:in) {
			for(int d=dp.length-1;d>=0;d--) {
				if(dp[d])
					dp[d+i]=true;
			}
		}
		System.out.println(dp[sum/2]?"possible":"impossible");
	}
}
            
            
            
        