結果

問題 No.4 おもりと天秤
ユーザー kou6839kou6839
提出日時 2014-11-08 14:36:25
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 767 bytes
コンパイル時間 2,042 ms
コンパイル使用メモリ 72,004 KB
実行使用メモリ 60,124 KB
最終ジャッジ日時 2023-08-30 02:41:31
合計ジャッジ時間 9,762 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
56,116 KB
testcase_01 AC 124 ms
55,736 KB
testcase_02 AC 129 ms
55,516 KB
testcase_03 AC 128 ms
56,368 KB
testcase_04 AC 130 ms
56,172 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
 

public class Main {
	static int sum=0;
	static int[] omori;
	static boolean dfs(int now,int sum1,int kazu){
		if(now==kazu){
			if(sum1==sum/2){
				return true;
			}else{
				return false;
			}			
		}
		if(dfs(now+1,sum1,kazu)) return true;
		if(dfs(now+1,sum1+omori[now],kazu)) return true;
		return false;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		 omori = new int[N];
		for(int i=0;i<N;i++){
			int temp=sc.nextInt();
			sum+=temp;
			omori[i]=temp;
		}
		if(!(sum%2==0)){
			System.out.println("impossible");
			return;
		}
		if(dfs(0,0,N)){
			System.out.println("possible");
		}else{
			System.out.println("impossible");
		}
		
	}
}	
0