結果

問題 No.745 letinopia raoha
ユーザー taktak
提出日時 2019-02-04 14:37:47
言語 F#
(F# 4.0)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 1,751 bytes
コンパイル時間 5,027 ms
コンパイル使用メモリ 168,560 KB
実行使用メモリ 24,884 KB
最終ジャッジ日時 2023-08-26 16:36:26
合計ジャッジ時間 6,444 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
24,840 KB
testcase_01 AC 50 ms
22,272 KB
testcase_02 AC 73 ms
22,804 KB
testcase_03 AC 73 ms
23,068 KB
testcase_04 AC 51 ms
24,284 KB
testcase_05 AC 74 ms
24,860 KB
testcase_06 AC 76 ms
24,884 KB
testcase_07 AC 77 ms
22,820 KB
testcase_08 AC 77 ms
22,840 KB
testcase_09 AC 56 ms
24,236 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

ソースコード

diff #

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

0