結果
| 問題 | No.4 おもりと天秤 |
| コンテスト | |
| ユーザー |
tenten
|
| 提出日時 | 2020-11-18 16:53:52 |
| 言語 | Java (openjdk 26.0.2.1) |
| 結果 |
AC
|
| 実行時間 | 78 ms / 5,000 ms |
| + 79µs | |
| コード長 | 674 bytes |
| 記録 | |
| コンパイル時間 | 1,371 ms |
| コンパイル使用メモリ | 84,180 KB |
| 実行使用メモリ | 45,056 KB |
| 最終ジャッジ日時 | 2026-08-23 22:20:28 |
| 合計ジャッジ時間 | 4,676 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_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();
boolean[] isPossible = new boolean[n * 100 + 1];
isPossible[0] = true;
int total = 0;
for (int i = 0; i < n; i++) {
int x = sc.nextInt();
total += x;
for (int j = i * 100; j >= 0 ; j--) {
isPossible[j + x] |= isPossible[j];
}
}
if (total % 2 == 1 || !isPossible[total / 2]) {
System.out.println("impossible");
} else {
System.out.println("possible");
}
}
}
tenten