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.  
  11. int n;ll v;
  12. cin >> n >> v;
  13. vector<tmp> a(n);
  14. for (int i = 0; i < n; i++) {
  15. cin >> a[i].b >> a[i].h >> a[i].w >> a[i].d;
  16. }
  17. if (v == 0) {
  18. cout << fixed << setprecision(2) << 0.00 ;
  19. return 0;
  20. }
  21. double lo = 0, hi = 1e7;
  22. double ans = 0;
  23. for (int i = 0; i < 100; i++) {
  24. double mid = (lo + hi) / 2;
  25. double sum = 0;
  26. for (const auto &x : a) {
  27. if (mid > x.b) {
  28. double high = min(mid - x.b, (double)x.h);
  29. sum += high * x.w * x.d;
  30. }
  31. }
  32. if (sum < v) {
  33. lo = mid;
  34. } else {
  35. ans = mid;
  36. hi = mid;
  37. }
  38. }
  39. cout << fixed << setprecision(2) << ans << endl;
  40. return 0;
  41. }
  42.  
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
0.00