結果

問題 No.135 とりあえず1次元の問題
ユーザー ikd
提出日時 2015-11-01 22:12:58
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 44 ms / 5,000 ms
コード長 530 bytes
コンパイル時間 965 ms
コンパイル使用メモリ 68,664 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2025-01-03 07:59:12
合計ジャッジ時間 2,236 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>

using namespace std;

int main(){

    int n;
    cin>> n;

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

    sort(x.begin(), x.end());

    int d = 100000000;
    bool flag = false;
    for(int i=1; i<n; i++){
        if(x[i]-x[i-1]<d && x[i]!=x[i-1]){
            d = x[i]-x[i-1];
            flag = true;
        }
    }

    if(flag){
        cout<< d<< endl;
    }else{
        cout<< "0"<< endl;
    }
    return 0;
}
0