結果

問題 No.135 とりあえず1次元の問題
ユーザー ldsyb
提出日時 2016-02-29 17:15:16
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 47 ms / 5,000 ms
コード長 413 bytes
コンパイル時間 1,023 ms
コンパイル使用メモリ 70,352 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2025-01-03 14:07:10
合計ジャッジ時間 2,167 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
   int ans = 10000000,n;
   cin >> n;
   if(n == 1){
      cout << 0 << endl;
      return 0;
   }
   int x[n];
   for(int i = 0;i < n;i++) cin >> x[i];
   stable_sort(x,x + n);
   for(int i = 0;i < n - 1;i++) if(x[i] != x[i + 1]) ans = min(ans,x[i + 1] - x[i]);
   if(ans == 10000000) ans = 0;
   cout << ans << endl;
}
0