Submission #169069


Source Code Expand

Copy
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;
class Program
{
    static void Main()
    {
        var sc = new Scanner();
        var n = sc.Integer();
        var dic = new Dictionary<string, int>(n);
        var s = sc.ScanArray(n);
        foreach (var t in s)
        {
            if (dic.ContainsKey(t))
                dic[t]++;
            else dic.Add(t, 1);
        }
        var ans = dic.Aggregate((x, y) => (x.Value > y.Value) ? x : y);
        Console.WriteLine(ans.Key);
        
    }


}

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

    public char[] Separator { get; set; }
    public Scanner(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 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.ToArray();
    }
    public long[] LongArray(int length)
    {
        var a = new long[length];
        for (int i = 0; i < length; i++)
            a[i] = this.Long();
        return a.ToArray();
    }
    public double[] DoubleArray(int length)
    {
        var a = new double[length];
        for (int i = 0; i < length; i++)
            a[i] = this.Double();
        return a.ToArray();
    }

}
static public partial class EnumerableEx
{
    static public string AsString(this IEnumerable<char> source)
    {
        return new string(source.ToArray());
    }
}
//*/

Submission Info

Submission Time
Task B - 投票
User camypaper
Language C# (Mono 2.10.8.1)
Score 100
Code Size 3522 Byte
Status AC
Exec Time 571 ms
Memory 8404 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 3
AC × 18
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, case_01.txt, case_02.txt, case_03.txt, case_04.txt, case_05.txt, case_06.txt, case_07.txt, case_08.txt, case_09.txt, case_10.txt, case_11.txt, case_12.txt, case_13.txt, case_14.txt, case_15.txt
Case Name Status Exec Time Memory
case_01.txt AC 152 ms 8344 KB
case_02.txt AC 571 ms 8336 KB
case_03.txt AC 150 ms 8388 KB
case_04.txt AC 147 ms 8336 KB
case_05.txt AC 148 ms 8344 KB
case_06.txt AC 154 ms 8400 KB
case_07.txt AC 145 ms 8340 KB
case_08.txt AC 153 ms 8388 KB
case_09.txt AC 155 ms 8404 KB
case_10.txt AC 183 ms 8360 KB
case_11.txt AC 155 ms 8340 KB
case_12.txt AC 149 ms 8340 KB
case_13.txt AC 144 ms 8344 KB
case_14.txt AC 146 ms 8340 KB
case_15.txt AC 146 ms 8400 KB
sample_01.txt AC 146 ms 8340 KB
sample_02.txt AC 151 ms 8332 KB
sample_03.txt AC 151 ms 8328 KB