[ create a new paste ] login | about

Link: http://codepad.org/hb2P1V3J    [ raw code | output | fork ]

C++, pasted on Dec 18:
#include <bits/stdc++.h>
using namespace std;

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	cout << fixed << setprecision(10);
	
	int n, t; cin >> n >> t;
	vector<int> a(n), b(n), d(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i] >> d[i];
	}

	double lo = 0, hi = t;
	for (int gg = 0; gg < 60; gg++) {
		double c = (lo + hi)/2;

		double sum = 0;
		for (int i = 0; i < n; i++) {
			double f = c*d[i];

			if (f > b[i]) f = b[i];
			if (f < a[i]) f = a[i];

			sum += f;
		}

		if (sum > t) {
			hi = c;
		} else {
			lo = c;
		}
	}

	double c = lo;
	for (int i = 0; i < n; i++) {
		double f = c*d[i];

		if (f > b[i]) f = b[i];
		if (f < a[i]) f = a[i];

		cout << f << '\n';
	}

	return 0;
}


Output:
1
Line 24: error: bits/stdc++.h: No such file or directory


Create a new paste based on this one


Comments: