Submission #2227731


Source Code Expand

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

using static System.Console;
using static AtCoder.Util;
using static AtCoder.Cin;
using static System.Math;

namespace AtCoder {
    class Program {

        struct City : IComparable<City> {
            public string Name;
            public int Population;

            public City(string name, int population) {
                Name = name;
                Population = population;
            }

            public int CompareTo(City other) => 
                this.Population.CompareTo(other.Population);
        }

        static void Main() {
            var n = ReadInt();
            var subs = new List<City>();
            var cities = Range(0, n).Select(_ => {
                var name = ReadString();
                var population = ReadInt();
                return new City(name, population);
            }).ToList();
            var sum = cities.Sum(c=>c.Population);
            var bigCity = cities.Max();
            (bigCity.Population / (double) sum > 0.5 ?
                bigCity.Name : "atcoder").WriteLine();
        }
    }
}
/* ***************** Following Contents are my common library ******** */

namespace AtCoder {
    static class Util {
        public static T debug<T>(this T value) {
            Console.Error.WriteLine($"debug:{value}");
            return value;
        }

        public static long ToLong(this String s) => long.Parse(s);
        public static long ToLong(this char c) => c - '0';
        public static int ToInt(this String s) => int.Parse(s);
        public static int ToInt(this char c) => c - '0';
        public static void Times(this int n, Action action) {
            for (int i = 0; i < n; i++) action();
        }
        public static void Times(this long n, Action action) {
            for (long i = 0; i < n; i++) action();
        }
        public static void Call<T>(this T t, Action<T> action) => action(t);
        public static bool In<T>(this T t, IEnumerable<T> range) =>
            range.Contains(t);
        public static void WriteLine<T>(this T t) => Console.WriteLine(t);
        public static T Call<S, T>(this S s, Func<S, T> func) => func(s);
        public static void Each<T>(this IEnumerable<T> e, Action<T> action) {
            foreach (var v in e) action(v);
        }

        public static VectorInt2 ReadVectorInt2() => 
            new VectorInt2(ReadInt(), ReadInt());

        public static string ReplaceX(this string input, string pattern, string replace) =>
            Regex.Replace(input, pattern, replace);

        public static IEnumerable<int> Range(int i, int j) => Enumerable.Range(i, j);
        public static void Swap<T>(this IList<T> enumerable, int i, int j) {
            var buf = enumerable[i];
            enumerable[i] = enumerable[j];
            enumerable[j] = buf;

        }
        public static void ReverseRange<T>(this IList<T> enumerable, int i, int j) {
            int half = (j - i) / 2;
            for (int k = 0; k <= half; k++) enumerable.Swap(i + k, j - k);
        }
        
        public static bool isEmpty<T>(this IEnumerable<T> enumerable) => !enumerable.Any();
    }

    static class Cin {
        private static Queue<string> tokens;
        static Cin () {
            string line;
            tokens = new Queue<string> ();
            while ((line = Console.ReadLine ()) != null) {
                foreach (var token in line.Split (' ')) {
                    tokens.Enqueue (token);
                }
            }
        }

        static public int ReadInt() => int.Parse(tokens.Dequeue());
        static public IEnumerable<int> ReadInt(long n) {
            var list = new List<int>();
            for (int i = 0; i < n; i++) list.Add(ReadInt());
            return list;
        }
        static public long ReadLong() => long.Parse(tokens.Dequeue());
        static public IEnumerable<long> ReadLong(long n) {
            for (int i = 0; i < n; i++) yield return ReadLong();
        }
        static public string ReadString() => tokens.Dequeue();
        static public IEnumerable<string> ReadString(long n) {
            for (int i = 0; i < n; i++) yield return ReadString();
        }
    }

    struct VectorInt2 {
        public int X { get; set; }
        public int Y { get; set; }

        public VectorInt2(int x, int y) {
            X = x; Y = y;
        }

        static public VectorInt2 operator+ (VectorInt2 v1, VectorInt2 v2) =>
            new VectorInt2(v1.X + v2.X, v1.Y + v2.Y);
        static public VectorInt2 operator- (VectorInt2 v1, VectorInt2 v2) =>
            new VectorInt2(v1.X - v2.X, v1.Y - v2.Y);
        static public VectorInt2 operator* (VectorInt2 v1, VectorInt2 v2) =>
            new VectorInt2(v1.X * v2.X, v1.Y * v2.Y);
        static public VectorInt2 operator* (VectorInt2 v1, int i) =>
            new VectorInt2(v1.X * i, v1.Y * i);
        static public VectorInt2 operator* (int i, VectorInt2 v2) =>
            new VectorInt2(i * v2.X, i * v2.Y);
        static public VectorInt2 operator/ (VectorInt2 v1, int i) =>
            new VectorInt2(v1.X / i, v1.Y / i);
    }
}

Submission Info

Submission Time
Task B - 町の合併
User yuchiki
Language C# (Mono 4.6.2.0)
Score 100
Code Size 5327 Byte
Status AC
Exec Time 32 ms
Memory 13652 KB

Judge Result

Set Name sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 3
AC × 36
Set Name Test Cases
sample sample-01.txt, sample-02.txt, sample-03.txt
All 00.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, sample-01.txt, sample-02.txt, sample-03.txt, sample-01.txt, sample-02.txt, sample-03.txt
Case Name Status Exec Time Memory
00.txt AC 31 ms 9428 KB
01.txt AC 31 ms 13652 KB
02.txt AC 30 ms 11604 KB
03.txt AC 31 ms 13652 KB
04.txt AC 31 ms 11604 KB
05.txt AC 30 ms 9556 KB
06.txt AC 32 ms 11604 KB
07.txt AC 32 ms 11604 KB
08.txt AC 32 ms 13652 KB
09.txt AC 31 ms 9556 KB
10.txt AC 30 ms 9556 KB
11.txt AC 30 ms 11604 KB
12.txt AC 30 ms 9556 KB
13.txt AC 30 ms 11604 KB
14.txt AC 31 ms 11604 KB
15.txt AC 31 ms 13652 KB
16.txt AC 31 ms 13652 KB
17.txt AC 31 ms 11604 KB
18.txt AC 32 ms 11604 KB
19.txt AC 32 ms 11604 KB
20.txt AC 31 ms 9556 KB
21.txt AC 32 ms 11604 KB
22.txt AC 32 ms 13652 KB
23.txt AC 30 ms 9556 KB
24.txt AC 30 ms 11604 KB
25.txt AC 31 ms 11476 KB
26.txt AC 31 ms 11604 KB
27.txt AC 32 ms 13652 KB
28.txt AC 32 ms 11604 KB
29.txt AC 32 ms 11604 KB
sample-01.txt AC 31 ms 11476 KB
sample-02.txt AC 31 ms 9556 KB
sample-03.txt AC 30 ms 9556 KB