結果
| 問題 | No.4 おもりと天秤 |
| コンテスト | |
| ユーザー |
iicafiaxus
|
| 提出日時 | 2016-08-29 23:06:25 |
| 言語 | D (dmd 2.112.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 5,000 ms |
| コード長 | 565 bytes |
| 記録 | |
| コンパイル時間 | 678 ms |
| コンパイル使用メモリ | 113,112 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2026-03-05 07:10:08 |
| 合計ジャッジ時間 | 1,397 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;
void main(){
int n = readln.chomp.to!int;
int[] ws = readln.chomp.split.map!(to!int).array;
ws.sort!("a > b")();
bool[] fs;
fs.length = 10009;
fs[0] = 1;
foreach(w; ws){
foreach_reverse(i; 0 .. 10009){
if(i - w >= 0 && fs[i - w]) fs[i] = 1;
}
}
string ans;
int sum = ws.reduce!((a, b) => a + b);
if(sum % 2 == 0 && fs[sum / 2]) ans = "possible";
else ans = "impossible";
ans.writeln;
}
iicafiaxus