Submission #1200389

#TimeUsernameProblemLanguageResultExecution timeMemory
1200389Valaki2Room Temperature (JOI24_ho_t1)C++20
100 / 100
240 ms28132 KiB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define fi first
#define se second

void solve() {
    int n, t;
    cin >> n >> t;
    vector<int> v(1 + n, 0);
    set<int> s;
    for(int i = 1; i <= n; i++) {
        cin >> v[i];
        s.insert(v[i] % t);
    }
    vector<int> w;
    for(int x : s) {
        w.pb(x);
    }
    w.pb(w[0] + t);
    int maxi = 0;
    for(int i = 0; i < w.size() - 1; i++) {
        maxi = max(maxi, w[i + 1] - w[i]);
    }
    int rem = t - maxi;
    int ans = (rem + 1) / 2;
    cout << ans << "\n";
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    // int T = 1; cin >> T; while(T--)
    solve();
}
#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...