# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
3589 |
2013-08-31T06:45:40 Z |
imsifile |
Jogging (kriii1_J) |
C++ |
|
1000 ms |
7524 KB |
// 1/tanx = x/y - a*1/y (각도가 높아질수록 감소)
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<set>
using namespace std;
struct lin {
double a, b;
bool operator< (const lin& c) const {
if(a!=c.a)return a<c.a;
return b<c.b;
}
}ba[111111], im, dl[111111];
int dir(lin p, lin q, lin r){
double t = p.a*q.b + q.a*r.b + r.a*p.b - p.b*q.a - q.b*r.a - r.b*p.a;
if(t>0)return 1;
if(t<0)return -1;
return 0; // 기울기가 1이 되어야 함
}
int n, m, cn;
double xs[111111], dap[111111];
set<lin> conv;
set<lin>::iterator it, a, b, lm;
int main(){
int i, j, k;
scanf("%d%d", &n, &m);
for(i=0; i<n; i++)scanf("%lf%lf", &ba[i].a, &ba[i].b);
sort(ba, ba+n);
for(i=0; i<m; i++)scanf("%lf", &xs[i]);
for(i=m-1, j=n-1; i>=0; i--){
while(j>=0){
if(xs[i]>=ba[j].a)break;
im.a=-1/ba[j].b, im.b=ba[j].a/ba[j].b;
if(conv.empty()){
conv.insert(im), j--;
continue;
}
cn=0;
it=conv.lower_bound(im), lm=conv.begin();
if(it!=lm){
a=b=it, a--, b--;
if(a!=lm){
b--;
while(dir(*b,*a,im)!=1){
dl[cn++]=*a;
a=b, b--;
if(a==lm)break;
}
}
}
lm=conv.end();
if(it!=lm){
a=b=it, b++;
if(b!=lm){
while(dir(im,*a,*b)!=1){
dl[cn++]=*a;
a=b, b++;
if(a==lm)break;
}
}
}
if(it==conv.begin() || it==conv.end())conv.insert(im);
else{
a=it, a--;
if(dir(*a, im, *it)==1)conv.insert(im);
}
for(k=0; k<cn; k++)conv.erase(dl[k]);
j--;
}
if(conv.empty())dap[i]=0;
else{
a=it=conv.begin(), a++;
cn=0;
while(a!=conv.end()){
if(xs[i]*(*it).a+(*it).b > xs[i]*(*a).a+(*a).b)dl[cn++]=*it;
it=a, a++;
}
for(k=0; k<cn; k++)conv.erase(dl[k]);
it=conv.begin();
dap[i]=atan(1/(xs[i]*(*it).a+(*it).b));
}
}
for(i=0; i<m; i++)printf("%.7lf\n", dap[i]);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1000 ms |
7524 KB |
Program timed out |
2 |
Halted |
0 ms |
0 KB |
- |