結果

問題 No.185 和風
ユーザー soi09476291soi09476291
提出日時 2019-11-22 11:22:13
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,544 bytes
コンパイル時間 905 ms
コンパイル使用メモリ 104,064 KB
実行使用メモリ 18,304 KB
最終ジャッジ日時 2024-04-19 10:11:17
合計ジャッジ時間 1,372 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
18,048 KB
testcase_01 AC 23 ms
18,304 KB
testcase_02 AC 23 ms
18,176 KB
testcase_03 AC 23 ms
18,304 KB
testcase_04 AC 24 ms
18,048 KB
testcase_05 WA -
testcase_06 AC 24 ms
18,304 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Text;
using System.Linq;

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

            long[] X = new long[N];
            long[] Y = new long[N];
            long[] Z = new long[N];

            long tof = 0;

            for(long i = 0; i < N; i++)
            {
                var input = Console.ReadLine().Trim().Split(' ');

                X[i] = long.Parse(input[0]);
                Y[i] = long.Parse(input[1]);
            }

            for(int i = 0; i < N; i++)
            {
                Z[i] = Y[i] - X[i];
            }

            for(int i = 0; i < N - 1; i++)
            {
                if(tof == -1)
                {
                    break;
                }
                for(int j = 1; j < N; j++)
                {
                    if(Z[i] == Z[j])
                    {
                        tof = 1;
                    }
                    else
                    {
                        tof = -1;
                        break;
                    }
                }
            }

            for(int i = 0; i < N; i++)
            {
                if(Z[i] < 0)
                {
                    tof = -1;
                }
            }

            if(tof == 1)
            {
                Console.WriteLine(Z[0]);
            }
            else if(tof == -1)
            {
                Console.WriteLine(-1);
            }
        }        
    }
}
0