結果

問題 No.716 距離
ユーザー kya_ski
提出日時 2020-03-30 23:09:05
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 387 bytes
コンパイル時間 1,875 ms
コンパイル使用メモリ 168,112 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-23 06:21:45
合計ジャッジ時間 3,112 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &e : a) cin >> e;
    
    int ans1 = 1e9;
    for (int i = 0; i+1 < n; i++) ans1 = min(ans1, a[i+1] - a[i]);
    int ans2 = *max_element(a.begin(), a.end()) - *min_element(a.begin(), a.end());
    
    cout << ans1 << endl;
    cout << ans2 << endl;
    return 0;
}
0