結果

問題 No.406 鴨等間隔の法則
コンテスト
ユーザー Nobita Gomu
提出日時 2017-10-05 14:40:12
言語 F#
(F# 10.0)
コンパイル:
fsharp_c _filename_
実行:
/usr/bin/dotnet_wrap
結果
AC  
実行時間 130 ms / 2,000 ms
+ 84µs
コード長 469 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 16,898 ms
コンパイル使用メモリ 210,248 KB
実行使用メモリ 69,508 KB
最終ジャッジ日時 2026-08-11 05:37:50
合計ジャッジ時間 16,600 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (283 ミリ秒)。
  main -> /home/judge/data/code/bin/Release/net10.0/main.dll
  main -> /home/judge/data/code/bin/Release/net10.0/publish/

ソースコード

diff #
raw source code

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