记录编号 252346 评测结果 WWWWWWWWWT
题目名称 2250.贿赂 最终得分 0
用户昵称 Sky_miner 是否通过 未通过
代码语言 C++ 运行时间 1.525 s
提交时间 2016-04-20 09:19:39 内存使用 0.31 MiB
显示代码纯文本
#include<cstdio>
#include<iostream>
using namespace std;
const int maxn=15;
double ans=0,A,temp=0,a[maxn],b[maxn];
int n,K;
bool flag[maxn];
void DFS(int x,int cnt){
	if(x>n){
		double t=(double)1;
		for(int i=1;i<=n;i++) {
			if(flag[i]) t*=b[i]/(double)100;
			else t*=((double)100-b[i])/(double)100;
		}
		if(cnt<=(n>>1)){
			double B=0;
			for(int i=1;i<=n;i++) {
				if(!flag[i]) B+=a[i];
			}
			t*=A/(A+B);
		}
		ans+=t;
		return;
	}
	flag[x]=true;
	DFS(x+1,cnt+1);
	flag[x]=false;
	DFS(x+1,cnt);
}
void dfs(int x,int pos){
	if(x>K){
		DFS(1,0);
		temp=max(ans,temp);
		ans=0;
		return;
	}
	if(pos>n) return;
	for(int i=pos;i<=n;i++){
		if(b[i]==100) continue;
		b[i]+=10;
		dfs(x+1,i);
		b[i]-=10;
	}
}
int main(){
	freopen("bribe.in","r",stdin);
	freopen("bribe.out","w",stdout);
	scanf("%d%d%lf",&n,&K,&A);
	for(int i=1;i<=n;i++) scanf("%lf%lf",&a+i,&b+i);
	dfs(1,1);
	printf("%.6lf\n",temp);
	return 0;
}