結果

問題 No.4 おもりと天秤
ユーザー tetsukicktetsukick
提出日時 2017-04-26 17:11:07
言語 PHP
(8.3.4)
結果
MLE  
実行時間 -
コード長 1,042 bytes
コンパイル時間 84 ms
コンパイル使用メモリ 12,068 KB
実行使用メモリ 822,112 KB
最終ジャッジ日時 2023-10-11 13:52:46
合計ジャッジ時間 6,092 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

<?php


function kumiawase($zentai,$nukitorisu){
    $zentaisu=count($zentai);
    if($zentaisu<$nukitorisu){
        return;
    }elseif($nukitorisu==1){
        for($i=0;$i<$zentaisu;$i++){
            $arrs[$i]=array($zentai[$i]);
        }
    }elseif($nukitorisu>1){
        $j=0;
        for($i=0;$i<$zentaisu-$nukitorisu+1;$i++){
            $ts=kumiawase(array_slice($zentai,$i+1),$nukitorisu-1);
            foreach($ts as $t){
                array_unshift($t,$zentai[$i]);
                $arrs[$j]=$t;
                $j++;
            }
        }
    }
    return $arrs;
}

$count = trim(fgets(STDIN));
$array = explode(" ",trim(fgets(STDIN)));
$sum = array_sum($array);
$sumhanbun = $sum/2;
$flag = 0;


if ($sum%2 != 0){
}else {
    for ($i=1;$i<$count;$i++){
        foreach(kumiawase($array,$i) as $arr){
            $sumkumiawase = array_sum($arr);
            if ($sumkumiawase == $sumhanbun){
                $flag=1;
            }
        }
    }
}

if ($flag == 1) {
    echo 'possible';
}else {
    echo 'impossible';
}
0