結果

問題 No.397 NO MORE KADOMATSU
ユーザー kuuso1kuuso1
提出日時 2016-08-26 00:47:14
言語 F#
(F# 4.0)
結果
AC  
実行時間 106 ms / 2,000 ms
コード長 968 bytes
コンパイル時間 4,600 ms
コンパイル使用メモリ 173,768 KB
実行使用メモリ 41,116 KB
平均クエリ数 36.83
最終ジャッジ日時 2023-09-24 00:28:36
合計ジャッジ時間 6,728 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 98 ms
40,744 KB
testcase_01 AC 96 ms
38,768 KB
testcase_02 AC 94 ms
39,232 KB
testcase_03 AC 99 ms
41,116 KB
testcase_04 AC 95 ms
40,400 KB
testcase_05 AC 103 ms
39,196 KB
testcase_06 AC 106 ms
39,064 KB
testcase_07 AC 106 ms
40,684 KB
testcase_08 AC 101 ms
38,628 KB
testcase_09 AC 99 ms
40,804 KB
testcase_10 AC 97 ms
39,084 KB
testcase_11 AC 91 ms
39,016 KB
testcase_12 AC 103 ms
38,804 KB
testcase_13 AC 106 ms
38,840 KB
testcase_14 AC 100 ms
39,072 KB
testcase_15 AC 101 ms
39,104 KB
testcase_16 AC 92 ms
38,896 KB
testcase_17 AC 91 ms
39,100 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

ソースコード

diff #

open System
open System.Collections.Generic

let ri () = stdin.ReadLine() |> int
let ria () = stdin.ReadLine().Split() |> Array.map int
let swap a b (xs:'t []) = 
    let tmp = xs.[a]
    xs.[a] <- xs.[b]
    xs.[b] <- tmp

type Sol() =
    member this.Solve() = 
        let N = ri ()
        let A = ria ()
        
        let L = new List<int*int> ()
        for i in 0..(N-2) do
            let m = A |> Array.skip i |> Array.min
            let trgt = A |> Array.skip i |> Array.findIndex ( (=) m ) |> (+) i
            
            //printfn "%s" (String.Join(" ",A))
            //printfn "min: %d" m
            //printfn "midx:%d" trgt
            
            
            if trgt <> i then (
                swap i trgt A ;
                L.Add(i,trgt)
            )
        
        L.Count |> printfn "%d"
        L |> Seq.iter (fun (a,b) -> printfn "%d %d" a b)
        
        let dummy = ri()
        ()
        
let mySol = new Sol()
mySol.Solve()
0