답안 #15318

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
15318 2015-07-12T05:54:43 Z gs14004 최적의 능력 구성 (kriii3_C) C++14
62 / 62
171 ms 10300 KB
#include <cstdio>
#include <algorithm>
using namespace std;

double dp[1<<20];
bool vis[1<<20];

int n;
int p[21], d[21];

double f(int x){
	if(x == 0) return 0;
	if(vis[x]) return dp[x];
	double ret = 0;
	int cnt = 0;
	for(int i=0; i<n; i++){
		if((x >> i) & 1){
			cnt++;
			ret += 0.01 * p[i] * d[i] + (1 - 0.01 * p[i]) * f(x ^ (1<<i));
		}
	}
	ret /= cnt;
	vis[x] = 1;
	return dp[x] = ret;
}
int main(){
	scanf("%d",&n);
	for(int i=0; i<n; i++){
		scanf("%d %d",&p[i],&d[i]);
	}
	double ret = 0;
	for(int i=0; i<(1<<n); i++){
		ret = max(ret,f(i));
	}
	printf("%.8f",ret);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 10300 KB Output is correct
2 Correct 0 ms 10300 KB Output is correct
3 Correct 0 ms 10300 KB Output is correct
4 Correct 0 ms 10300 KB Output is correct
5 Correct 0 ms 10300 KB Output is correct
6 Correct 0 ms 10300 KB Output is correct
7 Correct 0 ms 10300 KB Output is correct
8 Correct 0 ms 10300 KB Output is correct
9 Correct 0 ms 10300 KB Output is correct
10 Correct 0 ms 10300 KB Output is correct
11 Correct 0 ms 10300 KB Output is correct
12 Correct 0 ms 10300 KB Output is correct
13 Correct 0 ms 10300 KB Output is correct
14 Correct 0 ms 10300 KB Output is correct
15 Correct 0 ms 10300 KB Output is correct
16 Correct 0 ms 10300 KB Output is correct
17 Correct 0 ms 10300 KB Output is correct
18 Correct 0 ms 10300 KB Output is correct
19 Correct 0 ms 10300 KB Output is correct
20 Correct 0 ms 10300 KB Output is correct
21 Correct 0 ms 10300 KB Output is correct
22 Correct 0 ms 10300 KB Output is correct
23 Correct 0 ms 10300 KB Output is correct
24 Correct 0 ms 10300 KB Output is correct
25 Correct 0 ms 10300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 163 ms 10300 KB Output is correct
2 Correct 155 ms 10300 KB Output is correct
3 Correct 161 ms 10300 KB Output is correct
4 Correct 160 ms 10300 KB Output is correct
5 Correct 163 ms 10300 KB Output is correct
6 Correct 161 ms 10300 KB Output is correct
7 Correct 159 ms 10300 KB Output is correct
8 Correct 164 ms 10300 KB Output is correct
9 Correct 158 ms 10300 KB Output is correct
10 Correct 157 ms 10300 KB Output is correct
11 Correct 153 ms 10300 KB Output is correct
12 Correct 159 ms 10300 KB Output is correct
13 Correct 162 ms 10300 KB Output is correct
14 Correct 162 ms 10300 KB Output is correct
15 Correct 163 ms 10300 KB Output is correct
16 Correct 163 ms 10300 KB Output is correct
17 Correct 159 ms 10300 KB Output is correct
18 Correct 171 ms 10300 KB Output is correct
19 Correct 158 ms 10300 KB Output is correct
20 Correct 153 ms 10300 KB Output is correct