結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
holeguma
|
| 提出日時 | 2015-07-26 03:24:11 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 84 ms / 5,000 ms |
| コード長 | 617 bytes |
| コンパイル時間 | 2,053 ms |
| コンパイル使用メモリ | 75,368 KB |
| 実行使用メモリ | 51,292 KB |
| 最終ジャッジ日時 | 2024-06-26 09:16:18 |
| 合計ジャッジ時間 | 4,397 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
import java.io.*;
class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null){
int n=Integer.parseInt(line);
int[] w=new int[n];
int[] dp=new int[10001];
dp[0]=1;
int total=0;
String[] values=br.readLine().split(" ");
for(int i=0;i<n;i++){
w[i]=Integer.parseInt(values[i]);
for(int j=10000;j>=0;j--){
if(dp[j]==1){
dp[j+w[i]]=1;
}
}
total+=w[i];
}
if(total%2==1){
System.out.println("impossible");
continue;
}
total/=2;
System.out.println(dp[total]==1?"possible":"impossible");
}
}
}
holeguma