結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
vektor_dnchr
|
| 提出日時 | 2016-11-07 19:44:07 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 181 ms / 5,000 ms |
| コード長 | 1,063 bytes |
| コンパイル時間 | 2,142 ms |
| コンパイル使用メモリ | 77,712 KB |
| 実行使用メモリ | 54,656 KB |
| 最終ジャッジ日時 | 2024-06-26 10:04:21 |
| 合計ジャッジ時間 | 6,599 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
import java.util.*;
public class Main {
public static void main(String[] args) throws Exception {
// Here your code !
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int[] W = new int[100];
boolean[][] dp = new boolean[101][10001];
int sum = 0;
for(int i=0; i<101; i++)
for(int j=0; j<10001; j++)
dp[i][j] = false;
for(int i=0; i<N; i++){
W[i] = sc.nextInt();
sum += W[i];
}
if(sum%2 == 1) System.out.println("impossible ");
else{
dp[0][0] = true;
for(int i=0; i<N; i++){
for(int j=0; j<=10000; j++){
if(dp[i][j] == true){
dp[i+1][j+W[i]] = true;
dp[i+1][j] = true;
}
}
}
if(dp[N][sum/2] == true) System.out.println("possible");
else System.out.println("impossible ");
}
}
}
vektor_dnchr