#include <bits/stdc++.h>
using namespace std;
template <unsigned M_> struct ModInt {
static constexpr unsigned M = M_;
unsigned x;
constexpr ModInt() : x(0) {}
constexpr ModInt(unsigned x_) : x(x_ % M) {}
constexpr ModInt(unsigned long long x_) : x(x_ % M) {}
constexpr ModInt(int x_)
: x(((x_ %= static_cast<int>(M)) < 0) ? (x_ + static_cast<int>(M))
: x_) {}
constexpr ModInt(long long x_)
: x(((x_ %= static_cast<long long>(M)) < 0)
? (x_ + static_cast<long long>(M))
: x_) {}
ModInt &operator+=(const ModInt &a) {
x = ((x += a.x) >= M) ? (x - M) : x;
return *this;
}
ModInt &operator-=(const ModInt &a) {
x = ((x -= a.x) >= M) ? (x + M) : x;
return *this;
}
ModInt &operator*=(const ModInt &a) {
x = (static_cast<unsigned long long>(x) * a.x) % M;
return *this;
}
ModInt &operator/=(const ModInt &a) { return (*this *= a.inv()); }
ModInt pow(long long e) const {
if (e < 0)
return inv().pow(-e);
ModInt a = *this, b = 1;
for (; e; e >>= 1) {
if (e & 1)
b *= a;
a *= a;
}
return b;
}
ModInt inv() const {
unsigned a = M, b = x;
int y = 0, z = 1;
for (; b;) {
const unsigned q = a / b;
const unsigned c = a - q * b;
a = b;
b = c;
const int w = y - static_cast<int>(q) * z;
y = z;
z = w;
}
assert(a == 1);
return ModInt(y);
}
ModInt operator+() const { return *this; }
ModInt operator-() const {
ModInt a;
a.x = x ? (M - x) : 0;
return a;
}
ModInt operator+(const ModInt &a) const { return (ModInt(*this) += a); }
ModInt operator-(const ModInt &a) const { return (ModInt(*this) -= a); }
ModInt operator*(const ModInt &a) const { return (ModInt(*this) *= a); }
ModInt operator/(const ModInt &a) const { return (ModInt(*this) /= a); }
template <class T> friend ModInt operator+(T a, const ModInt &b) {
return (ModInt(a) += b);
}
template <class T> friend ModInt operator-(T a, const ModInt &b) {
return (ModInt(a) -= b);
}
template <class T> friend ModInt operator*(T a, const ModInt &b) {
return (ModInt(a) *= b);
}
template <class T> friend ModInt operator/(T a, const ModInt &b) {
return (ModInt(a) /= b);
}
explicit operator bool() const { return x; }
bool operator==(const ModInt &a) const { return (x == a.x); }
bool operator!=(const ModInt &a) const { return (x != a.x); }
friend std::ostream &operator<<(std::ostream &os, const ModInt &a) {
return os << a.x;
}
};
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rng(123);
using i64 = long long;
using i128 = __int128_t;
// using mint = ModInt<1000000007U>;
using mint = ModInt<998244353U>;
void solve() {
int n, t;
cin >> n >> t;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
a[i] %= t;
}
sort(a.begin(), a.end());
a.resize(unique(a.begin(), a.end()) - a.begin());
int max_d = a[0] + t - a.back();
for (int i = 0; i + 1 < n; i++) {
max_d = max(max_d, a[i + 1] - a[i]);
}
cout << (t - max_d + 1) / 2 << '\n';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T = 1;
// cin >> T;
for (int tc = 1; tc <= T; tc++) {
solve();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |