結果

問題 No.70 睡眠の重要性!
ユーザー cccccc
提出日時 2022-09-08 11:40:12
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 56 ms / 5,000 ms
コード長 1,084 bytes
コンパイル時間 14,304 ms
コンパイル使用メモリ 146,232 KB
実行使用メモリ 164,608 KB
最終ジャッジ日時 2023-08-15 20:30:58
合計ジャッジ時間 15,340 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
31,044 KB
testcase_01 AC 56 ms
28,944 KB
testcase_02 AC 56 ms
29,080 KB
testcase_03 AC 56 ms
29,264 KB
testcase_04 AC 56 ms
28,892 KB
testcase_05 AC 55 ms
164,608 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  Determining projects to restore...
  Restored /home/judge/data/code/main.csproj (in 144 ms).
.NET 向け Microsoft (R) Build Engine バージョン 17.0.0-preview-21470-01+cb055d28f
Copyright (C) Microsoft Corporation.All rights reserved.

  プレビュー版の .NET を使用しています。https://aka.ms/dotnet-core-preview をご覧ください
  main -> /home/judge/data/code/bin/Release/net6.0/main.dll
  main -> /home/judge/data/code/bin/Release/net6.0/publish/

ソースコード

diff #

using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;


class Program
{
    static void Main()
    {
        /*3
          22:24 5:9
          22:46 5:37
          1:11 7:11
        */

        int N = int.Parse(Console.ReadLine());
        string[] HMhm;
        int[] hm;

        TimeSpan time, sTime, eTime;
        int sleepTime = 0;

        for ( int i = 0; i < N; i++)
        {
            // 睡眠時間を取得
            HMhm = Console.ReadLine().Split(' ');
            
            // 就寝時間を取得
            hm = HMhm[0].Split(':').Select(int.Parse).ToArray();
            sTime = new TimeSpan(hm[0], hm[1], 0);

            // 起床時間を取得
            hm = HMhm[1].Split(':').Select(s => int.Parse(s)).ToArray();
            eTime = new TimeSpan(hm[0], hm[1], 0);

            time = (eTime - sTime < new TimeSpan(0, 0, 0) ? eTime - sTime + new TimeSpan(24, 0, 0) : eTime - sTime);

            sleepTime += time.Hours * 60 + time.Minutes;
        }
        Console.WriteLine(sleepTime);
    }
}
0