记录编号 318043 评测结果 AAAAAAAAAAAAAAAAAAAA
题目名称 溶液混合 最终得分 100
用户昵称 Gravatarcoolkid 是否通过 通过
代码语言 C++ 运行时间 0.040 s
提交时间 2016-10-08 20:10:32 内存使用 0.32 MiB
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<cstdlib>
using namespace std;

double readint(){
	char ch=getchar();int res=0;
	while(!isdigit(ch)) ch=getchar();
	while(isdigit(ch)) res=res*10+ch-48,ch=getchar();
	return res;
}

const int MAXN=233;

struct aqueous{
	double c,v,m;
	aqueous(){
		c=v=m=0.0;
	}
	bool operator < (const aqueous &w)const{
		return c<w.c;
	}
};

aqueous Aq[MAXN];
double target=0;
int n=0;
const double EPS=1e-6;

void init(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		//aqueous &QvQ=Aq[i];
		Aq[i].c=readint();
		Aq[i].c/=100;
	}
	for(int i=1;i<=n;i++){
		//aqueous &QwQ=Aq[i];
		//QwQ.v=readint();
		//QwQ.m=QwQ.v*QwQ.c;
		Aq[i].v=readint();
		Aq[i].m=Aq[i].v*Aq[i].c;
	}
	target=readint();
	target/=100;
	if(target<EPS){
		printf("0.00000\n");
		exit(0);
	}
}

double v=0,s=0;


void work(){
	sort(Aq+1,Aq+1+n);
	for(int i=1;i<=n;i++){
		v+=Aq[i].v;
		s+=Aq[i].m;
	}
	if(s/v-target>EPS){
		int pos=n;
		while(s/v-target>EPS){
			if(pos<=0){
				printf("%0.00000\n");
				return;
			}
			v-=Aq[pos].v;
			s-=Aq[pos].m;
			pos--;
		}
		
		if(fabs(s/v-target)<=EPS){

			printf("%.5lf\n",v);
			return;
		}

		printf("%.5lf\n",(s-v*Aq[pos+1].c)/(target-Aq[pos+1].c));
	}
	else{
		int pos=1;
		while(s/v-target<-EPS){
			if(pos>n){
				printf("%0.00000\n");
				return;
			}

			v-=Aq[pos].v;
			s-=Aq[pos].m;
			pos++;
		}
		
		if(fabs(s/v-target)<=EPS){
			printf("%.5lf\n",v);
			return;
		}

		printf("%.5lf\n",(s-v*Aq[pos-1].c)/(target-Aq[pos-1].c));
	}
}
		
int main(){
	freopen("mix.in","r",stdin);
	freopen("mix.out","w",stdout);
	init();
	work();
	#ifdef DEBUG
		while(1);
	#endif
	return 0;
}
/*
47
35 41 77 41 85 37 61 49 59 43 79 55 75 43 51 69 61 83 43 55 45 47 59 79 45 37 53 53 63 81 51 85 67 69 35 81 69 47 77 53 77 71 79 77 63 43 41
426 277 273 929 404 185 90 507 250 646 635 310 638 905 658 813 756 596 560 670 40 913 312 951 732 541 615 859 729 580 467 228 194 921 550 87 814 108 722 557 949 131 925 758 279 292 116
35
*/