結果

問題 No.4 おもりと天秤
ユーザー youthfuldays072youthfuldays072
提出日時 2018-05-04 11:02:29
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 566 bytes
コンパイル時間 2,061 ms
コンパイル使用メモリ 71,532 KB
実行使用メモリ 56,248 KB
最終ジャッジ日時 2023-09-10 09:31:46
合計ジャッジ時間 6,075 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,672 KB
testcase_01 AC 122 ms
55,848 KB
testcase_02 WA -
testcase_03 AC 123 ms
55,644 KB
testcase_04 AC 133 ms
55,896 KB
testcase_05 AC 142 ms
55,960 KB
testcase_06 WA -
testcase_07 AC 142 ms
55,944 KB
testcase_08 AC 143 ms
56,012 KB
testcase_09 AC 144 ms
55,944 KB
testcase_10 AC 143 ms
55,792 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 124 ms
55,944 KB
testcase_17 AC 124 ms
55,732 KB
testcase_18 WA -
testcase_19 AC 141 ms
55,840 KB
testcase_20 AC 141 ms
55,904 KB
testcase_21 AC 146 ms
56,140 KB
testcase_22 AC 142 ms
56,144 KB
権限があれば一括ダウンロードができます

ソースコード

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[] dp= new int[10101];
		
		Arrays.fill(dp,1);
		
		int sum=0;


		for(int i=0;i<n;i++) {
			int buf=sc.nextInt();
			sum+=buf;
			
			for(int j=10000;j>=0;j--) {
				dp[j+buf]+=dp[j];
			}

		}

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

	}

}



0