Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int n;
- cin>>n;
- vector<int> p(n);
- for(auto &e: p) cin>>e;
- long double p9 = 1;
- vector<long double> pSum(n + 1);
- for (int i = 1; i <= n; i++)
- {
- pSum[i] = (pSum[i - 1] + p9);
- p9 *= 0.9;
- }
- vector<long double> dp(n + 1, -1e18);
- dp[0] = 0;
- for (int i = 0; i < n; i++)
- {
- auto ndp = dp;
- for (int j=0; j<=i; j++)
- {
- if(j+1 <= n)
- ndp[j + 1] = max(ndp[j + 1], dp[j] * 0.9 + p[i]);
- }
- swap(ndp, dp);
- }
- long double ans = -1e18;
- for (int i = 1; i <= n; i++)
- {
- long double x = 1200.0 / sqrt(1.0 * i);
- ans = max(ans, (dp[i] / pSum[i]) - x);
- }
- cout<<fixed<<setprecision(15);
- cout<<ans<<"\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment