Submission #1089771

#TimeUsernameProblemLanguageResultExecution timeMemory
1089771an22inkleRoom Temperature (JOI24_ho_t1)C++17
0 / 100
0 ms348 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::set<int> S; std::vector<int> v; for (int i = 0; i < n; i++) { int x; std::cin >> x; S.insert(x); } for (auto i : S) v.push_back(i); std::sort(v.begin(), v.end()); n = v.size(); int min = 2e9; for (int i = 0; i < n; i++) { int a = v[i], b = v[(i + 1) % n]; 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 == 2e9 ? 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...