結果
問題 |
No.135 とりあえず1次元の問題
|
ユーザー |
![]() |
提出日時 | 2018-09-06 00:01:40 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 39 ms / 5,000 ms |
コード長 | 466 bytes |
コンパイル時間 | 885 ms |
コンパイル使用メモリ | 59,248 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-15 18:53:07 |
合計ジャッジ時間 | 2,036 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
#include <iostream> #include <algorithm> using namespace std; int main() { int n; cin >> n; int x[n]; for(int i = 0; i < n; i++) cin >> x[i]; sort(x,x+n); int min = 100000000,cou = 0; for(int i = 1; i < n; i++){ if(x[i] - x[i-1] < min && x[i] != x[i-1]) min = x[i] - x[i-1]; if(x[i] == x[i-1]) cou++; } cout << ((n == 1 || n == cou + 1) ? 0 : min) << endl; return 0; }