結果

問題 No.135 とりあえず1次元の問題
ユーザー satanic
提出日時 2015-11-29 21:54:19
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 22 ms / 5,000 ms
コード長 443 bytes
コンパイル時間 1,026 ms
コンパイル使用メモリ 66,540 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2025-01-03 10:29:59
合計ジャッジ時間 2,142 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
  ios::sync_with_stdio(false);
  int n, input, d, min=10000000;
  cin >> n;
  int x[n];
  int bDiffer=0;
  
  for(int i=0; i<n; ++i){
    cin >> x[i];
  }
  sort(x,x+n);
  for(int i=0; i<n-1; ++i){
    d=x[i]-x[i+1];
    d *= (d<0) ? -1 : 1;
    if(d!=0 && min>d){
      min=d;
      bDiffer=1;
    }
  }
  cout << min*bDiffer << "\n";

  return 0;
}
0