結果

問題 No.1053 ゲーミング棒
ユーザー ikdikd
提出日時 2020-05-16 00:02:31
言語 F#
(F# 4.0)
結果
TLE  
実行時間 -
コード長 990 bytes
コンパイル時間 14,082 ms
コンパイル使用メモリ 189,868 KB
実行使用メモリ 63,648 KB
最終ジャッジ日時 2023-10-19 18:24:35
合計ジャッジ時間 20,701 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
32,452 KB
testcase_01 AC 87 ms
32,716 KB
testcase_02 AC 92 ms
32,456 KB
testcase_03 AC 92 ms
32,460 KB
testcase_04 AC 93 ms
32,452 KB
testcase_05 AC 86 ms
32,700 KB
testcase_06 AC 87 ms
32,716 KB
testcase_07 AC 86 ms
32,700 KB
testcase_08 AC 93 ms
32,452 KB
testcase_09 AC 86 ms
32,700 KB
testcase_10 AC 86 ms
32,700 KB
testcase_11 AC 94 ms
32,452 KB
testcase_12 AC 91 ms
32,452 KB
testcase_13 AC 88 ms
32,716 KB
testcase_14 AC 88 ms
32,716 KB
testcase_15 AC 91 ms
32,456 KB
testcase_16 AC 86 ms
32,716 KB
testcase_17 AC 92 ms
32,452 KB
testcase_18 AC 91 ms
32,456 KB
testcase_19 AC 86 ms
32,700 KB
testcase_20 AC 87 ms
32,716 KB
testcase_21 AC 88 ms
32,716 KB
testcase_22 AC 93 ms
32,452 KB
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (823 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.0/publish/

ソースコード

diff #

// Learn more about F# at http://fsharp.org

open System

let rec ok (a: seq<int>) (seen: Set<int>) =
    match a |> Seq.tryHead with
    | None -> true
    | Some(x) ->
        if seen.Contains x
        then false
        else ok (a |> Seq.skipWhile (fun y -> y = x)) (seen.Add x)

[<EntryPoint>]
let main argv =
    let n = stdin.ReadLine() |> int

    let a =
        stdin.ReadLine().Split()
        |> Array.map (fun x -> int (x) - 1)
        |> Array.toSeq

    if (ok a (new Set<int>([]))) then
        printfn "0"
        exit 0

    let mutable freq = Array.create n 0
    for x in a do
        freq.[x] <- freq.[x] + 1
    match freq |> Array.tryFindIndex (fun v -> v >= 2) with
    | None -> printfn "0"
    | Some(x) ->
        let b =
            [ (a |> Seq.skipWhile (fun y -> y = x))
              (a |> Seq.takeWhile (fun y -> y = x)) ]
            |> Seq.concat
        if (ok b (new Set<int>([]))) then printfn "1" else printfn "-1"
    0 // return an integer exit code
0