# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
537456 | tqbfjotld | Planine (COCI21_planine) | C++14 | 3 ms | 724 KiB |
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 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);
}
Compilation message (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... |