結果

問題 No.70 睡眠の重要性!
ユーザー guriceringuricerin
提出日時 2020-01-10 12:32:01
言語 F#
(F# 4.0)
結果
AC  
実行時間 64 ms / 5,000 ms
コード長 1,199 bytes
コンパイル時間 3,547 ms
コンパイル使用メモリ 164,668 KB
実行使用メモリ 24,524 KB
最終ジャッジ日時 2023-08-15 14:23:17
合計ジャッジ時間 4,764 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
22,496 KB
testcase_01 AC 63 ms
22,488 KB
testcase_02 AC 63 ms
22,436 KB
testcase_03 AC 64 ms
22,380 KB
testcase_04 AC 64 ms
24,524 KB
testcase_05 AC 64 ms
24,516 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

[<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 toM h = h * 60

let limit = toM 24

let f (s: string array) =
    let hm1 = s
    let h1, m1 = Convert.ToInt32(hm1.[0]), Convert.ToInt32(hm1.[1])
    m1 + toM h1

let solve() =
    let n = read int
    let mutable ans = 0
    for i in 0 .. n - 1 do
        let s = reada string |> Array.map (fun x -> x.Split(':'))

        let hm1 = f s.[0]
        let hm2 = f s.[1]
        if hm1 <= hm2 then ans <- ans + (hm2 - hm1) else ans <- ans + (limit - hm1) + hm2

    puts ans
    ()

[<EntryPoint>]
let main _ =
    try
        solve()
    with e -> printfn "%s" (e.ToString())
    writer.Close()
    0 // return an integer exit code
0