結果
問題 |
No.135 とりあえず1次元の問題
|
ユーザー |
|
提出日時 | 2015-05-09 10:00:41 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 454 bytes |
コンパイル時間 | 808 ms |
コンパイル使用メモリ | 64,124 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2025-01-03 05:48:36 |
合計ジャッジ時間 | 1,810 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 1 |
other | AC * 17 WA * 5 |
ソースコード
#include <iostream> #include <stdlib.h> #include <algorithm> using namespace std; int main(){ int n; cin>>n; int x[n]; int absv = 1000000; int abst; for (int i = 0; i < n ; ++i) { cin>>x[i]; } sort(x, x+n); for (int i = 0; i < n-1; ++i) { abst=abs(x[i]-x[i+1]); if(abst == 0){ cout<<"0"<<endl; return 0; } if(absv == 1){ cout<<"1"<<endl; return 0; } if( abst <= absv ){ absv = abst; } } cout<<absv<<endl; }