Language: C++

#include <bits/stdc++.h>
using namespace std;

const double pi  = 2 * acos(0.0);
const double eps = 1e-10;

#define INF (1<<29)
#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int Cost;
struct Edge {
  int src, dst; Cost cost;
  Edge(int s, int d, Cost c) : src(s), dst(d), cost(c) {}
};
typedef vector<Edge>  Edges;
typedef vector<Edges> Graph;
typedef vector<Cost>  Array;
typedef vector<Array> Matrix;

int dx[8] = {0, 1, 0, -1, 1, -1, 1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, -1, 1};

map<int, map<int, double>> height;

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  double r;
  int n;
  while (cin >> r >> n, r && n) {
    height.clear();
    int lx, rx, h;
    int l_end = INF;
    int r_end = -INF;
    rep(i, n) {
      cin >> lx >> rx >> h;
      l_end = min(l_end, lx);
      r_end = max(r_end, rx);
      REP(j, lx, rx) {
        height[j][j+1] = max(h, height[j][j+1]);
      }
    }

    // simulation
    double center = -r;
    double step = 0.0001;
    double ans = -step;
    while (true) {
      bool judge = true;
      REP(i, l_end, r_end) {
        int lx = i;
        int rx = i + 1;
        double h = height[lx][rx];
        double dl = sqrt(fabs(h - center) * fabs(h - center) + abs(lx) * abs(lx));
        double dr = sqrt(fabs(h - center) * fabs(h - center) + abs(rx) * abs(rx));
        if (dl < r || dr < r) {
          judge = false;
          break;
        }
      }
      if (!judge) break;
      center += step;
      ans += step;
    }
    cout << fixed << setprecision(4) << ans << endl;
  }
  return 0; 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:45:29: error: no matching function for call to 'max(int&, std::map<int, double>::mapped_type&)'
   45 |         height[j][j+1] = max(h, height[j][j+1]);
      |                          ~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:45:29: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::map<int, double>::mapped_type' {aka 'double'})
   45 |         height[j][j+1] = max(h, height[j][j+1]);
      |                          ~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:45:29: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   45 |         height[j][j+1] = max(h, height[j][j+1]);
      |                          ~~~^~~~~~~~~~~~~~~~~~~