結果

問題 No.482 あなたの名は
ユーザー taktak
提出日時 2018-04-24 09:33:17
言語 F#
(F# 4.0)
結果
WA  
実行時間 -
コード長 714 bytes
コンパイル時間 4,329 ms
コンパイル使用メモリ 157,980 KB
実行使用メモリ 46,816 KB
最終ジャッジ日時 2023-09-09 23:25:38
合計ジャッジ時間 10,276 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
24,772 KB
testcase_01 AC 80 ms
22,560 KB
testcase_02 AC 80 ms
22,632 KB
testcase_03 AC 80 ms
20,760 KB
testcase_04 AC 80 ms
22,548 KB
testcase_05 AC 81 ms
22,616 KB
testcase_06 AC 82 ms
24,680 KB
testcase_07 AC 89 ms
22,908 KB
testcase_08 WA -
testcase_09 AC 86 ms
22,772 KB
testcase_10 AC 87 ms
22,908 KB
testcase_11 AC 88 ms
23,088 KB
testcase_12 WA -
testcase_13 AC 88 ms
22,856 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 187 ms
42,712 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 187 ms
40,736 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 186 ms
42,792 KB
testcase_24 AC 187 ms
42,836 KB
testcase_25 AC 186 ms
42,712 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 187 ms
45,044 KB
testcase_29 AC 185 ms
44,824 KB
testcase_30 AC 81 ms
24,708 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

ソースコード

diff #

let stepCountToSort (arr:int[]) =
    let cnt = ref 0
    let swap a b = 
        let t = arr.[a]
        arr.[a] <- arr.[b]
        arr.[b] <- t
                
    for i in 1..arr |> Array.length do
        let idx = i-1
        if i <> arr.[idx] then
            //arr.[idx]が本来あるべき位置
            let rightIdx = arr.[idx]-1                    
            swap idx rightIdx  
            incr cnt
    cnt.Value    

let N,K = let t = stdin.ReadLine().Split() 
          in t.[0] |> int, t.[1] |> int64
let D   = stdin.ReadLine().Split() |> Array.map int
               
D
|> stepCountToSort
|> int64
|> function
    | x when x<=K && (K-x)%2L=0L -> "YES"
    | _ -> "NO"
|> printfn "%s"        
0