結果

問題 No.716 距離
ユーザー zeronosu77108
提出日時 2020-06-20 16:43:10
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 458 bytes
コンパイル時間 880 ms
コンパイル使用メモリ 131,312 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-30 18:41:23
合計ジャッジ時間 2,122 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <climits>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector a(n, 0);
    for (int i=0; i<n; i++) cin >> a[i];
    
    sort(a.begin(), a.end());
    
    int _max = abs(a.front() - a.back());
    int _min = INT_MAX;
    for (int i=1; i<n; i++) _min = min(_min, abs(a[i-1]-a[i]));
    cout << _min << endl << _max << endl;
}

/*
*/
0