# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
537573 |
2022-03-15T08:50:32 Z |
zaneyu |
Planine (COCI21_planine) |
C++14 |
|
2000 ms |
1324 KB |
/*input
9 6
0 0
1 2
3 0
6 3
8 1
9 2
11 1
12 4
14 0
*/
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define MNTO(x,y) x=min(x,y)
#define MXTO(x,y) x=max(x,y)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define ll long long
#define ld long double
#define sz(x) (int)x.size()
#define pii pair<int,int>
#define pdd pair<ld,ld>
#define f first
#define s second
#define pb push_back
#define ALL(x) x.begin(),x.end()
const int INF=0x3f3f3f3f;
const int maxn=1e6+5;
pii arr[maxn];
int h;
ld get(int a,int i){
ld m=1.0*(arr[a].s-arr[i].s)/(arr[a].f-arr[i].f);
ld c=arr[i].s-m*arr[i].f;
return (h-c)/m;
}
int main(){
ios::sync_with_stdio(false),cin.tie(0);
int n;
cin>>n>>h;
REP(i,n) cin>>arr[i].f>>arr[i].s;
vector<pdd> v;
REP1(i,n-2){
if(i%2) continue;
ld l=-INF,r=INF;
REP(j,i){
if(j%2==0) continue;
if(arr[j].s>arr[i].s) MXTO(l,get(j,i));
}
for(int j=i+1;j<n;j+=2){
if(arr[j].s>arr[i].s) MNTO(r,get(j,i));
}
v.pb({l,r});
}
sort(ALL(v));
ld cur=-INF;
int ans=0;
for(auto x:v){
//cout<<x.f<<' '<<x.s<<'\n';
if(x.f>cur) ++ans,cur=x.s;
else MNTO(cur,x.s);
}
cout<<ans<<'\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
307 ms |
696 KB |
Output is correct |
2 |
Correct |
285 ms |
828 KB |
Output is correct |
3 |
Correct |
308 ms |
752 KB |
Output is correct |
4 |
Execution timed out |
2090 ms |
1324 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
340 KB |
Output is correct |
2 |
Correct |
12 ms |
368 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
15 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
14 ms |
396 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
307 ms |
696 KB |
Output is correct |
2 |
Correct |
285 ms |
828 KB |
Output is correct |
3 |
Correct |
308 ms |
752 KB |
Output is correct |
4 |
Execution timed out |
2090 ms |
1324 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |