結果

問題 No.135 とりあえず1次元の問題
ユーザー fujitafujita
提出日時 2023-05-10 10:39:04
言語 C#
(.NET 8.0.203)
結果
WA  
実行時間 -
コード長 1,547 bytes
コンパイル時間 19,512 ms
コンパイル使用メモリ 168,912 KB
実行使用メモリ 42,880 KB
最終ジャッジ日時 2024-05-05 00:01:23
合計ジャッジ時間 12,522 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
41,960 KB
testcase_01 WA -
testcase_02 AC 45 ms
29,568 KB
testcase_03 RE -
testcase_04 AC 44 ms
29,184 KB
testcase_05 AC 47 ms
29,416 KB
testcase_06 AC 50 ms
29,696 KB
testcase_07 AC 45 ms
29,184 KB
testcase_08 AC 45 ms
29,312 KB
testcase_09 AC 44 ms
29,440 KB
testcase_10 AC 46 ms
29,408 KB
testcase_11 AC 46 ms
29,408 KB
testcase_12 AC 44 ms
29,416 KB
testcase_13 AC 45 ms
29,420 KB
testcase_14 AC 47 ms
29,536 KB
testcase_15 AC 46 ms
29,440 KB
testcase_16 AC 45 ms
29,696 KB
testcase_17 AC 45 ms
29,568 KB
testcase_18 AC 45 ms
29,184 KB
testcase_19 AC 45 ms
29,824 KB
testcase_20 AC 44 ms
29,440 KB
testcase_21 WA -
testcase_22 AC 91 ms
42,112 KB
evil01.txt AC 85 ms
197,716 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (103 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.Collections.Generic;
using System;
using System.Drawing;
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;
            
            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