Submission #1272307

#TimeUsernameProblemLanguageResultExecution timeMemory
1272307goulthenRoom Temperature (JOI24_ho_t1)C++20
100 / 100
76 ms8520 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define ll long long #define rep(i,a,b) for (int i = a; i <= b; i++) #define per(i,a,b) for (int i = a; i >= b; i--) #define fi first #define se second #define pii pair<int,int> #define pb push_back const int MAXN = 5e5+10; const int INF = 1e18 + 5; const int MOD = 1e9+7; int a[MAXN]; void solve() { int n,t;cin >> n >> t; rep(i,1,n) { cin >> a[i]; a[i] %= t; } sort(a+1,a+n+1); deque<int> q; rep(i,1,n) q.pb(a[i]); int ans = INF; rep(i,1,n) { ans = min(ans, (q[n-1]-q[0]+1)/2); int tmp = (q.back()-t); q.pop_back(); q.push_front(tmp); } cout << ans << '\n'; } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(nullptr); int tt = 1; //cin >> tt; while (tt--) solve(); return 0; }
#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...