結果

問題 No.135 とりあえず1次元の問題
ユーザー temp
提出日時 2015-02-16 12:18:01
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 41 ms / 5,000 ms
コード長 716 bytes
コンパイル時間 1,157 ms
コンパイル使用メモリ 73,984 KB
実行使用メモリ 7,504 KB
最終ジャッジ日時 2025-01-03 05:19:05
合計ジャッジ時間 1,839 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <string>

using namespace std;

int x[1000001];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    x[t] = 1;
  }
  if (n <= 1) {
    std::cout << 0 << std::endl;
    return 0;
  }
  int ans = 2e9;
  int p = 0;
  while (!x[p]) p++;
  for (int i = p+1; i <= 1000000; i++) {
    if (x[i]) {
      ans = min(ans, i-p);
      p = i;
    }
  }
  if (ans == 2e9) {
    std::cout << 0 << std::endl;
  }else {
    std::cout << ans << std::endl;
  }
}
0