Submission #224826


Source Code Expand

using System;
using System.Collections.Generic;
using System.Linq;
class Problem
{
    void Solve()
    {
        var sc = new Scanner();
        var n = sc.Integer();
        sc.Separator = "-".ToCharArray();
        var l = new int[n];
        var r = new int[n];
        for (int i = 0; i < n; i++)
        {
            var p = sc.Integer();
            var pk = p/10;
            var pm = p % 10;
            if (pm < 5)
                pm = 0;
            else pm = 5;
            var q = sc.Integer();
            var qk = q / 10;
            var qm = q % 10;
            if (qm == 0)
            { }
            else if (qm < 5)
                qm = 5;
            else 
            {
                qm = 0;
                qk++;
                if (qk % 10 == 6)
                    qk += 4;
            }
            l[i] = pk * 10 + pm;
            r[i] = qk * 10 + qm;
        }
        var res = l.Zip(r, (u, v) => new { u, v }).OrderBy(x => x.u).ThenBy(x => x.v).ToArray();
        foreach(var x in res)
            System.Diagnostics.Debug.WriteLine("{0}-{1}",x.u,x.v);
        for (int i = 0; i < n; i++)
        {
            var left = res[i].u;
            var right = res[i].v;
            for (int j = i+1; j < n; j++)
            {
                if (right < res[j].u)
                {
                    i = j - 1;
                    break;
                }
                else right = Math.Max(res[j].v, right);
            }
            Console.WriteLine("{0}-{1}",left,right);
            if (right == res[n - 1].v)
                break;
        }


    }

    static void Main()
    {
        // For CodeForces
#if ONLINE_JUDGE
        System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("en-US");
#endif
#if DEBUG
        var ostream = new System.IO.FileStream("debug.txt", System.IO.FileMode.Open, System.IO.FileAccess.Write);
        var iStream = new System.IO.FileStream("input.txt", System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);
        Console.SetIn(new System.IO.StreamReader(iStream));
        System.Diagnostics.Debug.AutoFlush = true;
        System.Diagnostics.Debug.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(new System.IO.StreamWriter(ostream, System.Text.Encoding.UTF8)));
        try
        {
#endif
            var problem = new Problem();
            problem.Solve();
#if DEBUG
        }
        catch (Exception ex)
        {
            System.Diagnostics.Debug.WriteLine(Enumerable.Repeat('/', 50).AsString());
            System.Diagnostics.Debug.WriteLine(ex.Message);
            System.Diagnostics.Debug.WriteLine(ex.StackTrace);
            Console.Error.WriteLine("{0} occured", ex.GetType());
        }
        Console.ReadKey(true);
#endif
    }


}

public class Scanner
{
    readonly System.IO.TextReader reader;
    string[] buffer = new string[0];
    int position;

    public char[] Separator { get; set; }
    public Scanner(System.IO.TextReader reader = null, string separator = null)
    {
        if (reader == null)
            this.reader = Console.In;
        else
            this.reader = reader;
        if (string.IsNullOrEmpty(separator))
            separator = " ";
        this.Separator = separator.ToCharArray();

    }
    public string Scan()
    {
        if (this.position < this.buffer.Length)
            return this.buffer[this.position++];
        this.buffer = this.reader.ReadLine().Split(this.Separator, StringSplitOptions.RemoveEmptyEntries);
        this.position = 0;
        return this.buffer[this.position++];
    }

    public string[] ScanToEndLine()
    {
        if (this.position >= this.buffer.Length)
            return this.reader.ReadLine().Split(this.Separator, StringSplitOptions.RemoveEmptyEntries);
        var size = this.buffer.Length - this.position;
        var ar = new string[size];
        Array.Copy(this.buffer, position, ar, 0, size);
        return ar;

    }

    public string ScanLine()
    {
        if (this.position >= this.buffer.Length)
            return this.reader.ReadLine();
        else
        {
            var sb = new System.Text.StringBuilder();
            for (; this.position < buffer.Length; this.position++)
            {
                sb.Append(this.buffer[this.position]);
                sb.Append(' ');
            }
            return sb.ToString();
        }
    }
    public string[] ScanArray(int length)
    {
        var ar = new string[length];
        for (int i = 0; i < length; i++)
        {
            ar[i] = this.Scan();
        }
        return ar;
    }

    public int Integer()
    {
        return int.Parse(this.Scan());
    }
    public long Long()
    {
        return long.Parse(this.Scan());
    }
    public double Double()
    {
        return double.Parse(this.Scan());
    }

    public int[] IntArray(int length)
    {
        var a = new int[length];
        for (int i = 0; i < length; i++)
            a[i] = this.Integer();
        return a;
    }
    public long[] LongArray(int length)
    {
        var a = new long[length];
        for (int i = 0; i < length; i++)
            a[i] = this.Long();
        return a;
    }
    public double[] DoubleArray(int length)
    {
        var a = new double[length];
        for (int i = 0; i < length; i++)
            a[i] = this.Double();
        return a;
    }

}
static public partial class EnumerableEx
{
    static public string AsString(this IEnumerable<char> source)
    {
        return new string(source.ToArray());
    }
    static public IEnumerable<T> Enumerate<T>(this int count, Func<int, T> selector)
    {
        return Enumerable.Range(0, count).Select(x => selector(x));
    }
}

//*/

Submission Info

Submission Time
Task D - 感雨時刻の整理
User camypaper
Language C# (Mono 2.10.8.1)
Score 0
Code Size 5928 Byte
Status TLE
Exec Time 2038 ms
Memory 9288 KB

Judge Result

Set Name all
Score / Max Score 0 / 100
Status
AC × 2
WA × 43
TLE × 3
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 147 ms 6312 KB
00_sample_02.txt WA 138 ms 6276 KB
00_sample_03.txt AC 142 ms 6244 KB
cho_cho_chokudai.txt WA 200 ms 8724 KB
chokudai_ga_cho.txt WA 199 ms 8812 KB
test_01.txt WA 137 ms 6276 KB
test_02.txt WA 139 ms 6260 KB
test_03.txt WA 143 ms 6372 KB
test_04.txt WA 139 ms 6312 KB
test_05.txt WA 172 ms 6356 KB
test_06.txt WA 188 ms 6256 KB
test_07.txt WA 169 ms 6388 KB
test_08.txt WA 166 ms 6256 KB
test_09.txt WA 177 ms 6408 KB
test_10.txt WA 151 ms 6376 KB
test_11.txt WA 163 ms 6380 KB
test_12.txt WA 182 ms 6392 KB
test_13.txt WA 180 ms 6312 KB
test_14.txt WA 158 ms 6372 KB
test_15.txt WA 179 ms 6380 KB
test_16.txt WA 140 ms 6280 KB
test_17.txt WA 138 ms 6372 KB
test_18.txt WA 158 ms 6380 KB
test_19.txt WA 153 ms 6428 KB
test_20.txt WA 156 ms 6376 KB
test_21.txt WA 203 ms 8792 KB
test_22.txt WA 226 ms 8736 KB
test_23.txt WA 270 ms 8668 KB
test_24.txt WA 198 ms 8668 KB
test_25.txt WA 198 ms 8680 KB
test_26.txt WA 205 ms 8728 KB
test_27.txt WA 203 ms 8776 KB
test_28.txt WA 202 ms 8672 KB
test_29.txt WA 138 ms 6284 KB
test_30.txt WA 140 ms 6272 KB
test_31.txt WA 147 ms 6744 KB
test_32.txt WA 148 ms 6324 KB
test_33.txt WA 183 ms 8172 KB
test_34.txt WA 137 ms 6324 KB
test_35.txt WA 142 ms 6304 KB
test_36.txt WA 242 ms 8680 KB
test_37.txt WA 228 ms 8672 KB
test_38.txt WA 221 ms 8640 KB
test_39.txt WA 206 ms 8660 KB
test_40.txt WA 297 ms 9056 KB
test_41.txt TLE 2035 ms 8908 KB
test_42.txt TLE 2038 ms 9288 KB
test_43.txt TLE 2036 ms 8980 KB