結果
問題 | No.564 背の順 |
ユーザー | guricerin |
提出日時 | 2020-01-07 12:43:36 |
言語 | F# (F# 4.0) |
結果 |
AC
|
実行時間 | 88 ms / 2,000 ms |
コード長 | 1,237 bytes |
コンパイル時間 | 3,533 ms |
コンパイル使用メモリ | 167,644 KB |
実行使用メモリ | 25,216 KB |
最終ジャッジ日時 | 2023-08-14 23:14:24 |
合計ジャッジ時間 | 5,293 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 84 ms
23,196 KB |
testcase_01 | AC | 86 ms
25,116 KB |
testcase_02 | AC | 88 ms
25,144 KB |
testcase_03 | AC | 87 ms
25,124 KB |
testcase_04 | AC | 85 ms
23,084 KB |
testcase_05 | AC | 86 ms
23,252 KB |
testcase_06 | AC | 85 ms
25,140 KB |
testcase_07 | AC | 86 ms
23,008 KB |
testcase_08 | AC | 87 ms
23,028 KB |
testcase_09 | AC | 85 ms
23,152 KB |
testcase_10 | AC | 86 ms
25,216 KB |
testcase_11 | AC | 87 ms
23,212 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(19,9): warning FS0025: Incomplete pattern matches on this expression. For example, the value '[|_; _; _|]' may indicate a case not covered by the pattern(s).
ソースコード
open System open System.Collections.Generic [<AutoOpen>] module Cin = let read f = stdin.ReadLine() |> f let reada f = stdin.ReadLine().Split() |> Array.map f let readChars() = read string |> Seq.toArray let readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString())) [<AutoOpen>] module Cout = let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput())) let print (s: string) = writer.Write s let println (s: string) = writer.WriteLine s let inline puts (s: ^a) = string s |> println let solve() = let [| H; N |] = reada int let hs = Array.zeroCreate (N - 1) for i in 0 .. N - 2 do hs.[i] <- read int let hs = Array.append hs [| H |] |> Array.sort |> Array.rev seq { for i in 0 .. N - 1 do if H = hs.[i] then yield (i + 1) } |> Seq.head |> function | n when n % 10 = 1 -> sprintf "%dst" n | n when n % 10 = 2 -> sprintf "%dnd" n | n when n % 10 = 3 -> sprintf "%drd" n | n -> sprintf "%dth" n |> puts [<EntryPoint>] let main _ = try solve() with e -> printfn "%s" (e.ToString()) writer.Close() 0 // return an integer exit code