이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n, h, ans = 0, last = -1e18, idx = -1;
cin >> n >> h;
int x[n], y[n];
pair<double, double> pos[n/2-1];
double m, c;
for(int i = 0; i < n; i++) cin >> x[i] >> y[i];
for(int i = 1; i < n; i += 2) {
if(i != 1) {
m = (y[i]-y[i-1])*1.0/(x[i]-x[i-1]);
c = y[i] - m*x[i];
pos[idx].first = (h-c)/m;
}
idx++;
if(i != n-2) {
m = (y[i]-y[i+1])*1.0/(x[i]-x[i+1]);
c = y[i] - m*x[i];
pos[idx].second = (h-c)/m;
}
}
sort(pos, pos+n/2-1);
for(int i = 0; i < n/2-1; i++) {
if(pos[i].second > (last+1e-10)) {
ans++;
last = (int)(pos[i].first+1e-11);
}
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |