Submission #2710622


Source Code Expand

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int X, Y;

        public void Run()
        {
            {
                var line = Input.ReadIntArray();
                X = line[0];
                Y = line[1];
            }

            int ret = int.MaxValue;

            if (Y >= X) ret = Math.Min(ret, Y - X);
            if ((-Y) >= X) ret = Math.Min(ret, (-Y - X) + 1); // 1.. -> Reverse
            if(Y >= (-X)) ret = Math.Min(ret, (Y - (-X)) + 1); // Reverse -> 1..
            if ((-Y) >= (-X)) ret = Math.Min(ret, ((-Y) - (-X)) + 2); // Reverse -> 1.. -> Reverse
            Console.WriteLine(ret);
        
        }
    }

    // libs ----------


    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }

    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Submission Info

Submission Time
Task A - Simple Calculator
User threecourse
Language C# (Mono 4.6.2.0)
Score 300
Code Size 2043 Byte
Status AC
Exec Time 23 ms
Memory 13396 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 14
Set Name Test Cases
Sample 0_00.txt, 0_01.txt, 0_02.txt
All 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt
Case Name Status Exec Time Memory
0_00.txt AC 23 ms 11220 KB
0_01.txt AC 23 ms 11348 KB
0_02.txt AC 23 ms 11220 KB
1_00.txt AC 23 ms 11348 KB
1_01.txt AC 22 ms 9300 KB
1_02.txt AC 23 ms 11348 KB
1_03.txt AC 23 ms 13396 KB
1_04.txt AC 23 ms 11348 KB
1_05.txt AC 23 ms 13396 KB
1_06.txt AC 23 ms 11348 KB
1_07.txt AC 23 ms 11348 KB
1_08.txt AC 23 ms 11348 KB
1_09.txt AC 23 ms 11348 KB
1_10.txt AC 23 ms 11348 KB