#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
876 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
492 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
876 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |