結果

問題 No.406 鴨等間隔の法則
ユーザー Nobita Gomu
提出日時 2017-10-05 14:40:12
言語 F#
(F# 4.0)
結果
AC  
実行時間 197 ms / 2,000 ms
コード長 469 bytes
コンパイル時間 13,691 ms
コンパイル使用メモリ 183,828 KB
実行使用メモリ 66,816 KB
最終ジャッジ日時 2024-07-07 12:14:10
合計ジャッジ時間 18,658 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (294 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 #

let f (s:string) = s.Split ' ' |> Seq.map int
let uniqCount = Seq.distinct >> Seq.length

let isValid0 n s = n = (s |> f |> uniqCount)
let isValid1 s =
    let cache = s |> (f >> Seq.sort >> Seq.cache)
    1 = (Seq.zip cache (Seq.skip 1 cache)
         |> Seq.map (fun e -> (snd e) - (fst e))
         |> uniqCount)

let isValid n s = (isValid0 n s) && (isValid1 s)

if isValid (stdin.ReadLine () |> int) (stdin.ReadLine ()) then
    "YES"
else
    "NO"
|> printfn "%s"
0