結果

問題 No.740 幻の木
ユーザー taktak
提出日時 2019-02-08 14:37:48
言語 F#
(F# 4.0)
結果
AC  
実行時間 416 ms / 2,000 ms
コード長 1,498 bytes
コンパイル時間 15,006 ms
コンパイル使用メモリ 190,756 KB
実行使用メモリ 58,260 KB
最終ジャッジ日時 2024-06-28 02:20:46
合計ジャッジ時間 19,334 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 6
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (615 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 #
プレゼンテーションモードにする

type Tree = { LeafNum: int; FallPerMonth: int }
type Time = { Month: int; Elapsed: int }
type Doing = { Tree: Tree; Time: Time }
type Done = { Elapsed: int }
type State = DOING of Doing | DONE of Done
type Environment = { WindyStart: int; WindySpan: int }
type Wind = Normal | Windy
let isWindy env month =
if env.WindyStart <= month && month < env.WindyStart + env.WindySpan then Windy
else Normal
let update env doing =
let updateTree env month tree =
match isWindy env month with
| Windy -> { tree with LeafNum = tree.LeafNum - tree.FallPerMonth * 2 }
| Normal -> { tree with LeafNum = tree.LeafNum - tree.FallPerMonth }
let updateTime time =
match time with
| { Month = 12 }-> { Month = 1; Elapsed = time.Elapsed + 1 }
| _ -> { Month = time.Month + 1; Elapsed = time.Elapsed + 1 }
let newTree = updateTree env doing.Time.Month doing.Tree
let newTime = updateTime doing.Time
match newTree with
| { LeafNum = x } when x <= 0 -> DONE { Elapsed = newTime.Elapsed }
| _ -> DOING { Tree = newTree; Time = newTime }
let simulate env tree =
let rec f state =
match state with
| DONE x -> x.Elapsed
| DOING x -> f <| update env x
f <| DOING { Tree = tree; Time = { Month = 1; Elapsed = 0 } }
let N, M, P, Q =
let t = stdin.ReadLine().Split() |> Array.map int
t.[0], t.[1], t.[2], t.[3]
let tree = { LeafNum = N; FallPerMonth = M }
let environment = { WindyStart = P; WindySpan = Q }
simulate environment tree
|> printfn "%i"
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0