Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <iomanip>
- #define task "FILL"
- using namespace std;
- using ll = long long;
- using ld = long double;
- using ull = unsigned long long;
- const int N = 1e5 + 2;
- const ld eps = 1e-3;
- int n, t;
- ll V;
- struct Jar
- {
- int h, b, w, d;
- } a[N];
- void Read()
- {
- cin >> n >> V;
- for (int i = 1; i <= n; ++i)
- cin >> a[i].h >> a[i].b >> a[i].w >> a[i].d;
- cin >> t;
- }
- bool Check(ld v)
- {
- ld ans = 0;
- for (int i = 1; i <= n; ++i)
- {
- if (v >= a[i].h)
- {
- ans += (ld)1.0 * a[i].w * a[i].d * min(v - a[i].h, (ld)a[i].b);
- if (ans >= (ld)V - eps)
- return true;
- }
- }
- return false;
- }
- void Solve()
- {
- ld l = 0, m, h = 1e18;
- while (h - l >= eps)
- {
- m = (l + h) / 2;
- if (Check(m))
- h = m;
- else
- l = m;
- }
- cout << fixed << setprecision(2) << h;
- }
- int32_t main()
- {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- if (fopen(task ".INP", "r"))
- {
- freopen(task ".INP", "r", stdin);
- freopen(task ".OUT", "w", stdout);
- }
- Read();
- Solve();
- }
Add Comment
Please, Sign In to add comment