結果

問題 No.185 和風
ユーザー r6eve
提出日時 2017-08-11 09:58:55
言語 OCaml
(5.2.1)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 333 bytes
コンパイル時間 254 ms
コンパイル使用メモリ 21,444 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-09 00:11:14
合計ジャッジ時間 796 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

let () =
  let n = Scanf.scanf "%d " (fun i -> i) in
  let rec doit i z =
    if i = n then z
    else
      let x, y = Scanf.scanf "%d %d " (fun x y -> x, y) in
      if x >= y then (-1)
      else
        let s = y - x in
        if z <> (-1) && z <> s then (-1)
        else doit (i + 1) s in
  doit 0 (-1) |> Printf.printf "%d\n"
0