結果
| 問題 | No.70 睡眠の重要性! | 
| コンテスト | |
| ユーザー |  明智重蔵 | 
| 提出日時 | 2015-08-08 05:36:42 | 
| 言語 | C#(csc) (csc 3.9.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 27 ms / 5,000 ms | 
| コード長 | 2,791 bytes | 
| コンパイル時間 | 981 ms | 
| コンパイル使用メモリ | 112,748 KB | 
| 実行使用メモリ | 19,328 KB | 
| 最終ジャッジ日時 | 2024-07-18 05:49:59 | 
| 合計ジャッジ時間 | 1,646 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 6 | 
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    static string InputPattern = "Input3";
    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();
        if (InputPattern == "Input1") {
            WillReturn.Add("3");
            WillReturn.Add("22:24 5:9");
            WillReturn.Add("22:46 5:37");
            WillReturn.Add("1:11 7:11");
            //1176
            //それぞれ、6時間45分 / 6時間51分 / 6時間0分の睡眠なので、
            //合計で19時間36分です。
            //これを分単位に直すと1176分となります。
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("5");
            WillReturn.Add("22:30 4:30");
            WillReturn.Add("22:46 4:46");
            WillReturn.Add("1:17 7:26");
            WillReturn.Add("0:38 7:0");
            WillReturn.Add("23:49 7:41");
            //1943
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }
    struct PairTimeDef
    {
        internal int StaH;
        internal int StaM;
        internal int EndH;
        internal int EndM;
    }
    static void Main()
    {
        List<string> InputList = GetInputList();
        var PairTimeList = new List<PairTimeDef>();
        foreach (string EachStr in InputList.Skip(1)) {
            string[] wkArr = EachStr.Split(' ', ':');
            PairTimeDef WillAdd;
            WillAdd.StaH = int.Parse(wkArr[0]);
            WillAdd.StaM = int.Parse(wkArr[1]);
            WillAdd.EndH = int.Parse(wkArr[2]);
            WillAdd.EndM = int.Parse(wkArr[3]);
            PairTimeList.Add(WillAdd);
        }
        Console.WriteLine(DeriveSum(PairTimeList));
    }
    //合計睡眠時間を求める
    static int DeriveSum(List<PairTimeDef> pPairTimeList)
    {
        int WillReturn = 0;
        foreach (PairTimeDef EachPairTime in pPairTimeList) {
            int StaKeikaMinute = DeriveKeikaMinute(EachPairTime.StaH, EachPairTime.StaM);
            int EndKeikaMinute = DeriveKeikaMinute(EachPairTime.EndH, EachPairTime.EndM);
            //Sta <= End の場合は、24時をまたいでいない
            if (StaKeikaMinute <= EndKeikaMinute) {
                WillReturn += EndKeikaMinute - StaKeikaMinute;
                continue;
            }
            //Sta > End の場合は、24時をまたいだ対応
            WillReturn += 24 * 60 - StaKeikaMinute;
            WillReturn += EndKeikaMinute;
        }
        return WillReturn;
    }
    //0時0分からの経過分数を求める
    static int DeriveKeikaMinute(int pH, int pM)
    {
        return pH * 60 + pM;
    }
}
            
            
            
        