#include <bits/stdc++.h>
#define st first
#define nd second
#define db double
#define re register
#define pb push_back
#define mk make_pair
#define int long long
#define pii pair<int, int>
#define ull unsigned long long
#define mst(a, b) memset(a, b, sizeof(a))
using namespace std;
const int N = 3e5 + 10, INF = 1e9 + 1, mod = 998244353;
inline int read()
{
int s = 0, w = 1;
char ch = getchar();
while(ch < '0' || ch > '9') { if(ch == '-') w *= -1; ch = getchar(); }
while(ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
return s * w;
}
int n;
db ans, X, H;
bool flag;
signed main()
{
n = read();
X = read(), H = read();
for(re int i = 2, x, h; i <= n; i++){
x = read(), h = read();
db k = (H - ans) / X; //斜率 y = kx + ans
db y = k * x + ans;
if(h != y) flag = true;
if(h >= y) X = x, H = h;
else ans = (h * X - H * x) / (X - x);
}
if(flag && !ans) cout << "-1\n";
else printf("%.10lf\n", ans);
return 0;
}
Main.cpp: In function ‘int main()’:
Main.cpp:29:14: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
29 | for(re int i = 2, x, h; i <= n; i++){
| ^
Main.cpp:29:21: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
29 | for(re int i = 2, x, h; i <= n; i++){
| ^
Main.cpp:29:24: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
29 | for(re int i = 2, x, h; i <= n; i++){
| ^