#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define sqr(x) ((ll)(x))*(x)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
vector<pii> p;
vector<pair<double, double>> intervals;
int N, H;
int main() {
cin >> N >> H; p.resize(N); FOR(i, 0, N) cin >> p[i].first >> p[i].second;
intervals.resize((N-3)/2);
for (int i = 2; i < N-1; i += 2) {
intervals[(i/2)-1] = {p[i].first + ((double)(H-p[i].second)*(p[i-1].first-p[i].first))/(p[i-1].second-p[i].second), p[i].first + ((double)(H-p[i].second)*(p[i+1].first-p[i].first))/(p[i+1].second-p[i].second)};
}
sort(all(intervals));
double furthest = -299999999ll; int f = 0;
FOR(i, 0, (N-3)/2) {
if (intervals[i].first > furthest) {
f++;
furthest = intervals[i].second;
}
}
cout << f;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
304 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |