#include
using namespace std;
#define dir_l 2 #define dir_r 3
struct circle { double x, y, r; void read() { scanf("%lf%lf%lf", &x, &y, &r); } };
typedef pair <double, int> dpr;
inline double sqr(double x) { return x * x; }
const int maxn = 100009; const double finf = 1e23; const double eps = 1e-8;
int n, t; dpr y[maxn * 2]; circle c[maxn];
int checkDir(double x) { int wl(0), wr(0); t = 0; for (int i = 1; i <= n; ++ i) if (c[i]. x + c[i]. r <= x) { ++ wl; } else if (c[i]. x - c[i]. r >= x) { ++ wr; } else { double dt(sqrt(sqr(c[i]. r) - sqr(x - c[i]. x))); y[t ++] = dpr(c[i]. y - dt, i); y[t ++] = dpr(c[i]. y + dt, -i); } if (wl && wr) return 0; if (wl) return dir_l; if (wr) return dir_r; sort(y, y + t); int mb(-1), me(-1), ca(0); for (int i = 0, c = 0; i < t; ca = max(ca, c), ++ i) if (y[i]. second > 0) { me = y[i]. second; ++ c; } else { if (mb == -1) mb = -y[i]. second; – c; } if (ca == n) return 1; if (c[mb]. x == x && c[me]. x == x) return 0; else if (c[me]. x == x) swap(mb, me); if (c[mb]. x == x) { if (c[me]. x > x) return dir_r; else return dir_l; } else { int da(c[mb]. x < x); int db(c[me]. x < x); if (da != db) return 0; else if (da) return dir_l; else return dir_r; } }
int main() { #ifndef ONLINE_JUDGE freopen(".in", “r”, stdin); #endif
scanf("%d", &n);
double l(-finf), r(finf);
for (int i = 1; i <= n; ++ i) {
c[i]. read();
l = max(l, c[i]. x - c[i]. r + eps);
r = min(r, c[i]. x + c[i]. r - eps);
}
int ret(0);
while (l + eps < r) {
double mid((l + r) / 2);
int g(checkDir(mid));
if (g < 2) {
ret = g;
break;
}
else if (g == dir_l)
r = mid - eps;
else
l = mid + eps;
}
puts(ret ? "YES" : "NO");
}