제출 #1126515

#제출 시각아이디문제언어결과실행 시간메모리
1126515czaudernaRoom Temperature (JOI24_ho_t1)C++20
100 / 100
148 ms6560 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back const int INF = 1e9; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n, k; cin >> n >> k; vector<int> inp, arr; for(int i=0; i<n; i++){ int x; cin >> x; inp.pb(x); } sort(inp. begin(), inp.end()); for(int i=1; i<n; i++){ int diff = inp[i]-inp[0]; diff = diff/k; inp[i]-=diff*k; } sort(inp. begin(), inp.end()); arr.pb(inp[0]-k); for(int i=1; i<n; i++){ arr.pb(inp[i]-k); } for(auto x:inp) arr.pb(x); int out = INF; for(int i=0; i<n; i++){ int diff = arr[i+n-1]-arr[i]; out = min(out, diff/2 + diff%2); } cout << out << '\n'; 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...