0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

C#でAtCoder Beginners Selection(ABC086C - Traveling)

Posted at

####準備
[C#でAtCoderデビューのための準備]
(https://qiita.com/azumabashi/items/7aa9e4b77c10970cc30a)
のあとで AtCoder Beginners Selection をやってみました。

####問題文
ABC086C - Traveling
[https://atcoder.jp/contests/abs/tasks/arc089_a]
(https://atcoder.jp/contests/abs/tasks/arc089_a)

####提出結果

using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());

        string result = "Yes";
        int tBefore = 0;
        int xBefore = 0;
        int yBefore = 0;
        for (int i = 0; i < N; i++)
        {
            string[] input = Console.ReadLine().Split(' ');
            if (result != "No")
            {
                int t = Math.Abs(int.Parse(input[0]) - tBefore);
                int x = Math.Abs(int.Parse(input[1]) - xBefore);
                int y = Math.Abs(int.Parse(input[2]) - yBefore);
                if ((t - (x + y)) < 0)
                {
                    result = "No";
                }
                else if ((t - (x + y)) % 2 != 0)
                {
                    result = "No";
                }
                tBefore = t;
                xBefore = x;
                yBefore = y;

            }
        }

        Console.WriteLine($"{result}");

    }
}

####テスト実行
image.png
image.png
image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?