結果

問題 No.4 おもりと天秤
ユーザー リチウムリチウム
提出日時 2014-11-17 17:44:28
言語 Java21
(openjdk 21)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 497 bytes
コンパイル時間 2,817 ms
コンパイル使用メモリ 70,756 KB
実行使用メモリ 56,148 KB
最終ジャッジ日時 2023-08-30 20:26:24
合計ジャッジ時間 6,528 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,624 KB
testcase_01 AC 119 ms
56,148 KB
testcase_02 AC 118 ms
55,624 KB
testcase_03 AC 118 ms
55,848 KB
testcase_04 AC 118 ms
56,032 KB
testcase_05 AC 133 ms
55,552 KB
testcase_06 AC 121 ms
55,640 KB
testcase_07 AC 135 ms
55,352 KB
testcase_08 AC 127 ms
55,668 KB
testcase_09 AC 138 ms
56,056 KB
testcase_10 AC 133 ms
55,708 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 118 ms
54,600 KB
testcase_14 WA -
testcase_15 AC 120 ms
55,656 KB
testcase_16 AC 121 ms
55,848 KB
testcase_17 AC 119 ms
55,544 KB
testcase_18 AC 136 ms
55,980 KB
testcase_19 AC 135 ms
55,768 KB
testcase_20 AC 135 ms
55,976 KB
testcase_21 AC 136 ms
55,824 KB
testcase_22 AC 134 ms
55,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		boolean ok[]=new boolean[10001];
		ok[0]=true;
		int sum=0;
		for(int i=0;i<n;i++){
			int x=sc.nextInt();
			
			for(int j=0;j<=sum;j++){
				if(ok[j])ok[j+x]=true;
			}
			sum+=x;
		}
		String s="";
		if(sum%2==1)s="impossible";
		else {
			if(ok[sum/2])s="possible";
			else s="impossible";
		}
		System.out.println(s);
	}}
0