結果
問題 |
No.716 距離
|
ユーザー |
![]() |
提出日時 | 2019-12-05 03:14:21 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,116 bytes |
コンパイル時間 | 2,083 ms |
コンパイル使用メモリ | 111,896 KB |
実行使用メモリ | 29,988 KB |
最終ジャッジ日時 | 2024-12-15 07:18:37 |
合計ジャッジ時間 | 3,363 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 WA * 16 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Text; using System.Linq; using System.Collections; using System.Collections.Generic; using static System.Console; using static System.Math; namespace YukiCoder { public class Program { public static void Main(string[] args) { new Program().Solve(); } public void Solve() { int n = int.Parse(ReadLine()); int[] a = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); Array.Sort(a); bool isDuplicated = false; for (int i = 0; i < a.Length - 1; i++) { for (int j = i + 1; j < a.Length; j++) { if (a[i] == a[j]) isDuplicated = true; } } int min; if (isDuplicated) // same num { min = 0; } else { min = Abs(a[0] - a[1]); } WriteLine(min); WriteLine(Abs(a[0] - a[a.Length -1])); } } }