From 4e286a841d8ba5c8ee2b441a5fbd74aeed3dd53b Mon Sep 17 00:00:00 2001 From: Kirito <1362050620@qq.com> Date: Wed, 8 Jun 2016 09:38:13 +0800 Subject: [PATCH] =?UTF-8?q?Create=201036=5FZERO=E6=97=B6=E3=81=AE=E9=AD=94?= =?UTF-8?q?=E7=8E=8B.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VIJOS/1036_ZERO时の魔王.cpp | 69 +++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 VIJOS/1036_ZERO时の魔王.cpp diff --git a/VIJOS/1036_ZERO时の魔王.cpp b/VIJOS/1036_ZERO时の魔王.cpp new file mode 100644 index 0000000..37cf885 --- /dev/null +++ b/VIJOS/1036_ZERO时の魔王.cpp @@ -0,0 +1,69 @@ +#include +#include +struct map +{int x; +int y; +int p; +int k; +long long value;}city[100001]; +int n,ex,ey,sum=0; +int cmp1(const void*a,const void *b) +{struct map*c=(struct map*)a; +struct map*d=(struct map*)b; +if(c->x!=d->x)return c->x-d->x; +else +return c->y-d->y; +} + + + + +int cmp2(const void*a,const void *b) +{struct map*c=(struct map*)a; +struct map*d=(struct map*)b; +if(c->y!=d->y)return c->y-d->y; +else +return c->x-d->x; +} + + + + +int searchx() +{int i,add=0; +for(i=1;;i++) +{add+=city[i].value; +if(add>=sum/2) +break;} +return city[i].x; +} + + + + +int searchy() +{int i,add=0; +for(i=1;;i++) +{add+=city[i].value; +if(add>=sum/2) +break;} +return city[i].y; +} + + + + +int main() +{scanf("%d\n",&n); +int i; +for(i=1;i<=n;i++) +{scanf("%d %d %d %d\n",&city[i].x,&city[i].y,&city[i].p,&city[i].k); +city[i].value=city[i].p*city[i].k; +sum+=city[i].value;} +qsort(&city[1],n,sizeof(city[0]),cmp1); +ex=searchx(); +qsort(&city[1],n,sizeof(city[0]),cmp2); +ey=searchy(); +printf("%d %d",ex,ey); +return 0; +}