fork(1) download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. const int max_n = 100111, inf = 1000111222;
  6.  
  7. int n, a[max_n], b[max_n];
  8. long double p[max_n], best = 0, ans = 0;
  9. long long t;
  10.  
  11. long double get(int a, long double p) {
  12. long double res = 0, cur = 1;
  13. long double q = 1 - p;
  14. res = (a + t * best) * (1 - pow(q, t));
  15. res -= p * best * (pow(q, t) * (t * q - t - 1) + 1) / (q - 1) / (q - 1);
  16. return res;
  17. for (int i = 1; i <= t; ++i) {
  18. res -= cur * p * i * best;
  19. cur *= (1 - p);
  20. }
  21. return res;
  22. }
  23.  
  24. int main() {
  25. //freopen("input.txt", "r", stdin);
  26. //freopen("output.txt", "w", stdout);
  27. scanf("%d%I64d", &n, &t);
  28. for (int i = 0; i < n; ++i) {
  29. double x;
  30. scanf("%d%d%lf", &a[i], &b[i], &x);
  31. p[i] = x;
  32. best = max(best, p[i] * b[i]);
  33. }
  34. for (int i = 0; i < n; ++i) {
  35. long double res = get(a[i], p[i]);
  36. ans = max(ans, res);
  37. }
  38. cout << fixed << setprecision(20) << ans << "\n";
  39. return 0;
  40. }
Success #stdin #stdout 0s 17576KB
stdin
2 10000000000
3 3 0.000000002
10000 20007 0.000000001
stdout
20647.16065496807853563155