結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
kou6839
|
| 提出日時 | 2014-11-08 14:36:25 |
| 言語 | Java (openjdk 23) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 767 bytes |
| コンパイル時間 | 2,140 ms |
| コンパイル使用メモリ | 74,848 KB |
| 実行使用メモリ | 108,392 KB |
| 最終ジャッジ日時 | 2024-12-31 08:38:54 |
| 合計ジャッジ時間 | 59,094 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 TLE * 9 |
ソースコード
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");
}
}
}
kou6839