結果
問題 | No.135 とりあえず1次元の問題 |
ユーザー |
|
提出日時 | 2020-11-25 08:55:51 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 52 ms / 5,000 ms |
コード長 | 566 bytes |
コンパイル時間 | 1,798 ms |
コンパイル使用メモリ | 177,108 KB |
実行使用メモリ | 8,320 KB |
最終ジャッジ日時 | 2024-07-23 19:13:57 |
合計ジャッジ時間 | 2,684 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); int N; cin >> N; vector<int> x(N); set<int> se; rep(i,N){ cin >> x[i]; se.insert(x[i]); } if(se.size() == 1){ cout << 0 << endl; return 0; } sort(x.begin(), x.end()); int ans = 1e9; rep(i,N-1){ if(x[i+1] - x[i] < ans && x[i+1] != x[i]){ ans = x[i+1] - x[i]; } } cout << ans << endl; }