結果

問題 No.799 赤黒かーどげぇむ
ユーザー taktak
提出日時 2019-03-27 03:37:50
言語 F#
(F# 4.0)
結果
AC  
実行時間 73 ms / 2,000 ms
コード長 534 bytes
コンパイル時間 7,074 ms
コンパイル使用メモリ 186,808 KB
実行使用メモリ 30,848 KB
最終ジャッジ日時 2024-04-19 09:07:30
合計ジャッジ時間 8,930 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
30,720 KB
testcase_01 AC 73 ms
30,720 KB
testcase_02 AC 72 ms
30,848 KB
testcase_03 AC 71 ms
30,848 KB
testcase_04 AC 72 ms
30,592 KB
testcase_05 AC 71 ms
30,464 KB
testcase_06 AC 71 ms
30,464 KB
testcase_07 AC 72 ms
30,592 KB
testcase_08 AC 72 ms
30,464 KB
testcase_09 AC 72 ms
30,848 KB
testcase_10 AC 72 ms
30,464 KB
testcase_11 AC 73 ms
30,568 KB
testcase_12 AC 72 ms
30,464 KB
testcase_13 AC 72 ms
30,592 KB
testcase_14 AC 71 ms
30,208 KB
testcase_15 AC 71 ms
30,592 KB
testcase_16 AC 72 ms
30,592 KB
testcase_17 AC 72 ms
30,720 KB
testcase_18 AC 71 ms
30,336 KB
testcase_19 AC 72 ms
30,848 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (235 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 #

open System

let solve a b c d =
    let cdSet = [c .. d] |> Set.ofList
    let cdSetSize = d - c + 1 
    let cnts = [a .. b] |> Seq.countBy(fun x -> Set.contains x cdSet)
    let getCount flag = Seq.tryFind(fun (k, _) -> k = flag) >> Option.map snd >> Option.defaultValue 0
    let t1 = cnts |> getCount false 
    let t2 = cnts |> getCount true
    cdSetSize * t1 + (cdSetSize - 1) * t2
    
let a, b, c, d =
    let t = Console.ReadLine().Split() |> Array.map int
    t.[0], t.[1], t.[2], t.[3]

solve a b c d
|> Console.WriteLine
0