結果
問題 |
No.135 とりあえず1次元の問題
|
ユーザー |
|
提出日時 | 2024-06-22 22:52:56 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 38 ms / 5,000 ms |
コード長 | 569 bytes |
コンパイル時間 | 1,661 ms |
コンパイル使用メモリ | 171,412 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-22 22:52:59 |
合計ジャッジ時間 | 2,388 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef int64_t ll; template <typename tp> void show(vector<tp> v){ for(ll i=0;i<v.size()-1;i++) cout<<v[i]<<" "; cout<<v[v.size()-1]<<endl; } int main(){ ll n; cin>>n; vector<ll> x(n); for(ll i=0;i<n;i++) cin>>x[i]; vector<ll> diff(n-1); sort(x.begin(),x.end()); for(ll i=0;i<n-1;i++) diff[i]=x[i+1]-x[i]; ll ans=pow(10,9); for(ll i=0;i<n-1;i++) if(ans>diff[i]&&diff[i]!=0) ans=diff[i]; if(ans==pow(10,9)){ cout<<0<<endl; }else{ cout<<ans<<endl; } }