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 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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |