結果

問題 No.135 とりあえず1次元の問題
ユーザー fujitafujita
提出日時 2023-05-10 13:23:15
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 83 ms / 5,000 ms
コード長 2,216 bytes
コンパイル時間 10,093 ms
コンパイル使用メモリ 148,448 KB
実行使用メモリ 42,288 KB
最終ジャッジ日時 2023-08-17 19:18:19
合計ジャッジ時間 12,708 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
37,516 KB
testcase_01 AC 53 ms
28,916 KB
testcase_02 AC 53 ms
28,692 KB
testcase_03 AC 50 ms
30,644 KB
testcase_04 AC 55 ms
28,928 KB
testcase_05 AC 55 ms
28,784 KB
testcase_06 AC 55 ms
29,028 KB
testcase_07 AC 55 ms
28,784 KB
testcase_08 AC 56 ms
30,896 KB
testcase_09 AC 55 ms
28,980 KB
testcase_10 AC 56 ms
30,928 KB
testcase_11 AC 56 ms
28,768 KB
testcase_12 AC 55 ms
29,200 KB
testcase_13 AC 55 ms
28,908 KB
testcase_14 AC 55 ms
29,092 KB
testcase_15 AC 56 ms
29,124 KB
testcase_16 AC 55 ms
28,916 KB
testcase_17 AC 56 ms
29,084 KB
testcase_18 AC 56 ms
29,028 KB
testcase_19 AC 56 ms
29,284 KB
testcase_20 AC 57 ms
31,032 KB
testcase_21 AC 81 ms
42,288 KB
testcase_22 AC 83 ms
39,604 KB
evil01.txt AC 79 ms
172,388 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  Determining projects to restore...
  Restored /home/judge/data/code/main.csproj (in 124 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.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 , temp = 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) //配列が1以下
            {
                Console.WriteLine("0");
            }
            else if (!(list.Count < 2))
            {
                temp = list[list.Count - 1];
            }


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