Submission #18108

# Submission time Handle Problem Language Result Execution time Memory
18108 2016-01-21T03:50:49 Z jun6873 최적의 능력 구성 (kriii3_C) C++
0 / 62
0 ms 17468 KB
#include <cstdio>
#include <algorithm>
using namespace std;

const int mnum = (1 << 20) + 1;

int N;
double pct[mnum];
double exd[mnum];

inline int last(int n) { return n&(-n); }
inline int amt(int n) { return __builtin_popcount(n & ((1<<N)-1)); }

void fill_table()
{
	for (int i=2; i<=N; i++) {
		for (int n=1; n < (1<<N); n++) {
			if (amt(n)==i) {
				int b1 = n-last(n), b2 = last(n);
				pct[n] = pct[b1] + pct[b2] - pct[b1] * pct[b2];
				exd[n] = exd[b1] + exd[b2] - ((pct[b1] * exd[b2] * amt(b1) + pct[b2] * exd[b1] * amt(b2)) / double(amt(b1) + amt(b2)));
			}
		}
	}

}

int main()
{
	scanf("%d", &N);

	for (int i=1, c=0; c<N; c++, i = i<<1) {
		int a, b;
		scanf("%d%d", &a, &b);

		pct[i] = (double)a / 100.0;
		exd[i] = (double)a * (double)b / 100.0;
	}

	fill_table();
	double res = 0.0;
	for (int i=1; i < (1<<N); i++)
		res = max(exd[i], res);

	printf("%.10f", res);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 17468 KB Output is correct
2 Correct 0 ms 17468 KB Output is correct
3 Correct 0 ms 17468 KB Output is correct
4 Incorrect 0 ms 17468 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Halted 0 ms 0 KB -