結果
| 問題 | No.4 おもりと天秤 |
| コンテスト | |
| ユーザー |
kou6839
|
| 提出日時 | 2014-11-08 15:23:21 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
AC
|
| 実行時間 | 76 ms / 5,000 ms |
| コード長 | 679 bytes |
| 記録 | |
| コンパイル時間 | 3,796 ms |
| コンパイル使用メモリ | 84,268 KB |
| 実行使用メモリ | 48,044 KB |
| 最終ジャッジ日時 | 2026-03-13 01:26:01 |
| 合計ジャッジ時間 | 5,919 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N=sc.nextInt();
int sum=0;
int[] 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;
}
boolean[] check = new boolean[10001];
check[0]=true;
for(int i=0;i<N;i++){
for(int j=10000;j>=0;j--){
if(check[j]&&!check[j+omori[i]]){
check[j+omori[i]]=true;
}
}
}
if(check[sum/2]){
System.out.println("possible");
}else{
System.out.println("impossible");
}
}
}
kou6839