結果

問題 No.366 ロボットソート
ユーザー kuuso1kuuso1
提出日時 2016-09-06 23:47:53
言語 F#
(F# 4.0)
結果
AC  
実行時間 97 ms / 2,000 ms
コード長 836 bytes
コンパイル時間 4,753 ms
コンパイル使用メモリ 171,408 KB
実行使用メモリ 25,264 KB
最終ジャッジ日時 2023-08-28 15:29:44
合計ジャッジ時間 7,789 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
23,140 KB
testcase_01 AC 83 ms
23,040 KB
testcase_02 AC 88 ms
24,988 KB
testcase_03 AC 81 ms
24,824 KB
testcase_04 AC 85 ms
25,028 KB
testcase_05 AC 83 ms
22,868 KB
testcase_06 AC 83 ms
25,028 KB
testcase_07 AC 83 ms
22,924 KB
testcase_08 AC 83 ms
23,028 KB
testcase_09 AC 82 ms
23,040 KB
testcase_10 AC 90 ms
21,044 KB
testcase_11 AC 92 ms
23,196 KB
testcase_12 AC 94 ms
25,224 KB
testcase_13 AC 92 ms
25,264 KB
testcase_14 AC 93 ms
23,272 KB
testcase_15 AC 92 ms
21,048 KB
testcase_16 AC 94 ms
23,212 KB
testcase_17 AC 92 ms
23,088 KB
testcase_18 AC 94 ms
23,132 KB
testcase_19 AC 93 ms
21,224 KB
testcase_20 AC 84 ms
20,916 KB
testcase_21 AC 94 ms
25,248 KB
testcase_22 AC 97 ms
23,172 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

/home/judge/data/code/Main.fs(9,13): warning FS0025: Incomplete pattern matches on this expression. For example, the value '[|_; _; _|]' may indicate a case not covered by the pattern(s).

ソースコード

diff #

open System

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

type Sol() =
    member this.Solve() = 
        
        let [|N;K|] = ria ()
        let A = ria ()
        
        let B = Array.sort A
        let mutable ans = 0
        
        for i in 0..(N-1) do
            let n = Array.findIndex (fun x -> x = B.[i]) A
            if ( (n - i) % K ) = 0 then (
                for j in 0..( (n-i)/K - 1 ) do
                (
                    let tmp = A.[(n - j*K)];
                    A.[(n - j*K)] <- A.[(n - j*K) - K];
                    A.[(n - j*K) - K] <- tmp;
                    ans <- ans + 1
                )
            ) else ans <- -1000000000
        
        
        if ans < 0 then ans <- -1
        printfn "%d" ans
        
let mySol = new Sol()
mySol.Solve()
0