結果

問題 No.135 とりあえず1次元の問題
ユーザー momoyuu
提出日時 2023-10-24 18:03:55
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 18 ms / 5,000 ms
コード長 469 bytes
コンパイル時間 2,927 ms
コンパイル使用メモリ 252,940 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-24 10:47:11
合計ジャッジ時間 3,894 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false); 

    int n;
    cin>>n;
    vector<ll> a(n);
    for(int i = 0;i<n;i++) cin>>a[i];
    sort(a.begin(),a.end());
    a.erase(unique(a.begin(),a.end()),a.end());
    n = a.size();
    if(n==1) cout<<0<<endl;
    else{
        ll ans = 1e9;
        for(int i = 0;i+1<n;i++) ans = min(ans,a[i+1]-a[i]);
        cout<<ans<<endl;
    }
}

0