結果
問題 |
No.135 とりあえず1次元の問題
|
ユーザー |
|
提出日時 | 2022-06-02 09:45:42 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,403 bytes |
コンパイル時間 | 827 ms |
コンパイル使用メモリ | 103,936 KB |
実行使用メモリ | 31,232 KB |
最終ジャッジ日時 | 2024-09-21 01:56:01 |
合計ジャッジ時間 | 13,351 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 2 |
other | TLE * 1 -- * 21 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; namespace yukicoder { class Program { static void Main(string[] args) { int a = int.Parse(Console.ReadLine()); string[] s = Console.ReadLine().Split(' '); int[] b = new int[a]; int ans = 1; int c = 0; for (int x = 0; x < a ; x++) { b[x] = int.Parse(s[x]); } for (int i = 0; i < a; i++) { for (int j = i; j < a; j++) { if (b[i] > b[j]) { c = b[i]; b[i] = b[j]; b[j] = c; } } } for(int z = 0; z < a-1; z++) { if (z == 0) { ans = b[z + 1] - b[z]; } else if(b[z-1]==b[z]) { if (ans > b[z - 1]) { ans = b[z + 1]; } } else if (ans> b[z + 1] - b[z]&& b[z + 1] - b[z]!=0) { ans = b[z + 1] - b[z]; } } Console.WriteLine(ans); } } }