結果
問題 | No.4 おもりと天秤 |
ユーザー | 綾地寧々 |
提出日時 | 2015-05-22 12:30:53 |
言語 | PHP (8.2.11) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 808 bytes |
コンパイル時間 | 73 ms |
コンパイル使用メモリ | 18,768 KB |
実行使用メモリ | 18,912 KB |
最終ジャッジ日時 | 2023-09-20 08:46:00 |
合計ジャッジ時間 | 1,526 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 17 ms
18,680 KB |
testcase_01 | AC | 16 ms
18,604 KB |
testcase_02 | AC | 17 ms
18,680 KB |
testcase_03 | AC | 16 ms
18,684 KB |
testcase_04 | AC | 17 ms
18,736 KB |
testcase_05 | AC | 17 ms
18,708 KB |
testcase_06 | AC | 17 ms
18,692 KB |
testcase_07 | AC | 17 ms
18,732 KB |
testcase_08 | AC | 17 ms
18,776 KB |
testcase_09 | AC | 17 ms
18,768 KB |
testcase_10 | AC | 17 ms
18,472 KB |
testcase_11 | AC | 17 ms
18,752 KB |
testcase_12 | AC | 17 ms
18,704 KB |
testcase_13 | AC | 17 ms
18,712 KB |
testcase_14 | AC | 17 ms
18,656 KB |
testcase_15 | AC | 17 ms
18,728 KB |
testcase_16 | AC | 16 ms
18,472 KB |
testcase_17 | WA | - |
testcase_18 | AC | 17 ms
18,764 KB |
testcase_19 | AC | 17 ms
18,604 KB |
testcase_20 | AC | 17 ms
18,696 KB |
testcase_21 | AC | 16 ms
18,472 KB |
testcase_22 | AC | 17 ms
18,772 KB |
コンパイルメッセージ
No syntax errors detected in Main.php
ソースコード
<?php $weight = trim(fgets(STDIN)); $weight_array = explode(" ", trim(fgets(STDIN))); rsort($weight_array, SORT_NUMERIC); $left = array(); $right = array(); $result = FALSE; foreach ( $weight_array as $w ) { if ( array_sum($left) <= array_sum($right) ) { $left[] = $w; } else { $right[] = $w; } } if ( array_sum($left) != array_sum($right) ) { $dif = array_sum($left) - array_sum($right); if ( ($dif % 2) == 0 ) { $dif /= 2; for ( $i=0; $i<count($left); $i++ ) { for ( $j=0; $j<count($right); $j++ ) { if ( ($left[$i] - $right[$j]) == $dif ) { $result = TRUE; } if ( $result === TRUE ) { break; } } if ( $result === TRUE ) { break; } } } } else { $result = TRUE; } if ( $result ) { echo 'possible'.PHP_EOL; } else { echo 'impossible'.PHP_EOL; }