Submission #285408


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;
                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}-{1}", 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
#region HashMap
class HashMap<K, V> : Dictionary<K, V>
{
    new public V this[K i]
    {
        get
        {
            V v;
            return TryGetValue(i, out v) ? v : base[i] = default(V);
        }
        set { base[i] = value; }
    }
}
#endregion

Submission Info

Submission Time
Task D - 感雨時刻の整理
User camypaper
Language C# (Mono 2.10.8.1)
Score 0
Code Size 8877 Byte
Status WA
Exec Time 211 ms
Memory 7220 KB

Judge Result

Set Name all
Score / Max Score 0 / 100
Status
AC × 2
WA × 46
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 130 ms 6692 KB
00_sample_02.txt WA 125 ms 6676 KB
00_sample_03.txt AC 129 ms 6712 KB
cho_cho_chokudai.txt WA 187 ms 7200 KB
chokudai_ga_cho.txt WA 187 ms 7192 KB
test_01.txt WA 130 ms 6740 KB
test_02.txt WA 128 ms 6728 KB
test_03.txt WA 130 ms 6740 KB
test_04.txt WA 130 ms 6824 KB
test_05.txt WA 129 ms 6724 KB
test_06.txt WA 129 ms 6780 KB
test_07.txt WA 127 ms 6744 KB
test_08.txt WA 128 ms 6724 KB
test_09.txt WA 130 ms 6884 KB
test_10.txt WA 132 ms 6820 KB
test_11.txt WA 130 ms 6808 KB
test_12.txt WA 130 ms 6776 KB
test_13.txt WA 128 ms 6816 KB
test_14.txt WA 130 ms 6820 KB
test_15.txt WA 130 ms 6772 KB
test_16.txt WA 132 ms 6760 KB
test_17.txt WA 138 ms 6836 KB
test_18.txt WA 131 ms 6768 KB
test_19.txt WA 134 ms 6824 KB
test_20.txt WA 129 ms 6796 KB
test_21.txt WA 196 ms 7208 KB
test_22.txt WA 193 ms 7200 KB
test_23.txt WA 202 ms 7204 KB
test_24.txt WA 193 ms 7184 KB
test_25.txt WA 196 ms 7208 KB
test_26.txt WA 191 ms 7208 KB
test_27.txt WA 191 ms 7220 KB
test_28.txt WA 211 ms 7176 KB
test_29.txt WA 127 ms 6664 KB
test_30.txt WA 130 ms 6696 KB
test_31.txt WA 141 ms 6896 KB
test_32.txt WA 130 ms 6688 KB
test_33.txt WA 170 ms 6936 KB
test_34.txt WA 129 ms 6672 KB
test_35.txt WA 129 ms 6824 KB
test_36.txt WA 195 ms 7216 KB
test_37.txt WA 194 ms 7196 KB
test_38.txt WA 194 ms 7212 KB
test_39.txt WA 193 ms 7196 KB
test_40.txt WA 195 ms 7204 KB
test_41.txt WA 184 ms 7180 KB
test_42.txt WA 194 ms 7204 KB
test_43.txt WA 187 ms 7188 KB