/**
* author: wxhtzdy
* created: 03.07.2022 11:30:53
**/
#include <bits/stdc++.h>
using namespace std;
typedef long double ldb;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, h;
cin >> n >> h;
vector<int> x(n), y(n);
for (int i = 0; i < n; i++) {
cin >> x[i] >> y[i];
}
vector<tuple<ldb, int, int>> ev;
for (int i = 2; i < n - 1; i += 2) {
ldb L = x[i] + h * (((ldb) x[i - 1] - x[i]) / (ldb) (y[i - 1] - y[i]));
ldb R = x[i] + h * (((ldb) x[i + 1] - x[i]) / (ldb) (y[i + 1] - y[i]));
ev.emplace_back(L, 0, i);
ev.emplace_back(R, 1, i);
}
sort(ev.begin(), ev.end());
set<int> st;
int ans = 0;
for (auto& p : ev) {
if (get<1>(p) == 0) {
st.insert(get<2>(p));
} else {
if (st.find(get<2>(p)) != st.end()) {
st.clear();
ans += 1;
}
}
}
cout << ans << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
1104 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
596 KB |
Output is correct |
2 |
Incorrect |
1 ms |
464 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
1104 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |