結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-04-26 17:11:57 |
| 言語 | PHP (843.2) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 546 bytes |
| コンパイル時間 | 2,065 ms |
| コンパイル使用メモリ | 32,272 KB |
| 実行使用メモリ | 32,912 KB |
| 最終ジャッジ日時 | 2024-09-13 12:35:44 |
| 合計ジャッジ時間 | 1,873 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 14 RE * 9 |
コンパイルメッセージ
No syntax errors detected in Main.php
ソースコード
<?php
$count = trim(fgets(STDIN));
$numStr = trim(fgets(STDIN));
$nums = str_split($numStr);
rsort($nums);
$totala = 0;
$totalb = 0;
//$totala = $totala + $nums[0];
if (array_sum($nums)%2 === 0) {
foreach ($nums as $value) {
if($totala > $totalb) {
$totalb = $totalb + $value;
} else {
$totala = $totala + $value;
}
}
if($totala === $totalb) {
echo "Possible" . "\n";
//echo "A:" . $totala . "\n";
//echo "B:" . $totalb;
}
} else {
echo "Impossible";
}
?>