結果

問題 No.135 とりあえず1次元の問題
ユーザー gemygemy
提出日時 2023-09-16 20:42:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 40 ms / 5,000 ms
コード長 643 bytes
コンパイル時間 2,576 ms
コンパイル使用メモリ 224,848 KB
実行使用メモリ 7,628 KB
最終ジャッジ日時 2023-09-16 20:42:19
合計ジャッジ時間 3,914 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
5,936 KB
testcase_01 AC 3 ms
4,380 KB
testcase_02 AC 3 ms
4,380 KB
testcase_03 AC 4 ms
4,380 KB
testcase_04 AC 4 ms
4,380 KB
testcase_05 AC 4 ms
4,380 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 4 ms
4,380 KB
testcase_09 AC 4 ms
4,380 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 4 ms
4,440 KB
testcase_13 AC 4 ms
4,384 KB
testcase_14 AC 5 ms
5,480 KB
testcase_15 AC 4 ms
4,440 KB
testcase_16 AC 4 ms
5,752 KB
testcase_17 AC 4 ms
5,568 KB
testcase_18 AC 4 ms
4,376 KB
testcase_19 AC 4 ms
5,412 KB
testcase_20 AC 4 ms
5,028 KB
testcase_21 AC 34 ms
4,380 KB
testcase_22 AC 40 ms
7,628 KB
evil01.txt AC 35 ms
7,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repp(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define all(v) begin(v), end(v)
using namespace std;
using ll = long long int;

int N, X[1000001] = {0};

int main() {
    // 入力
    cin >> N;
    rep(i, N) { int x; cin >> x; X[x]++; }

    // 点
    vector<int> v;
    rep(i, 1000001) if (X[i] != 0) v.push_back(i);

    // 出力
    if (v.size() == 1) cout << 0 << endl;
    else {
        int Min = 10000000;
        for (int i = 0; i < v.size() - 1; i++) Min = min(Min, v[i + 1] - v[i]);
        cout << Min << endl;
    }
}
0