Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- typedef pair<int, int> ii;
- const int ms = 105;
- long double dp[ms][ms][ms];
- bool vis[ms][ms][ms];
- int n;
- long double a[ms];
- long double solve(int on, int have, int acc){
- long double &x = dp[on][have][acc];
- if(vis[on][have][acc]) return x;
- vis[on][have][acc] = true;
- if(on == n){
- if(acc == 0) return x = 0;
- if(acc == have) return x = acc;
- return x = powl(acc, acc/(long double) have);
- }
- x = a[on] * solve(on + 1, have + 1, acc + 1) + (1-a[on]) * solve(on + 1, have + 1, acc);
- x = max(x, solve(on + 1, have, acc));
- return x;
- }
- int main () {
- ios::sync_with_stdio(0); cin.tie(0);
- cin >> n;
- cout << fixed << setprecision(10);
- for(int i = 0; i < n; ++i){
- cin >> a[i];
- a[i] /= 100;
- }
- sort(a, a + n, greater<int>());
- cout << solve(0, 0, 0) << '\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement