Skip to content

Commit ede7763

Browse files
committed
Solved problem 443D from codeforces
1 parent 398fbff commit ede7763

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
5+
int const N = 101;
6+
int n;
7+
double a[N];
8+
9+
int main() {
10+
double mx = 0;
11+
cin >> n;
12+
for(int i = 0; i < n; ++i)
13+
cin >> a[i];
14+
15+
sort(a, a + n);
16+
reverse(a, a + n);
17+
18+
double res = 0;
19+
for(int k = 0; k < n; ++k) {
20+
double sol = 0;
21+
for(int i = 0; i <= k; ++i) {
22+
double cur = a[i];
23+
for(int j = 0; j <= k; ++j)
24+
if(i != j)
25+
cur *= (1.0 - a[j]);
26+
sol += cur;
27+
}
28+
res = max(res, sol);
29+
}
30+
31+
cout << fixed << setprecision(10) << res << endl;
32+
33+
return 0;
34+
}

CodeForces/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@
170170
- [441A. Valera and Antique Items](http://codeforces.com/problemset/problem/441/A)
171171
- [441C. Valera and Tubes](http://codeforces.com/contest/441/problem/C)
172172
- [443A. Anton and Letters](http://codeforces.com/problemset/problem/443/A)
173+
- [443D. Andrey and Problem](http://codeforces.com/contest/443/problem/D)
173174
- [448A. Rewards](http://codeforces.com/problemset/problem/448/A)
174175
- [448D. Multiplication Table](http://codeforces.com/contest/448/problem/D)
175176
- [449B. Jzzhu and Cities](http://codeforces.com/contest/449/problem/B)

0 commit comments

Comments
 (0)