結果

問題 No.482 あなたの名は
ユーザー taktak
提出日時 2018-04-24 09:28:00
言語 F#
(.NET 7)
結果
WA  
実行時間 -
コード長 762 bytes
コンパイル時間 4,296 ms
コンパイル使用メモリ 155,764 KB
実行使用メモリ 46,820 KB
最終ジャッジ日時 2023-09-09 23:23:42
合計ジャッジ時間 10,530 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
24,720 KB
testcase_01 AC 79 ms
22,808 KB
testcase_02 AC 79 ms
22,688 KB
testcase_03 WA -
testcase_04 AC 80 ms
22,648 KB
testcase_05 AC 80 ms
22,688 KB
testcase_06 AC 81 ms
24,732 KB
testcase_07 AC 88 ms
22,908 KB
testcase_08 WA -
testcase_09 AC 87 ms
22,936 KB
testcase_10 AC 87 ms
23,028 KB
testcase_11 AC 86 ms
22,968 KB
testcase_12 WA -
testcase_13 AC 87 ms
22,904 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 182 ms
44,824 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 182 ms
42,760 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 183 ms
44,796 KB
testcase_24 AC 182 ms
44,856 KB
testcase_25 AC 184 ms
42,740 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 184 ms
42,700 KB
testcase_29 AC 181 ms
44,760 KB
testcase_30 AC 79 ms
20,764 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
|> function
    | 0 -> "YES"
    | x ->
        let x = x |> int64
        if x<=K && (K-x)%2L=0L then "YES"
        else "NO"
|> printfn "%s"        
0