Submission #229562


Source Code Expand

using System;
using System.Collections.Generic;
using System.Linq;
class Problem
{
    void Solve()
    {
        var sc = new Scanner();
        var n = sc.Integer();
        var a = new long[n];
        var b = new long[n];
        for (int i = 0; i < n; i++)
        {
            a[i] = sc.Long();
            b[i] = sc.Long();
        }
        var c = new int[1000050];
        for (int i = 0; i < n; i++)
        {
            c[a[i]]++;
            c[b[i] + 1]--;
        }
        long max = 0;
        long sum = 0;
        for (int i = 0; i < c.Length; i++)
        {
            max = Math.Max(max, sum);
            sum += c[i];
        }
        Console.WriteLine(max);
       
    }
    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)
        {
            Console.Error.WriteLine(ex.Message);
            Console.WriteLine(ex.StackTrace);
        }
        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 C - AtColor
User camypaper
Language C# (Mono 2.10.8.1)
Score 100
Code Size 4821 Byte
Status AC
Exec Time 520 ms
Memory 15284 KB

Judge Result

Set Name Sample Subtask1 Subtask2
Score / Max Score 0 / 0 30 / 30 70 / 70
Status
AC × 2
AC × 17
AC × 42
Set Name Test Cases
Sample subtask0_sample01.txt, subtask0_sample02.txt
Subtask1 subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask0_sample01.txt, subtask0_sample02.txt
Subtask2 subtask0_sample01.txt, subtask0_sample02.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt, subtask2_13.txt, subtask2_14.txt, subtask2_15.txt, subtask2_16.txt, subtask2_17.txt, subtask2_18.txt, subtask2_19.txt, subtask2_20.txt, subtask2_21.txt, subtask2_22.txt, subtask2_23.txt, subtask2_24.txt, subtask2_25.txt
Case Name Status Exec Time Memory
subtask0_sample01.txt AC 130 ms 12372 KB
subtask0_sample02.txt AC 129 ms 12320 KB
subtask1_01.txt AC 130 ms 12320 KB
subtask1_02.txt AC 130 ms 12360 KB
subtask1_03.txt AC 136 ms 12580 KB
subtask1_04.txt AC 133 ms 12600 KB
subtask1_05.txt AC 131 ms 12600 KB
subtask1_06.txt AC 131 ms 12584 KB
subtask1_07.txt AC 129 ms 12580 KB
subtask1_08.txt AC 129 ms 12580 KB
subtask1_09.txt AC 520 ms 12580 KB
subtask1_10.txt AC 139 ms 12596 KB
subtask1_11.txt AC 138 ms 12600 KB
subtask1_12.txt AC 134 ms 12644 KB
subtask1_13.txt AC 134 ms 12600 KB
subtask1_14.txt AC 132 ms 12640 KB
subtask1_15.txt AC 140 ms 12600 KB
subtask2_01.txt AC 219 ms 15140 KB
subtask2_02.txt AC 242 ms 15284 KB
subtask2_03.txt AC 217 ms 15200 KB
subtask2_04.txt AC 239 ms 15204 KB
subtask2_05.txt AC 231 ms 15236 KB
subtask2_06.txt AC 243 ms 15188 KB
subtask2_07.txt AC 246 ms 15204 KB
subtask2_08.txt AC 244 ms 15204 KB
subtask2_09.txt AC 245 ms 15212 KB
subtask2_10.txt AC 247 ms 15204 KB
subtask2_11.txt AC 251 ms 15204 KB
subtask2_12.txt AC 243 ms 15148 KB
subtask2_13.txt AC 241 ms 15268 KB
subtask2_14.txt AC 445 ms 15164 KB
subtask2_15.txt AC 251 ms 15256 KB
subtask2_16.txt AC 260 ms 15268 KB
subtask2_17.txt AC 247 ms 15204 KB
subtask2_18.txt AC 245 ms 15204 KB
subtask2_19.txt AC 254 ms 15204 KB
subtask2_20.txt AC 252 ms 15204 KB
subtask2_21.txt AC 245 ms 15204 KB
subtask2_22.txt AC 242 ms 15200 KB
subtask2_23.txt AC 329 ms 15204 KB
subtask2_24.txt AC 251 ms 15160 KB
subtask2_25.txt AC 243 ms 15260 KB