結果

問題 No.1538 引きこもりさんは引き算が得意。
ユーザー yulianess27__yulianess27__
提出日時 2021-06-17 19:19:54
言語 PHP
(8.3.4)
結果
WA  
実行時間 -
コード長 1,316 bytes
コンパイル時間 1,313 ms
コンパイル使用メモリ 18,552 KB
実行使用メモリ 19,112 KB
最終ジャッジ日時 2023-09-01 22:22:58
合計ジャッジ時間 7,780 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
18,912 KB
testcase_01 AC 16 ms
18,904 KB
testcase_02 AC 16 ms
18,900 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 16 ms
18,792 KB
testcase_09 AC 16 ms
18,988 KB
testcase_10 AC 27 ms
18,984 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 15 ms
18,860 KB
testcase_14 AC 16 ms
18,884 KB
testcase_15 WA -
testcase_16 AC 17 ms
18,936 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 16 ms
18,848 KB
testcase_22 AC 16 ms
18,872 KB
testcase_23 AC 15 ms
18,884 KB
testcase_24 AC 16 ms
18,900 KB
testcase_25 WA -
testcase_26 AC 15 ms
18,876 KB
testcase_27 AC 15 ms
18,880 KB
testcase_28 AC 16 ms
18,764 KB
testcase_29 AC 15 ms
18,900 KB
testcase_30 AC 16 ms
18,964 KB
testcase_31 AC 16 ms
18,976 KB
testcase_32 AC 16 ms
18,900 KB
testcase_33 WA -
testcase_34 AC 15 ms
18,968 KB
testcase_35 AC 16 ms
18,756 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 TLE -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
list($n, $k) = explode(" ", trim(fgets(STDIN)));
$list = explode(" ", trim(fgets(STDIN)));
if (in_array($k, $list)) echo 'Yes';

// 順列操作
function permutations($a, $s = '') {
    global $k;
  $r = array();
  if (count($a) && is_array($a)) {
    foreach ($a as $k => $v) {
      if ($s != '' ) {
          $_s = $s .','.$v;
      } else {
          $_s = $v;
      }
      //もらった1文字を除いた文字の配列を作って
      $_a = $a;
      unset($_a[$k]);
      //再帰呼び出し
      $_r = permutations($_a, $_s);
      if (!empty($_r)) {
          // 計算チェック
          $list = [];
          foreach(explode(",", $_r[0]) as $v) {
            if (empty($list)) {
                $list = [$v, - $v];
            } else {
                foreach($list as $l) {
                    $tmp = [$l + $v, $l - $v];
                }
                if (in_array($k, $tmp)) {
                    echo 'Yes';
                    exit;
                }
            }
          }
      }
      //返り値にする変数に結果を追加
    //   $r = array_merge($r, $_r);
    }
  } else {
    //第1引数が空っぽの配列だったら、再帰呼び出しはここでストップ
    //返り値はこれだけ
    $r[] = $s;
  }
  return $r;
}

permutations($list);

echo "No";
0