結果
| 問題 | 
                            No.135 とりあえず1次元の問題
                             | 
                    
| コンテスト | |
| ユーザー | 
                             haraduka_
                         | 
                    
| 提出日時 | 2015-01-25 23:57:01 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 19 ms / 5,000 ms | 
| コード長 | 1,080 bytes | 
| コンパイル時間 | 845 ms | 
| コンパイル使用メモリ | 91,068 KB | 
| 実行使用メモリ | 7,552 KB | 
| 最終ジャッジ日時 | 2025-01-03 03:06:48 | 
| 合計ジャッジ時間 | 1,757 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 22 | 
ソースコード
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<functional>
#include<utility>
#include<iterator>
#include<algorithm>
#include<sstream>
#include<fstream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<ctime>
#include<cstring>
#include<iomanip>
using namespace std;
#define len(val) static_cast<int>(val.size())
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
typedef pair<int, int> P;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int x[(int)1e6+1];
    memset(x, 0, sizeof(x));
    rep(i, n){
        int tmp; cin >> tmp;
        x[tmp] = 1;
    }
    int res = -1;
    int now = -1;
    rep(i, 1e6+1){
        if(x[i]){
            if(now == -1){
                now = i;
            }else{
                if(res == -1) res = (i-now);
                else res = min(res, i - now);
                now = i;
            }
        }
    }
    cout << (res == -1 ? 0 : res) << endl;
}
            
            
            
        
            
haraduka_