結果

問題 No.185 和風
ユーザー fujitafujita
提出日時 2023-05-09 17:30:48
言語 C#
(.NET 8.0.203)
結果
MLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,412 bytes
コンパイル時間 10,860 ms
コンパイル使用メモリ 144,488 KB
実行使用メモリ 162,304 KB
最終ジャッジ日時 2023-08-17 08:23:14
合計ジャッジ時間 8,015 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
28,224 KB
testcase_01 AC 51 ms
28,312 KB
testcase_02 AC 50 ms
28,312 KB
testcase_03 AC 50 ms
28,196 KB
testcase_04 AC 50 ms
28,388 KB
testcase_05 AC 49 ms
28,356 KB
testcase_06 MLE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
  Determining projects to restore...
  Restored /home/judge/data/code/main.csproj (in 161 ms).
.NET 向け Microsoft (R) Build Engine バージョン 17.0.0-preview-21470-01+cb055d28f
Copyright (C) Microsoft Corporation.All rights reserved.

  プレビュー版の .NET を使用しています。https://aka.ms/dotnet-core-preview をご覧ください
  main -> /home/judge/data/code/bin/Release/net6.0/main.dll
  main -> /home/judge/data/code/bin/Release/net6.0/publish/

ソースコード

diff #

using System;

namespace yukicoder
{
    class Program
    {

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

            int[] strings1 = new int[N * 2];
            //int[] strings2 = new int[str.Length];

            for (int i = 0; i <= N * 2 - 1; i++)
            {
                var str = Console.ReadLine().Split(" ");
                int n = 0;
                strings1[i] = int.Parse(str[n]);
                strings1[i + 1] = int.Parse(str[n + 1]);
                i++;
            }
            

            for (int k = strings1.Length -1; k >= 0;)
            {
                if (strings1[k] - strings1[k - 1] == strings1[k - 2] - strings1[k - 3])
                {
                    k = k - 2;
                    if(k == 1 && strings1[1] - strings1[0] > 0)
                    {
                        Console.WriteLine(strings1[1] - strings1[0]);
                        break;
                    }
                    else if(k <= 1 && strings1[1] - strings1[0] <= 0  )
                    {
                        Console.WriteLine("-1");
                        break;
                    }

                    continue;
                }
                else
                {
                    Console.WriteLine("-1");
                    break;
                }
                
            }
           
        }
    }
}
0