結果

問題 No.482 あなたの名は
ユーザー taktak
提出日時 2018-04-24 09:46:07
言語 F#
(F# 4.0)
結果
AC  
実行時間 191 ms / 2,000 ms
コード長 738 bytes
コンパイル時間 3,599 ms
コンパイル使用メモリ 162,352 KB
実行使用メモリ 44,912 KB
最終ジャッジ日時 2023-09-09 23:26:00
合計ジャッジ時間 9,201 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
20,720 KB
testcase_01 AC 80 ms
22,608 KB
testcase_02 AC 81 ms
20,756 KB
testcase_03 AC 80 ms
20,596 KB
testcase_04 AC 80 ms
22,624 KB
testcase_05 AC 80 ms
22,568 KB
testcase_06 AC 81 ms
22,632 KB
testcase_07 AC 89 ms
22,900 KB
testcase_08 AC 89 ms
24,900 KB
testcase_09 AC 88 ms
22,992 KB
testcase_10 AC 88 ms
24,936 KB
testcase_11 AC 89 ms
22,996 KB
testcase_12 AC 87 ms
22,776 KB
testcase_13 AC 88 ms
24,892 KB
testcase_14 AC 88 ms
24,876 KB
testcase_15 AC 187 ms
42,720 KB
testcase_16 AC 187 ms
44,748 KB
testcase_17 AC 187 ms
44,820 KB
testcase_18 AC 188 ms
42,716 KB
testcase_19 AC 188 ms
44,864 KB
testcase_20 AC 191 ms
44,752 KB
testcase_21 AC 188 ms
42,760 KB
testcase_22 AC 188 ms
44,736 KB
testcase_23 AC 186 ms
42,972 KB
testcase_24 AC 188 ms
44,912 KB
testcase_25 AC 190 ms
44,784 KB
testcase_26 AC 187 ms
42,864 KB
testcase_27 AC 187 ms
44,696 KB
testcase_28 AC 188 ms
42,748 KB
testcase_29 AC 185 ms
44,724 KB
testcase_30 AC 81 ms
22,704 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
        while i <> arr.[idx] do            
            //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