fork download
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. using namespace std;
  4. struct tmp {
  5. ll b, h, w, d;
  6. };
  7. int main() {
  8. ios::sync_with_stdio(false);
  9. cin.tie(NULL);
  10. freopen("FILL.INP","r",stdin);
  11. freopen("FILL.OUT","w",stdout);
  12. int n;ll v;
  13. cin >> n >> v;
  14. vector<tmp> a(n);
  15. for (int i = 0; i < n; i++) {
  16. cin >> a[i].b >> a[i].h >> a[i].w >> a[i].d;
  17. }
  18. if (v == 0) {
  19. cout << fixed << setprecision(2) << 0.00 ;
  20. return 0;
  21. }
  22. double lo = 0, hi = 1e7;
  23. double ans = 0;
  24. for (int i = 0; i < 100; i++) {
  25. double mid = (lo + hi) / 2;
  26. double sum = 0;
  27. for (const auto &x : a) {
  28. if (mid > x.b) {
  29. double high = min(mid - x.b, (double)x.h);
  30. sum += high * x.w * x.d;
  31. }
  32. }
  33. if (sum < v) {
  34. lo = mid;
  35. } else {
  36. ans = mid;
  37. hi = mid;
  38. }
  39. }
  40. cout << fixed << setprecision(2) << ans << endl;
  41. return 0;
  42. }
  43.  
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
Standard output is empty