結果

問題 No.4 おもりと天秤
ユーザー youthfuldays072
提出日時 2018-05-04 10:46:21
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 585 bytes
コンパイル時間 2,154 ms
コンパイル使用メモリ 75,352 KB
実行使用メモリ 41,812 KB
最終ジャッジ日時 2024-06-28 00:58:42
合計ジャッジ時間 6,063 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Main main=new Main();
		main.run();
	}

	void run() {

		Scanner sc=new Scanner(System.in);

		int n=sc.nextInt();

		int[] w=new int[n];

		for (int i = 0; i < w.length; i++) {
			w[i]=sc.nextInt();
		}


		Arrays.sort(w);

		int[] dp= new int[10001];

		int sum=0;

		dp[0]=1;

		for(int i=0;i<n;i++) {

			sum+=w[i];

			dp[sum]=1;
		}

		if(sum%2==1 || dp[sum/2]!=1) {
			System.out.println("impossible");
		}else {
			System.out.println("possible");
		}

	}

}



0