結果
問題 | No.4 おもりと天秤 |
ユーザー |
|
提出日時 | 2017-04-26 17:33:50 |
言語 | PHP (843.2) |
結果 |
AC
|
実行時間 | 60 ms / 5,000 ms |
コード長 | 451 bytes |
コンパイル時間 | 3,853 ms |
コンパイル使用メモリ | 31,504 KB |
実行使用メモリ | 31,252 KB |
最終ジャッジ日時 | 2024-06-26 10:14:30 |
合計ジャッジ時間 | 2,018 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
コンパイルメッセージ
No syntax errors detected in Main.php
ソースコード
<?php // Here your code ! $count = trim(fgets(STDIN)); $weights = explode(' ', trim(fgets(STDIN))); $sum = array_sum($weights); if ($sum % 2 == 1) { echo 'impossible'; exit; } $point = array_fill(0, $sum + 1, false); $point[0] = true; foreach ($weights as $weight) { for ($i = $sum; $i >= 0; $i--) { if ($point[$i]) { $point[$i + $weight] = true; } } } echo ($point[$sum / 2]) ? 'possible' : 'impossible';