結果

問題 No.4 おもりと天秤
ユーザー n120aosssssssssn120aosssssssss
提出日時 2017-05-19 22:12:57
言語 PHP
(8.3.4)
結果
WA  
実行時間 -
コード長 345 bytes
コンパイル時間 3,570 ms
コンパイル使用メモリ 32,380 KB
実行使用メモリ 32,740 KB
最終ジャッジ日時 2023-10-19 02:50:50
合計ジャッジ時間 5,689 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
32,644 KB
testcase_01 AC 44 ms
32,644 KB
testcase_02 AC 45 ms
32,704 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 45 ms
32,704 KB
testcase_06 AC 44 ms
32,644 KB
testcase_07 AC 44 ms
32,704 KB
testcase_08 AC 44 ms
32,704 KB
testcase_09 AC 44 ms
32,704 KB
testcase_10 AC 44 ms
32,704 KB
testcase_11 AC 46 ms
32,644 KB
testcase_12 AC 44 ms
32,644 KB
testcase_13 AC 45 ms
32,644 KB
testcase_14 AC 45 ms
32,644 KB
testcase_15 AC 44 ms
32,644 KB
testcase_16 AC 44 ms
32,704 KB
testcase_17 WA -
testcase_18 AC 45 ms
32,704 KB
testcase_19 AC 46 ms
32,704 KB
testcase_20 AC 44 ms
32,704 KB
testcase_21 AC 45 ms
32,704 KB
testcase_22 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
$n = trim(fgets(STDIN));
$vList = explode(' ', (trim(fgets(STDIN))));
$sum = array_sum($vList);
rsort($vList);
$a = 0;
$b = 0;

if(!$sum%2) {
	echo 'impossible'.PHP_EOL;	
}
foreach($vList as $v) {
	if($a > $b) {
		$b = $b + $v;
	} else {
		$a = $a + $v;
	}
}
if($a === $b) {
	echo 'possible'.PHP_EOL;
} else {
	echo 'impossible'.PHP_EOL;
}
0