Submission #1089775

#TimeUsernameProblemLanguageResultExecution timeMemory
1089775an22inkleRoom Temperature (JOI24_ho_t1)C++17
100 / 100
74 ms7260 KiB
#include<bits/stdc++.h> using pair = std::array<int, 2>; using ll = long long; int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int n, m; std::cin >> n >> m; std::vector<int> v(n); for (int i = 0; i < n; i++) { std::cin >> v[i]; v[i] %= m; } std::sort(v.begin(), v.end()); int min = v[n-1] - (v[n-1]+v[0])/2; for (int i = 0; i < n; i++) { int a = v[i], b = v[(i + 1) % n]; if (a == b) continue; b -= m; int mid = (a + b)/2; min = std::min(min, std::max({ std::abs(mid - v[0]), std::abs(mid - b), std::abs(mid - a) })); } std::cout << min << '\n'; }
#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...