結果

問題 No.360 増加門松列
ユーザー kuuso1kuuso1
提出日時 2016-09-12 01:53:37
言語 F#
(F# 4.0)
結果
WA  
実行時間 -
コード長 912 bytes
コンパイル時間 16,634 ms
コンパイル使用メモリ 190,508 KB
実行使用メモリ 34,688 KB
最終ジャッジ日時 2024-04-28 12:17:59
合計ジャッジ時間 19,876 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 82 ms
31,360 KB
testcase_03 AC 85 ms
31,104 KB
testcase_04 WA -
testcase_05 AC 92 ms
34,688 KB
testcase_06 WA -
testcase_07 AC 90 ms
34,688 KB
testcase_08 AC 93 ms
34,560 KB
testcase_09 AC 90 ms
34,652 KB
testcase_10 AC 82 ms
31,360 KB
testcase_11 AC 82 ms
31,340 KB
testcase_12 WA -
testcase_13 AC 85 ms
30,976 KB
testcase_14 AC 83 ms
31,488 KB
testcase_15 AC 87 ms
34,652 KB
testcase_16 AC 80 ms
31,104 KB
testcase_17 AC 84 ms
31,360 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 89 ms
34,668 KB
testcase_21 AC 88 ms
34,560 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (448 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 #

open System

let rec insertions x = function
    | []             -> [[x]]
    | (y :: ys) as l -> (x::l)::(List.map (fun x -> y::x) (insertions x ys))

let rec permutations = function
    | []      -> seq [ [] ]
    | x :: xs -> Seq.concat (Seq.map (insertions x) (permutations xs))

let ri () = stdin.ReadLine() |> int
let ria () = stdin.ReadLine().Split() |> Array.map int

let isAscending (a:int list) = 
    a |> List.pairwise |> List.map (fun (x,y) -> x<y) |> List.reduce (fun s x -> s && x)

type Sol() =
    member this.Solve() = 
        let D = ria() |> Array.toList
        let permu = permutations D
        
        let ret = Seq.tryFind (fun ar -> ((isAscending (List.take 4 ar ) && (isAscending (List.skip 4 ar ))) = true )) permu
        if (Option.isSome ret) then "YES" else "NO"
        |> printfn "%s"
                                   
        
        
let mySol = new Sol()
mySol.Solve()
0