結果

問題 No.135 とりあえず1次元の問題
ユーザー kcm1700kcm1700
提出日時 2015-01-25 23:26:02
言語 C++11
(gcc 8.5.0)
結果
AC  
実行時間 15 ms / 5,000 ms
コード長 387 bytes
コンパイル時間 245 ms
使用メモリ 3,476 KB
最終ジャッジ日時 2023-01-17 22:58:49
合計ジャッジ時間 1,340 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 14 ms
3,356 KB
evil01.txt AC 13 ms
3,476 KB
testcase_02 AC 1 ms
3,032 KB
testcase_03 AC 1 ms
2,968 KB
testcase_04 AC 1 ms
3,080 KB
testcase_05 AC 1 ms
3,032 KB
testcase_06 AC 1 ms
2,996 KB
testcase_07 AC 1 ms
3,036 KB
testcase_08 AC 1 ms
3,080 KB
testcase_09 AC 1 ms
2,992 KB
testcase_10 AC 1 ms
3,072 KB
testcase_11 AC 1 ms
3,080 KB
testcase_12 AC 1 ms
3,000 KB
testcase_13 AC 1 ms
3,028 KB
testcase_14 AC 1 ms
3,032 KB
testcase_15 AC 1 ms
3,036 KB
testcase_16 AC 1 ms
3,024 KB
testcase_17 AC 1 ms
2,968 KB
testcase_18 AC 2 ms
3,092 KB
testcase_19 AC 1 ms
3,032 KB
testcase_20 AC 1 ms
3,092 KB
testcase_21 AC 1 ms
3,076 KB
testcase_22 AC 9 ms
3,476 KB
testcase_23 AC 15 ms
3,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <algorithm>

using namespace std;

int dat[100003];

int main(){
  int n;
  scanf("%d",&n);
  for( int i = 0 ;i < n; i ++) scanf("%d",&dat[i]);
  sort(dat,dat+n);
  int ans = 0;
  for (int i = 0; i + 1 < n; i++) {
    int cur = dat[i+1] - dat[i];
    if (cur == 0) continue;
    if (ans == 0 || ans > cur) {
      ans = cur;
    }
  }
  printf("%d\n", ans);
}
0