結果

問題 No.406 鴨等間隔の法則
ユーザー guriceringuricerin
提出日時 2020-01-10 15:26:15
言語 F#
(.NET 7)
結果
AC  
実行時間 152 ms / 2,000 ms
コード長 1,102 bytes
コンパイル時間 4,249 ms
コンパイル使用メモリ 165,960 KB
実行使用メモリ 34,228 KB
最終ジャッジ日時 2023-09-21 19:11:09
合計ジャッジ時間 9,532 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
25,792 KB
testcase_01 AC 68 ms
24,768 KB
testcase_02 AC 73 ms
24,644 KB
testcase_03 AC 68 ms
22,784 KB
testcase_04 AC 144 ms
31,576 KB
testcase_05 AC 102 ms
25,172 KB
testcase_06 AC 104 ms
27,268 KB
testcase_07 AC 104 ms
27,336 KB
testcase_08 AC 146 ms
31,508 KB
testcase_09 AC 149 ms
32,092 KB
testcase_10 AC 107 ms
25,560 KB
testcase_11 AC 135 ms
28,524 KB
testcase_12 AC 114 ms
24,368 KB
testcase_13 AC 111 ms
26,200 KB
testcase_14 AC 137 ms
30,976 KB
testcase_15 AC 79 ms
23,392 KB
testcase_16 AC 85 ms
23,508 KB
testcase_17 AC 77 ms
23,240 KB
testcase_18 AC 81 ms
25,588 KB
testcase_19 AC 81 ms
23,628 KB
testcase_20 AC 84 ms
25,932 KB
testcase_21 AC 87 ms
23,924 KB
testcase_22 AC 93 ms
24,676 KB
testcase_23 AC 115 ms
28,752 KB
testcase_24 AC 132 ms
30,544 KB
testcase_25 AC 151 ms
32,120 KB
testcase_26 AC 152 ms
34,228 KB
testcase_27 AC 139 ms
32,380 KB
testcase_28 AC 147 ms
32,228 KB
testcase_29 AC 150 ms
32,136 KB
testcase_30 AC 149 ms
34,152 KB
testcase_31 AC 148 ms
33,932 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

ソースコード

diff #

open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f
    let readChars() = read string |> Seq.toArray
    let readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<AutoOpen>]
module Cout =
    let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
    let print (s: string) = writer.Write s
    let println (s: string) = writer.WriteLine s
    let inline puts (s: ^a) = string s |> println

let solve() =
    let n = read int
    let xs = reada int64 |> Array.sort

    let ok1 = Array.tail xs |> Array.forall (fun x -> x <> xs.[0])
    let mutable ok2 = true
    for i in 0 .. n - 3 do
        let d1 = xs.[i] - xs.[i + 1] |> abs
        let d2 = xs.[i + 1] - xs.[i + 2] |> abs
        if d1 <> d2 then ok2 <- false

    if ok1 && ok2 then "YES" else "NO"
    |> puts

    ()

[<EntryPoint>]
let main _ =
    try
        solve()
    with e -> printfn "%s" (e.ToString())
    writer.Close()
    0 // return an integer exit code
0