結果
| 問題 |
No.745 letinopia raoha
|
| コンテスト | |
| ユーザー |
tak
|
| 提出日時 | 2019-02-04 14:37:47 |
| 言語 | F# (F# 4.0) |
| 結果 |
AC
|
| 実行時間 | 396 ms / 2,000 ms |
| コード長 | 1,751 bytes |
| コンパイル時間 | 18,408 ms |
| コンパイル使用メモリ | 194,128 KB |
| 実行使用メモリ | 34,612 KB |
| 最終ジャッジ日時 | 2024-12-25 15:31:49 |
| 合計ジャッジ時間 | 22,635 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 8 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.fsproj を復元しました (501 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/
ソースコード
type Judge = Perfect | Great | Good | Miss
type Notes = { A: int; B: int; C: int; D: int }
type Status = { Chain: int; Score: int; Notes: Notes }
type Result = Score of int | Failed
type State = Playing of Status | Finished of Result
let simulateBest a b c d =
let calc (chain: int) (judge: Judge): int =
match judge with
| Perfect -> 100 * pown 2 (chain / 100)
| Great -> 50 * pown 2 (chain / 100)
| _ -> 0
let update (status: Status): State =
match status.Notes with
| { D = 10 } -> Finished Failed // 死
| { C = 0; D = 0 } as n ->
match n with
| { A = 0; B = 0 } -> Finished <| Score status.Score
| n when n.B > 0 ->
let newChain = status.Chain + 1
let newScore = status.Score + (calc status.Chain Judge.Great)
let newNotes = { n with B = n.B - 1 }
Playing { Chain = newChain; Score = newScore; Notes = newNotes }
| n ->
let newChain = status.Chain + 1
let newScore = status.Score + (calc status.Chain Judge.Perfect)
let newNotes = { n with A = n.A - 1 }
Playing { Chain = newChain; Score = newScore; Notes = newNotes }
| n -> Playing { status with Notes = { n with C = 0; D = 0 } } // C, Dを消費しきる
let rec f (state: State): string =
match state with
| Finished x ->
match x with
| Score x -> sprintf "Possible\n%i" x
| Failed -> "Impossible"
| Playing s -> f <| update s
f <| Playing { Chain = 0; Score = 0; Notes = { A = a; B = b; C = c; D = d } }
let A, B, C, D =
let t = stdin.ReadLine().Split() |> Array.map int
in t.[0], t.[1], t.[2], t.[3]
simulateBest A B C D
|> stdout.WriteLine
tak