結果

問題 No.135 とりあえず1次元の問題
ユーザー GOTKAKO
提出日時 2025-07-13 17:48:16
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 505 bytes
コンパイル時間 1,877 ms
コンパイル使用メモリ 194,872 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-07-13 17:48:20
合計ジャッジ時間 3,719 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 11 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int N; cin >> N;
    if(N == 1){cout << 0 << endl; return 0;}
    vector<int>  ap(1001001);
    while(N--){
        int x; cin >> x;
        ap.at(x)++;
    }
    int back = -1001001,answer = 10010001;
    for(int i=0; i<=1000000; i++){
        if(ap.at(i) > 1){answer = 0; break;}
        if(ap.at(i) == 1) answer = min(answer,i-back),back = i;
    }
    cout << answer << endl;
}
0