Submission #1089768

#TimeUsernameProblemLanguageResultExecution timeMemory
1089768an22inkleRoom Temperature (JOI24_ho_t1)C++17
35 / 100
1 ms500 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 = 1e9 + 1; 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 > 1e9 ? 0 : 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...