結果

問題 No.4 おもりと天秤
ユーザー 綾地寧々綾地寧々
提出日時 2015-05-22 08:38:47
言語 PHP
(8.3.4)
結果
WA  
実行時間 -
コード長 342 bytes
コンパイル時間 1,170 ms
コンパイル使用メモリ 18,336 KB
実行使用メモリ 19,012 KB
最終ジャッジ日時 2023-09-20 08:44:42
合計ジャッジ時間 1,726 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
18,868 KB
testcase_01 AC 16 ms
18,888 KB
testcase_02 AC 16 ms
18,924 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 16 ms
18,900 KB
testcase_06 AC 16 ms
18,760 KB
testcase_07 AC 16 ms
18,912 KB
testcase_08 AC 16 ms
18,892 KB
testcase_09 AC 16 ms
18,868 KB
testcase_10 AC 16 ms
19,008 KB
testcase_11 AC 16 ms
18,976 KB
testcase_12 AC 16 ms
18,916 KB
testcase_13 AC 16 ms
18,916 KB
testcase_14 AC 17 ms
18,920 KB
testcase_15 AC 16 ms
18,852 KB
testcase_16 AC 16 ms
18,824 KB
testcase_17 WA -
testcase_18 AC 17 ms
18,980 KB
testcase_19 AC 16 ms
18,820 KB
testcase_20 AC 17 ms
18,944 KB
testcase_21 AC 16 ms
18,832 KB
testcase_22 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
$weight = trim(fgets(STDIN));
$weight_array = explode(" ", trim(fgets(STDIN)));
rsort($weight_array, SORT_NUMERIC);
$left = 0;
$right = 0;
foreach ( $weight_array as $w ) {
	if ( $left <= $right ) {
		$left += $w;
	}
	else {
		$right += $w;
	}
}
if ( $left == $right ) {
	echo 'possible'.PHP_EOL;
}
else {
	echo 'impossible'.PHP_EOL;
}
0