Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <cstdlib>
- #include <cmath>
- using namespace std;
- typedef long long ll;
- int n;
- ll now;
- ll cost;
- double w[100][100];
- double p[100];
- double ans;
- int main()
- {
- freopen("tvshow.in", "r", stdin);
- freopen("tvshow.out", "w", stdout);
- scanf("%d%I64d\n", &n, &cost);
- for (int i = 0; i < n; i++)
- {
- scanf("%lf", &p[i]);
- p[i] /= 100.;
- }
- for (int i = 0; i < n; i++)
- {
- w[i][i] = 1.;
- for (int j = i + 1; j <= n; j++)
- w[i][j] = w[i][j - 1] * p[j - 1];
- }
- ans = 100.;
- for (int i = 1; i <= n; i++)
- ans = max(ans, w[0][i] * (double)(100LL << (ll)i));
- now = 50LL;
- for (int i = 0; i < n; i++)
- {
- now = now << 1LL;
- if (now <= cost)
- continue;
- ll tmp_now = now - cost;
- double r = w[0][i] * (double)tmp_now;
- double tans = 0.;
- for (int j = i; j <= n; j++)
- {
- double rr = r * (1. - p[j]);
- double tt = 0.;
- for (int k = j + 1; k <= n; k++)
- {
- tt = max(rr, tt);
- if (k < n)
- rr = rr * p[k] * 2.;
- }
- tans += tt;
- if (j < n)
- r = r * p[j] * 2.;
- }
- tans += r;
- ans = max(ans, tans);
- }
- printf("%.10lf\n", ans);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement