제출 #1327555

#제출 시각아이디문제언어결과실행 시간메모리
1327555lywoemRoom Temperature (JOI24_ho_t1)C++17
100 / 100
374 ms32044 KiB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define l(a, b, i) for (ll i = a; i < b; i++)
#define rl(a, b, i) for (ll i = a; i >= b; i--)
#define vpair vector<pair<ll, ll>>
#define inf LLONG_MAX
#define ninf LLONG_MIN

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll N, T; cin >> N >> T; vector<ll> vec(N);
    set<ll> st; // để insert những cái số dư khác nhau có thể tồn tại khi chia cho T
    l(0, N, i) {
        cin >> vec[i];
        ll re = (vec[i] % T); 
        st.insert(re);
    }

    vector<ll> vecRe;
    for (auto x : st) vecRe.push_back(x);
    ll sz = vecRe.size();

    ll maxgap = ninf;
    l(1, sz, i) {
        maxgap = max(maxgap, vecRe[i] - vecRe[i - 1]);
    }
    maxgap = max(maxgap, vecRe[0] + T - vecRe[sz - 1]);

    cout << (T - maxgap + 1) / 2;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...