結果
問題 | No.135 とりあえず1次元の問題 |
ユーザー |
![]() |
提出日時 | 2016-08-25 21:26:06 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 35 ms / 5,000 ms |
コード長 | 534 bytes |
コンパイル時間 | 607 ms |
コンパイル使用メモリ | 73,308 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-11 06:55:15 |
合計ジャッジ時間 | 1,538 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <string> #include <set> using namespace std; int main() { int n; cin >> n; vector<int> x; x.resize(n); for (int i = 0; i < n; i++) { cin >> x[i]; } sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()),x.end()); if (x.size() == 1) { cout << 0 << endl; return 0; } int mn=1000000; int pre; pre = x[0]; for (int i = 1; i < x.size(); i++) { mn = min(mn, x[i] - pre); pre = x[i]; } cout << mn << endl; return 0; }