제출 #4115

#제출 시각아이디문제언어결과실행 시간메모리
4115SkeasJogging (kriii1_J)C++98
0 / 1
108 ms5348 KiB
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <sstream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define EPS 1e-9
#define ll long long
int dq[100005];
int n,m;
double rest[100005];
pii star[100005];

int main() {
#ifdef LOCAL
	freopen("input.txt","r",stdin);
#endif
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;++i) {
		int x,y; scanf("%d%d",&x,&y);
		star[i] = mp(x,y);
	} sort(star,star+n);
	int nn = 0;
	for(int i=0;i<n;++i) {
		if(nn==0) star[nn++] = star[i];
		else {
			if(star[nn-1].f == star[i].f) star[nn-1] = star[i];
			else star[nn++] = star[i];
		}
	} n = nn;
	for(int i=0;i<m;++i) scanf("%lf",rest+i);

	vector<double> ans;
	int s = 0, e = 0;
	int j=n-1;
	for(int i=m-1;i>=0;--i) {
		while(j >= 0 && star[j].f > rest[i]) {
			while(s < e && star[dq[e-1]].s <= star[j].s) e--;
			while(s+1 < e &&
				(ll)(star[dq[e-1]].s-star[j].s) * (star[dq[e-2]].f-star[e-1].f) <= (ll)(star[dq[e-2]].s-star[e-1].s) * (star[dq[e-1]].f-star[j].f))
				e--;
			dq[e++] = j;
			j--;
		}
		while(s+1 < e && (ll)star[dq[e-1]].s * (star[dq[e-2]].f-rest[i])  <= (ll)star[dq[e-2]].s * (star[dq[e-1]].f-rest[i])) e--;
		if(s==e) ans.push_back(0);
		else ans.push_back(atan(star[dq[e-1]].s/(star[dq[e-1]].f-rest[i])));
	}

	for(int i=m-1;i>=0;--i) printf("%.7lf\n",ans[i]);
}
#Verdict Execution timeMemoryGrader output
Fetching results...