結果
| 問題 | No.4 おもりと天秤 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2016-03-07 23:15:31 | 
| 言語 | Java (openjdk 23) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 761 bytes | 
| コンパイル時間 | 2,209 ms | 
| コンパイル使用メモリ | 77,464 KB | 
| 実行使用メモリ | 54,388 KB | 
| 最終ジャッジ日時 | 2024-09-24 12:04:07 | 
| 合計ジャッジ時間 | 6,205 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 20 WA * 3 | 
ソースコード
import java.io.PrintWriter;
import java.util.Scanner;
public class Main {
	static int mod=1000003;
	public static void main(String[] args) throws Exception {
		PrintWriter pw=new PrintWriter(System.out);
		Scanner sc=new Scanner(System.in);
		
		int n=sc.nextInt();
		int sum=0;
		int[] w=new int[n];
		for(int i=0;i<n;i++){
			int tmp=sc.nextInt();
			sum+=tmp;
			w[i]=tmp;
		}
		if(sum%2!=0){
			pw.println("impossible");
			pw.close();
			return;
		}
		boolean[] check=new boolean[10001];
		check[0]=true;
		for(int i=0;i<n;i++){
			for(int j=0;j+w[i]<10001;j++){
				if(check[j]&&!check[j+w[i]]){
					check[j+w[i]]=true;
				}
			}
		}
		if(check[sum/2]){
			pw.print("possible");
		}else{
			pw.print("impossible");
		}
		pw.close();
		sc.close();
	} 
}
            
            
            
        