結果
| 問題 |
No.135 とりあえず1次元の問題
|
| コンテスト | |
| ユーザー |
Kaz_nl
|
| 提出日時 | 2017-08-20 17:56:24 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 19 ms / 5,000 ms |
| コード長 | 458 bytes |
| コンパイル時間 | 609 ms |
| コンパイル使用メモリ | 64,352 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-14 17:32:56 |
| 合計ジャッジ時間 | 1,986 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 22 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, d;
cin >> n;
vector<int> a(n);
for (auto& e : a) cin >> e;
sort(a.begin(), a.end());
int min = 1000001;
for (int i = 0; i < n - 1; i++) {
if (a[i] == a[i + 1]) {
continue;
}
d = a[i + 1] - a[i];
if (d < min) min = d;
}
if (min == 1000001) min = 0;
cout << min << endl;
}
Kaz_nl