結果

問題 No.116 門松列(1)
ユーザー guriceringuricerin
提出日時 2020-01-08 16:50:06
言語 F#
(F# 4.0)
結果
AC  
実行時間 77 ms / 5,000 ms
コード長 1,080 bytes
コンパイル時間 3,779 ms
コンパイル使用メモリ 164,712 KB
実行使用メモリ 16,940 KB
最終ジャッジ日時 2023-08-15 00:38:16
合計ジャッジ時間 6,686 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
16,892 KB
testcase_01 AC 71 ms
16,940 KB
testcase_02 AC 72 ms
16,800 KB
testcase_03 AC 72 ms
16,932 KB
testcase_04 AC 64 ms
16,452 KB
testcase_05 AC 65 ms
16,448 KB
testcase_06 AC 65 ms
16,264 KB
testcase_07 AC 73 ms
16,736 KB
testcase_08 AC 71 ms
16,740 KB
testcase_09 AC 71 ms
16,940 KB
testcase_10 AC 71 ms
16,768 KB
testcase_11 AC 71 ms
16,768 KB
testcase_12 AC 71 ms
16,812 KB
testcase_13 AC 72 ms
16,732 KB
testcase_14 AC 70 ms
16,764 KB
testcase_15 AC 71 ms
16,816 KB
testcase_16 AC 72 ms
16,900 KB
testcase_17 AC 70 ms
16,780 KB
testcase_18 AC 71 ms
16,928 KB
testcase_19 AC 71 ms
16,856 KB
testcase_20 AC 70 ms
16,908 KB
testcase_21 AC 71 ms
16,812 KB
testcase_22 AC 77 ms
16,848 KB
testcase_23 AC 65 ms
16,252 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 ok i j k = i <> j && j <> k && i <> k

let ok2 i j k =
    let l = [ i; j; k ] |> List.sort
    List.min l = j || List.max l = j

let solve() =
    let n = read int
    let A = reada int
    let mutable cnt = 0
    for i in 0 .. n - 3 do
        let a, b, c = A.[i], A.[i + 1], A.[i + 2]
        if (ok a b c) && (ok2 a b c) then cnt <- cnt + 1

    puts cnt


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