結果
問題 | No.4 おもりと天秤 |
ユーザー |
|
提出日時 | 2015-05-23 15:44:26 |
言語 | PHP (7.2.24) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 769 bytes |
コンパイル時間 | 349 ms |
コンパイル使用メモリ | 18,840 KB |
実行使用メモリ | 23,356 KB |
最終ジャッジ日時 | 2023-09-20 10:53:17 |
合計ジャッジ時間 | 8,060 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 15 ms
18,832 KB |
testcase_01 | AC | 14 ms
18,664 KB |
testcase_02 | AC | 17 ms
18,880 KB |
testcase_03 | AC | 15 ms
18,864 KB |
testcase_04 | AC | 14 ms
18,720 KB |
testcase_05 | AC | 15 ms
18,896 KB |
testcase_06 | AC | 15 ms
18,664 KB |
testcase_07 | AC | 14 ms
18,864 KB |
testcase_08 | AC | 15 ms
18,708 KB |
testcase_09 | AC | 15 ms
18,836 KB |
testcase_10 | AC | 15 ms
18,980 KB |
testcase_11 | AC | 15 ms
18,932 KB |
testcase_12 | AC | 14 ms
18,864 KB |
testcase_13 | AC | 14 ms
18,964 KB |
testcase_14 | AC | 15 ms
18,864 KB |
testcase_15 | AC | 15 ms
18,892 KB |
testcase_16 | AC | 14 ms
18,972 KB |
testcase_17 | AC | 15 ms
18,812 KB |
testcase_18 | TLE | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
コンパイルメッセージ
No syntax errors detected in Main.php
ソースコード
<?php $n = trim(fgets(STDIN)); $w_array = explode(" ", trim(fgets(STDIN))); rsort($w_array); $w_target = array_sum($w_array); if ( $w_target % 2 ) { echo 'impossible'.PHP_EOL; exit(0); } $w_target /= 2; if ( put_weight(0,0,0) ) { echo 'possible'.PHP_EOL; } else { echo 'impossible'.PHP_EOL; } function put_weight ( $put, $w_index, $w_count ) { global $w_array, $w_target, $n; if ( ($w_count >= $n) || ($w_index >= $n) ) { return FALSE; } if ( ($put + $w_array[$w_index]) > $w_target ) { return FALSE; } if ( ($put + $w_array[$w_index]) == $w_target ) { return TRUE; } $put += $w_array[$w_index]; $ret = FALSE; for ( $i=$w_index+1; $i<$n; $i++ ) { $ret = put_weight($put, $i, $w_count+1); if ( $ret === TRUE ) { break; } } return $ret; }