Submission #1089771

# Submission time Handle Problem Language Result Execution time Memory
1089771 2024-09-17T06:20:25 Z an22inkle Room Temperature (JOI24_ho_t1) C++17
0 / 100
0 ms 348 KB
#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 time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -