結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,828 KB
testcase_01 AC 122 ms
56,340 KB
testcase_02 AC 131 ms
55,656 KB
testcase_03 AC 125 ms
55,920 KB
testcase_04 WA -
testcase_05 AC 139 ms
55,864 KB
testcase_06 AC 119 ms
55,700 KB
testcase_07 AC 140 ms
56,104 KB
testcase_08 AC 141 ms
56,040 KB
testcase_09 AC 146 ms
55,668 KB
testcase_10 WA -
testcase_11 AC 127 ms
55,476 KB
testcase_12 WA -
testcase_13 AC 125 ms
55,752 KB
testcase_14 WA -
testcase_15 AC 123 ms
55,856 KB
testcase_16 WA -
testcase_17 AC 124 ms
56,052 KB
testcase_18 AC 140 ms
55,480 KB
testcase_19 AC 143 ms
55,960 KB
testcase_20 AC 147 ms
55,776 KB
testcase_21 AC 144 ms
55,968 KB
testcase_22 AC 140 ms
56,016 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,0);

		int sum=0;

		dp[0]=1;

		for(int i=0;i<n;i++) {
			int buf=sc.nextInt();
			sum+=buf;

			for(int j=0;j<=10000;j++) {
				dp[j+buf]=dp[j];
			}


		}

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

	}

}



0