This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
int n; ld h; cin >> n >> h;
int p = n/2 - 1;
vector<ld> l(p+1),r(p+1);
vector<pair<ld,ld>> points(n+1);
for(int i = 0; i < n; i++) cin >> points[i].f >> points[i].s;
for(int i = 1; i <= p; i++){
ld ldif = (points[2*i-1].s - points[2*i].s)/(points[2*i].f-points[2*i-1].f);
ld rdif = (points[2*i+1].s - points[2*i].s)/(points[2*i + 1].f-points[2*i].f);
l[i] = points[2*i].f - (h-points[2*i].s)/ldif;
r[i] = points[2*i].f + (h-points[2*i].s)/rdif;
}
for(int i = 2; i <= p; i++) l[i] = max(l[i],l[i-1]);
for(int i = p-1; i >= 1; i--) r[i] = min(r[i],r[i+1]);
vector<int> dp(p+1);
r[0] = -1e15;
int ptr = 0;
for(int i = 1; i <= p; i++){
while(l[i] > r[ptr]) ptr++;
dp[i] = dp[ptr-1]+1;
}
cout << dp[p] << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |