제출 #1175633

#제출 시각아이디문제언어결과실행 시간메모리
1175633superautoMecho (IOI09_mecho)C++20
컴파일 에러
0 ms0 KiB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int findMinRadius(vector<int>& cities, vector<int>& towers) {
    int n = cities.size(), m = towers.size();
    int maxRadius = 0;
    
    for (int i = 0; i < n; i++) {
        auto it = lower_bound(towers.begin(), towers.end(), cities[i]);
        int dist1 = (it != towers.end()) ? abs(*it - cities[i]) : INT_MAX;
        int dist2 = (it != towers.begin()) ? abs(*prev(it) - cities[i]) : INT_MAX;
        maxRadius = max(maxRadius, min(dist1, dist2));
    }
    
    return maxRadius;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> cities(n), towers(m);
    
    for (int i = 0; i < n; i++) cin >> cities[i];
    for (int i = 0; i < m; i++) cin >> towers[i];
    
    cout << findMinRadius(cities, towers) << endl;
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

mecho.cpp: In function 'int findMinRadius(std::vector<int>&, std::vector<int>&)':
mecho.cpp:13:67: error: 'INT_MAX' was not declared in this scope
   13 |         int dist1 = (it != towers.end()) ? abs(*it - cities[i]) : INT_MAX;
      |                                                                   ^~~~~~~
mecho.cpp:4:1: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
    3 | #include <algorithm>
  +++ |+#include <climits>
    4 |