AtCoder Beginner Contest 025

Submission #3731075

Source codeソースコード

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Net;
using System.Text;
using Microsoft.Win32.SafeHandles;
using static System.Math;
// ReSharper disable MemberCanBeMadeStatic.Local
// ReSharper disable PossibleNullReferenceException
// ReSharper disable UnusedMember.Global
// ReSharper disable UnusedMember.Local
// ReSharper disable ArrangeTypeMemberModifiers
// ReSharper disable SuggestVarOrType_BuiltInTypes
// ReSharper disable SuggestVarOrType_Elsewhere
// ReSharper disable InvertIf
// ReSharper disable InconsistentNaming
// ReSharper disable ConvertIfStatementToSwitchStatement

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve();
            Console.Read();
        }


        private void Solve()
        {
            int N = cin.Int, A = cin.Int, B = cin.Int;
            var ans = 0;
            //東が+、西が-

            for (int i = 0; i < N; i++)
            {
                var s = cin.Str;
                var d = cin.Int;
                if (d < A) d = A;
                else if (d > B) d = B;

                if (s == "East")
                {
                    ans += d;
                }
                else
                {
                    ans -= d;
                }
            }

            if (ans == 0) Console.WriteLine(0);
            else if (ans > 0) Console.WriteLine($"East {ans}");
            else Console.WriteLine($"West {-ans}");
        }


        /// <summary>aとbをスワップする</summary>
        void Swap(ref int a, ref int b)
        {
            var tmp = b;
            b = a;
            a = tmp;
        }

        /// <summary>aとbの最大公約数を求める</summary>
        static long Gcd(long a, long b)
        {
            while (true)
            {
                if (a < b)
                {
                    var a1 = a;
                    a = b;
                    b = a1;
                    continue;
                }

                if (b > 0)
                {
                    var a1 = a;
                    a = b;
                    b = a1 % b;
                    continue;
                }
                return a;
            }
        }

        /// <summary>aとbの最小公約数を求める</summary>
        static long Lcm(long a, long b)
        {
            return a / Gcd(a, b) * b;
        }

    }

#pragma warning disable IDE1006 // 命名スタイル
    public static class cin
#pragma warning restore IDE1006 // 命名スタイル
    {
        private const char _separator = ' ';
        private static readonly Queue<string> _input = new Queue<string>();


        public static string ReadLine => Console.ReadLine();

        public static string Str => Read;
        public static string Read
        {
            get {
                if (_input.Count != 0) return _input.Dequeue();

                // ReSharper disable once PossibleNullReferenceException
                var tmp = Console.ReadLine().Split(_separator);
                foreach (var val in tmp)
                {
                    _input.Enqueue(val);
                }

                return _input.Dequeue();
            }
        }

        public static int Int => int.Parse(Read);

        public static long Long => long.Parse(Read);

        public static double Double => double.Parse(Read);

        public static string[] StrArray(long n)
        {
            var ret = new string[n];
            for (long i = 0; i < n; ++i) ret[i] = Read;
            return ret;
        }

        public static int[] IntArray(long n)
        {
            var ret = new int[n];
            for (long i = 0; i < n; ++i) ret[i] = Int;
            return ret;
        }

        public static long[] LongArray(long n)
        {
            var ret = new long[n];
            for (long i = 0; i < n; ++i) ret[i] = Long;
            return ret;
        }

        static bool TypeEquals<T, U>() => typeof(T) == typeof(U);
        static T ChangeType<T, U>(U a) => (T)System.Convert.ChangeType(a, typeof(T));
        static T Convert<T>(string s) => TypeEquals<T, int>() ? ChangeType<T, int>(int.Parse(s))
            : TypeEquals<T, long>() ? ChangeType<T, long>(long.Parse(s))
            : TypeEquals<T, double>() ? ChangeType<T, double>(double.Parse(s))
            : TypeEquals<T, char>() ? ChangeType<T, char>(s[0])
            : ChangeType<T, string>(s);

        static void Multi<T>(out T a) => a = Convert<T>(Str);
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = StrArray(2); a = Convert<T>(ar[0]); b = Convert<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = StrArray(3); a = Convert<T>(ar[0]); b = Convert<U>(ar[1]); c = Convert<V>(ar[2]);
        }
    }
}

Submission

Task問題 B - 双子とスイカ割り
User nameユーザ名 Kichi_128
Created time投稿日時
Language言語 C# (Mono 4.6.2.0)
Status状態 AC
Score得点 100
Source lengthソースコード長 5120 Byte
File nameファイル名
Exec time実行時間 25 ms
Memory usageメモリ使用量 13396 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - sample-01.txt,sample-02.txt,sample-03.txt
All 100 / 100 sample-01.txt,sample-02.txt,sample-03.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,sample-01.txt,sample-02.txt,sample-03.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
sample-01.txt AC 24 ms 11220 KB
sample-02.txt AC 24 ms 11220 KB
sample-03.txt AC 24 ms 11220 KB
test-01.txt AC 24 ms 11220 KB
test-02.txt AC 23 ms 9172 KB
test-03.txt AC 24 ms 11220 KB
test-04.txt AC 24 ms 11220 KB
test-05.txt AC 23 ms 9172 KB
test-06.txt AC 24 ms 11220 KB
test-07.txt AC 24 ms 11220 KB
test-08.txt AC 24 ms 11220 KB
test-09.txt AC 24 ms 11220 KB
test-10.txt AC 23 ms 9172 KB
test-11.txt AC 24 ms 13268 KB
test-12.txt AC 25 ms 13268 KB
test-13.txt AC 24 ms 11220 KB
test-14.txt AC 24 ms 11220 KB
test-15.txt AC 23 ms 9172 KB
test-16.txt AC 25 ms 13396 KB
test-17.txt AC 24 ms 9172 KB
test-18.txt AC 24 ms 11220 KB
test-19.txt AC 25 ms 11220 KB
test-20.txt AC 24 ms 9172 KB
test-21.txt AC 24 ms 13268 KB
test-22.txt AC 24 ms 11220 KB
test-23.txt AC 24 ms 11220 KB
test-24.txt AC 24 ms 11348 KB
test-25.txt AC 24 ms 11220 KB
test-26.txt AC 25 ms 13396 KB
test-27.txt AC 23 ms 9300 KB
test-28.txt AC 24 ms 11220 KB
test-29.txt AC 24 ms 11348 KB
test-30.txt AC 24 ms 9172 KB