結果

問題 No.135 とりあえず1次元の問題
ユーザー kekenx
提出日時 2020-03-05 15:12:52
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 40 ms / 5,000 ms
コード長 402 bytes
コンパイル時間 1,624 ms
コンパイル使用メモリ 170,660 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-14 01:15:45
合計ジャッジ時間 3,265 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  for (int i = 0; i < n; ++i) cin >> x[i];

  const int INF = 1000000000;
  int ans = INF;
  sort(x.begin(), x.end());
  for (int i = 1; i < n; ++i) {
    if (x[i] != x[i - 1])  {
      ans = min(ans, x[i] - x[i - 1]);
    }
  }
  if (ans == INF) puts("0");
  else cout << ans << '\n';
  return 0;
}
0