Problem:
Problem F: Ballon Contest
Problem
空の様子がいつもと違う。色とりどりの多彩な熱気球が空を覆っていた。今日は熱気球の大会だ。
熱気球から落とされた得点付きボールを参加者全員で取り合うらしい。
せっかくなので優勝者を予想してみることにした。
レクリエーションにはN人参加する。
N
人の参加者はそれぞれ自分の位置が与えられる。複数の参加者に同じ位置が与えられる事はない。
上空の熱気球からM個のボールが１個ずつ落下する。
参加者は全員同じタイミングで走り始め、ボールに向かって同じ速度で一直線に走る。
ボールの落下位置に一番早く辿り着けた人がボールを取得できる。同時に複数人辿り着いた場合は、一様な確率で取得できる人が決まる。
参加者がボールを取得すると参加者全員が元の位置に戻る。
参加者が走り始めてから参加者の全員が元の位置に戻るまでに別のボールが落下する事はない。
各ボールには得点と落下する位置が与えられ、ボールを取得すると得点を得られる。
ボールは落下中に空気抵抗を受けるため、実際に落下する地点にはズレが発生する。落下予定の位置より最大でX軸方向に±
dx
、Y軸方向に±
dy
だけ一様な確率でズレる。
得られる得点の期待値を求め、期待値の最も大きい参加者の期待値を出力せよ。
Input
入力は複数のデータセットからなる。
各データセットは以下で表される。
N
M
x
1
y
1
.
.
x
N
y
N
bx
1
by
1
dx
1
dy
1
score
1
.
.
bx
M
by
M
dx
M
dy
M
score
M
1行目には、参加者の人数
N
、ボールの数
M
が与えられる。
2行目から
N
+1行目までには、参加者の情報が与えられる。
x
i
,
y
i
は、それぞれ参加者の位置のX座標・Y座標である。
N
+2行目から
N
+
M
+1行目までには、ボールの情報が与えられる。各ボールが実際に落下する地点のX座標・Y座標はそれぞれ
bx
j
-
dx
j
から
bx
j
+
dx
j
まで、
by
j
-
dy
j
から
by
j
+
dy
j
までの範囲のどこかである。
score
j
はボールの得点である。
入力の終わりは2つのゼロからなる。
Constraints
入力は以下の条件を満たす。
1 ≤
N
≤ 100
1 ≤
M
≤ 10
0 ≤
x
i
,
y
i
,
bx
j
,
by
j
≤ 10000
1 ≤
dx
j
,
dy
j
≤ 10000
1 ≤
score
j
≤ 100
テストケースの数は 10 を超えない。
入力に含まれる値は全て整数である。
Output
各データセット毎に、答えを一行に出力しなさい。
出力は0.0001以下の誤差を含んでもよい。
Sample Input
3 4
10 75
50 5
90 75
50 50 10 10 2
40 90 1 1 3
10 20 10 15 1
50 70 50 50 4
4 2
25 25
25 75
75 75
75 25
50 50 10 10 1
50 50 15 15 2
1 1
5 5
1 1 1 1 1
0 0
Sample Output
5.442857
0.750000
1.000000

Submitted solutions:

code_snippet: #include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <complex>
#include <cmath>
using namespace std;

#define EPS 1e-8
#define INF 1e100

typedef complex<double> P;
typedef vector<P> vP;

const P iu(0.0, 1.0);

double dot(P a, P b){
	return real(a) * real(b) + imag(a) * imag(b);
}

double cross(P a, P b){
	return real(a) * imag(b) - imag(a) * real(b);
}

int ccw(P a, P b, P c) {
	b -= a; c -= a;
	if (cross(b, c) > EPS)	return +1;	// counter clockwise
	if (cross(b, c) < -EPS)	return -1;	// clockwise
	if (dot(b, c) < -EPS)	return +2;	// c--a--b on line
	if (norm(b) < norm(c))	return -2;	// a--b--c on line
	return 0;
}

P crosspoint(P a1, P a2, P b1, P b2){
	double t = cross(b1 - a1, b1 - b2) / cross(a2 - a1, b1 - b2);
	return a1 + t * (a2 - a1);
}

P centroid(const vP &pl){
	P s;
	int sz = pl.size() - 1;
	if(sz < 1){ return P(INF, INF); }
	for(int i = 1; i <= sz; ++i){
		s += pl[i];
	}
	return s / (double)sz;
}

vP convex_cut(const vP &pl, P la, P lb) {
	vP Q;
	for (int i = 1; i < pl.size(); ++i) {
		P A = pl[i-1], B = pl[i];
		if (ccw(la, lb, A) != -1){ Q.push_back(A); }
		if (ccw(la, lb, A) * ccw(la, lb, B) < 0){
			Q.push_back(crosspoint(A, B, la, lb));
		}
	}
	if(!Q.empty() && Q.back() != Q[0]){
		Q.push_back(Q[0]);
	}
	return Q;
}

double area(const vP p){
	double s = 0.0;
	for(int i = 1; i < p.size(); ++i){
		s += cross(p[i-1], p[i]);
	}
	return 0.5 * abs(s);
}

double solve(int n, int m){
	int x, y, dx, dy, scr;
	vector<P> pt(n);
	for(int i = 0; i < n; ++i){
		scanf("%d%d", &x, &y);
		pt[i] = P(x, y);
	}

	vector<double> sum(n);
	for(int i = 0; i < m; ++i){
		scanf("%d%d%d%d%d", &x, &y, &dx, &dy, &scr);
		double S0 = dx * dy * 4.0;

		for(int j = 0; j < n; ++j){
			vP plg(5);
			plg[0] = plg[4] = P(x - dx, y - dy);
			plg[1] = P(x + dx, y - dy);
			plg[2] = P(x + dx, y + dy);
			plg[3] = P(x - dx, y + dy);

			for(int k = 0; k < n; ++k){
				if(k != j){
					P mid = 0.5 * (pt[j] + pt[k]);
					P dif = iu * (pt[k] - pt[j]);
					
					vP p1 = convex_cut(plg, mid, mid + dif);
					vP p2 = convex_cut(plg, mid, mid - dif);

					if(p1.empty()){ p1.swap(p2); }
					P cn = centroid(p1);
					plg.swap(norm(pt[j] - cn) < norm(pt[k] - cn) ? p1 : p2);
				}
			}
			
			sum[j] += area(plg) / S0 * scr;
		}
	}

	return *max_element(sum.begin(), sum.end());
}

int main(){
	int n, m;
	while(scanf("%d%d", &n, &m), n){
		printf("%f\n", solve(n, m));
	}
}
accuracy: 1
time_ms: 110
memory_kb: 3564
final_rank: 15

code_snippet: #include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 105

struct Point{
	Point(double arg_x,double arg_y){
		x = arg_x;
		y = arg_y;
	}

	Point(){
		x = y = 0.0;
	}

	Point operator + (Point p){ return Point(x+p.x,y+p.y); }
	Point operator - (Point p){ return Point(x-p.x,y-p.y);}
	Point operator * (double a){ return Point(a*x,a*y); }
	Point operator / (double a){ return Point(x/a,y/a); }

	double abs(){ return sqrt(norm()); }
	double norm(){ return x*x + y*y; }

	bool operator<(const Point &p) const{
		return x != p.x? x < p.x: y < p.y;
	}

	bool operator == (const Point &p) const{
		return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
	}

	double x,y;
};

typedef Point Vector;
typedef vector<Point> Polygon;

struct Line{
	Line(){

	}
	Line(Point a,Point b){
		p[0] = a;
		p[1] = b;
	}
	/*void outPut(){

		printf("(%.3lf,%.3lf)-(%.3lf,%.3lf)\n",p[0].x,p[0].y,p[1].x,p[1].y);
	}*/
	Point p[2];
};

int N,num_ball;
double NUM = 20005;
double E[SIZE];

Point C[SIZE];
Polygon L;


double cross(Vector a,Vector b){
    return a.x*b.y-a.y*b.x;
}

double dot(Vector a,Vector b){
    return a.x*b.x + a.y*b.y;
}

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -1;
static const int ON_SEGMENT = 0;

int ccw(Point p0,Point p1,Point p2){

	Vector a = p1 - p0;
	Vector b = p2 - p0;

	if(cross(a,b) > EPS)return COUNTER_CLOCKWISE;
	if(cross(a,b) < -EPS)return CLOCKWISE;
	if(dot(a,b) < -EPS)return ONLINE_BACK;
	if(a.norm() < b.norm())return ONLINE_FRONT;

	return ON_SEGMENT;
}

Point calc_Cross_Point(double x1,double x2,double x3,double x4,double y1,double y2,double y3,double y4){
	Point ret;
	ret.x = ((x2-x1)*(y3*(x4-x3)+x3*(y3-y4))-(x4-x3)*(y1*(x2-x1)+x1*(y1-y2)))/((y2-y1)*(x4-x3)-(y4-y3)*(x2-x1));
	if(x1 != x2){
		ret.y = ((y2-y1)*ret.x+y1*(x2-x1)+x1*(y1-y2))/(x2-x1);
	}else{
		ret.y = ((y4-y3)*ret.x+y3*(x4-x3)+x3*(y3-y4))/(x4-x3);
	}
	return ret;
}

Point calc_Cross_Point(Point a,Point b,Point c,Point d){
	return calc_Cross_Point(a.x,b.x,c.x,d.x,a.y,b.y,c.y,d.y);
}

Polygon ConvexCut(Polygon g,Point a,Point b){

	Polygon ret;
	int N = g.size();

	for(int i = 0; i < g.size(); i++){
		Point A = g[i], B = g[(i+1)%N];
		if(ccw(a,b,A) != -1)ret.push_back(A);
		if(ccw(a,b,A)*ccw(a,b,B) == -1)ret.push_back(calc_Cross_Point(a,b,A,B));
	}

	return ret;
}

double calc_S(Polygon g){

	int N = g.size();
	double ret = 0;

	for(int i = 0; i < g.size(); i++){
		ret += cross(g[i],g[(i+1)%N]);
	}
	return ret/2.0;
}

int func(double x1,double y1,double x2, double y2, double xp, double yp){
	double naiseki,norm1,norm2,gaiseki;
	norm1 = sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
	norm2 = sqrt((xp-x1)*(xp-x1)+(yp-y1)*(yp-y1));
	naiseki = (xp-x1)*(x2-x1)+(yp-y1)*(y2-y1);
	gaiseki = (x2-x1)*(yp-y1)-(xp-x1)*(y2-y1);
	if(gaiseki > EPS){
		return 1;
	}else if(gaiseki < -EPS){
		return -1;
	}
	if(naiseki < -EPS){
		return 2;
	}

	if(norm1 < norm2){
		return -2;
	}
	return 0;
}


//★★直線ではなく、線分の交差判定★★
bool is_Cross(Line a,Line b){

	if(func(a.p[0].x,a.p[0].y,a.p[1].x,a.p[1].y,b.p[0].x,b.p[0].y)*
			func(a.p[0].x,a.p[0].y,a.p[1].x,a.p[1].y,b.p[1].x,b.p[1].y) <= 0 &&
			func(b.p[0].x,b.p[0].y,b.p[1].x,b.p[1].y,a.p[0].x,a.p[0].y)*
			func(b.p[0].x,b.p[0].y,b.p[1].x,b.p[1].y,a.p[1].x,a.p[1].y) <= 0){
		return true;
	}
	return false;
}

/*
 * IN 2
 * ON 1
 * OUT 0
 *
 */
int contains(Polygon g,Point p){
	int n = g.size();
	bool x = false;
	for(int i = 0; i < n; i++){
		Point a = g[i]-p,b = g[(i+1)%n]-p;
		if(abs(cross(a,b)) < EPS && dot(a,b) < EPS)return 1;
		if(a.y > b.y)swap(a,b);
		if(a.y < EPS && EPS < b.y && cross(a,b) > EPS) x = !x;
	}
	return (x ? 2:0);
}

//他角形g1とg2が交差するかどうか調べる関数
bool intersect(const Polygon g1,const Polygon g2){

	int size_1 = g1.size(),size_2 = g2.size();

	for(int i = 0; i < size_1; i++){
		for(int k = 0; k < size_2; k++){
			if(is_Cross(Line(g1[i],g1[(i+1)%size_1]),Line(g2[k],g2[(k+1)%size_2]))){
				return true;
			}
		}
	}

	for(int i = 0; i < size_1; i++){
		if(contains(g2,g1[i]))return true;
	}

	for(int i = 0; i < size_2; i++){
		if(contains(g1,g2[i]))return true;
	}

	return false;
}

void func(){

	for(int i = 0; i < N; i++){
		scanf("%lf %lf",&C[i].x,&C[i].y);
	}

	for(int i = 0; i < N; i++){

		E[i] = 0;
	}

	double bx,by,dx,dy,score;

	Polygon work;
	double base_S,cross_S;

	for(int loop = 0; loop < num_ball; loop++){

		work.clear();
		scanf("%lf %lf %lf %lf %lf",&bx,&by,&dx,&dy,&score);

		work.push_back(Point(bx+dx,by+dy));
		work.push_back(Point(bx-dx,by+dy));
		work.push_back(Point(bx-dx,by-dy));
		work.push_back(Point(bx+dx,by-dy));

		base_S = calc_S(work);

		for(int i = 0; i < N; i++){

			Polygon p = work;
			for(int k = 0; k < N; k++){
				if(k == i)continue;

				Point from = (C[i]+C[k])/2; //中点
				Vector v1 = C[k]-C[i];
				Vector v2 = Vector(-v1.y,v1.x); //v1の法線ベクトル
				Point to = from+v2;
				p = ConvexCut(p,from,to);
				if(p.size() <= 2){
					break;
				}
			}
			if(p.size() <= 2)continue;
			E[i] += score*calc_S(p)/base_S; //p:人物[i]のボロノイ領域
		}
	}

	double ans = -1;
	for(int i = 0; i < N; i++){

		ans = max(ans,E[i]);
	}
	printf("%.10lf\n",ans);
}

int main(){

	while(true){
		scanf("%d %d",&N,&num_ball);
		if(N == 0 && num_ball == 0)break;

		func();
	}

	return 0;
}
accuracy: 1
time_ms: 120
memory_kb: 3208
final_rank: 13

code_snippet: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;


typedef ld  Weight;
struct Edge {
	int src, dest;
	int cap, rev;
	Weight weight;
	bool operator < (const Edge &rhs) const { return weight > rhs.weight; }
};


/* ??????????????¬ */

#include <complex>

typedef complex<ld> Point;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(x) (x).begin(),(x).end()


const ld pi = acos(-1.0);
const ld dtop = pi / 180.;
const ld ptod = 1. / dtop;

namespace std {
	bool operator<(const Point &lhs, const Point &rhs) {
		if (lhs.real() < rhs.real() - eps) return true;
		if (lhs.real() > rhs.real() + eps) return false;
		return lhs.imag() < rhs.imag();
	}
}

// ????????\???
Point input_Point() {
	ld x, y;
	cin >> x >> y;
	return Point(x, y);
}

// ????????????????????????
bool eq(const ld a, const ld b) {
	return (abs(a - b) < eps);
}

// ??????
ld dot(const Point& a, const Point& b) {
	return real(conj(a) * b);
}

// ??????
ld cross(const Point& a, const Point& b) {
	return imag(conj(a) * b);
}

// ??´????????????
class Line {
public:
	Point a, b;
	Line() : a(Point(0, 0)), b(Point(0, 0)) {}
	Line(Point a, Point b) : a(a), b(b) {}
	Point operator[](const int _num)const {
		if (_num == 0)return a;
		else if (_num == 1)return b;
		else {
			assert(false);
			return Point();
		}
	}
};

// ????????????
class Circle {
public:
	Point p;
	ld r;
	Circle() : p(Point(0, 0)), r(0) {}
	Circle(Point p, ld r) : p(p), r(r) {}
};

// ccw
// 1: a,b,c??????????¨???¨?????????????????¶
//-1: a,b,c???????¨???¨?????????????????¶
// 2: c,a,b???????????´???????????¶
//-2: a,b,c???????????´???????????¶
// 0: a,c,b???????????´???????????¶
int ccw(const Point& a, const Point &b, const Point &c) {
	const Point nb(b - a);
	const Point nc(c - a);
	if (cross(nb, nc) > eps) return 1;   // a,b,c??????????¨???¨?????????????????¶
	if (cross(nb, nc) < -eps) return -1; // a,b,c???????¨???¨?????????????????¶
	if (dot(nb, nc) < 0) return 2;       // c,a,b???????????´???????????¶
	if (norm(nb) < norm(nc)) return -2;  // a,b,c???????????´???????????¶
	return 0;                          // a,c,b???????????´???????????¶
}


/* ???????????? */

// ??´?????¨??´??????????????????
bool isis_ll(const Line& l, const Line& m) {
	return !eq(cross(l.b - l.a, m.b - m.a), 0);
}

// ??´?????¨?????????????????????
bool isis_ls(const Line& l, const Line& s) {
	return isis_ll(l, s) &&
		(cross(l.b - l.a, s.a - l.a) * cross(l.b - l.a, s.b - l.a) < eps);
}

// ????????¨?????????????????????
bool isis_ss(const Line& s, const Line& t) {
	return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0 &&
		ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
}

// ????????´????????????
bool isis_lp(const Line& l, const Point& p) {
	return (abs(cross(l.b - p, l.a - p)) < eps);
}

// ?????????????????????
bool isis_sp(const Line& s, const Point& p) {
	return (abs(s.a - p) + abs(s.b - p) - abs(s.b - s.a) < eps);
}

// ??????????¶?
Point proj(const Line &l, const Point& p) {
	ld t = dot(p - l.a, l.b - l.a) / norm(l.a - l.b);
	return l.a + t * (l.b - l.a);
}

//???????±??????????????????????
Point reflect(const Line &l, const Point &p) {
	Point pr = proj(l, p);
	return pr * 2.l - p;
}

// ??´?????¨??´????????????
Point is_ll(const Line &s, const Line& t) {
	Point sv = s.b - s.a, tv = t.b - t.a;
	assert(cross(sv, tv) != 0);
	return s.a + sv * cross(tv, t.a - s.a) / cross(tv, sv);
}
// ??´?????¨??´????????????
vector<Point> is_ll2(const Line &s, const Line& t) {
	Point sv = s.b - s.a, tv = t.b - t.a;
	if (cross(sv, tv) != 0)return vector<Point>(1, is_ll(s, t));
	else {
		vector<Point>ans;
		for (int k = 0; k < 2; ++k) {
			if (isis_sp(s, t[k]) && find(ans.begin(), ans.end(), t[k]) == ans.end())ans.push_back(t[k]);
			if (isis_sp(t, s[k]) && find(ans.begin(), ans.end(), s[k]) == ans.end())ans.push_back(s[k]);
		}
		return ans;
	}
}
// ????????¨???????????????
//???????????£????????¨???????????¨assert(false)
Point is_ss(const Line &s, const Line& t) {
	if (isis_ss(s, t)) {
		for (int k = 0; k < 2; ++k) {
			for (int l = 0; l < 2; ++l) {
				if (s[k] == t[l])return s[k];
			}
		}
		return is_ll(s, t);
	}
	else {
		//??????isis_ss?????????
		assert(false);
		return Point(0, 0);
	}
}
// ????????¨???????????????
vector<Point> is_ss2(const Line &s, const Line& t) {
	vector<Point> kouho(is_ll2(s, t));
	vector<Point>ans;
	for (auto p : kouho) {
		if (isis_sp(s, p) && isis_sp(t, p))ans.emplace_back(p);
	}
	return ans;
}
// ??´?????¨???????????¢
ld dist_lp(const Line& l, const Point& p) {
	return abs(p - proj(l, p));
}

//??´?????¨??´???????????¢
ld dist_ll(const Line& l, const Line& m) {
	return isis_ll(l, m) ? 0 : dist_lp(l, m.a);
}

// ??´?????¨??????????????¢
ld dist_ls(const Line& l, const Line& s) {
	return isis_ls(l, s) ? 0 : min(dist_lp(l, s.a), dist_lp(l, s.b));
}

// ????????¨???????????¢
ld dist_sp(const Line& s, const Point& p) {
	Point r = proj(s, p);
	return isis_sp(s, r) ? abs(r - p) : min(abs(s.a - p), abs(s.b - p));
}

// ????????¨??????????????¢
ld dist_ss(const Line& s, const Line& t) {
	if (isis_ss(s, t)) return 0;
	return min({ dist_sp(s, t.a), dist_sp(s, t.b), dist_sp(t, s.a), dist_sp(t, s.b) });
}


//??´?????¨??´?????????????????????????????????
Line line_bisection(const Line &s, const Line &t) {
	const Point laglanju(is_ll(s, t));
	const Point avec = !(abs(laglanju - s[0])<eps) ? s[0] - laglanju : s[1] - laglanju;
	const Point bvec = !(abs(laglanju - t[0])<eps) ? t[0] - laglanju : t[1] - laglanju;

	return Line(laglanju, laglanju + (abs(bvec)*avec + abs(avec)*bvec) / (abs(avec) + abs(bvec)));
}
//?????¨???????????´???????????????a?????????????????????
Line point_bisection(const Point&a, const Point&b) {
	const Point cen((a + b) / 2.l);
	const Point vec = (b - a)*Point(0, 1);
	return Line(cen, cen + vec);
}


//???????????´?????????????????????
//???????????´??????????????§???????????¨????¢?????????¨?????????
Point  inner_center(const vector<Line>&ls) {
	vector<Point>vertics;
	for (int i = 0; i <static_cast<int>(ls.size()); ++i) {
		vertics.push_back(is_ll(ls[i], ls[(i + 1) % 3]));
	}
	if (vertics[0] == vertics[1] || vertics[1] == vertics[2] || vertics[2] == vertics[0])return vertics[0];
	Line bi1(line_bisection(Line(vertics[0], vertics[1]), Line(vertics[0], vertics[2])));
	Line bi2(line_bisection(Line(vertics[1], vertics[2]), Line(vertics[1], vertics[0])));
	if (bi1[0] == bi2[0])return bi1[0];
	else {
		return is_ll(bi1, bi2);
	}
}

//???????????´?????????????????????
//???????????´??????????????§???????????¨????¢?????????¨?????????
vector<Point>  ex_center(const vector<Line>&ls) {
	vector<Point>vertics;
	for (int i = 0; i < static_cast<int>(ls.size()); ++i) {
		vertics.push_back(is_ll(ls[i], ls[(i + 1) % 3]));
	}
	if (abs(vertics[0] - vertics[1])<eps || abs(vertics[1] - vertics[2])<eps || (abs(vertics[2] - vertics[0])<eps))return vector<Point>();
	vector<Point>ecs;
	for (int i = 0; i < 3; ++i) {
		Line bi1(line_bisection(Line(vertics[i], vertics[i] * 2.0l - vertics[(i + 2) % 3]), Line(vertics[i], vertics[(i + 1) % 3])));
		Line bi2(line_bisection(Line(vertics[(i + 1) % 3], vertics[(i + 1) % 3] * 2.0l - vertics[(i + 2) % 3]), Line(vertics[(i + 1) % 3], vertics[i])));
		ecs.push_back(is_ll(bi1, bi2));
	}
	return ecs;
}


//a,b:??????
//c:????????§??????
//???????????´?????????????????¢?????????????±??????????
vector<Point>  same_dis(const vector<Line>&ls) {
	vector<Point>vertics;
	vertics.push_back(is_ll(ls[0], ls[2]));
	vertics.push_back(is_ll(ls[1], ls[2]));

	if (abs(vertics[0] - vertics[1]) < eps)return vector<Point>{vertics[0]};
	Line bis(line_bisection(ls[0], ls[1]));
	vector<Point>ecs;

	Line abi(line_bisection(Line(vertics[0], vertics[1]), ls[0]));
	ecs.push_back(is_ll(bis, abi));


	Line bbi(line_bisection(Line(vertics[0], 2.l*vertics[0] - vertics[1]), ls[0]));
	ecs.push_back(is_ll(bis, bbi));

	return ecs;
}
/* ??? */

// ?????¨????????????
vector<Point> is_cc(const Circle& c1, const Circle& c2) {
	vector<Point> res;
	ld d = abs(c1.p - c2.p);
	ld rc = (d * d + c1.r * c1.r - c2.r * c2.r) / (2 * d);
	ld dfr = c1.r * c1.r - rc * rc;
	if (abs(dfr) < eps) dfr = 0.0;
	else if (dfr < 0.0) return res; // no intersection
	ld rs = sqrt(dfr);
	Point diff = (c2.p - c1.p) / d;
	res.push_back(c1.p + diff * Point(rc, rs));
	if (dfr != 0.0) res.push_back(c1.p + diff * Point(rc, -rs));
	return res;
}

//???????????????????????????
/*  0 => out
1 => on
2 => in*/
int is_in_Circle(const Circle &cir, const  Point& p) {
	ld dis = abs(cir.p - p);
	if (dis > cir.r + eps)return 0;
	else if (dis < cir.r - eps)return 2;
	else return 1;
}
//???lc??????rc??????????????????
/*0 => out
1 => on
2 => in*/
int Circle_in_Circle(const Circle &lc, const  Circle&rc) {
	ld dis = abs(lc.p - rc.p);
	if (dis < rc.r - lc.r - eps)return 2;
	else if (dis>rc.r - lc.r + eps)return 0;
	else return 1;
}

// ?????¨??´????????????
vector<Point> is_lc(const Circle& c, const Line& l) {
	vector<Point> res;
	ld d = dist_lp(l, c.p);
	if (d < c.r + eps) {
		ld len = (d > c.r) ? 0.0 : sqrt(c.r * c.r - d * d); //safety;
		Point nor = (l.a - l.b) / abs(l.a - l.b);
		res.push_back(proj(l, c.p) + len * nor);
		res.push_back(proj(l, c.p) - len * nor);
	}
	return res;
}

// ?????¨??????????????¢
vector<Point> is_sc(const Circle& c, const Line& l) {
	vector<Point> v = is_lc(c, l), res;
	for (Point p : v)
		if (isis_sp(l, p)) res.push_back(p);
	return res;
}

// ?????¨????????\???
vector<Line> tangent_cp(const Circle& c, const Point& p) {
	vector<Line> ret;
	Point v = c.p - p;
	ld d = abs(v);
	ld l = sqrt(norm(v) - c.r * c.r);
	if (isnan(l)) { return ret; }
	Point v1 = v * Point(l / d, c.r / d);
	Point v2 = v * Point(l / d, -c.r / d);
	ret.push_back(Line(p, p + v1));
	if (l < eps) return ret;
	ret.push_back(Line(p, p + v2));
	return ret;
}

// ?????¨????????\???
vector<Line> tangent_cc(const Circle& c1, const Circle& c2) {
	vector<Line> ret;
	if (abs(c1.p - c2.p) - (c1.r + c2.r) > -eps) {
		Point center = (c1.p * c2.r + c2.p * c1.r) / (c1.r + c2.r);
		ret = tangent_cp(c1, center);
	}
	if (abs(c1.r - c2.r) > eps) {
		Point out = (-c1.p * c2.r + c2.p * c1.r) / (c1.r - c2.r);
		vector<Line> nret = tangent_cp(c1, out);
		ret.insert(ret.end(), all(nret));
	}
	else {
		Point v = c2.p - c1.p;
		v /= abs(v);
		Point q1 = c1.p + v * Point(0, 1) * c1.r;
		Point q2 = c1.p + v * Point(0, -1) * c1.r;
		ret.push_back(Line(q1, q1 + v));
		ret.push_back(Line(q2, q2 + v));
	}
	return ret;
}
//??????????????????????????¢???
ld two_Circle_area(const Circle&l, const Circle&r) {
	ld dis = abs(l.p - r.p);
	if (dis > l.r + r.r)return 0;
	else if (dis + r.r < l.r) {
		return r.r*r.r*pi;
	}
	else if (dis + l.r < r.r) {
		return l.r*l.r*pi;
	}
	else {
		ld ans = (l.r)*(l.r)*acos((dis*dis + l.r*l.r - r.r*r.r) / (2 * dis*l.r)) +
			(r.r)*(r.r)*acos((dis*dis + r.r*r.r - l.r*l.r) / (2 * dis*r.r)) -
			sqrt(4 * dis*dis*l.r*l.r - (dis*dis + l.r*l.r - r.r*r.r)*(dis*dis + l.r*l.r - r.r*r.r)) / 2;
		return ans;
	}

}

/* ????§???¢ */

typedef vector<Point> Polygon;

// ??¢???
ld get_area(const Polygon &p) {
	ld res = 0;
	int n = p.size();
	rep(j, n) res += cross(p[j], p[(j + 1) % n]);
	return res / 2;
}

//????§???¢????????¢??????
bool is_counter_clockwise(const Polygon &poly) {
	ld angle = 0;
	int n = poly.size();
	rep(i, n) {
		Point a = poly[i], b = poly[(i + 1) % n], c = poly[(i + 2) % n];
		angle += arg((c - b) / (b - a));
	}
	return angle > eps;
}

// ??????????????????
/*0 => out
1 => on
2 => in*/
int is_in_Polygon(const Polygon &poly, const  Point& p) {
	ld angle = 0;
	int n = poly.size();
	rep(i, n) {
		Point a = poly[i], b = poly[(i + 1) % n];
		if (isis_sp(Line(a, b), p)) return 1;
		angle += arg((b - p) / (a - p));
	}
	return eq(angle, 0) ? 0 : 2;
}
//??????????????????2?????????
enum { out, on, in };
int convex_contains(const Polygon &P, const Point &p) {
	const int n = P.size();
	Point g = (P[0] + P[n / 3] + P[2 * n / 3]) / 3.0l; // inner-point
	int a = 0, b = n;
	while (a + 1 < b) { // invariant: c is in fan g-P[a]-P[b]
		int c = (a + b) / 2;
		if (cross(P[a] - g, P[c] - g) > 0) { // angle < 180 deg
			if (cross(P[a] - g, p - g) > 0 && cross(P[c] - g, p - g) < 0) b = c;
			else                                                  a = c;
		}
		else {
			if (cross(P[a] - g, p - g) < 0 && cross(P[c] - g, p - g) > 0) a = c;
			else                                                  b = c;
		}
	}
	b %= n;
	if (cross(P[a] - p, P[b] - p) < 0) return 0;
	if (cross(P[a] - p, P[b] - p) > 0) return 2;
	return 1;
}

// ??????
//???????????????????????¨????????????????????§??¨???
Polygon convex_hull(vector<Point> ps) {
	int n = ps.size();
	int k = 0;
	sort(ps.begin(), ps.end());
	Polygon ch(2 * n);
	for (int i = 0; i < n; ch[k++] = ps[i++])
		while (k >= 2 && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0) --k;
	for (int i = n - 2, t = k + 1; i >= 0; ch[k++] = ps[i--])
		while (k >= t && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0) --k;
	ch.resize(k - 1);
	return ch;
}



//????????????
vector<Polygon> convex_cut(const Polygon &ps, const Line& l) {
	int n = ps.size();
	Polygon q;
	Polygon r;
	rep(i, n) {
		Point a = ps[i], b = ps[(i + 1) % n];
		Line m = Line(a, b);
		if (ccw(l.a, l.b, a) != -1) q.push_back(a);
		if (ccw(l.a, l.b, a) != 1) r.push_back(a);
		if (ccw(l.a, l.b, a) * ccw(l.a, l.b, b) < 0 && isis_ll(l, m)) {
			q.push_back(is_ll(l, m));
			r.push_back(is_ll(l, m));
		}
	}
	const vector<Polygon>polys{ q,r };
	return polys;
}


/* ??¢??¬??????????????? */
void add_Point(vector<Point> &ps, const Point p) {
	for (Point q : ps) if (abs(q - p) < eps) return;
	ps.push_back(p);
}




typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

void add_edge(Graph &g, int src, int dest, int cap, Weight weight) {
	g[src].push_back(Edge{ src, dest, cap, (int)g[dest].size(), weight });
	g[dest].push_back(Edge{ dest, src, 0, (int)g[src].size() - 1, -weight });
}

Graph segment_arrangement(const vector<Line> &s, const vector<Point> &p) {
	int n = p.size(), m = s.size();
	Graph g(n);
	rep(i, m) {
		vector<pair<ld, int>> vec;
		rep(j, n) {
			if (isis_sp(s[i], p[j]))
				vec.emplace_back(abs(s[i].a - p[j]), j);
		}
		sort(all(vec));
		rep(j, vec.size() - 1) {
			int from = vec[j].second, to = vec[j + 1].second;
			add_edge(g, from, to, 1, static_cast<Weight>(abs(p[from] - p[to])));
		}
	}
	return g;
}
pair<vector<Point>, Graph> sennbunn_arrangement(const vector<Line>&s) {
	vector<Point>crss;
	for (int i = 0; i < static_cast<int>(s.size()); ++i) {
		for (int j = i + 1; j < static_cast<int>(s.size()); ++j) {
			if (isis_ss(s[i], s[j])) {
				crss.push_back(is_ll2(s[i], s[j])[0]);
			}
		}
	}
	for (int i = 0; i <static_cast<int>(s.size()); ++i) {
		crss.push_back(s[i][0]);
		crss.push_back(s[i][1]);
	}
	sort(crss.begin(), crss.end());
	crss.erase(unique(crss.begin(), crss.end()), crss.end());

	return make_pair(crss, segment_arrangement(s, crss));
}

Graph Circle_arrangement(const vector<Circle> &c, const vector<Point> &p) {
	const int n = p.size(), m = c.size();
	Graph g(n);
	rep(i, m) {
		vector<pair<ld, int>> vec;
		rep(j, n) if (abs(abs(c[i].p - p[j]) - c[i].r) < eps)
			vec.emplace_back(arg(c[i].p - p[j]), j);
		sort(all(vec));
		rep(j, vec.size() - 1) {
			int from = vec[j].second, to = vec[j + 1].second;
			ld angle = vec[j + 1].first - vec[j].first;
			add_edge(g, from, to, 1, static_cast<Weight>(angle * c[i].r));
		}
		if (vec.size() >= 2) {
			int from = vec.back().second, to = vec.front().first;
			ld angle = vec.front().first - vec.back().first;
			add_edge(g, from, to, 1, static_cast<Weight>(angle * c[i].r));
		}
	}
	return g;
}


int main() {
	cout << setprecision(10) << fixed;
	while (1) {
		int N, M; cin >> N >> M;
		if (!N)break;
		vector<Point>ps;
		for (int i = 0; i < N; ++i) {
			int x, y; cin >> x >> y;
			ps.emplace_back(x, y);
		}
		vector<Polygon>areas(N, Polygon{ Point(-1e8,-1e8),Point(1e8,-1e8),Point(1e8,1e8),Point(-1e8,1e8) });
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				if (i == j)continue;
				else {
					Line l(point_bisection(ps[i], ps[j]));
					areas[i] = convex_cut(areas[i], l)[0];
				}
			}
		}
		vector<ld>anss(N);
		while (M--) {
			int bx, by, dx, dy, score; cin >> bx >> by >> dx >> dy >> score;
			ld sum = 4 * dx*dy;
			for (int i = 0; i < N; ++i) {
				Point ld(bx - dx, by - dy);
				Point rd(bx + dx, by - dy);
				Point ru(bx + dx, by + dy);
				Point lu(bx - dx, by + dy);
				Polygon catch_area = areas[i];
				catch_area = convex_cut(catch_area,Line(ld, rd))[0];
				catch_area = convex_cut(catch_area, Line(rd, ru))[0];
				catch_area = convex_cut(catch_area, Line(ru, lu))[0];
				catch_area = convex_cut(catch_area, Line(lu, ld))[0];
				anss[i] += get_area(catch_area)*score / sum;
			}

		}
		ld ans = *max_element(anss.begin(), anss.end());
		cout << ans << endl;
		
	}
	return 0;
}
accuracy: 1
time_ms: 140
memory_kb: 3364
final_rank: 14

code_snippet: #include <iostream>
#include <vector>
#include <fstream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <functional>
#include <ctime>
#include <numeric>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define fst first
#define snd second
#define all(c) ((c).begin()), ((c).end())


const double EPS = 1e-8;
int sign(double x) {
  if (x < -EPS) return -1;
  if (x > +EPS) return +1;
  return 0;
}
struct point {
  typedef double T;
  T x, y; 
  point &operator+=(point p) { x += p.x; y += p.y; return *this; }
  point &operator-=(point p) { x -= p.x; y -= p.y; return *this; }
  point &operator*=(T a)     { x *= a;   y *= a;   return *this; }
  point &operator/=(T a)     { return *this *= (1.0/a); }
  point operator-() const    { return {-x, -y}; }
  bool operator<(point p) const { 
    int s = sign(x - p.x);
    return s ? s < 0 : sign(y - p.y) < 0;
  }
};
bool operator==(point p, point q) { return !(p < q) && !(q < p); }
point operator+(point p, point q) { return p += q; }
point operator-(point p, point q) { return p -= q; }
point operator*(point::T a, point p) { return p *= a; }
point operator*(point p, point::T a) { return p *= a; }
point operator/(point p, point::T a) { return p /= a; }
point::T dot(point p, point q) { return p.x*q.x+p.y*q.y; }
point::T cross(point p, point q) { return p.x*q.y-p.y*q.x; } // left turn > 0
point::T norm2(point p) { return dot(p,p); }
point orth(point p) { return {-p.y, p.x}; }
point::T norm(point p) { return sqrt(dot(p,p)); }
point::T arg(point p) { return atan2(p.y, p.x); }

struct line { point p, q; };
typedef vector<point> polygon;

polygon convex_cut(polygon ps, line l) {
  vector<point> qs;
  for (int i = 0; i < ps.size(); ++i) {
    int j = (i+1 == ps.size() ? 0 : i+1);
    if (sign(cross(l.p - ps[i], l.q - ps[i])) >= 0) qs.push_back(ps[i]); 
    if (sign(cross(l.p - ps[i], l.q - ps[i])) *
        sign(cross(l.p - ps[j], l.q - ps[j])) < 0) {
      auto a = cross(ps[j] - ps[i], l.q - l.p);
      auto b = cross(l.p - ps[i], l.q - l.p); 
      qs.push_back(ps[i] + b/a*(ps[j] - ps[i]));
    }
  }
  return qs;
}

struct delaunay {
  struct edge {
    int src, dst;
  };
  int n;
  vector<point> ps;
  vector<vector<edge>> adj; // optional
  vector<int> inner;
  int incircle(int a, int b, int c, int p) {
    point u = ps[a]-ps[p], v = ps[b]-ps[p], w = ps[c]-ps[p];
    return sign(norm2(u)*cross(v,w)
               +norm2(v)*cross(w,u)
               +norm2(w)*cross(u,v)) > 0;
  }
  bool orient(int a, int b, int p) { 
    point u = ps[a]-ps[b], v = ps[p]-ps[b];
    int s = sign(cross(u, v));
    return s ? s > 0 : sign(dot(u, v)) > 0;
  }
  delaunay(vector<point> ps) : n(ps.size()), ps(ps), adj(n), inner(n) {
    if (n <= 1) return;
    vector<unordered_map<int,int>> ccw(n); // ccw[u][v] is the third pt for (u,v)
    auto make_triangle = [&](int a, int b, int c) {
      ccw[a][b] = c; ccw[b][c] = a; ccw[c][a] = b;
    };
    vector<int> is(n); iota(all(is), 0);
    sort(all(is), [&](int i, int j) { return ps[i] < ps[j]; });

    // delaunay flips
    int nflip = 0;
    function<void(int,int)> rec = [&](int a, int b) { 
      if (!ccw[a].count(b) || !ccw[b].count(a)) return;
      int c = ccw[a][b], d = ccw[b][a];
      if (incircle(a, b, c, d) > 0) {
        ++nflip;
        ccw[a].erase(b); ccw[b].erase(a);
        make_triangle(d, c, a);
        make_triangle(c, d, b);
        rec(a, d); rec(d, b); rec(b, c); rec(c, a);
      }
    };
    // lexicographic triangulation 
    vector<int> next(n,-1), prev(n,-1); 
    next[is[0]] = prev[is[0]] = is[1];
    next[is[1]] = prev[is[1]] = is[0];
    for (int i = 2; i < n; ++i) {
      int h = is[i], u = is[i-1], v = u;
      while ( orient(u, next[u], h)) u = next[u];
      while (!orient(v, prev[v], h)) v = prev[v];
      for (int w = v; w != u; w = next[w]) 
        if (sign(cross(ps[next[w]]-ps[h], ps[w]-ps[h])) > 0) 
          make_triangle(w, h, next[w]);
      next[h] = u; prev[u] = h;
      prev[h] = v; next[v] = h;
    }
    for (int u: is) { 
      auto nbh = ccw[u]; // hardcopy
      for (auto z: nbh) rec(z.fst, z.snd); // flip
    }
    // complete graph structure
    for (int u: is) {
      int v = ccw[u].begin()->fst, s = v;
      while (ccw[s].count(u)) {
        s = ccw[s][u];
        if (s == v) break;
      }
      if (v != s) { inner[u] = false; v = s; }
      do {
        adj[u].push_back({u, v});
        if (!ccw[u].count(v)) break;
        v = ccw[u][v];
      } while (v != s);
    }
  }
};
struct voronoi {
  struct edge {
    int src, dst;
    point::T len;
  };
  int n, m;
  vector<point> ps, qs; // qs is the voronoi vertices
  map<point,int> id;
  vector<vector<int>> cell;
  vector<vector<edge>> adj;

  void add_edge(int u, int v) {
    auto len = norm(qs[u] - qs[v]);
    adj[u].push_back({u, v, len});
    adj[v].push_back({v, u, len});
  }
  int node(point p) { 
    if (!id.count(p)) { id[p] = m++; qs.push_back(p); adj.push_back({}); }
    return id[p];
  }
  voronoi(delaunay DT, vector<point> domain) : 
    n(DT.n), m(0), ps(DT.ps), cell(n) {
    for (int u = 0; u < n; ++u) {
      vector<point> region = domain;
      for (auto e: DT.adj[u]) {
        point s = (ps[e.src]+ps[e.dst])/2, d = orth(ps[e.dst]-ps[e.src]);
        region = convex_cut(region, {s, s+d});
      }
      for (int i = 0; i < region.size(); ++i) {
        add_edge(node(region[i]), node(region[(i+1)%region.size()]));
        cell[u].push_back(node(region[i]));
      }
    }
  }
  voronoi(vector<point> ps, vector<point> domain) :
    voronoi(delaunay(ps), domain) { }
};
int main() {
  for (int n, m; scanf("%d %d", &n, &m); ) {
    if (n == 0) break;
    vector<point> ps(n);
    for (int i = 0; i < n; ++i) 
      scanf("%lf %lf", &ps[i].x, &ps[i].y);
    delaunay DT(ps);

    vector<double> score(n);
    double ans = 0.0;
    for (int j = 0; j < m; ++j) {
      point c, d;
      double s; 
      scanf("%lf %lf %lf %lf %lf", &c.x, &c.y, &d.x, &d.y, &s);
      vector<point> domain = {
        c + point({-d.x, -d.y}),
        c + point({+d.x, -d.y}),
        c + point({+d.x, +d.y}),
        c + point({-d.x, +d.y}),
      };
      voronoi V(DT, domain);

      vector<point> &qs = V.qs;
      for (int i = 0; i < n; ++i) {
        point::T area = 0;
        int K = V.cell[i].size();
        for (int k = 0; k < K; ++k) {
          int v = V.cell[i][k], w = V.cell[i][(k+1)%K];
          area += cross(qs[v], qs[w]);
        }
        //cerr << "area of " << i << "th region: " << area << endl;
        score[i] += s * area / 2 / (4 * d.x * d.y);
        ans = max(ans, score[i]);
      }
    }
    printf("%.12lf\n", ans);
  }
}
accuracy: 1
time_ms: 20
memory_kb: 3332
final_rank: 11

code_snippet: #include<bits/stdc++.h>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-5)
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define COUNTER_CLOCKWISE 1
#define CLOCKWISE -1 
#define ONLINE_BACK 2
#define ONLINE_FRONT -2
#define ON_SEGMENT 0

using namespace std;

class Point{
public:
  double x,y;

  Point(double x = 0,double y = 0): x(x),y(y){}

  Point operator + (Point p){return Point(x+p.x,y+p.y);}
  Point operator - (Point p){return Point(x-p.x,y-p.y);}
  Point operator * (double a){return Point(a*x,a*y);}
  Point operator / (double a){return Point(x/a,y/a);}
  Point operator * (Point a){ return Point(x * a.x - y * a.y, x * a.y + y * a.x); }

  bool operator < (const Point& p) const{ return !equals(x,p.x)?x<p.x:(!equals(y,p.y)&&y<p.y); }

  bool operator == (const Point& p)const{ return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS; }

};

struct Segment{
  Point p1,p2;
  Segment(Point p1 = Point(),Point p2 = Point()):p1(p1),p2(p2){}
  bool operator <  (const Segment& s) const { return ( p2 == s.p2 ) ? p1 < s.p1 : p2 < s.p2; }
  bool operator == (const Segment& s) const { return ( s.p1 == p1 && s.p2 == p2 ) || ( s.p1 == p2 && s.p2 == p1 ); }

};

typedef Point Vector;
typedef Segment Line;
typedef vector<Point> Polygon;

ostream& operator << (ostream& os,const Point& a){ os << "(" << a.x << "," << a.y << ")"; }

ostream& operator << (ostream& os,const Segment& a){ os << "( " << a.p1 << " , " << a.p2 << " )"; }

double dot(Point a,Point b){ return a.x*b.x + a.y*b.y; }

double cross(Point a,Point b){ return a.x*b.y - a.y*b.x; }

double norm(Point a){ return a.x*a.x+a.y*a.y; }

double abs(Point a){ return sqrt(norm(a)); }

//rad ????§???????????????¢?????§?????????????????¨
Point rotate(Point a,double rad){ return Point(cos(rad)*a.x - sin(rad)*a.y,sin(rad)*a.x + cos(rad)*a.y); }

// ??????????????¢????????????
double toRad(double agl){ return agl*M_PI/180.0; }

// a => prev, b => cur, c=> next
// prev ?????? cur ????????£??? next ????????????????§????????±???????
double getArg(Point a,Point b,Point c){
  double arg1 = atan2(b.y-a.y,b.x-a.x);
  double arg2 = atan2(c.y-b.y,c.x-b.x);
  double arg = fabs( arg1 - arg2 );
  while( arg > M_PI ) arg -= 2.0 * M_PI;
  return fabs(arg);
}

int ccw(Point p0,Point p1,Point p2){
  Point a = p1-p0;
  Point b = p2-p0;
  if(cross(a,b) > EPS)return COUNTER_CLOCKWISE;
  if(cross(a,b) < -EPS)return CLOCKWISE;
  if(dot(a,b) < -EPS)return ONLINE_BACK;
  if(norm(a) < norm(b))return ONLINE_FRONT;
  return ON_SEGMENT;
}

bool intersectLL(Line l, Line m) {
  return abs(cross(l.p2-l.p1, m.p2-m.p1)) > EPS || // non-parallel
         abs(cross(l.p2-l.p1, m.p1-l.p1)) < EPS;   // same line
}
bool intersectLS(Line l, Line s) {
  return cross(l.p2-l.p1, s.p1-l.p1)*       // s[0] is left of l
         cross(l.p2-l.p1, s.p2-l.p1) < EPS; // s[1] is right of l
}
bool intersectLP(Line l,Point p) {
  return abs(cross(l.p2-p, l.p1-p)) < EPS;
}
bool intersectSS(Line s, Line t) {
  return ccw(s.p1,s.p2,t.p1)*ccw(s.p1,s.p2,t.p2) <= 0 &&
         ccw(t.p1,t.p2,s.p1)*ccw(t.p1,t.p2,s.p2) <= 0;
}
bool intersectSP(Line s, Point p) {
  return abs(s.p1-p)+abs(s.p2-p)-abs(s.p2-s.p1) < EPS; // triangle inequality
}

Point projection(Line l,Point p) {
  double t = dot(p-l.p1, l.p1-l.p2) / norm(l.p1-l.p2);
  return l.p1 + (l.p1-l.p2)*t;
}
Point reflection(Line l,Point p) {
  return p + (projection(l, p) - p) * 2;
}
double distanceLP(Line l, Point p) {
  return abs(p - projection(l, p));
}
double distanceLL(Line l, Line m) {
  return intersectLL(l, m) ? 0 : distanceLP(l, m.p1);
}

double distanceLS(Line l, Line s) {
  if (intersectLS(l, s)) return 0;
  return min(distanceLP(l, s.p1), distanceLP(l, s.p2));
}
double distanceSP(Line s, Point p) {
  Point r = projection(s, p);
  if (intersectSP(s, r)) return abs(r - p);
  return min(abs(s.p1 - p), abs(s.p2 - p));
}

double distanceSS(Line s, Line t) {
  if (intersectSS(s, t)) return 0;
  return min(min(distanceSP(s, t.p1), distanceSP(s, t.p2)),
             min(distanceSP(t, s.p1), distanceSP(t, s.p2)));
}

Point crosspoint(Line l,Line m){
  double A = cross(l.p2-l.p1,m.p2-m.p1);
  double B = cross(l.p2-l.p1,l.p2-m.p1);
  if(abs(A) < EPS && abs(B) < EPS){
    vector<Point> vec;
    vec.push_back(l.p1),vec.push_back(l.p2),vec.push_back(m.p1),vec.push_back(m.p2);
    sort(vec.begin(),vec.end());
    assert(vec[1] == vec[2]); //???????????°??????????????????
    return vec[1];
    //return m.p1;
  }
  if(abs(A) < EPS)assert(false);
  return m.p1 + (m.p2-m.p1)*(B/A);
}

//Polygon??????????§???¢?????????Line??§?????????????????´(COUNTER_CLOCKWISE)????????????
Polygon cutPolygon( Polygon P, Line l ){
    Polygon u;
    for ( int i = 0; i < P.size(); i++ ){
        Point a = P[i], b = P[(i+1)%P.size()];
        if ( ccw(l.p1, l.p2, a) != CLOCKWISE ) u.push_back(a);
	 //if( ccw(l.p1,l.p2,a) != COUNTER_CLOCKWISE ) R.push_back(a); // ????????????????????´???
        if ( ccw(l.p1, l.p2, a) * ccw(l.p1, l.p2, b) == -1 ){
      u.push_back(crosspoint(Segment(a, b), l));
        }
    }
    return u;
}

double getArea(vector<Point>& vec) {
  double sum = 0;
  for(int i=0;i<vec.size();i++)
    sum += cross(vec[i],vec[(i+1)%vec.size()]);
  return fabs(sum)/2.0;
}

class Voronoi
{
public:
  Polygon poly;
 
  Voronoi(Polygon poly):poly(poly){}
 
  Point polar(double a,double rad){ return Point(a*cos(rad),a*sin(rad)); }
 
  double args(Point p){ return atan2(p.y,p.x); }
 
  Line CreateLine(Point p,Point pp){
    Point mid = (p+pp)/2;
    Point sl = pp-p;//?????????5
    double rad = args(sl);
    Point ap = polar(abs(sl),rad+M_PI/2)+mid;
    //ap.x = abs(sl)*cos(rad+M_PI/2)+mid.x;
    //ap.y = abs(sl)*sin(rad+M_PI/2)+mid.y;
    return Line(mid,ap);
  } 

  //?????????pos??????????????????????????????V(pos)?????¢???????????? 
  //points???????§???¢??????????????¨????????????????????????]
  //pos???points?????????????????????
  double getAreaOfVoronoi(vector<Point>& points,int pos)
  {
    Polygon polx = poly;
    int N = points.size();
    for(int i=0;i<N;i++)
      if(i != pos)
	polx = cutPolygon(polx,CreateLine(points[pos],points[i]));
    return getArea(polx);
  }  

};

const int MAX_N = 110;
int N,M;
double maxi[MAX_N];
vector<Point> ps;

void update(Point ball,Point d,double score){
  Polygon poly(4);
  poly[0] = Point(ball.x-d.x,ball.y-d.y);
  poly[1] = Point(ball.x+d.x,ball.y-d.y);
  poly[2] = Point(ball.x+d.x,ball.y+d.y);
  poly[3] = Point(ball.x-d.x,ball.y+d.y);
  double area = abs(d.x*2) * abs(d.y*2);
  Voronoi vor(poly);
  rep(i,N){
    maxi[i] += ( vor.getAreaOfVoronoi(ps,i) / area ) * score;
  }
}

int main(){
  while( cin >> N >> M, N|M ){
    ps.clear();
    ps.resize(N);
    rep(i,N) cin >> ps[i].x >> ps[i].y;
    
    rep(i,N) maxi[i] = 0;
    rep(i,M) {
      Point b,d;
      double score;
      cin >> b.x >> b.y >> d.x >> d.y >> score;
      update(b,d,score);
    }
    int max_p = 0;
    REP(i,1,N) if( !equals(maxi[max_p],maxi[i]) && maxi[max_p] < maxi[i] ) max_p = i;
    printf("%.10f\n",maxi[max_p]);
  }
  return 0;
}
accuracy: 1
time_ms: 280
memory_kb: 1352
final_rank: 10

code_snippet: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;
const int MAX_M = 10;

/* typedef */

struct Ball {
  int x, y, dx, dy, sc;
  Ball() {}
  Ball(int _x, int _y, int _dx, int _dy, int _sc):
    x(_x), y(_y), dx(_dx), dy(_dy), sc(_sc) {}
};

struct Pt {
  double x, y;

  Pt() {}
  Pt(double _x, double _y) : x(_x), y(_y) {}
  Pt(const Pt& pt) : x(pt.x), y(pt.y) {}

  Pt operator+(const Pt pt) const { return Pt(x + pt.x, y + pt.y); }
  Pt operator-() const { return Pt(-x, -y); }
  Pt operator-(const Pt pt) const { return Pt(x - pt.x, y - pt.y); }
  Pt operator*(double t) const { return Pt(x * t, y * t); }
  Pt operator/(double t) const { return Pt(x / t, y / t); }
  double dot(Pt v) { return x * v.x + y * v.y; }
  double cross(Pt v) { return x * v.y - y * v.x; }
  Pt mid(const Pt pt) { return Pt((x + pt.x) / 2, (y + pt.y) / 2); }
  
  string to_s() {
    char s[1000];
    sprintf(s, "(%f,%f)", x, y);
    return string(s);
  }
};

struct CL {
  Pt pt;
  double t0, t1;
  CL() {}
  CL(const Pt& _pt, double _t0, double _t1) : pt(_pt), t0(_t0), t1(_t1) {}
};

typedef vector<Pt> vpt;

/* global variables */

int n, m;
Pt pts[MAX_N];
Ball bs[MAX_M];
double evs[MAX_N];

/* subroutines */

bool cross_lines(const Pt& a0, const Pt& a1, const Pt& b0, const Pt& b1,
		 CL& cl) {
  Pt da = a1 - a0;
  Pt db = b1 - b0;

  double op01 = da.cross(db);
  if (op01 == 0.0) return false; /* need to handle parallel?? */

  Pt v = b0 - a0;
  double op0 = v.cross(da);
  double op1 = v.cross(db);

  double t0 = op1 / op01;
  double t1 = op0 / op01;

  cl.pt = db * t1 + b0;
  cl.t0 = t0;
  cl.t1 = t1;
  return true;
}

void convex_cut(const vpt& scpol, vpt& dcpol, const Pt& pt0, const Pt& pt1) {
  int n = scpol.size();
  Pt v = pt1 - pt0;
  dcpol.clear();

  for (int i = 0; i < n; i++) {
    Pt cpt0 = scpol[i];
    double cr0 = v.cross(cpt0 - pt0);
    if (cr0 >= 0.0) dcpol.push_back(cpt0);
    
    Pt cpt1 = scpol[(i + 1) % n];
    double cr1 = v.cross(cpt1 - pt0);
    if (cr0 * cr1 < 0.0) {
      CL cl;
      cross_lines(pt0, pt1, cpt0, cpt1, cl);
      dcpol.push_back(cl.pt);
    }
  }
}

double calc_area(const vpt& cpol) {
  int nc = cpol.size();
  if (nc < 3) return 0.0;

  Pt pt0 = cpol[0];
  Pt v0 = cpol[1] - pt0;
  double area = 0.0;
  
  for (int i = 2; i < nc; i++) {
    Pt v1 = cpol[i] - pt0;
    area += v0.cross(v1);
    v0 = v1;
  }

  return area / 2;
}

/* main */

int main() {
  for (;;) {
    cin >> n >> m;
    if (n == 0) break;

    for (int i = 0; i < n; i++) {
      cin >> pts[i].x >> pts[i].y;
      evs[i] = 0.0;
    }

    for (int i = 0; i < m; i++)
      cin >> bs[i].x >> bs[i].y >> bs[i].dx >> bs[i].dy >> bs[i].sc;

    vpt cpols[2];

    for (int k = 0; k < m; k++) {
      Ball& bk = bs[k];
      double totalarea = 4 * bk.dx * bk.dy;
      
      for (int i = 0; i < n; i++) {
	Pt& pti = pts[i];
	int cur = 0, nxt = 1;

	cpols[0].clear();
	cpols[0].push_back(Pt(bk.x - bk.dx, bk.y - bk.dy));
	cpols[0].push_back(Pt(bk.x + bk.dx, bk.y - bk.dy));
	cpols[0].push_back(Pt(bk.x + bk.dx, bk.y + bk.dy));
	cpols[0].push_back(Pt(bk.x - bk.dx, bk.y + bk.dy));

	for (int j = 0; j < n; j++) {
	  if (i == j) continue;

	  Pt& ptj = pts[j];
	  Pt pm = pti.mid(ptj);
	  Pt vij = ptj - pti;
	  Pt v(-vij.y, vij.x);

	  convex_cut(cpols[cur], cpols[nxt], pm - v, pm + v);
	  cur ^= 1;
	  nxt ^= 1;
	}	

	double area = calc_area(cpols[cur]);
	evs[i] += bk.sc * area / totalarea;
      }
    }

    double maxev = 0.0;
    for (int i = 0; i < n; i++)
      if (maxev < evs[i]) maxev = evs[i];

    printf("%.6lf\n", maxev);
  }

  return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 1252
final_rank: 1

code_snippet: #include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
#include <assert.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

namespace geom{
#define X real()
#define Y imag()
#define at(i) ((*this)[i])
#define SELF (*this)
	enum {TRUE = 1, FALSE = 0, BORDER = -1};
	typedef int BOOL;
	typedef double R;
	const R INF = 1e8;
	const R EPS = 1e-12;
	const R PI = 3.1415926535897932384626;
	inline int sig(const R &x) { return (abs(x) < EPS ? 0 : x > 0 ? 1 : -1); }
	inline BOOL less(const R &x, const R &y) {return sig(x-y) ? x < y : BORDER;}
	typedef complex<R> P;
	inline R norm(const P &p){return p.X*p.X+p.Y*p.Y;}
	inline R inp(const P& a, const P& b){return (conj(a)*b).X;}
	inline R outp(const P& a, const P& b){return (conj(a)*b).Y;}
	inline P unit(const P& p){return p/abs(p);}
	inline P proj(const P &s, const P &t){return t*inp(s, t)/norm(t);}
	inline int ccw(const P &s, const P &t, const P &p, int adv=0){
		int res = sig(outp(t-s, p-s));
		if(res || !adv) return res;
		if(sig(inp(t-s, p-s)) < 0) return -2;	// p-s-t
		if(sig(inp(s-t, p-t)) < 0) return 2;	// s-t-p
		return 0;								// s-p-t
	}
	
	
	struct L : public vector<P>{	// line
		L(const P &p1, const P &p2){this->push_back(p1);this->push_back(p2);}
		L(){}
		P dir()const {return at(1) - at(0);}
		BOOL online(const P &p)const {return !sig(outp(p-at(0), dir()));}
	};
	struct S : public L{	// segment
		S(const P &p1, const P &p2):L(p1, p2){}
		S(){}
		BOOL online(const P &p)const {
			if(!sig(norm(p - at(0))) || !sig(norm(p - at(1)))) return BORDER;
			return !sig(abs(at(0)-p) + abs(at(1) - p) - abs(at(0) - at(1)));
		}
	};
	struct C : public P{
		C(){}
		C(const P& p, const R r):P(p), r(r){}
		R r;
		BOOL inside(const P& p)const { return less(norm(p-SELF), r*r);}
	};
	struct F : public C{
		R s, t;
		F(const C &c, R ss, R tt):C(c), s(ss), t(tt){
			if(PI < s) s -= 2*PI;
			if(PI < t) t -= 2*PI;
		}
		BOOL inside(const P& p)const {
			P v = p - SELF;
			if(!sig(norm(v))) return BORDER;
			R a = arg(v);
			if(t < s){
				if((!less(s, a) && !less(a, t)) || !less(norm(v), r*r)) return FALSE;
				return less(s, a) | less(a, t) | less(norm(v), r*r);
			}else{
				if(!less(s, a) || !less(a, t) || !less(norm(v), r*r)) return FALSE;
				return less(s, a) | less(a, t) | less(norm(v), r*r);
			}
		}
	};
	P crosspoint(const L &l, const L &m);
	struct G : public vector<P>{
		G(size_type size=0):vector(size){}
		S edge(int i)const {return S(at(i), at(i+1 == size() ? 0 : i+1));}
		BOOL contains(const P &p)const {
			R sum = .0;
			REP(i, size()){
				if(S(at(i), at((i+1)%size())).online(p)) return BORDER;	// online
				sum += arg((at(i) - p) / (at((i+1)%size()) - p));
			}
			return !!sig(sum);
		}
		R area()const {
			R sum = 0;
			REP(i, size()) sum += outp(at(i), at((i+1)%size()));
			return abs(sum / 2.);
		}
		
		G convex_hull(bool online = false) {
			if(size() < 2) return *this;
			sort(ALL(*this));
			G r;
			r.resize((int)size()*2);
			int k=0;
			for(int i=0;i<size();r[k++]=at(i++))
				while(k>1 && ccw(r[k-2], r[k-1], at(i)) < 1-online) k--;
			int t = k;
			for(int i=(int)size()-1;i>=0;r[k++]=at(i--))
				while(k>t && ccw(r[k-2], r[k-1], at(i)) < 1-online) k--;
			r.resize(k-1);
			return r;
		}
		G cut(const L &l)const {
			G g;
			REP(i, size()){
				const S &s = edge(i);
				if(ccw(l[0], l[1], s[0], 0) >= 0) g.push_back(s[0]);
				if(ccw(l[0], l[1], s[0], 0) * ccw(l[0], l[1], s[1], 0) < 0)
					g.push_back(crosspoint(s, l));
			}
			return g;
		}
		G Voronoi(const vector<P> &p, const int t)const {
			G g = *this;
			REP(i, p.size())if(i!=t){
				const P m = (p[t]+p[i])*0.5;
				g = g.cut(L(m, m+(p[i]-p[t])*P(0, 1)));
			}
			return g;
		}
	};

	inline P proj(const P &s, const L &t){return t[0] + proj(s-t[0], t[1]-t[0]);}
	inline P reflect(const P &s, const L &t){return 2.*proj(s, t) - s;}
	inline S reflect(const S &s, const L &t){return S(reflect(s[0], t), reflect(s[1], t));}
	BOOL intersect(const S &s, const S &t){
		const int p = ccw(t[0], t[1], s[0], 1) * ccw(t[0], t[1], s[1], 1);
		const int q = ccw(s[0], s[1], t[0], 1) * ccw(s[0], s[1], t[1], 1);
		return (p>0||q>0) ? FALSE : (!p||!q) ? BORDER : TRUE;
	}
	BOOL intersect(const S &s, const L &l){
		if(l.online(s[0]) || l.online(s[1])) return BORDER;
		return (sig(outp(l.dir(), s[0]-l[0])) * sig(outp(l.dir(), s[1]-l[0])) <= 0);
	}
	R dist2(const L &l, const P &p){return norm(outp(l.dir(), p - l[0])) / norm(l.dir());}
	R dist2(const S &s, const P &p){
		if(inp(p-s[0],  s.dir()) < EPS) return norm(p - s[0]);
		if(inp(p-s[1], -s.dir()) < EPS) return norm(p - s[1]);
		return dist2((const L &)s, p);
	}
	R dist2(const S &s, const L &l){
		return intersect(s, l) ? .0 : min(dist2(l, s[0]), dist2(l, s[1]));
	}
	R dist2(const S &s, const S &t){
		return intersect(s, t) ? .0 : min(min(dist2(s, t[0]), dist2(t, s[0])), 
									   	  min(dist2(s, t[1]), dist2(t, s[1])));
	}
	template <class T> R dist2(const G &g, const T& t){ // todo: 内部に完全に含まれる場合
		R res = INF;
		REP(i, g.size()) res = min(res, dist2(g.edge(i), t));
		return res;
	}
	template<class S, class T> R dist(const S& s, const T& t){return sqrt(dist2(s, t));}
	inline BOOL intersect(const C &a, const C &b){
		return less((a.r-b.r)*(a.r-b.r), norm(a-b)) + less(norm(a-b), (a.r+b.r)*(a.r+b.r)) - 1;
	}
	inline BOOL intersect(const C &c, const L &l){
		return less(dist2(l, c), c.r*c.r);
	}
	inline BOOL intersect(const C &c, const S &s){
		int d = less(dist2(s, c), c.r*c.r);
		if(d != TRUE) return d;
		int p = c.inside(s[0]), q = c.inside(s[1]);
		return (p<0 || q<0) ? BORDER : p&q;
	}
	
	/*
	 * CCWでs[0]->s[1]にかけてが共通部分
	 */
	inline S crosspoint(const C &c1, const C &c2){
		if(!intersect(c1, c2)) return S();
		R d = abs(c1 - c2);
		R x = (c1.r*c1.r - c2.r*c2.r + d*d) / (2*d);
		R h = sqrt(c1.r*c1.r - x*x);
		P u = unit(c2-c1);
		return S(c1 + u*x + u*P(0,-1)*h, c1 + u*x + u*P(0,1)*h);
	}
	inline P crosspoint(const L &l, const L &m){
		R A = outp(l.dir(), m.dir()), B = outp(l.dir(), l[1] - m[0]);
		if(!sig(abs(A)) && !sig(abs(B))) return m[0]; // same line
		if(abs(A) < EPS) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
		return m[0] + B / A * (m[1] - m[0]);
	}
	inline S crosspoint(const C &c, const L &l){
		R d2 = dist2(l, c);
		if(c.r*c.r+EPS < d2) return S();
		P m = proj(c, l);
		P u = unit(l[1]-l[0]);
		R d = sqrt(c.r*c.r - d2);
		return S(m+u*d, m-u*d);
	}
	inline vector<P> crosspoint(const C &c, const S &s){
		vector<P> res = crosspoint(c, (const L&)s);
		RREP(i, res.size()){
			if(inp(res[i]-s[0], s.dir())*inp(res[i]-s[1], -s.dir())<EPS)
				res.erase(res.begin() + i);
		}
		return res;
	}
	inline R commonarea(const C &a, const C &b){
		if(less(norm(a-b), (a.r-b.r)*(a.r-b.r)) == TRUE) return min(a.r*a.r, b.r*b.r)*PI;
		if(less((a.r+b.r)*(a.r+b.r), norm(a-b)) == TRUE) return .0;
		double d = abs(a-b);
		double rc = (d*d + a.r*a.r - b.r*b.r) / (2*d);
		double theta = acos(rc / a.r);
		double phi = acos((d - rc) / b.r);
		return a.r*a.r*theta + b.r*b.r*phi - d*a.r*sin(theta);
	}
	vector<L> CommonTangent(C c1, C c2){
		if(c1.r > c2.r) swap(c1, c2);
		double d = abs(c1-c2);
		vector<L> res;
		if(d < EPS) return res;
		if(d + EPS > c1.r + c2.r){
			// 内接線
			P crs = (c1*c2.r + c2*c1.r) / (c1.r + c2.r);
			double rad = asin(c1.r/abs(crs-c1));
			res.push_back(L(crs, crs + (c1-crs)*polar(1., rad)));
			res.push_back(L(crs, crs + (c1-crs)*polar(1., -rad)));
		}
		if(c1.r + d + EPS > c2.r){
			// 外接線
			double rad = 0.5*PI+asin((c2.r-c1.r) / d);
			P v = unit(c2-c1)*polar(1., rad);
			if(c1.r + d - EPS < c2.r){
				res.push_back(L(c1+v*c1.r, c1+v*c1.r+(c1-c2)*P(0, 1)));
			}else{
				res.push_back(L(c1+v*c1.r, c2+v*c2.r));
				v = 2.*proj(v, c2-c1) - v;
				res.push_back(L(c1+v*c1.r, c2+v*c2.r));
			}
		}
		return res;
	}
	
	
	struct Arrangement{
		struct AEdge{
			int u, v, t;
			R cost;
			AEdge(int u=0, int v=0, int t=0, R cost=0)
				:u(u), v(v), t(t), cost(cost){}
		};
		typedef vector<vector<AEdge>> AGraph;
		vector<P> p;
		AGraph g;
		Arrangement(){}
		Arrangement(vector<S> seg){
			int m = seg.size();
			REP(i, m){
				p.push_back(seg[i][0]);
				p.push_back(seg[i][1]);
				REP(j, i) if(sig(outp(seg[i].dir(), seg[j].dir())) && intersect(seg[i], seg[j]) == TRUE)
					p.push_back(crosspoint(seg[i], seg[j]));
			}
			sort(ALL(p)); UNIQUE(p);
			int n=p.size();
			g.resize(n);
			REP(i, m){
				S &s = seg[i];
				vector<pair<R, int>> ps;
				REP(j, n) if(s.online(p[j])) ps.emplace_back(norm(p[j] - s[0]), j);
				sort(ALL(ps));
				REP(j, (int)ps.size()-1){
					const int u=ps[j].second;
					const int v=ps[j+1].second;
					g[u].emplace_back(u, v, 0, abs(p[u] - p[v]));
					g[v].emplace_back(v, u, 0, abs(p[u] - p[v]));
				}
			}
		}
		
		int getIdx(P q){
			auto it = lower_bound(ALL(p), q);
			if(it == p.end() || *it != q) return -1;
			return it - p.begin();
		}
	};

	struct min_ball {
		P center;
		R radius2;
		min_ball(const vector<P>& p) {
			FOR(it, p) ps.push_back(*it);
		}
		min_ball& compile() {
			m = 0;
			center = P(0, 0);
			radius2 = -1;
			make_ball(ps.end());
			return *this;
		}
	private:
		list<P> ps;
		list<P>::iterator supp_end;
		int m;
		P v[3], c[3];
		R z[3], r[3];
		void pop() { --m; }
		void push(const P& p) {
			if (m == 0) {
				c[0] = p; r[0] = 0;
			} else {
				R e = norm(p-c[m-1]) - r[m-1];
				P delta = p - c[0];
				v[m] = p - c[0];
				for (int i = 1; i < m; ++i)
					v[m] -= v[i] * inp(v[i], delta) / z[i];
				z[m] = inp(v[m], v[m]);
				c[m] = c[m-1] + e*v[m]/z[m]*.5;
				r[m] = r[m-1] + e*e/z[m]*.25;
			}
			center	= c[m];
			radius2 = r[m]; ++m;
		}
		void make_ball(list<P>::iterator i) {
			supp_end = ps.begin();
			if (m == 3) return;
			for (list<P>::iterator k = ps.begin(); k != i; ) {
				list<P>::iterator j = k++;
				if (norm(*j-center) > radius2) {
					push(*j); make_ball(j); pop();
					move_to_front(j);
				}
			}
		}
		void move_to_front(list<P>::iterator j) {
			if (supp_end == j) ++supp_end;
			ps.splice (ps.begin(), ps, j);
		}
	};

#undef SELF
#undef at
}

using namespace geom;


namespace std{
	bool operator<(const P &a, const P &b){return sig(a.X-b.X) ? a.X < b.X : a.Y < b.Y;}
	bool operator==(const P &a, const P &b){return !sig(norm(a-b));}
	istream& operator>>(istream &is, P &p){R x,y;is>>x>>y;p=P(x, y);return is;}
	istream& operator>>(istream &is, L &l){l.resize(2);return is >> l[0] >> l[1];}
	istream& operator>>(istream &is, C &c){return is >> (P &)c >> c.r;}
//	const double Z = 3;
//	ostream& operator<<(ostream &os, const P &p){return os << "circle("<<Z*(200+p.X)<<", "<<Z*(200-p.Y)<<", 2)";}
//	ostream& operator<<(ostream &os, const C &c){return os << "circle("<<Z*(200+c.X)<<", "<<Z*(200-c.Y)<<", "<<Z*(c.r)<<")";}
//	ostream& operator<<(ostream &os, const S &s){return os << "line("<<Z*(200+s[0].X)<<", "<<Z*(200-s[0].Y)<<", "<<Z*(200+s[1].X)<<", "<<Z*(200-s[1].Y)<<")";}
//	ostream& operator<<(ostream &os, const G &g){REP(i, g.size()) cout << g.edge(i) << endl;return os;}
}


int n, m;

int main(){
	ios::sync_with_stdio(false);
	while(cin >> n >> m, n){
		vector<P> p(n);
		vector<R> ans(n, .0);
		REP(i, n) cin >> p[i];
		REP(i, m){
			R sx, sy, dx, dy, score;
			G g;
			cin >> sx >> sy >> dx >> dy >> score;
			g.emplace_back(sx-dx, sy-dy);
			g.emplace_back(sx+dx, sy-dy);
			g.emplace_back(sx+dx, sy+dy);
			g.emplace_back(sx-dx, sy+dy);
			score /= dx*dy*4;
			REP(j, n) ans[j] += g.Voronoi(p, j).area() * score;
		}
		printf("%.14f\n", *max_element(ALL(ans)));
	}
	return 0;
}
accuracy: 1
time_ms: 420
memory_kb: 1288
final_rank: 12

code_snippet: #include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;
typedef complex<double> P;
typedef vector<P> L;
typedef vector<P> Pol;
const double EPS = 1e-5;
int sign(double x){ return x > EPS ? 1 : x < -EPS ? -1 : 0; }

// テ・ツ??ァツゥツ催」ツδサテ・ツ、ツ姪ァツゥツ?
double dot(P a, P b){return real(conj(a) * b);}
double cross(P a, P b){return imag(conj(a) * b);}
int ccw(P a, P b, P c) {
    b -= a; c -= a;
    return sign(cross(b,c)) ? : dot(b,c) < 0 ? 2 : norm(b) < norm(c) ? -2 : 0;
}

P vec(L l){return l[1] - l[0];}
vector<P> pLL(L l, L m){
    double A = cross(vec(l), vec(m));
    double B = cross(vec(l), l[1] - m[0]);
    if(sign(A) == 0 && sign(B) == 0) return {l[0], l[1], m[0], m[1]}; // テ、ツコツ古ァツ崢エテァツキツ堙」ツ?古ゥツ?催」ツ?ェテ」ツ?」テ」ツ?ヲテ」ツ??」ツつ?
    if(sign(A) == 0) return{}; // テァツ崢エテァツキツ堙」ツ?古、ツコツ、テ」ツつ湘」ツつ嘉」ツ?ェテ」ツ??
    return {m[0] + vec(m) * B / A};
}

// テ・ツ?クテ・ツ、ツ堙ィツァツ津・ツスツ「テ」ツ?ョテァツ崢エテァツキツ堙」ツ?ォテ」ツつ暗」ツつ凝・ツ按?ヲツ鳴ュテ」ツ?づァツ崢エテァツキツ堙」ツ?ョテ・ツキツヲテ・ツ?エテ」ツ??」ツ?妥ヲツョツ凝」ツ??
// verify : aoj1283
Pol convex_cut(const Pol& A, L l){
    int n = A.size();
    Pol B;
    for(int i = 0; i < n; i++){
        P a = A[i], b = A[(i + 1) % n];
        if(ccw(l[0], l[1], a) != -1) B.push_back(a); //Aテ」ツ?古ァツ崢エテァツキツ嗟テ」ツ?ョテ・ツ渉ウテ・ツ?エテ」ツ?ァテ」ツ?ェテ」ツ??
        if(ccw(l[0], l[1], a) * ccw(l[0], l[1], b) < 0)
            B.push_back(pLL(l, {a, b})[0]);
    }
    return B;
}
// テ・ツ楪づァツ崢エテ、ツコツ古ァツュツ嘉・ツ按?ァツキツ?
// verify: maximamcup2013 D
L bisector(P a, P b){
    P mid = (a + b) / 2.0;
    P vec = (mid - a) * P(0.0, 1.0);
    return {mid, mid + vec};
}
// テァツつケテゥツ崢?・ツ青?sテ」ツ?ョテ」ツ??」ツ?。sテァツ閉ェテァツ崢ョテ」ツ?ョテ」ツδ愿」ツδュテ」ツδ偲」ツつ、テゥツ?佚・ツ淞?
// verify: maximamcup2013 D
Pol voronoi_cell(Pol A, const vector<P>& ps, int s){
    for(int i = 0; i < ps.size(); i++){
        if(i != s) A = convex_cut(A, bisector(ps[s], ps[i]));
    }
    return A;

}

double area(const Pol& A) {
    double res = 0;
    int n = A.size();
    for(int i = 0; i < n; i++){
        res += cross(A[i], A[(i + 1) % n]);
    }
    return abs(res) / 2.0;
}
Pol unite(Pol P, Pol b) {
    for(int i = 0; i < b.size(); i++) {
        L l = {b[i], b[(i+1)%b.size()]};
        P = convex_cut(P, l);
    }
    return P;
}

int main(){
    int N, M;
    while(cin >> N >> M && N > 0) {
        vector<P> vp(N);
        REP(i, N) {
            double x, y;
            cin >> x >> y;
            vp[i] = {x, y};
        }
        vector<Pol> pols(N);
        Pol uni;
        uni.push_back(P(-1e6, -1e6));
        uni.push_back(P(+1e6, -1e6));
        uni.push_back(P(+1e6, +1e6));
        uni.push_back(P(-1e6, +1e6));
        REP(i, N) pols[i] = voronoi_cell(uni, vp, i);

        vector<double> exp(N);

        REP(_, M) {
            Pol bal;
            double bx, by, dx, dy, score;
            cin >> bx >> by >> dx >> dy >> score;
            bal.push_back(P(bx-dx, by-dy));
            bal.push_back(P(bx+dx, by-dy));
            bal.push_back(P(bx+dx, by+dy));
            bal.push_back(P(bx-dx, by+dy));
            double SUM = dx * dy * 4;
            double verify = 0;
            REP(i, N) {
                double ratio = area(unite(pols[i], bal)) / SUM;
                exp[i] += score * ratio;
                verify += ratio;
            }
            assert(sign(verify - 1) == 0);
        }
        printf("%.6f\n", *max_element(exp.begin(), exp.end()));
    }
    return 0;
}
accuracy: 1
time_ms: 60
memory_kb: 1288
final_rank: 5

code_snippet: #include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
#define DEBUG(x) cerr << #x << " = " << x << endl
typedef double D;
const D EPS = 1e-8;
const D PI = M_PI;
struct P {
  D x, y;
  P() { }
  P(D x_, D y_) : x(x_), y(y_) { }
};
struct L {
  P a, b;
  L() { }
  L(P a_, P b_) : a(a_), b(b_) { }
};
struct C {
  P p; D r;
  C() { }
  C(P p_, D r_) : p(p_), r(r_) { }
};
P operator +(P a, P b) { return P(a.x + b.x, a.y + b.y); }
P operator -(P a, P b) { return P(a.x - b.x, a.y - b.y); }
P operator *(P a, D b) { return P(a.x * b, a.y * b); }
P operator /(P a, D b) { return P(a.x / b, a.y / b); }
P vec(P from, P to) { return to - from; }
D inp(P a, P b) { return a.x*b.x + a.y*b.y; }
D outp(P a, P b) { return a.x*b.y - a.y*b.x; }
D norm(P p) { return inp(p, p); }
D abs(P p) { return sqrt(norm(p)); }
int sig(D a, D b) {
  if(a < b - EPS) return -1;
  if(a > b + EPS) return +1;
  return 0;
}
// !!! とりあえずここまで写してください !!!
D arg(P p) { return atan2(p.y, p.x); }
P rot90(P p) { return P(-p.y, p.x); }
P rot(P p, D radian) {
  P q;
  q.x = cos(radian)*p.x - sin(radian)*p.y;
  q.y = sin(radian)*p.x + cos(radian)*p.y;
  return q;
}
int ccw(P a, P b, P c) { // 重なっている点があるとうまく動かないと思われる
  b = vec(a, b); c = vec(a, c);

  // a - b - c が折れ曲がるとき
  if(sig(outp(b, c), 0.0) > 0) return +1; // 反時計回り
  if(sig(outp(b, c), 0.0) < 0) return -1; // 時計回り

  // a - b - c が直線上に並ぶとき
  if(sig(inp(b, c), 0.0) < 0) return +2; // c - a - b
  if(norm(b) < norm(c))       return -2; // a - b - c
  return 0;                              // a - c - b
}
P projection(L l, P p) { // 直線lに対する点pの写像
  P a = vec(l.a, l.b);
  P b = vec(l.a, p);
  D t = inp(a, b) / norm(a);
  return l.a + a * t;
}
P reflection(L l, P p) { // 直線lに対する点pの反射
  return p + vec(p, projection(l, p)) * 2;
}

// 線分と点
bool iSP(L s, P p) {
  return ccw(s.a, s.b, p) == 0;
}
D dSP(L s, P p) {
  P r = projection(s, p);
  if(iSP(s, r)) return abs(p - r); // 写像がs上にある
  return min(abs(p - s.a), abs(p - s.b)); // 写像がs上にない
}

// 直線と点
bool iLP(L l, P p) {
  return abs(ccw(l.a, l.b, p)) != 1;
}
D dLP(L l, P p) {
  return abs(p - projection(l, p));
}

// 線分と線分
bool iSS(L s, L t) { // 端を含む
  return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0 &&
    ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
}
D dSS(L s, L t) {
  if(iSS(s, t)) return 0;
  return min(min(dSP(s, t.a), dSP(s, t.b)),
      min(dSP(t, s.a), dSP(t, s.b)));
}
// P cSS(L s, L t) はiSS(s,t)を確認してからcLLを使う

// 直線と直線
bool iLL(L l, L m) {
  return sig(outp(vec(l.a, l.b), vec(m.a, m.b)), 0.0) != 0 || // 平行でない
    sig(outp(vec(l.a, l.b), vec(l.a, m.a)), 0.0) == 0;   // 同じ直線
}
D dLL(L l, L m) {
  return iLL(l, m) ? 0.0 : dLP(l, m.a);
}
P cLL(L l, L m) {
  D d = outp(vec(m.a, m.b), vec(l.a, l.b));
  return l.a + vec(l.a, l.b) * outp(vec(m.a, m.b), vec(l.a, m.b)) / d;
}

// 直線と線分
bool iLS(L l, L s) {
  return sig(outp(vec(l.a, l.b), vec(l.a, s.a)), 0.0) *
    sig(outp(vec(l.a, l.b), vec(l.a, s.b)), 0.0) <= 0;
}
D dLS(L l, L s) {
  if(iSS(l, s)) return 0.0;
  return min(dLP(l, s.a), dLP(l, s.b));
}
// P cLS(L s, L t) はiSS(s,t)を確認してからcLLを使う

// 円と直線
int iCL(C c, L l) {
  D d = dLP(l, c.p);
  int s = sig(d, c.r);
  if(s < 0) return 2;
  if(s == 0) return 1;
  return 0;
}
vector<P> cCL(C c, L l) {
  P a = projection(l, c.p);
  D s = abs(c.p - a);
  D t = sqrt(c.r*c.r-s*s);
  P v = vec(l.a,l.b)/abs(l.a-l.b);
  vector<P> res;
  res.push_back(a+v*t);
  res.push_back(a-v*t);
  return res;
}

// 円と点
vector<P> tCP(C c, P p) {
  vector<P> res;
  D d = abs(c.p - p);
  if(sig(d,c.r) < 0) return res;
  D rc = c.r*c.r/d;
  D rs = sqrt(max(0.0, c.r*c.r - rc*rc));
  P v = (p - c.p) / abs(p - c.p);
  res.emplace_back(c.p + v*rc + rot90(v)*rs);
  res.emplace_back(c.p + v*rc - rot90(v)*rs);
  return res;
}

// 円と線分
int iCS(C c, L s) {
  if(sig(abs(c.p - s.a), c.r) <= 0 && sig(abs(c.p - s.b), c.r) <= 0)
    return -2; // 線分の両端が円の内側にある
  if(sig(abs(c.p - s.a), c.r) <= 0 || sig(abs(c.p - s.b), c.r) <= 0)
    return -1; // 線分の端の一方が円の内側、他方が円の外側にある
  if(sig(dLP(s, c.p), c.r) < 0) // dSPじゃなくてdLPで十分だと思う
    return +2; // 線分と円周が2点で交わる
  if(sig(dLP(s, c.p), c.r) == 0)
    return +1; // 線分と円周が1点で交わる
  return 0;
}
// vector<P> cCS(C c, L s) はiCSの状態によって定義が難しいが、
// p <- cCL(c,s)からiSP(s,p)==trueのものだけを抜き出せば良い気がする

// 円と円
// int iCC(C a, C b) はaがbの内側にある場合などもあるので定義が難しい
// 2点で接していることを確認すること
vector<P> cCC(C a, C b) {
  D d = abs(b.p - a.p);
  D x = (d*d + a.r*a.r - b.r*b.r) / (2*d);
  D y = sqrt(a.r*a.r - x*x);
  P v = (b.p - a.p) / d;
  vector<P> res;
  res.emplace_back(a.p + v*x + rot90(v)*y);
  res.emplace_back(a.p + v*x - rot90(v)*y);
  return res;
}
// tCCinに同じ円を食わせたり、
// tCCoutにどちらかが他方に囲まれている円を食わせたりすると破綻することは分かっているが、
// そのあたりが厳密にverifyできていない (AOJ 2201でACすることは確認した)
vector<L> tCCout(C a, C b) {
  vector<L> res;
  if(sig(abs(a.r - b.r), abs(a.p - b.p)) >= 0) return res;
  if(sig(a.r, b.r) == 0) {
    P v = (b.p - a.p) / abs(b.p - a.p);
    v = rot90(v);
    res.emplace_back(a.p + v*a.r, b.p + v*b.r);
    res.emplace_back(a.p - v*a.r, b.p - v*b.r);
    return res;
  }
  P p = (a.p*b.r - b.p*a.r) / (b.r - a.r);
  vector<P> at = tCP(a, p);
  vector<P> bt = tCP(b, p);
  for(int i = 0; i < (int)min(at.size(), bt.size()); ++i) {
    res.emplace_back(at[i], bt[i]);
  }
  return res;
}
vector<L> tCCin(C a, C b) {
  vector<L> res;
  if(sig(abs(a.r + b.r), abs(a.p - b.p)) >= 0) return res;
  P p = (a.p*b.r + b.p*a.r) / (a.r + b.r);
  vector<P> at = tCP(a, p);
  vector<P> bt = tCP(b, p);
  for(int i = 0; i < (int)min(at.size(), bt.size()); ++i) {
    res.emplace_back(at[i], bt[i]);
  }
  return res;
}
vector<L> tCC(C a, C b) {
  vector<L> res;
  for(L l : tCCout(a, b)) res.push_back(l);
  for(L l : tCCin(a, b)) res.push_back(l);
  return res;
}

// 多角形
typedef vector<P> G;
// 半時計回りを仮定している (時計回りならabsを取る)
D area(G g) {
  D res = 0.0;
  for(int i = 0; i < (int)g.size(); i++) {
    res += outp(g[i], g[(i+1)%g.size()]);
  }
  return res / 2.0;
}
// ON = 0, IN = 1, OUT = -1
int containsGP(G g, P p) {
  int side = -1;
  for(int i = 0; i < (int)g.size(); i++) {
    if(ccw(g[i], g[(i+1)%g.size()], p) == 0) return 0;
    P a = vec(p, g[i]);
    P b = vec(p, g[(i+1)%g.size()]);
    if(a.y > b.y) swap(a, b);
    if(sig(a.y, 0.0) <= 0 && sig(b.y, 0.0) > 0 && sig(outp(a, b), 0.0) > 0) side *= -1;
  }
  return side;
}
bool operator <(P a, P b) {
  if(sig(a.x, b.x) != 0) return a.x < b.x;
  return a.y < b.y;
}
// 凸包を構成する点を得る。半時計回り
// 辺上の点も含めるときは ccw(..) == -1 とすること
G convex_hull(vector<P> ps) {
  int N = ps.size();
  int k = 0; // 凸包を構成する点の数
  sort(ps.begin(), ps.end());
  G res(N * 2);
  for(int i = 0; i < N; i++) {
    // 時計回りの折れ曲がりがあったら、折れ点を削除
    while(k >= 2 && ccw(res[k - 2], res[k - 1], ps[i]) <= 0) k--;
    res[k++] = ps[i];
  }
  int t = k + 1;
  // 右端は取らない (重複するから)
  // 左端は取る (重複するけど、あとから取り除いたほうが楽)
  for(int i = N - 2; i >= 0; i--) {
    while(k >= t && ccw(res[k - 2], res[k - 1], ps[i]) <= 0) k--;
    res[k++] = ps[i];
  }
  res.resize(k - 1);
  return res;
}
// l.a -> l.b の厳密に右側の領域を切り落とす
G convex_cut(G g, L l) {
  G res;
  for(int i = 0; i < (int)g.size(); ++i) {
    P a = g[i];
    P b = g[(i+1)%g.size()];
    if(ccw(l.a, l.b, a) != -1) res.push_back(a);
    // 端の点を含まないiLS
    if(ccw(l.a, l.b, a)*ccw(l.a, l.b, b) < 0) {
      res.push_back(cLL(L(a, b), l));
    }
  }
  return res;
}
// aとbの垂直二等分線をaが左側に来るように計算する
L bisector(P a, P b) {
  P p = (a + b) / 2;
  return L(p, p + rot90(vec(a,b)));
}
// 外枠をgとして点集合vのk番目の点のボロノイ領域を返す
G voronoi_cell(G g, vector<P> v, int k) {
  for(int i = 0; i < (int)v.size(); ++i) {
    if(i == k) continue;
    g = convex_cut(g, bisector(v[k], v[i]));
  }
  return g;
}
int main() {
  while(true) {
    int N, M; cin >> N >> M;
    if(N == 0 && M == 0) break;
    vector<P> v;
    for(int i = 0; i < N; i++) {
      double x, y; cin >> x >> y;
      v.emplace_back(x,y);
    }
    vector<double> score(N);
    for(int i = 0; i < M; i++) {
      int bx,by,dx,dy;
      int s;
      cin >> bx >> by >> dx >> dy;
      cin >> s;
      G g;
      g.emplace_back(bx-dx,by+dy);
      g.emplace_back(bx-dx,by-dy);
      g.emplace_back(bx+dx,by-dy);
      g.emplace_back(bx+dx,by+dy);
      D all = area(g);
      for(int j = 0; j < N; j++) {
        D a = area(voronoi_cell(g, v, j));
        score[j] += a / all * s;
      }
    }
    cout.setf(ios::fixed);
    cout.precision(5);
    cout << *max_element(score.begin(), score.end()) << endl;
  }
}
accuracy: 1
time_ms: 170
memory_kb: 1320
final_rank: 8

code_snippet: #include<iostream>
#include<cfloat>
#include<cassert>
#include<cmath>
#include<vector>
#include<cstdio>
#include<set>
using namespace std;

#define EPS (1e-8)
#define equals(a, b) (fabs((a) - (b)) < EPS )
#define dle(a, b) (equals(a, b) || a < b )

static const double PI = acos(-1);

class Point{
    public:
    double x, y;
    
    Point ( double x = 0, double y = 0): x(x), y(y){}
    
    Point operator + ( Point p ){ return Point(x + p.x, y + p.y); }
    Point operator - ( Point p ){ return Point(x - p.x, y - p.y); }
    Point operator * ( double a ){ return Point(x*a, y*a); }
    Point operator / ( double a ){ return Point(x/a, y/a); }

    double abs() { return sqrt(norm());}
    double norm() { return x*x + y*y; }

    bool operator < ( const Point &p ) const {
	return x != p.x ? x < p.x : y < p.y;
    }

    bool operator == ( const Point &p ) const {
	return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
    }
};

typedef Point Vector;

class Segment{
    public:
    Point p1, p2;
    Segment(Point s = Point(), Point t = Point()): p1(s), p2(t){}
};

typedef Segment Line;

typedef vector<Point> Polygon;

double norm( Vector a ){ return a.x*a.x + a.y*a.y; }
double abs( Vector a ){ return sqrt(norm(a)); }
Point polar( double a, double r ){ return Point(cos(r)*a, sin(r)*a);}
double getDistance( Vector a, Vector b ){ return abs(a - b); }
double dot( Vector a, Vector b ){ return a.x*b.x + a.y*b.y; }
double cross( Vector a, Vector b ){ return a.x*b.y - a.y*b.x; }

Point project( Segment s, Point p ){
    Vector base = s.p2 - s.p1;
    double t = dot(p - s.p1, base)/norm(base);
    return s.p1 + base*t;
}

Point reflect( Segment s, Point p ){
    return p + (project(s, p) - p)*2.0;
}

// verified by uoa2062
bool isOnSegment( Point a, Point b, Point c){
    if ( a == c || b == c ) return true;
    return (abs(a-c) + abs(c-b) < abs(a-b) + EPS );
}

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

// EPS can be 0
// need to check for 920, 833, 866
int ccw( Point p0, Point p1, Point p2 ){
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if ( cross(a, b) > EPS ) return COUNTER_CLOCKWISE;
    if ( cross(a, b) < -EPS ) return CLOCKWISE;
    if ( dot(a, b) < -EPS ) return ONLINE_BACK;
    if ( norm(a) < norm(b) ) return ONLINE_FRONT;
    return ON_SEGMENT;
}

// intersect Segment p1-p2 and Segment p3-p4 ?
bool isIntersect(Point p1, Point p2, Point p3, Point p4){
    return ( ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 &&
	     ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0 );
}

// intersect Segment s1 and Segment s2 ?
// verified by 920, 833, 866, uoa2062
bool isIntersect(Segment s1, Segment s2){
    return isIntersect(s1.p1, s1.p2, s2.p1, s2.p2);
}

// verified by 920, 833, uoa2062
Point getCrossPoint(Segment s1, Segment s2){
    assert( isIntersect(s1, s2) );
    Vector base = s2.p2 - s2.p1;
    double d1 = abs(cross(base, s1.p1 - s2.p1));
    double d2 = abs(cross(base, s1.p2 - s2.p1));
    double t = d1/(d1 + d2);
    return s1.p1 + (s1.p2 - s1.p1)*t;
}

Point getCrossPointLines( Line s1, Line s2){
    Vector a = s1.p2 - s1.p1;
    Vector base = s2.p2 - s2.p1;
    return s1.p1 + a * cross(base, s2.p1 - s1.p1)/cross(base, a);
}

double arg(Vector p){
    return atan2(p.y, p.x);
}

Polygon cutPolygon( Polygon P, Line l ){
    Polygon u;
    for ( int i = 0; i < P.size(); i++ ){
	Point a = P[i], b = P[(i+1)%P.size()];
	if ( ccw(l.p1, l.p2, a) != CLOCKWISE ) u.push_back(a);
	if ( ccw(l.p1, l.p2, a) * ccw(l.p1, l.p2, b) == -1 ){
	    u.push_back(getCrossPointLines(Segment(a, b), l));
	}
    }
    return u;
}

double getArea(Polygon p){
    double sum = 0.0;
    for(int i = 0; i < p.size(); i++){
	sum += cross(p[i], p[(i+1)%p.size()]);
    }
    return abs(sum/2);
}

Line getCutLine( Point p1, Point p2 ){
    Vector v = p2 - p1;
    v = polar(abs(v), arg(v)+PI/2.0);
    double dx = (p2.x + p1.x)/2.0;
    double dy = (p2.y + p1.y)/2.0;
    return Line(Point(dx, dy), Point(v.x+dx, v.y+dy));
}

vector<Polygon> getVoronoi( vector<Point> PV ){
  static const int  X_MIN = -1000000;
  static const int Y_MIN = -1000000;
  static const int X_MAX = 1000000;
  static const int Y_MAX = 1000000;
  vector<Polygon> V;
  for ( int i = 0; i < PV.size(); i++ ){
    Polygon P;
    P.push_back(Point(X_MIN, Y_MIN));
    P.push_back(Point(X_MAX, Y_MIN));
    P.push_back(Point(X_MAX, Y_MAX));
    P.push_back(Point(X_MIN, Y_MAX));
    for ( int j = 0; j < PV.size(); j++ ){
      if ( i == j ) continue;
      P = cutPolygon(P, getCutLine(PV[i], PV[j]));
    }
    V.push_back(P);
  }
  return V;
}

int main(){
  int N, M;
  double S[100];

  while(1){
    cin >> N >> M;
    if ( N == 0 && M == 0 ) break;
    vector<Point> P;
    int x, y, dx, dy, s;
    set<Point> ps;
    for ( int i = 0; i < N; i++ ){
      cin >> x >> y;
      P.push_back(Point(x, y));
      ps.insert(Point(x, y));
    }
    assert(ps.size()==N);
    vector<Polygon> G = getVoronoi(P);

    for ( int i = 0; i < N; i++ ) S[i] = 0;
    double maxscore = 0;

    for ( int i = 0; i < M; i++ ){
      cin >> x >> y >> dx >> dy >> s;
      Polygon sq;
      sq.push_back(Point(x-dx, y-dy));
      sq.push_back(Point(x+dx, y-dy));
      sq.push_back(Point(x+dx, y+dy));
      sq.push_back(Point(x-dx, y+dy));
      
      for ( int p = 0; p < N; p++ ){
	Polygon sx = sq;
	Polygon g = G[p];
	for ( int j = 0; j < g.size(); j++ ){
	  Line l = Line(g[j], g[(j+1)%g.size()]);
	  sx = cutPolygon(sx, l);
	}
	S[p] += s*getArea(sx)/(dx*2*dy*2);
      }
    }

    for ( int i = 0; i < N; i++ ) maxscore = max(maxscore, S[i]);

    printf("%.8lf\n", maxscore);
  }
}
accuracy: 1
time_ms: 60
memory_kb: 1352
final_rank: 7

code_snippet: #include<algorithm>
#include <cstring>
#include <iostream>
#include<cmath>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<vector>
#include<utility>
#include<stack>
#include <complex>
#include <cassert>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

const double EPS = 1e-8;
const int INF = 1<<29;
const double PI = acos(-1);

typedef complex<double> P;

namespace std {
bool operator<(const P &a, const P&b) {
  return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
}
}
double cross(const P &a, const P&b) {
  return imag(conj(a)*b);
}
double dot(const P &a, const P&b) {
  return real(conj(a)*b);
}
struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
  L() {}
};
typedef  vector<P> G;

int ccw(P a, P b, P c) {
  b-=a; c-=a;
  if (cross(b,c) > 0) return 1;
  if (cross(b,c) < 0) return -1;
  if (dot(b,c) < 0) return 2;
  if (norm(b) < norm(c)) return -2;
  return 0;
}
P crosspoint(const L &l, const L &m) {
  double A = cross(l[1]-l[0], m[1]-m[0]);
  double B = cross(l[1]-l[0], l[1]-m[0]);
  if (abs(A) < EPS && abs(B) < EPS) return m[0];
  if (abs(A) < EPS) assert(false);
  return m[0] + B/A*(m[1]-m[0]);
}
double area( const G &g) {
  double A = 0;
  for (int i=0; i<g.size(); ++i)
    A += cross(g[i],g[(i+1)%g.size()]);
  return abs(A/2);
}
G convex_cut(const G &g, const L &l) {
  G Q;
  for (int i=0; i<g.size(); ++i) {
    P A = g[i];
    P B = g[(i+1)%g.size()];
    if (ccw(l[0], l[1],A) != -1) Q.push_back(A);
    if (ccw(l[0],l[1],A)  * ccw(l[0],l[1],B) < 0)
      Q.push_back(crosspoint(L(A,B),l));
  }
  return Q;
}
L bisector(const P &a, const P &b) {
  P A = (a+b)*P(0.5,0);
  return L(A,A+(b-a)*P(0,PI/2));
}
G voronoi_cell(G g, const vector<P> &v, int s) {
  for (int i=0; i<v.size(); ++i) {
    if (i!=s) {
      g = convex_cut(g,bisector(v[s],v[i]));
    }
  }
  return g;
}

double ans[100];

int main() {
  int n,m;
  while(cin>>n>>m,n||m) {
    vector<P> p(n);
    for (int i=0; i< n; ++i) cin >> p[i].real() >> p[i].imag();
    memset(ans,0,sizeof(ans));
    for (int i=0; i<m; ++i) {
      int bx,by,dx,dy;
      cin>>bx>>by>>dx>>dy;
      int score;
      cin >> score;
      G g;
      g.push_back(P(bx-dx,by-dy));
      g.push_back(P(bx+dx,by-dy));
      g.push_back(P(bx+dx,by+dy));
      g.push_back(P(bx-dx,by+dy));
      for (int i=0; i<n; ++i) {
        G v = voronoi_cell(g, p, i);
        ans[i] += area(v) / area(g) * score;
      }
    }
    double res = *max_element(ans,ans+n);
    printf("%.10f\n", res);
  }
  
}
accuracy: 1
time_ms: 270
memory_kb: 1272
final_rank: 9

code_snippet: #include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define lengthof(array) (sizeof(array) / sizeof(*array))
#define dump(a) (cerr << (#a) << " = " << (a) << endl)
#define FOR(it,c) for(__typeof((c).begin())it=(c).begin(); it!=(c).end();++it)
#define RFOR(it,c) for(__typeof((c).rbegin())it=(c).rbegin(); it!=(c).rend();++it)

template<class T> inline void chmax(T& a, const T& b) { if(b > a) a = b; }
template<class T> inline void chmin(T& a, const T& b) { if(b < a) a = b; }

template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << '(' << p.first << ", " << p.second << ')';
	return os;
}

template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	copy(v.begin(), v.end(), ostream_iterator<T>(os, " "));
	return os;
}

const double EPS = 1e-9;

struct point {
	double x, y;
	point():x(0), y(0) {}
	point(double x, double y):x(x), y(y) {}
	point(const point& p):x(p.x), y(p.y) {}

	point operator+ (const point& p) const {
		return point(x + p.x, y + p.y);
	}

	point operator- (const point& p) const {
		return point(x - p.x, y - p.y);
	}

	point operator* (const double s) const {
		return point(x * s, y * s);
	}

	point operator* (const point& p) const {
		return point(x * p.x - y * p.y, x * p.y + y * p.x);
	}

	point operator/ (const double s) const {
		return point(x / s, y / s);
	}

	bool operator< (const point& p) const {
		return x + EPS < p.x || abs(x - p.x) < EPS && y + EPS < p.y;
	}

	bool operator== (const point& p) const {
		return abs(x - p.x) < EPS && abs(y - p.y) < EPS;
	}
};

point rotate90(const point& p) {
	return point(-p.y, p.x);
}

point rotate(const point& p, const double theta) {
	const double s = sin(theta), c = cos(theta);
	return point(c * p.x - s * p.y, s * p.x + c * p.y);
}

double angle(const point& p) {
	return atan2(p.y, p.x);
}

double abs(const point& p) {
	return sqrt(p.x * p.x + p.y * p.y);
}

double norm(const point& p) {
	return p.x * p.x + p.y * p.y;
}

double dot(const point& l, const point& r) {
	return l.x * r.x + l.y * r.y;
}

double cross(const point& l, const point& r) {
	return l.x * r.y - l.y * r.x;
}

struct line {
	point a, b;
	line(point a, point b):a(a), b(b){}
};

struct segment {
	point a, b;
	segment(point a, point b):a(a), b(b){}
};

struct circle {
	point c;
	double r;
	circle(point c, double r):c(c), r(r){}
};

typedef vector<point> polygon;

int ccw(const point& a, point b, point c) {
	b = b - a;
	c = c - a;
	if(cross(b, c) > EPS) return 1; // ccw
	if(cross(b, c) < -EPS) return -1; // cw
	if(dot(b, c) < 0) return 2; // c, a, b 順に一直線上
	if(norm(b) < norm(c)) return -2; // a, b, c 順に一直線上
	return 0; //a, c, b 順で一直線上
}

point projection(const line& l, const point& p) {
	const point dif = l.b - l.a;
	const double tmp = dot(p - l.a, dif) / norm(dif);
	return l.a + dif * tmp;
}

bool intersect(const line& l, const line& m) {
	return abs(cross(l.b - l.a, m.b - m.a)) > EPS || abs(cross(l.b - l.a, m.b - l.a)) < EPS;
}

bool intersect(const line& l, const segment& s) {
	return cross(l.b - l.a, s.a - l.a) * cross(l.b - l.a, s.b - l.a) < EPS;
}

bool intersect(const line& l, const point& p) {
	return abs(ccw(l.a, l.b, p)) != -1;
}

bool intersect(const segment& s, const segment& t) {
	return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0 &&
		ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
}

bool intersect(const segment& s, const point& p) {
	return ccw(s.a, s.b, p) == 0;
}

bool intersect(const circle& c, const point& p) {
	return abs(c.c - p) <= c.r + EPS;
}

bool intersect(const circle& c, const circle& d) {
	return abs(c.c - d.c) <= c.r + d.r && abs(c.c - d.c) >= abs(c.r - d.r);
}

double dist(const line& l, const point& p) {
	return abs(p - projection(l, p));
}

double dist(const line& l, const line& m) {
	return intersect(l, m) ? 0 : dist(l, m.a);
}

double dist(const line& l, const segment& s) {
	return intersect(l, s) ? 0 : min(dist(l, s.a), dist(l, s.b));
}

double dist(const segment& s, const point& p) {
	const point tmp = projection(line(s.a, s.b), p);
	return intersect(s, tmp) ? abs(tmp - p) : min(abs(s.a - p), abs(s.b - p));
}

double dist(const segment& s, const segment& t) {
	if(intersect(s, t))
		return 0;
	return min(min(dist(s, t.a), dist(s, t.b)), min(dist(t, s.a), dist(t, s.b)));
}

point crosspoint(const line& l, const line& m) {
	const double tmp = cross(l.b - l.a, m.b - m.a);
//	if(abs(tmp) < EPS) // 平行
//		return l.a;
	return m.a + (m.b - m.a) * cross(l.b - l.a, l.a - m.a) * (1.0 / tmp);
}

point crosspoint(const segment& s, const segment& t) {
	if(!intersect(s, t)) // 交点を持たない
		return s.a; // 用改善

	const double tmp = cross(s.b - s.a, t.b - t.a);
	if(abs(tmp) < EPS) { // 一直線上
		if(intersect(s, t.a)) return t.a;
		if(intersect(s, t.b)) return t.b;
		if(intersect(t, s.a)) return s.a;
		return s.b;
	}

	return t.a + (t.b - t.a) * cross(s.b - s.a, s.b - t.a) * (1.0 / tmp);
}

vector<point> crosspoint(const circle &c, const circle& d) {
	vector<point> res;
	if(abs(c.c - d.c) < EPS) // 中心の座標が同じ
		return res;

	const double tmp = abs(c.c - d.c);
	const double rc = (tmp * tmp + c.r * c.r - d.r * d.r) / (tmp + tmp);
	const double rs = sqrt(c.r * c.r - rc * rc);
	const point diff = (d.c - c.c) / tmp;
	res.push_back(point(c.c + diff * point(rc, rs)));
	res.push_back(point(c.c + diff * point(rc, -rs)));
	return res;
}

vector<point> crosspoint(const circle& c, const line& l) {
	vector<point> res;
	const point h = projection(l, c.c);
	const double d = abs(h - c.c);
	if(d > c.r - EPS) {
		res.push_back(h);
	}
	else if(d <= c.r - EPS) {
		point v = l.b - l.a;
		v = v * sqrt(c.r * c.r - d * d) / abs(v);
		res.push_back(h + v);
		res.push_back(h - v);
	}

	return res;
}

vector<point> crosspoint(const circle& c, const segment& s) {
	vector<point> res;
	vector<point> tmp = crosspoint(c, line(s.a, s.b));
	for(int i = 0; i < tmp.size(); ++i)
		if(intersect(s, tmp[i]))
			res.push_back(tmp[i]);

	return res;
}

double areaTriangle(point a, point b, const point& c) {
	a = a - c;
	b = b - c;
	return fabs(a.x * b.y - b.x * a.y) / 2.0;
}

double area(const polygon& p) {
	const int num = p.size();
	if(num < 3)
		return 0;

	if(num == 3)
		return areaTriangle(p[0], p[1], p[2]);

	double res = cross(p[num - 1], p[0]);
	for(int i = 1; i < num; ++i) {
		res += cross(p[i - 1], p[i]);
	}

	return res * 0.5;
}

// L.aからL.bの方向を見た場合に，点aが左側に来る．
line bisector(const point& a, const point& b) {
	return line(point((a.x - a.y + b.x + b.y) / 2.0, (a.y + a.x + b.y - b.x) / 2.0),
				point((a.x + a.y + b.x - b.y) / 2.0, (a.y - a.x + b.y + b.x) / 2.0));
}

// L.aからL.bを向いた時の左側を残して切断する．
polygon convex_cut(const polygon& p, const line& l) {
	const int num = p.size();
	polygon res;
	for(int i = 0; i < num; ++i) {
		const int next = (i + 1) % num;
		const int d1 = ccw(l.a, l.b, p[i]);
		const int d2 = ccw(l.a, l.b, p[next]);
		if(d1 != -1)
			res.push_back(p[i]);

		if(d1 * d2 == -1)
			res.push_back(crosspoint(l, line(p[i], p[next])));
	}

	return res;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	polygon init;
	init.push_back(point(-30000, -30000));
	init.push_back(point(30000, -30000));
	init.push_back(point(30000, 30000));
	init.push_back(point(-30000, 30000));

	for(int n, m; cin >> n >> m, n;) {
		vector<point> pos;
		pos.reserve(n);
		for(int i = 0; i < n; ++i) {
			int x, y;
			cin >> x >> y;
			pos.push_back(point(x, y));
		}

		vector<polygon> voronoi(n, init);
		for(int i = 0; i < n; ++i)
			for(int j = 0; j < n; ++j)
				if(i != j)
					voronoi[i] = convex_cut(voronoi[i], bisector(pos[i], pos[j]));

		vector<double> e(n, 0.0);
		for(int i = 0; i < m; ++i) {
			int bx, by, dx, dy, score;
			cin >> bx >> by >> dx >> dy >> score;

			const int s = 4 * dx * dy;
			polygon range;
			range.push_back(point(bx - dx, by - dy));
			range.push_back(point(bx + dx, by - dy));
			range.push_back(point(bx + dx, by + dy));
			range.push_back(point(bx - dx, by + dy));

			for(int j = 0; j < n; ++j) {
				polygon p(voronoi[j]);
				for(int k = 0; k < 4; ++k)
					p = convex_cut(p, line(range[k], range[(k + 1) % 4]));
				e[j] += area(p) / s * score;
			}
		}

		printf("%.10lf\n", *max_element(e.begin(), e.end()));
	}

	return EXIT_SUCCESS;
}
accuracy: 1
time_ms: 30
memory_kb: 1276
final_rank: 2

code_snippet: #include<iostream>
#include<complex>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)
#define fs first
#define sc second
#define pb push_back
#define sz size()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)

using namespace std;

typedef complex<double> P;
typedef pair<P,P> L;
typedef vector<P> Poly;

inline double dot(P x,P y){return real(conj(x)*y);}

inline double cross(P x,P y){return imag(conj(x)*y);}

//for line(segment)
inline int ccw(P a,P b,P c){
  b -= a;c -= a;
  if (cross(b,c)>EPS) return 1;   //counter clockwise
  if (cross(b,c)<-EPS) return -1; //clockwise
  if (dot(b, c)<-EPS) return 2;   //c--a--b on line
  if (abs(b)<abs(c)) return -2;   //a--b--c on line
  return 0;                       //on segment
}

inline P line_cp(L a,L b){
  return a.fs+(a.sc-a.fs)*cross(b.sc-b.fs,b.fs-a.fs)/cross(b.sc-b.fs,a.sc-a.fs);
}

//for polygon

//all vertex is already sorted.
inline double area(Poly &p){
  if(p.size()<3)return 0;
  double res = cross(p[p.size()-1],p[0]);
  for(int i=1;i<p.size();i++)res += cross(p[i-1],p[i]);
  return res/2;
}

//all vertex is already sorted.
inline Poly convex_cut(Poly &p,L l){
  Poly res;
  int n = p.size();
  for(int i=0;i<n;i++){
    int nxt = (i+1)%n;
    if(ccw(l.fs,l.sc,p[i]) != -1)res.pb(p[i]);
    if(ccw(l.fs,l.sc,p[i]) * ccw(l.fs,l.sc,p[nxt]) < 0){
      res.pb( line_cp(l, L(p[i],p[nxt]) ) );
    }
  }
  return res;
}

int main(){
  int n,m;
  int bx,by,dx,dy,s;
  P p[110];
  Poly vor[110];
  const int lim = 30000;
  double ans[110];

  while(cin >> n >> m,n+m){
    FOR(i,0,n)cin >> p[i].real() >> p[i].imag();
    
    FOR(i,0,n){
      ans[i] = 0.0;

      vor[i].resize(4);
      vor[i][0] = P(-lim,-lim); vor[i][1] = P(lim,-lim);
      vor[i][2] = P(lim,lim); vor[i][3] = P(-lim,lim);

      FOR(j,0,n){
	if(i!=j){
	  P nor = (p[i]-p[j]) * P(0,-1);
	  P mid = (p[i]+p[j])/2.0;
	  vor[i] = convex_cut(vor[i],L(mid,mid+nor));
	}
      }
    }
    FOR(i,0,m){
      cin >> bx >> by >> dx >> dy >> s;
      double rect = 4*dx*dy;
      Poly cut(4);
      cut[0] = P(bx-dx,by-dy); cut[1] = P(bx+dx,by-dy);
      cut[2] = P(bx+dx,by+dy); cut[3] = P(bx-dx,by+dy);
	
      FOR(j,0,n){
	Poly tmp = vor[j];
	FOR(k,0,4){
	  tmp = convex_cut(tmp,L(cut[k],cut[(k+1)%4]));

	}
	ans[j] += area(tmp)/rect*s;
      }
    }
    double res = 0.0;
    FOR(i,0,n)res = max(res,ans[i]);
    cout.setf(ios::fixed); cout.precision(9);
    cout << res << endl;
  }
}
accuracy: 1
time_ms: 40
memory_kb: 1340
final_rank: 3

code_snippet: #include<iostream>
#include<complex>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)
#define fs first
#define sc second
#define pb push_back
#define sz size()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)

using namespace std;

typedef complex<double> P;
typedef pair<P,P> L;
typedef vector<P> Poly;

double dot(P x,P y){return real(conj(x)*y);}

double cross(P x,P y){return imag(conj(x)*y);}

//for line(segment)
int ccw(P a,P b,P c){
  b -= a;c -= a;
  if (cross(b,c)>EPS) return 1;   //counter clockwise
  if (cross(b,c)<-EPS) return -1; //clockwise
  if (dot(b, c)<-EPS) return 2;   //c--a--b on line
  if (abs(b)<abs(c)) return -2;   //a--b--c on line
  return 0;                       //on segment
}

P line_cp(L a,L b){
  return a.fs+(a.sc-a.fs)*cross(b.sc-b.fs,b.fs-a.fs)/cross(b.sc-b.fs,a.sc-a.fs);
}

//for polygon

//all vertex is already sorted.
double area(Poly p){
  if(p.size()<3)return 0;
  double res = cross(p[p.size()-1],p[0]);
  for(int i=1;i<p.size();i++)res += cross(p[i-1],p[i]);
  return res/2;
}

//all vertex is already sorted.
Poly convex_cut(Poly p,L l){
  Poly res;
  int n = p.size();
  for(int i=0;i<n;i++){
    int nxt = (i+1)%n;
    if(ccw(l.fs,l.sc,p[i]) != -1)res.pb(p[i]);
    if(ccw(l.fs,l.sc,p[i]) * ccw(l.fs,l.sc,p[nxt]) < 0){
      res.pb( line_cp(l, L(p[i],p[nxt]) ) );
    }
  }
  return res;
}

int main(){
  int n,m;
  int bx,by,dx,dy,s;
  P p[110];
  Poly vor[110];
  const int lim = 30000;
  double ans[110];

  while(cin >> n >> m,n+m){
    FOR(i,0,n)cin >> p[i].real() >> p[i].imag();
    
    FOR(i,0,n){
      ans[i] = 0.0;

      vor[i].resize(4);
      vor[i][0] = P(-lim,-lim); vor[i][1] = P(lim,-lim);
      vor[i][2] = P(lim,lim); vor[i][3] = P(-lim,lim);

      FOR(j,0,n){
	if(i!=j){
	  P nor = (p[i]-p[j]) * P(0,-1);
	  P mid = (p[i]+p[j])/2.0;
	  vor[i] = convex_cut(vor[i],L(mid,mid+nor));
	}
      }
    }
    FOR(i,0,m){
      cin >> bx >> by >> dx >> dy >> s;
      double rect = 4*dx*dy;
      Poly cut(4);
      cut[0] = P(bx-dx,by-dy); cut[1] = P(bx+dx,by-dy);
      cut[2] = P(bx+dx,by+dy); cut[3] = P(bx-dx,by+dy);
	
      FOR(j,0,n){
	Poly tmp = vor[j];
	FOR(k,0,4){
	  tmp = convex_cut(tmp,L(cut[k],cut[(k+1)%4]));

	}
	ans[j] += area(tmp)/rect*s;
      }
    }
    double res = 0.0;
    FOR(i,0,n)res = max(res,ans[i]);
    cout.setf(ios::fixed); cout.precision(9);
    cout << res << endl;
  }
}
accuracy: 1
time_ms: 50
memory_kb: 1336
final_rank: 4

code_snippet: #include<iostream>
#include<complex>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<list>

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)
#define fs first
#define sc second
#define pb push_back
#define sz size()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)

using namespace std;

typedef complex<double> P;
typedef pair<P,P> L;
typedef vector<P> Poly;
typedef pair<P,double> C;

const double PI = acos(-1);

namespace std{
  bool operator<(const P &a,const P &b){
    return real(a)==real(b)?imag(a)<imag(b):real(a)<real(b);
  }
}

//for vector
P unit(P p){return p / abs(p);}

pair<P,P> norm(P p){return make_pair(p*P(0,1),p*P(0,-1));}

double dot(P x,P y){return real(conj(x)*y);}

double cross(P x,P y){return imag(conj(x)*y);}

//rotate a point counter-clockwise on the origin
P rotate(P v,double s){
  return P(real(v)*cos(s) - imag(v)*sin(s), real(v)*sin(s) + imag(v)*cos(s) );
}

//for point set
vector<P> convex_hull(vector<P> v){
  int n = v.sz, k = 0;
  sort(v.begin(),v.end());
  vector<P> r(2*n);
  for(int i=0;i<n;i++){
    while(k>1 && cross(r[k-1]-r[k-2],v[i]-r[k-1]) <= EPS)k--;
    r[k++] = v[i];
  }
  for(int i=n-2,t=k;i>=0;i--){
    while(k>t && cross(r[k-1]-r[k-2],v[i]-r[k-1]) <= EPS)k--;
    r[k++] = v[i];
  }
  r.resize(k-1);
  return r;
}

double caliper(Poly p){
  int n = p.sz;
  if(n==2)return abs(p[0]-p[1]);
  
  int i = 0, j = 0;
  for(int k=0;k<n;k++){
    if(!(p[i]<p[k]))i = k;
    if(p[j]<p[k])j = k;
  }

  double res = 0;
  int si = i, sj = j;
  while(i != sj || j != si){
    res = max(res,abs(p[i]-p[j]));
    if( cross(p[(i+1)%n] - p[i], p[(j+1)%n] - p[j]) < 0)i = (i+1)%n;
    else j = (j+1)%n;
  }
  return res;
}

//Minimam Cover Ball
//Using: Call for "solve" with vector<P> v, which is a point set, as argument 
const int dim = 2;
struct min_ball{
  P center,v[dim+1],c[dim+1];
  double radius2,z[dim+1],r[dim+1];
  list<P> ps;
  list<P>::iterator sup;
  int m;

  void solve(vector<P> v){
    m = 0;
    center = P(0,0);
    radius2 = -1;
    ps.clear();
    for(int i=0;i<v.sz;i++)ps.pb(v[i]);
    make_ball(ps.end());
  }

  void push(const P& p){
    if(!m){
      c[0] = p; r[0] = 0;
    }else{
      double e = dot(p-c[m-1],p-c[m-1]) - r[m-1];
      P d = v[m] = p-c[0];
      for(int i=1;i<m;i++)v[m] -= v[i]*dot(v[i],d)/z[i];
      z[m] = dot(v[m],v[m]);
      c[m] = c[m-1] + e*v[m]*(1.0/z[m]/2.0);
      r[m] = r[m-1] + e*e/z[m]/4.0;
    }
    center  = c[m];
    radius2 = r[m]; m++;
  }
  void make_ball(list<P>::iterator i){
    sup = ps.begin();
    if(m == dim + 1)return;
    for(list<P>::iterator k = ps.begin();k!=i;){
      list<P>::iterator j = k++;
      if(dot(*j-center,*j-center) > radius2){
        push(*j);
	make_ball(j); m--;
	if(sup == j)++sup;
	ps.splice (ps.begin(),ps,j);
      }
    }
  }
};

//for triangle

//return seta A
double arg(P a,P b,P c){return acos(dot(b-a,c-a)/(abs(b-a)*abs(c-a)));}
double arg(double a,double b,double c){return acos( (b*b+c*c-a*a)/(2*b*c) );}

double area_tri(P a,P b,P c){return abs(cross(b-a,c-a)/2);}

bool inter_tri(P a,P b,P c,P x){
  double sum = area_tri(a,b,x) + area_tri(b,c,x) + area_tri(c,a,x);
  if(abs(sum - area_tri(a,b,c)) > EPS)return false;
  return true;
}

double heron(double a,double b,double c){
  double s = (a+b+c)/2;
  return sqrt(s*(s-a)*(s-b)*(s-c));
}

//for line(segment)
int ccw(P a,P b,P c){
  b -= a;c -= a;
  if (cross(b,c)>EPS) return 1;   //counter clockwise
  if (cross(b,c)<-EPS) return -1; //clockwise
  if (dot(b, c)<-EPS) return 2;   //c--a--b on line
  if (abs(b)<abs(c)) return -2;   //a--b--c on line
  return 0;                       //on segment
}

bool orth(L a,L b){return abs(dot(a.fs-a.sc,b.fs-b.sc))<EPS;}

bool para(L a,L b){return abs(cross(a.fs-a.sc,b.fs-b.sc))<EPS;}

double line_dis(L a,P x){return abs(cross(a.sc-a.fs,x-a.fs))/abs(a.sc-a.fs);}

P line_cp(L a,L b){
  return a.fs+(a.sc-a.fs)*cross(b.sc-b.fs,b.fs-a.fs)/cross(b.sc-b.fs,a.sc-a.fs);
}

double seg_p_dis(L a,P x){
  if(dot(a.sc-a.fs,x-a.fs)<EPS)return abs(x-a.fs);
  if(dot(a.fs-a.sc,x-a.sc)<EPS)return abs(x-a.sc);
  return abs(cross(a.sc-a.fs,x-a.fs))/abs(a.sc-a.fs);
}

double seg_seg_dis(L a,L b){
  double res = 1e10;
  res = min(res,seg_p_dis(a,b.fs));
  res = min(res,seg_p_dis(a,b.sc));
  res = min(res,seg_p_dis(b,a.fs));
  res = min(res,seg_p_dis(b,a.sc));
  return res;
}
bool is_cp(L a,L b){
  if(ccw(a.fs,a.sc,b.fs)*ccw(a.fs,a.sc,b.sc)<=0)
    if(ccw(b.fs,b.sc,a.fs)*ccw(b.fs,b.sc,a.sc)<=0)return true;
  return false;
}

P seg_cp(L a,L b){
  double d = abs(cross(b.sc-b.fs,a.fs-b.fs));
  return a.fs + (a.sc-a.fs)*( d /(d + abs(cross(b.sc-b.fs,a.sc-b.fs))) );
}

//for polygon

//all vertex is already sorted.
double area(Poly p){
  if(p.size()<3)return 0;
  double res = cross(p[p.size()-1],p[0]);
  for(int i=1;i<p.size();i++)res += cross(p[i-1],p[i]);
  return res/2;
}

//all vertexes are already sorted.
bool inter_cp(Poly p,P x){
  if(p.empty())return false;

  int s = p.sz;
  double max = p[0].real();
  FOR(i,1,s)if(max < p[i].real())max = p[i].real();
  L h = L( x,P(max+1.0,x.imag()) );

  int c = 0;
  FOR(i,0,s){
    L l = L(p[i],p[(i+1)%s]);
    if(para(h,l) && abs(ccw(h.fs,h.sc,l.fs))!=1)c++;
    else if(is_cp(h,l))c++;
  }

  if(c&1)return true;
  return false;
}

//all inter-degrees are less than PI and all vertexes are already sorted.
bool inter_pos(Poly p,P x){
  int s = p.sz;
  FOR(i,0,s)if(ccw(p[i],p[(i+1)%s],x)==-1)return false;
  return true;
}

//all vertex is already sorted.
Poly convex_cut(Poly p,L l){
  Poly res;
  int n = p.size();
  for(int i=0;i<n;i++){
    int nxt = (i+1)%n;
    if(ccw(l.fs,l.sc,p[i]) != -1)res.pb(p[i]);
    if(ccw(l.fs,l.sc,p[i]) * ccw(l.fs,l.sc,p[nxt]) < 0){
      res.pb( line_cp(l, L(p[i],p[nxt]) ) );
    }
  }
  return res;
}

int main(){
  int n,m;
  int bx,by,dx,dy,s;
  P p[110];
  Poly vor[110];
  const int lim = 30000;
  double ans[110];

  while(cin >> n >> m,n+m){
    FOR(i,0,n)cin >> p[i].real() >> p[i].imag();
    
    FOR(i,0,n){
      ans[i] = 0.0;

      vor[i].resize(4);
      vor[i][0] = P(-lim,-lim); vor[i][1] = P(lim,-lim);
      vor[i][2] = P(lim,lim); vor[i][3] = P(-lim,lim);

      FOR(j,0,n){
	if(i!=j){
	  P nor = (p[i]-p[j]) * P(0,-1);
	  P mid = (p[i]+p[j])/2.0;
	  vor[i] = convex_cut(vor[i],L(mid,mid+nor));
	}
      }
    }
    FOR(i,0,m){
      cin >> bx >> by >> dx >> dy >> s;
      double rect = 4*dx*dy;
      Poly cut(4);
      cut[0] = P(bx-dx,by-dy); cut[1] = P(bx+dx,by-dy);
      cut[2] = P(bx+dx,by+dy); cut[3] = P(bx-dx,by+dy);
	
      FOR(j,0,n){
	Poly tmp = vor[j];
	FOR(k,0,4){
	  tmp = convex_cut(tmp,L(cut[k],cut[(k+1)%4]));

	}
	ans[j] += area(tmp)/rect*s;
      }
    }
    double res = 0.0;
    FOR(i,0,n)res = max(res,ans[i]);
    cout.setf(ios::fixed); cout.precision(9);
    cout << res << endl;
  }
}
accuracy: 1
time_ms: 50
memory_kb: 1348
final_rank: 6