結果

問題 No.135 とりあえず1次元の問題
ユーザー fujita
提出日時 2023-05-10 10:35:11
言語 C#
(.NET 8.0.404)
結果
WA  
実行時間 -
コード長 1,531 bytes
コンパイル時間 9,092 ms
コンパイル使用メモリ 168,112 KB
実行使用メモリ 42,880 KB
最終ジャッジ日時 2024-11-26 15:01:18
合計ジャッジ時間 11,840 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 20 WA * 1 RE * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (83 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

using System;

namespace yukicoder
{
    class Program
    {

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            var str = Console.ReadLine().Split(" ");
            int n = 0, ans = 0;
            
            //int[] ints = new int[N];
            List<int> list = new List<int>(N);
            
            for(int i = 0; i < N; i++)
            {
                list.Add(int.Parse(str[i]));
                
                if (list[n] == 0)
                {
                    list.RemoveAt(n);
                    n--;
                }
                n++;
            }

            list.Sort();

            if (list.Count < 2) 
            {
                Console.WriteLine("0");
            }
            

            int temp = list[list.Count - 1];
            for (int j = 0; j < list.Count  ; j++)
            {
                
                ans = list[j + 1] - list[j];
                if(ans < temp || j == list.Count - 2)
                {
                    if(j == list.Count - 2)
                    {
                        Console.WriteLine(temp);
                        break;
                    }
                    else if (ans == 0)
                    {
                        Console.WriteLine(list[j + 1] / list[j]);
                        break;
                    }
                    else
                    {
                        temp = ans;
                    }
                }
            }
        }
    }
}
0