結果

問題 No.135 とりあえず1次元の問題
ユーザー Mr_Duke_Togo
提出日時 2025-08-14 13:35:45
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,151 bytes
コンパイル時間 1,223 ms
コンパイル使用メモリ 102,568 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2025-08-14 13:35:49
合計ジャッジ時間 3,004 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 21 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cstdint>
#include <algorithm>
#include <climits>

template <typename T = uint32_t>
void radixsort_unsigned(std::vector<T>& arr) {
    if (arr.empty()) {
        return;
    }
    std::vector<std::vector<T>> buckets(256);
    for (size_t i = 0; i < sizeof(T); ++i) {
        for (T num : arr) {
            uint8_t bucketIndex = (num >> (i * 8)) & 0xFF;
            buckets[bucketIndex].push_back(num);
        }
        size_t arrIndex = 0;
        for (auto& bucket : buckets) {
            for (T num : bucket) {
                arr[arrIndex++] = num;
            }
            bucket.clear();
        }
    }
}


int main() {
    int n;
    std::cin >> n;
    std::vector<uint32_t> x(n);
    for (int i = 0; i < n; i++) {
        std::cin >> x[i];
    }
    radixsort_unsigned(x);
    x.erase(std::unique(x.begin(), x.end()), x.end());
    n = int(x.size());
    if (n == 1) {
        std::cout << 0 << std::endl;
    } else {
        uint32_t ans = 1e9;
        for (int i = 1; i <= n; i++) {
            ans = std::min(ans, x[i] - x[i - 1]);
        }
        std::cout << ans << std::endl;
    }
}
0