結果

問題 No.185 和風
ユーザー noelexnoelex
提出日時 2017-11-03 17:29:25
言語 F#
(F# 4.0)
結果
AC  
実行時間 344 ms / 1,000 ms
コード長 602 bytes
コンパイル時間 11,560 ms
コンパイル使用メモリ 194,508 KB
実行使用メモリ 35,120 KB
最終ジャッジ日時 2024-05-02 04:44:56
合計ジャッジ時間 15,191 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 341 ms
34,640 KB
testcase_01 AC 338 ms
34,980 KB
testcase_02 AC 339 ms
34,832 KB
testcase_03 AC 344 ms
34,476 KB
testcase_04 AC 342 ms
35,120 KB
testcase_05 AC 337 ms
35,116 KB
testcase_06 AC 340 ms
35,116 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (609 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

[<EntryPoint>]
let main argv = 
    let rec readLines n=function
        | lst when n=0 -> lst
        | lst -> 
            let line = Console.ReadLine().Split(' ') 
            (Seq.head line |> int, Seq.last line |> int) :: lst |> readLines (n-1)

    let rec solve n lst=
        match lst, n with
        | (x,y)::tail, None -> solve (Some (y-x)) tail
        | (x,y)::tail, Some n -> if n=y-x then solve (Some n) tail else -1
        | [], Some n when n > 0 -> n
        | _, _ -> -1

    let N = Console.ReadLine () |> int
    [] |> (readLines N) |> solve None |> printfn "%d"
    0
0