結果
問題 | No.135 とりあえず1次元の問題 |
ユーザー |
![]() |
提出日時 | 2016-02-14 16:15:53 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 45 ms / 5,000 ms |
コード長 | 470 bytes |
コンパイル時間 | 785 ms |
コンパイル使用メモリ | 69,420 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2025-01-03 14:05:25 |
合計ジャッジ時間 | 1,956 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int n, ans = 1e9; cin >> n; vector<int> xs; for (int i = 0; i < n; i++) { int x; cin >> x; xs.push_back(x); } sort(xs.begin(),xs.end()); for (int i = 1; i < n; i++) { if (xs[i] != xs[i-1]) ans = min(ans, xs[i]-xs[i-1]); } if (ans == 1e9) ans = 0; cout << ans << endl; return 0; }