結果

問題 No.70 睡眠の重要性!
コンテスト
ユーザー ccc
提出日時 2022-09-08 11:40:23
言語 C#
(.NET 10.0.201)
コンパイル:
dotnet_c
実行:
/usr/bin/dotnet_wrap
結果
AC  
実行時間 73 ms / 5,000 ms
コード長 1,084 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 6,583 ms
コンパイル使用メモリ 173,392 KB
実行使用メモリ 194,744 KB
最終ジャッジ日時 2026-05-18 03:00:39
合計ジャッジ時間 7,753 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 6
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (94 ミリ秒)。
  main -> /home/judge/data/code/bin/Release/net10.0/main.dll
  main -> /home/judge/data/code/bin/Release/net10.0/publish/

ソースコード

diff #
raw source code

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