# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
537456 | tqbfjotld | Planine (COCI21_planine) | C++14 | 3 ms | 724 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
int X[1000005];
int Y[1000005];
bool cmp(pair<int,int> a, pair<int,int>b){
if (a.second==b.second) return a.first<b.first;
else return a.second<b.second;
}
main(){
int n,h;
scanf("%lld%lld",&n,&h);
if (n==3){
printf("0");
return 0;
}
for (int x = 0; x<n; x++){
scanf("%lld%lld",&X[x],&Y[x]);
}
vector<pair<int,int> > v;
for (int x = 2; x<n-1; x+=2){
v.push_back({X[x]-(h-Y[x])*(X[x]-X[x-1])/(Y[x-1]-Y[x]),X[x]+(h-Y[x])*(X[x+1]-X[x])/(Y[x+1]-Y[x])});
}
sort(v.begin(),v.end(),cmp);
int cur = v[0].second;
int ans = 1;
for (auto x : v){
//printf("interval %lld/%lld to %lld/%lld\n",x.first.a,x.first.b,x.second.a,x.second.b);
if (x.first<=cur) continue;
ans++;
cur = x.second;
}
printf("%lld",ans);
}
컴파일 시 표준 에러 (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... |