Submission #285411


Source Code Expand

using System;
using System.Collections.Generic;
using System.Linq;
using Solver.Ex;
using Debug = System.Diagnostics.Debug;
using Watch = System.Diagnostics.Stopwatch;
using StringBuilder = System.Text.StringBuilder;
using System.Numerics;
namespace Solver
{

    public class Solver
    {
        struct Pair
        {
            public int from, to;
            public Pair(int f, int t) : this() { from = f; to = t; }
        }
        public void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var P = new Pair[N];
            for (int i = 0; i < N; i++)
            {
                var a = Console.ReadLine().Split('-').Select(x => int.Parse(x)).ToArray();
                if (a[0] % 10 < 5)
                    a[0] = (a[0] / 10) * 10;
                else a[0] = (a[0] / 10) * 10 + 5;
                if (a[1] % 10 > 5)
                    a[1] = ((a[1] / 10) + 1) * 10;
                else if (a[1] % 10 > 0)
                    a[1] = (a[1] / 10) * 10 + 5;
                if (a[1] % 100 == 60)
                    a[1] = ((a[1] / 100) + 1) * 100;
                P[i] = new Pair(a[0], a[1]);
            }
            Array.Sort(P, (l, r) => l.from.CompareTo(r.from));
            int id = 0;
            while (id < N)
            {
                var s = P[id].from;
                var e = P[id].to;
                int j = id;
                while (j < N && P[j].from <= e)
                {
                    e = Math.Max(P[j].to, e);
                    j++;
                }
                id = Math.Max(id + 1, j);
                IO.Printer.Out.WriteLine("{0:D4}-{1:D4}", s, e);

            }


        }


        internal IO.StreamScanner sc;
        static T[] Enumerate<T>(int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; i++) a[i] = f(i); return a; }
    }

    #region Main and Settings
    static class Program
    {
        static void Main(string[] arg)
        {
#if DEBUG
            var errStream = new System.IO.FileStream(@"..\..\dbg.out", System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite);
            Debug.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(errStream, "debugStream"));
            Debug.AutoFlush = false;
            var sw = new Watch(); sw.Start();
            IO.Printer.Out.AutoFlush = true;
            try
            {
#endif

                var solver = new Solver();
                solver.sc = new IO.StreamScanner(Console.OpenStandardInput());
                solver.Solve();
                IO.Printer.Out.Flush();
#if DEBUG
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
                Console.Error.WriteLine(ex.StackTrace);
            }
            finally
            {
                sw.Stop();
                Console.ForegroundColor = ConsoleColor.Green;
                Console.Error.WriteLine("Time:{0}ms", sw.ElapsedMilliseconds);
                Debug.Close();
                System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
            }
#endif
        }


    }
    #endregion
}

#region IO Helper
namespace Solver.IO
{
    public class Printer : System.IO.StreamWriter
    {
        static Printer()
        {
            Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false };
#if DEBUG
            Error = new Printer(Console.OpenStandardError()) { AutoFlush = true };
#else
            Error = new Printer(System.IO.Stream.Null) { AutoFlush = false };
#endif
        }
        public static Printer Out { get; set; }
        public static Printer Error { get; set; }
        public override IFormatProvider FormatProvider { get { return System.Globalization.CultureInfo.InvariantCulture; } }
        public Printer(System.IO.Stream stream) : base(stream, new System.Text.UTF8Encoding(false, true)) { }
        public Printer(System.IO.Stream stream, System.Text.Encoding encoding) : base(stream, encoding) { }
        public void Write<T>(string format, IEnumerable<T> source) { Write(format, source.OfType<object>().ToArray()); }
        public void WriteLine<T>(string format, IEnumerable<T> source) { WriteLine(format, source.OfType<object>().ToArray()); }
    }
    public class StreamScanner
    {
        public StreamScanner(System.IO.Stream stream) { iStream = stream; }
        private readonly System.IO.Stream iStream;
        private readonly byte[] buf = new byte[1024];
        private int len, ptr;
        private bool eof = false;
        public bool IsEndOfStream { get { return eof; } }
        const byte lb = 33, ub = 126, el = 10, cr = 13;
        public byte read()
        {
            if (eof) throw new System.IO.EndOfStreamException();
            if (ptr >= len) { ptr = 0; if ((len = iStream.Read(buf, 0, 1024)) <= 0) { eof = true; return 0; } }
            return buf[ptr++];
        }
        public char Char() { byte b = 0; do b = read(); while (b < lb || ub < b);            return (char)b; }
        public char[] Char(int n) { var a = new char[n]; for (int i = 0; i < n; i++) a[i] = Char(); return a; }
        public char[][] Char(int n, int m) { var a = new char[n][]; for (int i = 0; i < n; i++) a[i] = Char(m); return a; }
        public string Scan()
        {
            if (eof) throw new System.IO.EndOfStreamException();
            StringBuilder sb = null;
            var enc = System.Text.UTF8Encoding.Default;
            do
            {
                for (; ptr < len && (buf[ptr] < lb || ub < buf[ptr]); ptr++) ;
                if (ptr < len) break;
                ptr = 0;
                if ((len = iStream.Read(buf, 0, 1024)) <= 0) { eof = true; return ""; }
            } while (true);
            do
            {
                var f = ptr;
                for (; ptr < len; ptr++)
                    if (buf[ptr] < lb || ub < buf[ptr])
                    //if (buf[ptr] == cr || buf[ptr] == el)
                    {
                        string s;
                        if (sb == null) s = enc.GetString(buf, f, ptr - f);
                        else { sb.Append(enc.GetChars(buf, f, ptr - f)); s = sb.ToString(); }
                        ptr++; return s;
                    }
                if (sb == null) sb = new StringBuilder(enc.GetString(buf, f, len - f));
                else sb.Append(enc.GetChars(buf, f, len - f));
                ptr = 0;

            }
            while (!eof && (len = iStream.Read(buf, 0, 1024)) > 0);
            eof = true; return (sb != null) ? sb.ToString() : "";
        }
        public long Long()
        {
            long ret = 0; byte b = 0; bool isMynus = false;
            const byte zr = 48, nn = 57, my = 45;
            do b = read();
            while (b != my && (b < zr || nn < b));
            if (b == my) { isMynus = true; b = read(); }
            for (; true; b = read())
                if (b < zr || nn < b)
                    return isMynus ? -ret : ret;
                else ret = ret * 10 + b - zr;
        }
        public int Integer()
        {
            int ret = 0; byte b = 0; bool isMynus = false;
            const byte zr = 48, nn = 57, my = 45;
            do b = read();
            while (b != my && (b < zr || nn < b));
            if (b == my) { isMynus = true; b = read(); }
            for (; true; b = read())
                if (b < zr || nn < b)
                    return isMynus ? -ret : ret;
                else ret = ret * 10 + b - zr;
        }
        public double Double() { return double.Parse(Scan(), System.Globalization.CultureInfo.InvariantCulture); }
        public string[] Scan(int n) { var a = new string[n]; for (int i = 0; i < n; i++) a[i] = Scan(); return a; }
        public double[] Double(int n) { var a = new double[n]; for (int i = 0; i < n; i++) a[i] = Double(); return a; }
        public int[] Integer(int n) { var a = new int[n]; for (int i = 0; i < n; i++) a[i] = Integer(); return a; }
        public long[] Long(int n) { var a = new long[n]; for (int i = 0; i < n; i++)a[i] = Long(); return a; }
        public void Flush() { iStream.Flush(); }
    }
}
#endregion
#region Extension
namespace Solver.Ex
{
    static public partial class EnumerableEx
    {
        static public string AsString(this IEnumerable<char> ie) { return new string(ie.ToArray()); }
        static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") { return string.Join(st, ie); }
    }
}
#endregion

Submission Info

Submission Time
Task D - 感雨時刻の整理
User camypaper
Language C# (Mono 2.10.8.1)
Score 100
Code Size 8704 Byte
Status AC
Exec Time 241 ms
Memory 9528 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 163 ms 8932 KB
00_sample_02.txt AC 161 ms 8968 KB
00_sample_03.txt AC 165 ms 8952 KB
cho_cho_chokudai.txt AC 224 ms 9448 KB
chokudai_ga_cho.txt AC 227 ms 9528 KB
test_01.txt AC 164 ms 9020 KB
test_02.txt AC 162 ms 9056 KB
test_03.txt AC 165 ms 9040 KB
test_04.txt AC 165 ms 8956 KB
test_05.txt AC 163 ms 9060 KB
test_06.txt AC 164 ms 9088 KB
test_07.txt AC 164 ms 8976 KB
test_08.txt AC 164 ms 8996 KB
test_09.txt AC 165 ms 9088 KB
test_10.txt AC 164 ms 9068 KB
test_11.txt AC 164 ms 9032 KB
test_12.txt AC 167 ms 9020 KB
test_13.txt AC 171 ms 9048 KB
test_14.txt AC 170 ms 9136 KB
test_15.txt AC 166 ms 9012 KB
test_16.txt AC 162 ms 8992 KB
test_17.txt AC 169 ms 9060 KB
test_18.txt AC 168 ms 9004 KB
test_19.txt AC 166 ms 9052 KB
test_20.txt AC 166 ms 9000 KB
test_21.txt AC 227 ms 9416 KB
test_22.txt AC 230 ms 9460 KB
test_23.txt AC 241 ms 9480 KB
test_24.txt AC 225 ms 9476 KB
test_25.txt AC 228 ms 9424 KB
test_26.txt AC 230 ms 9468 KB
test_27.txt AC 227 ms 9472 KB
test_28.txt AC 229 ms 9404 KB
test_29.txt AC 162 ms 8968 KB
test_30.txt AC 165 ms 8984 KB
test_31.txt AC 176 ms 9136 KB
test_32.txt AC 165 ms 8932 KB
test_33.txt AC 208 ms 9252 KB
test_34.txt AC 160 ms 8924 KB
test_35.txt AC 163 ms 9096 KB
test_36.txt AC 227 ms 9476 KB
test_37.txt AC 230 ms 9432 KB
test_38.txt AC 227 ms 9472 KB
test_39.txt AC 230 ms 9488 KB
test_40.txt AC 225 ms 9472 KB
test_41.txt AC 222 ms 9464 KB
test_42.txt AC 227 ms 9420 KB
test_43.txt AC 220 ms 9424 KB