結果

問題 No.790 ちきんの括弧並べ
ユーザー taktak
提出日時 2019-02-20 22:17:43
言語 F#
(F# 4.0)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 286 bytes
コンパイル時間 6,590 ms
コンパイル使用メモリ 185,972 KB
実行使用メモリ 29,312 KB
最終ジャッジ日時 2024-04-25 08:53:50
合計ジャッジ時間 8,502 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
28,928 KB
testcase_01 AC 49 ms
28,928 KB
testcase_02 AC 48 ms
28,928 KB
testcase_03 AC 48 ms
28,928 KB
testcase_04 AC 48 ms
29,056 KB
testcase_05 AC 49 ms
29,312 KB
testcase_06 AC 51 ms
28,800 KB
testcase_07 AC 51 ms
28,800 KB
testcase_08 AC 61 ms
29,184 KB
testcase_09 AC 88 ms
28,800 KB
testcase_10 AC 45 ms
29,056 KB
testcase_11 AC 47 ms
28,800 KB
testcase_12 AC 51 ms
29,184 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (203 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

let solve n =
  let rec f n l r =
    if l = 0 && r = 0 then 1
    elif n > 0 then
      if l > 0 then
        (f (n-1) l (r-1)) + (f (n+1) (l-1) r)
      else
        f (n-1) l (r-1)
    else
      f (n+1) (l-1) r
  f 0 n n

let n = stdin.ReadLine() |> int

solve n
|> stdout.WriteLine
0