結果

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

ソースコード

diff #

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int &e : a) cin >> e;
    
    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());
    
    int ans = (a.size() > 1 ? 1e9 : 0);
    for (int i = 0; i + 1 < a.size(); i++) {
        ans = min(ans, a[i + 1] - a[i]);
    }
    
    cout << ans << '\n';
    return 0;
}
0