# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
541368 | AlperenT | Planine (COCI21_planine) | C++17 | 3 ms | 980 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int n, h, ans;
pair<long long, long long> arr[N];
vector<pair<long double, long double>> v;
long double l, r, mn;
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);
cin >> n >> h;
for(int i = 1; i <= n; i++) cin >> arr[i].first >> arr[i].second;
for(int i = 3; i <= n - 2; i += 2){
l = arr[i].first - ((long double)h / (arr[i - 1].second - arr[i].second)) * (arr[i].first - arr[i - 1].first);
r = arr[i].first + ((long double)h / (arr[i + 1].second - arr[i].second)) * (arr[i + 1].first - arr[i].first);
v.push_back({l, r});
}
sort(v.begin(), v.end());
mn = v[0].second;
for(int i = 1; i < v.size(); i++){
if(mn < v[i].first){
ans++;
mn = v[i].second;
}
else mn = min(mn, v[i].second);
}
cout << ans + 1;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |