結果

問題 No.4 おもりと天秤
ユーザー tetsukicktetsukick
提出日時 2017-04-26 17:27:34
言語 PHP
(8.3.4)
結果
MLE  
実行時間 -
コード長 1,062 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 11,824 KB
実行使用メモリ 816,760 KB
最終ジャッジ日時 2023-10-11 13:54:01
合計ジャッジ時間 6,346 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
12,056 KB
testcase_01 AC 7 ms
11,976 KB
testcase_02 AC 58 ms
16,120 KB
testcase_03 AC 8 ms
12,180 KB
testcase_04 AC 60 ms
16,244 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
set_time_limit (0);

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