Submission #591366


Source Code Expand

using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;


class Program
{
    public void Proc()
    {
        int count = int.Parse(Console.ReadLine());
        List<Memo> readed = new List<Memo>();
        for (int i = 0; i < count; i++)
        {
            readed.Add(new Memo(Console.ReadLine()));
        }

        foreach (Memo mem in readed)
        {
            this.Proc(mem);
        }


        this.MemoList.Sort((a, b) =>
        {
            if (a.Start < b.Start)
            {
                return -1;
            }
            else
            {
                return 1;
            }
        });

        foreach (Memo mem in this.MemoList)
        {
            Console.WriteLine(mem.Start.ToString("0000") + "-" + mem.End.ToString("0000"));
        }



    }

    private List<Memo> MemoList = new List<Memo>();

    private void Proc(Memo newMemo)
    {
        bool mustAdd = true;

        for (int i = MemoList.Count - 1; i >= 0; i--)
        {
            if (MemoList[i].Start <= newMemo.Start && newMemo.Start <= MemoList[i].End)
            {
                if (MemoList[i].Start <= newMemo.End && newMemo.End <= MemoList[i].End)
                {
                    // 含まれるケース
                    mustAdd = false;
                    break;
                }
                else
                {
                    // start が被るケース
                    newMemo.Start = MemoList[i].Start;
                    MemoList.RemoveAt(i);
                }
            }
            else if (this.MemoList[i].Start <= newMemo.End && newMemo.End <= this.MemoList[i].End)
            {
                // end が被るケース
                newMemo.End = this.MemoList[i].End;
                this.MemoList.RemoveAt(i);
            }
            else if (newMemo.Start <= this.MemoList[i].Start && this.MemoList[i].End <= newMemo.End)
            {
                // 含むケース
                this.MemoList.RemoveAt(i);
            }
        }
        if (mustAdd)
        {
            this.MemoList.Add(newMemo);
        }
    }

    public class Memo
    {
        public int Start;
        public int End;
        public Memo(string inputStr)
        {
            string[] tmp = inputStr.Split('-');
            int startH = int.Parse(tmp[0].Substring(0, 2));
            int startM = int.Parse(tmp[0].Substring(2));
            int endH = int.Parse(tmp[1].Substring(0,2));
            int endM = int.Parse(tmp[1].Substring(2));

            startM = startM - (startM % 5);

            if (endM % 5 > 0)
            {
                endM = endM + (5 - (endM % 5));
                if (endM >= 60) {
                    endH++;
                    endM = 0;
                }
            }

            this.Start = (startH * 100) + startM;
            this.End = (endH * 100) + endM;
        }

        

    }


    static void Main(string[] args)
    {
        Program prg = new Program();
        prg.Proc();
    }
}

Submission Info

Submission Time
Task D - 感雨時刻の整理
User mellotron
Language C# (Mono 2.10.8.1)
Score 100
Code Size 3148 Byte
Status AC
Exec Time 191 ms
Memory 9648 KB

Judge Result

Set Name all
Score / Max Score 100 / 100
Status
AC × 48
Set Name Test Cases
all 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, cho_cho_chokudai.txt, chokudai_ga_cho.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt, test_37.txt, test_38.txt, test_39.txt, test_40.txt, test_41.txt, test_42.txt, test_43.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 120 ms 7956 KB
00_sample_02.txt AC 119 ms 7904 KB
00_sample_03.txt AC 119 ms 8012 KB
cho_cho_chokudai.txt AC 173 ms 9568 KB
chokudai_ga_cho.txt AC 173 ms 9572 KB
test_01.txt AC 122 ms 8028 KB
test_02.txt AC 121 ms 8076 KB
test_03.txt AC 122 ms 8048 KB
test_04.txt AC 121 ms 8096 KB
test_05.txt AC 123 ms 8120 KB
test_06.txt AC 120 ms 8012 KB
test_07.txt AC 132 ms 7996 KB
test_08.txt AC 121 ms 7996 KB
test_09.txt AC 120 ms 8016 KB
test_10.txt AC 121 ms 8072 KB
test_11.txt AC 120 ms 8076 KB
test_12.txt AC 120 ms 8000 KB
test_13.txt AC 120 ms 8020 KB
test_14.txt AC 122 ms 8076 KB
test_15.txt AC 123 ms 8080 KB
test_16.txt AC 122 ms 7932 KB
test_17.txt AC 126 ms 8096 KB
test_18.txt AC 120 ms 7960 KB
test_19.txt AC 121 ms 8052 KB
test_20.txt AC 119 ms 8016 KB
test_21.txt AC 171 ms 9532 KB
test_22.txt AC 172 ms 9528 KB
test_23.txt AC 173 ms 9560 KB
test_24.txt AC 171 ms 9556 KB
test_25.txt AC 171 ms 9536 KB
test_26.txt AC 174 ms 9596 KB
test_27.txt AC 172 ms 9580 KB
test_28.txt AC 183 ms 9528 KB
test_29.txt AC 119 ms 7992 KB
test_30.txt AC 120 ms 7920 KB
test_31.txt AC 131 ms 8364 KB
test_32.txt AC 119 ms 7976 KB
test_33.txt AC 162 ms 9272 KB
test_34.txt AC 118 ms 7948 KB
test_35.txt AC 119 ms 8068 KB
test_36.txt AC 171 ms 9548 KB
test_37.txt AC 191 ms 9620 KB
test_38.txt AC 173 ms 9648 KB
test_39.txt AC 177 ms 9648 KB
test_40.txt AC 177 ms 9596 KB
test_41.txt AC 171 ms 9552 KB
test_42.txt AC 172 ms 9540 KB
test_43.txt AC 172 ms 9568 KB