結果

問題 No.135 とりあえず1次元の問題
コンテスト
ユーザー aaa aa
提出日時 2025-12-01 14:58:08
言語 C#
(.NET 8.0.404)
結果
WA  
実行時間 -
コード長 1,004 bytes
コンパイル時間 8,333 ms
コンパイル使用メモリ 171,092 KB
実行使用メモリ 43,008 KB
最終ジャッジ日時 2025-12-01 14:58:20
合計ジャッジ時間 11,704 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 2 WA * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (122 ミリ秒)。
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #
raw source code

using System;
public class Program
{
    public static void Main()
    {
        int num = int.Parse(Console.ReadLine() ?? string.Empty);
        string[] str = (Console.ReadLine() ?? string.Empty).Trim().Split(' ');
        //string str = Console.ReadLine() ?? string.Empty;

        if (num == 1)
        {
            Console.WriteLine(0);
            return;
        }
        int a = 0;
        if(int.Parse(str[num - 1]) < int.Parse(str[num - 2]))
        {
            a = int.Parse(str[num - 2]) - int.Parse(str[num - 1]);
        }
        else
        {
            a = int.Parse(str[num - 1]) - int.Parse(str[num - 2]);
        }

        for (int i = num-2;i >= 1;i--)
        {
            if(int.Parse(str[i]) == int.Parse(str[i - 1]))
            {
                continue;
            }
            if(a >= int.Parse(str[i]) - int.Parse(str[i-1]))
            {
                a = int.Parse(str[i]) - int.Parse(str[i - 1]);
            }
        }
        Console.WriteLine(a);
    }
}
0