結果
問題 |
No.135 とりあえず1次元の問題
|
ユーザー |
|
提出日時 | 2020-03-07 21:58:01 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 420 bytes |
コンパイル時間 | 501 ms |
コンパイル使用メモリ | 62,812 KB |
実行使用メモリ | 8,064 KB |
最終ジャッジ日時 | 2024-10-15 14:29:35 |
合計ジャッジ時間 | 1,618 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 21 WA * 1 |
ソースコード
#include <iostream> #include <set> using namespace std; int main(){ int N,x; set<int> Xs; cin >> N; for(int i=0;i<N;i++){ cin >> x;Xs.insert(x); } int ans=1e6+1; if(Xs.size()>1){ auto xb=Xs.begin(); for(int fx=(*xb),sx=(*(++xb));xb!=Xs.end();fx=sx,sx=(*(++xb))){ ans=min(ans,sx-fx); } }else ans=-1; cout << ans << endl; return 0; }