#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int n, h, endpt;
vector<pair<double, double> > arr;
bool comp(pair<double, double> i1, pair<double, double> i2){
return i1.second<i2.second;
}
signed main(){
cin >> n >> h;
if(n == 3){
cout << 0; return 0;
}
int prex = 0;
int prey = 0;
for(int i = 0; i < n; i++){
int x, y; cin >> x >> y;
if(i == 0 || i == n - 1) continue;
if(i % 2 && i != 1){
arr[(int)arr.size() - 1].second = prex + (h * (x - prex) / (y - prey));
}
else if(i%2 == 0){
arr.push_back(make_pair(x - (h * (x - prex)/ (prey - y)), 0));
}
prex = x; prey = y;
}
sort(arr.begin(), arr.end(), comp);
int cnt = 1;
double eest = arr[0].second;
for(int i = 1; i < (int)arr.size(); i++){
if(arr[i].first <= eest) continue;
eest = arr[i].second; cnt++;
}
cout << cnt;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
2 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |